public Visual GetControl(Application a) => sp ?? (sp = new StackPanel() .WithChild(ep = new Control_EvaluatablePresenter { EvalType = EvaluatableType.Boolean, Margin = new System.Windows.Thickness(24, 0, 0, 0) } .WithBinding(Control_EvaluatablePresenter.ExpressionProperty, new Binding("Evaluatable") { Source = this, Mode = BindingMode.TwoWay })) .WithChild(new Control_TimeAndUnit() .WithBinding(Control_TimeAndUnit.TimeProperty, new Binding("ExtensionTime") { Source = this, Mode = BindingMode.TwoWay }) .WithBinding(Control_TimeAndUnit.UnitProperty, new Binding("TimeUnit") { Source = this, Mode = BindingMode.TwoWay }) ));
public Visual GetControl(Application a) => control ?? (control = new StackPanel() .WithChild(new DockPanel { LastChildFill = true } .WithChild(new Label { Content = "Expression", VerticalAlignment = System.Windows.VerticalAlignment.Center }, Dock.Left) .WithChild(ep = new Control_EvaluatablePresenter { EvalType = EvaluatableType.Number, Margin = new System.Windows.Thickness(24, 0, 0, 0) } .WithBinding(Control_EvaluatablePresenter.ExpressionProperty, this, "Evaluatable", BindingMode.TwoWay))) .WithChild(new CheckBox { Content = "Trigger on increase" } .WithBinding(CheckBox.IsCheckedProperty, this, "DetectRising")) .WithChild(new CheckBox { Content = "Trigger on decrease" } .WithBinding(CheckBox.IsCheckedProperty, this, "DetectFalling")) .WithChild(new DockPanel { LastChildFill = true } .WithChild(new Label { Content = "Change required", VerticalAlignment = System.Windows.VerticalAlignment.Center }, Dock.Left) .WithChild(new DoubleUpDown { Minimum = 0 } .WithBinding(DoubleUpDown.ValueProperty, this, "DetectionThreshold"))));
/// <summary>Attempts to get an evaluatable from the suppliied data object. Will return true/false indicating if data is of correct format /// (an <see cref="IEvaluatable{T}"/> where T matches the given type. If the eval type is null, no type check is performed, the returned /// evaluatable may be of any sub-type.</summary> internal static bool TryGetData(IDataObject @do, out IEvaluatable evaluatable, out Control_EvaluatablePresenter source, Type evalType) { if (@do.GetData(@do.GetFormats().FirstOrDefault(x => x != "SourcePresenter")) is IEvaluatable data && (evalType == null || Utils.TypeUtils.ImplementsGenericInterface(data.GetType(), typeof(IEvaluatable <>), evalType))) { evaluatable = data; source = @do.GetData("SourcePresenter") as Control_EvaluatablePresenter; return(true); } evaluatable = null; source = null; return(false); }