MarchingCube on master
Branchless data index check Merge branch 'master' into chea… Merge pull request #5598 from Y… (compare)
grokys on control-nullability
Added nullable annotations to C… (compare)
NumericUpDown
and add a "Small Increment". Somethings are private though. So might have to copy the code and create a new one. My goal is to have a numeric textbox like in Blender: buttons either side of input; click and drag to increment/decrement; use a key modifier to use small increment; be able to do basic math.
So I changed the TextBox.Text
binding in my NumericUpDown
template to {TemplateBinding Text, Converter={x:Static cv:MathExpressionConverter.Instance }, Mode=TwoWay}
. And made my converter like so:
public class MathExpressionConverter : IValueConverter
{
public static readonly MathExpressionConverter Instance = new MathExpressionConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string input && MathExpressionParser.TryParseExpression(input, out var expression))
{
return expression.Compile().Invoke().ToString();
}
return new BindingNotification(new Exception("Invalid expression."), BindingErrorType.DataValidationError);
}
}
And I pretty much get what I want. It does the calculation without clearing the expression and when you press enter it commits the answer and displays the result. IDK how that works.
@grokys
@openmandev sounds like a bug. could you open an issue with a minimal repro and i'll try to fix it
WindowTitleBar
control. To make it easy to make custom chrome window
VisualRoot is Window window
?
protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
{
base.OnTemplateApplied(e);
if (VisualRoot is Window window)
{
var min = e.NameScope.Find<Button>("PART_MinimizeButton");
min.Click += (s, e) => window.WindowState = WindowState.Minimized;
var max = e.NameScope.Find<Button>("PART_MaximizeButton");
max.Click += (s, e) => window.WindowState = WindowState.Maximized;
var res = e.NameScope.Find<Button>("PART_RestoreButton");
res.Click += (s, e) => window.WindowState = WindowState.Normal;
var close = e.NameScope.Find<Button>("PART_CloseButton");
close.Click += (s, e) => window.Close();
max.IsVisible = window.WindowState != WindowState.Maximized;
res.IsVisible = window.WindowState == WindowState.Maximized;
//TODO: How to hand window.IsActive Changed
}
}
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);
if (VisualRoot is Window window)
{
window.BeginMoveDrag(e);
}
}
window.GetPropertyChangedObservable(Window.IsActiveProperty)
somehow. I can't find any example of it in the code though.
Wrong property to start with. :D
I tried:
window.GetPropertyChangedObservable(Window.WindowStateProperty)
.AddClassHandler((System.Action<WindowTitleBar, AvaloniaPropertyChangedEventArgs>)((t, e) =>
{
WindowState newValue = (WindowState)e.NewValue;
max.IsVisible = newValue != WindowState.Maximized;
res.IsVisible = newValue == WindowState.Maximized;
}));
but that doesn't do anything.