port from perforce
This commit is contained in:
38
intromat/Intromat/Views/Editors/DimensionEditorView.cs
Normal file
38
intromat/Intromat/Views/Editors/DimensionEditorView.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Intromat.Interfaces;
|
||||
using Intromat.Nodes.Code;
|
||||
using Intromat.ViewModels.Editors;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Intromat.Views.Editors
|
||||
{
|
||||
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
|
||||
[TemplatePart(Name = nameof(_textBlockValue), Type = typeof(TextBlock))]
|
||||
public class DimensionEditorView : EditorViewBase<DimensionEditorViewModel>
|
||||
{
|
||||
private Slider _sliderValue = null!;
|
||||
private TextBlock _textBlockValue = null!;
|
||||
|
||||
public DimensionEditorView()
|
||||
{
|
||||
DefaultStyleKey = typeof(DimensionEditorView);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
this.OneWayBind(ViewModel, vm => vm.Value, v => v._textBlockValue.Text, v => ((IntLiteralValue?)v)?.EvaluateDimension().ToString() ?? "0").DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.CustomValue, v => v._sliderValue.Value, i => i, v => (int)v).DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (int)v).DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (int)v).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
|
||||
_textBlockValue = (TextBlock)GetTemplateChild(nameof(_textBlockValue))!;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user