void LogEvents(NumericStepper control) { control.ValueChanged += delegate { Log.Write(control, "ValueChanged, Value: {0}", control.Value); }; }
Control NumericStepperControl() { var control = new NumericStepper(); LogEvents(control); return(control); }
Control SizeControl(Func <SizeF> getValue, Action <SizeF> setValue) { var xpoint = new NumericStepper(); xpoint.ValueBinding.Bind(() => getValue().Width, v => { var p = getValue(); p.Width = (float)v; setValue(p); Refresh(); }); var ypoint = new NumericStepper(); ypoint.ValueBinding.Bind(() => getValue().Height, v => { var p = getValue(); p.Height = (float)v; setValue(p); Refresh(); }); return(new StackLayout { Orientation = Orientation.Horizontal, Items = { "W:", xpoint, "H:", ypoint } }); }
Control CreateClientSizeControls() { var setClientSize = new CheckBox { Text = "ClientSize" }; setClientSize.CheckedBinding.Bind(() => setInitialClientSize, v => setInitialClientSize = v ?? false); var left = new NumericStepper(); left.Bind(c => c.Enabled, setClientSize, c => c.Checked); left.ValueBinding.Bind(() => initialClientSize.Width, v => initialClientSize.Width = (int)v); var top = new NumericStepper(); top.Bind(c => c.Enabled, setClientSize, c => c.Checked); top.ValueBinding.Bind(() => initialClientSize.Height, v => initialClientSize.Height = (int)v); return(new StackLayout { Orientation = Orientation.Horizontal, Items = { setClientSize, left, top } }); }
private DynamicLayout GenRadSettingsPanel() { //radiant system var radFaceType = new EnumDropDown <HoneybeeSchema.RadiantFaceTypes>(); radFaceType.Bind(_ => _.SelectedValue, _vm, _ => _.RadiantFaceType); //radFaceType.Bind(_ => _.Visible, _vm, _ => _.RadiantVisable); var minOptTime = new NumericStepper() { MinValue = 0, MaxValue = 24, MaximumDecimalPlaces = 1, Increment = 1 }; var switchOverTime = new NumericStepper() { MinValue = 0, MaxValue = 24, MaximumDecimalPlaces = 1, Increment = 1 }; minOptTime.Bind(_ => _.Value, _vm, _ => _.MinOptTime); //minOptTime.Bind(_ => _.Visible, _vm, _ => _.RadiantVisable); switchOverTime.Bind(_ => _.Value, _vm, _ => _.SwitchTime); //switchOverTime.Bind(_ => _.Visible, _vm, _ => _.RadiantVisable); var radSettings = new DynamicLayout(); radSettings.DefaultSpacing = new Size(5, 2); radSettings.Bind(_ => _.Visible, _vm, _ => _.RadiantVisable); radSettings.AddRow("Radiant Face Type:"); radSettings.AddRow(radFaceType); radSettings.AddRow("Minimum Operation Time:"); radSettings.AddRow(minOptTime); radSettings.AddRow("Switch Over Time:"); radSettings.AddRow(switchOverTime); return(radSettings); }
Control CreateInitialLocationControls() { var setLocationCheckBox = new CheckBox { Text = "Initial Location" }; setLocationCheckBox.CheckedBinding.Bind(() => setInitialLocation, v => setInitialLocation = v ?? false); var left = new NumericStepper(); left.Bind(c => c.Enabled, setLocationCheckBox, c => c.Checked); left.ValueBinding.Bind(() => initialLocation.X, v => initialLocation.X = (int)v); var top = new NumericStepper(); top.Bind(c => c.Enabled, setLocationCheckBox, c => c.Checked); top.ValueBinding.Bind(() => initialLocation.Y, v => initialLocation.Y = (int)v); return(new StackLayout { Orientation = Orientation.Horizontal, Items = { setLocationCheckBox, left, top } }); }
Control PointControl(Func <PointF> getValue, Action <PointF> setValue) { var xpoint = new NumericStepper(); xpoint.ValueBinding.Bind(() => getValue().X, v => { var p = getValue(); p.X = (float)v; setValue(p); }); var ypoint = new NumericStepper(); ypoint.ValueBinding.Bind(() => getValue().Y, v => { var p = getValue(); p.Y = (float)v; setValue(p); }); return(new StackLayout { Orientation = Orientation.Horizontal, Items = { "X:", xpoint, "Y:", ypoint } }); }
public void MaximumDecimalPlacesShouldUpdateWhenDecimalPlacesIsChanged() { Invoke(() => { var numeric = new NumericStepper(); numeric.DecimalPlaces = 3; Assert.AreEqual(3, numeric.DecimalPlaces, "DecimalPlaces isn't roundtripping set values"); Assert.AreEqual(3, numeric.MaximumDecimalPlaces, "MaximumDecimalPlaces should be changed to at minimum DecimalPlaces"); numeric.DecimalPlaces = 2; Assert.AreEqual(2, numeric.DecimalPlaces, "DecimalPlaces isn't roundtripping set values"); Assert.AreEqual(3, numeric.MaximumDecimalPlaces, "MaximumDecimalPlaces should only be changed when DecimalPlaces is greater than its current value"); numeric.MaximumDecimalPlaces = 2; Assert.AreEqual(2, numeric.DecimalPlaces, "DecimalPlaces should keep its original value"); Assert.AreEqual(2, numeric.MaximumDecimalPlaces, "MaximumDecimalPlaces wasn't updated to the new value"); numeric.MaximumDecimalPlaces = 1; Assert.AreEqual(1, numeric.DecimalPlaces, "DecimalPlaces should be updated to the new value of MaximumDecimalPlaces when its current value is greater"); Assert.AreEqual(1, numeric.MaximumDecimalPlaces, "MaximumDecimalPlaces wasn't updated to the new value"); numeric.MaximumDecimalPlaces = 0; Assert.AreEqual(0, numeric.DecimalPlaces, "DecimalPlaces should be updated to the new value of MaximumDecimalPlaces when its current value is greater"); Assert.AreEqual(0, numeric.MaximumDecimalPlaces, "MaximumDecimalPlaces wasn't updated to the new value"); }); }
public static NumericStepper CreateAndAddNumericEditorRow(this DynamicLayout container, String text, double currval, double minval, double maxval, int decimalplaces, Action <NumericStepper, EventArgs> command) { var txt = new Label { Text = text, VerticalAlignment = VerticalAlignment.Center }; txt.Font = new Font(SystemFont.Default, GetEditorFontSize()); var editor = new NumericStepper { Value = currval, DecimalPlaces = decimalplaces, MinValue = minval, MaxValue = maxval }; editor.Font = new Font(SystemFont.Default, GetEditorFontSize()); if (GlobalSettings.Settings.EditorTextBoxFixedSize) { editor.Width = 140; } if (command != null) { editor.ValueChanged += (sender, e) => command.Invoke((NumericStepper)sender, e); } var tr = new TableRow(txt, null, editor); container.AddRow(tr); container.CreateAndAddEmptySpace(); return(editor); }
Control WidthControl() { widthControl = new NumericStepper { MinValue = 1, MaxValue = 5000 }; return(widthControl); }
private void InitializeComponents() { m_samples_lb = new Label() { Text = Localization.LocalizeString("Samples", 6), VerticalAlignment = VerticalAlignment.Center, }; m_samples = new NumericStepper() { Value = 0, MaximumDecimalPlaces = 0, MaxValue = int.MaxValue, MinValue = 0, Width = 75, }; m_throttlems_lb = new Label() { Text = Localization.LocalizeString("Throttle (in ms)", 19), VerticalAlignment = VerticalAlignment.Center, }; m_throttlems = new NumericStepper() { Value = 0, MaximumDecimalPlaces = 0, MaxValue = int.MaxValue, MinValue = 0, Width = 75, }; }
public MainForm() { XamlReader.Load(this); #region Initialize Controls txtRegexPattern = FindChild <TextArea>("txtRegexPattern"); txtReplacementString = FindChild <TextArea>("txtReplacementString"); txtInputText = FindChild <TextArea>("txtInputText"); txtMatchValue = FindChild <TextArea>("txtMatchValue"); lboPatternHistory = FindChild <ListBox>("lboPatternHistory"); lboInputHistory = FindChild <ListBox>("lboInputHistory"); chkCompiled = FindChild <CheckBox>("chkCompiled"); chkCultureInvariant = FindChild <CheckBox>("chkCultureInvariant"); chkEcmaScript = FindChild <CheckBox>("chkEcmaScript"); chkExplicitCapture = FindChild <CheckBox>("chkExplicitCapture"); chkIgnoreWhite = FindChild <CheckBox>("chkIgnoreWhite"); chkIgnoreCase = FindChild <CheckBox>("chkIgnoreCase"); chkMultiline = FindChild <CheckBox>("chkMultiline"); chkRightToLeft = FindChild <CheckBox>("chkRightToLeft"); chkSingleLine = FindChild <CheckBox>("chkSingleLine"); nudTimeout = FindChild <NumericStepper>("nudTimeout"); splResultExplorer = FindChild <Splitter>("splResultExplorer"); tvwResultExplorer = FindChild <TreeGridView>("tvwResultExplorer"); lblStatusMessage = FindChild <Label>("lblStatusMessage"); lblPosition = FindChild <Label>("lblPosition"); #endregion // Initialize Controls }
public void MinMaxShouldRetainValue() { Invoke(() => { var numeric = new NumericStepper(); int valueChanged = 0; int currentValueChanged = 0; numeric.ValueChanged += (sender, e) => valueChanged++; numeric.MinValue = 100; numeric.MaxValue = 1000; Assert.AreEqual(100, numeric.MinValue, "MinValue should return the same value as set"); Assert.AreEqual(1000, numeric.MaxValue, "MaxValue should return the same value as set"); Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event should fire when changing the MinValue"); numeric.MinValue = double.NegativeInfinity; numeric.MaxValue = double.PositiveInfinity; numeric.Value = 0; Assert.AreEqual(double.NegativeInfinity, numeric.MinValue, "MinValue should be double.NegativeInfinity"); Assert.AreEqual(double.PositiveInfinity, numeric.MaxValue, "MaxValue should be double.PositiveInfinity"); Assert.AreEqual(0, numeric.Value, "Value should be back to 0"); Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event should fire when changing the MinValue"); }); }
Control HeightControl() { heightControl = new NumericStepper { MinValue = 1, MaxValue = 10000 }; return(heightControl); }
void pSubShapeXPos_UI(TableLayout tl) { TableRow tr = new TableRow(); tl.Rows.Add(tr); lbl_xPosRef = new Label { Text = "X Pos", ToolTip = "Position this element in X relative to a different element, or world origin" }; tr.Cells.Add(new TableCell() { Control = lbl_xPosRef }); TableLayout ptl = new TableLayout(); Panel p = new Panel { Content = ptl }; ptl.Rows.Add(new TableRow()); tr.Cells.Add(new TableCell() { Control = p }); num_minXPos = new NumericStepper { Increment = 0.1, DecimalPlaces = 2 }; pSetSize(num_minXPos, numWidth, num_Height); ptl.Rows[^ 1].Cells.Add(new TableCell()
static Control Copies() { var control = new NumericStepper { MinValue = 1 }; control.ValueBinding.BindDataContext <PrintSettings>(r => r.Copies, (r, v) => r.Copies = (int)v, defaultGetValue: 1); return(control); }
public void SettingValueInChangedHandlerShouldStickWhenTyped() { Exception exception = null; ManualForm("Type '2' in the numeric spinner. It should be set to 10 and ValueChanged called exactly 2 times.", form => { var label = new Label(); var numericStepper = new NumericStepper(); Assert.AreEqual(0, numericStepper.Value, "#1"); var changedCount = 0; numericStepper.ValueChanged += (sender, e) => { if (exception != null) { return; } try { changedCount++; if (changedCount == 1) { Assert.AreEqual(2, numericStepper.Value, "#2"); } else if (changedCount == 2) { Assert.AreEqual(10, numericStepper.Value, "#3"); } else if (changedCount > 2) { Assert.Fail($"#4. ValueChanged should only fire twice. New value is '{numericStepper.Value}' but should stay at 10."); } numericStepper.Value = 10; Assert.AreEqual(10, numericStepper.Value, "#5"); Application.Instance.AsyncInvoke(() => label.Text = $"Value is {numericStepper.Value}. ValueChanged called {changedCount} times."); } catch (Exception ex) { exception = ex; form.Close(); } }; numericStepper.Focus(); return(new StackLayout { Items = { numericStepper, label } }); }); if (exception != null) { ExceptionDispatchInfo.Capture(exception).Throw(); } }
Control OffsetYControl() { var control = new NumericStepper(); control.ValueBinding.Bind(() => OffsetY, v => { OffsetY = (float)v; Refresh(); }); return(control); }
public override void Apply(Component component) { base.Apply(component); NumericStepper numericStepper = (NumericStepper)component; numericStepper.Minimum = Minimum; numericStepper.Maximum = Maximum; numericStepper.Value = Value; numericStepper.Mode = Mode; numericStepper.Step = Step; }
Control CreateOpacityControl() { var control = new NumericStepper { Value = 1, MinValue = 0, MaxValue = 1, DecimalPlaces = 2, Increment = 0.1f }; control.ValueBinding.Bind(() => Opacity, v => { Opacity = (float)v; Refresh(); }); return(control); }
Control AngleControl() { var angle = new NumericStepper { MinValue = 0, MaxValue = 360 }; angle.ValueBinding.Bind(() => Angle, v => { Angle = (float)v; Refresh(); }); return(angle); }
Control RotationControl() { var control = new NumericStepper { MinValue = 0, MaxValue = 360 }; control.ValueBinding.Bind(() => Rotation, v => { Rotation = (float)v; Refresh(); }); return(control); }
Control ScaleYControl() { var control = new NumericStepper { MinValue = 1, MaxValue = 1000 }; control.ValueBinding.Bind(() => ScaleY, v => { ScaleY = (float)v; Refresh(); }); return(control); }
public TaskbarSection() { var layout = new DynamicLayout(); layout.DefaultSpacing = new Size(15, 6); layout.DefaultPadding = new Padding(10); layout.BeginVertical(); layout.BeginHorizontal(); layout.Add(null, false, false); layout.Add(null, true, true); layout.EndHorizontal(); layout.BeginHorizontal(); layout.Add(new Label { Text = "State:", VerticalAlignment = VerticalAlignment.Center }, false, false); dropTaskbarState = new EnumDropDown <TaskbarProgressState>(); dropTaskbarState.SelectedValue = TaskbarProgressState.Progress; layout.Add(dropTaskbarState, true, false); layout.EndHorizontal(); layout.BeginHorizontal(); layout.Add(new Label { Text = "Value:", VerticalAlignment = VerticalAlignment.Center }, false, false); numericStepper = new NumericStepper(); numericStepper.MinValue = 0; numericStepper.MaxValue = 100; numericStepper.Value = 50; layout.Add(numericStepper, true, false); layout.EndHorizontal(); layout.BeginHorizontal(); layout.Add(null, false, false); buttonSetTaskbar = new Button(); buttonSetTaskbar.Text = "Set Taskbar"; layout.Add(buttonSetTaskbar, true, false); layout.EndHorizontal(); layout.BeginHorizontal(); layout.Add(null, false, false); layout.Add(null, true, true); layout.EndHorizontal(); Content = layout; buttonSetTaskbar.Click += ButtonShowNot_Click; }
Control NumberOfColors() { var control = new NumericStepper { MinValue = 0, MaxValue = ushort.MaxValue, Value = DataType.NumberOfColors, }; control.ValueChanged += delegate { DataType.NumberOfColors = (ushort)Math.Max(0, Math.Min(ushort.MaxValue, control.Value)); }; return(control); }
private NumericStepper ConstructStepper(PlayerCountFilter filter) { var numericStepper = new NumericStepper { Value = 0, MinValue = 0 }; numericStepper.ValueBinding .BindDataContext( Binding.Property((PlayerCountFilter x) => x.PlayerCount) .Convert(r => (double)r, v => (int)v) ); numericStepper.DataContext = filter; return(numericStepper); }
public void ValueShouldBeRoundedToDecimalPlaces(double value, double newValue, int decimalPlaces) { Invoke(() => { var numeric = new NumericStepper(); int valueChanged = 0; numeric.ValueChanged += (sender, e) => valueChanged++; numeric.DecimalPlaces = decimalPlaces; numeric.Value = value; Assert.AreEqual(newValue, numeric.Value, "Value should be be rounded to the number of decimal places"); Assert.AreEqual(1, valueChanged, "ValueChanged event was not fired the correct number of times"); }); }
public void DefaultValuesShouldBeCorrect() { Invoke(() => { var numeric = new NumericStepper(); int valueChanged = 0; numeric.ValueChanged += (sender, e) => valueChanged++; Assert.AreEqual(double.NegativeInfinity, numeric.MinValue, "MinValue should be double.NegativeInfinity"); Assert.AreEqual(double.PositiveInfinity, numeric.MaxValue, "MaxValue should be double.PositiveInfinity"); Assert.AreEqual(0, numeric.Value, "initial value should be 0"); Assert.AreEqual(0, valueChanged, "ValueChanged event should not fire when setting to default values"); }); }
public void FractionalMinValueShouldSetValueCorrectly(double value, double minValue, double newValue, int decimalPlaces) { Invoke(() => { var numeric = new NumericStepper(); int valueChanged = 0; numeric.ValueChanged += (sender, e) => valueChanged++; numeric.DecimalPlaces = decimalPlaces; numeric.Value = value; numeric.MinValue = minValue; Assert.AreEqual(newValue, numeric.Value, "Value should be changed to match new MaxValue"); Assert.AreEqual(2, valueChanged, "ValueChanged event was not fired the correct number of times"); }); }
private static void UpdateStepperPrecision(NumericStepper stepper, int numDecimals) { if (numDecimals < 0) { numDecimals = 0; } double increment = 1.0 / Math.Pow(10.0, numDecimals); stepper.DecimalPlaces = numDecimals; stepper.Increment = increment; decimal d = (decimal)stepper.Value; decimal d2 = (decimal)Math.Pow(10.0, numDecimals); d = Math.Truncate(d * d2) / d2; stepper.Value = (double)d; }