コード例 #1
0
ファイル: NumericUpDownTests.cs プロジェクト: mhusen/Eto
		public void MinMaxShouldRetainValue()
		{
			TestUtils.Invoke(() =>
			{
				var numeric = new NumericUpDown();
				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");
			});
		}
コード例 #2
0
		void LogEvents(NumericUpDown control)
		{
			control.ValueChanged += delegate
			{
				Log.Write(control, "ValueChanged, Value: {0}", control.Value);
			};
		}
コード例 #3
0
        public EthernetPortSettings(EthernetPortProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            _deviceName = new ComboBox();
            _deviceName.DataStore = LibPcapLiveDeviceList.Instance.Where(dev => dev.Interface != null);
            _deviceName.KeyBinding = new PropertyBinding<string>("Name");
            _deviceName.TextBinding = new PropertyBinding<string>("Description");
            _deviceName.SelectedValueChanged += _deviceNameChanged;

            this.BeginVertical();
            this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name);
            this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId);
            this.AddRow(new Label() { Text = Constants.DeviceNameLabel }, _deviceName);
            this.EndVertical();

            this.AddRow();
        }
コード例 #4
0
        public ForeignDevicePortSettings(ForeignDevicePortProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            _localHost = new TextBox();
            _localHost.Bind(
                tb => tb.Text,
                _process,
                proc => proc.LocalHost,
                DualBindingMode.TwoWay);

            _localPort = new NumericUpDown();
            _localPort.Bind(
                nud => nud.Value,
                _process,
                proc => proc.LocalPort,
                DualBindingMode.TwoWay);

            _bbmdHost = new TextBox();
            _bbmdHost.Bind(
                tb => tb.Text,
                _process,
                proc => proc.BbmdHost,
                DualBindingMode.TwoWay);

            _bbmdPort = new NumericUpDown();
            _bbmdPort.Bind(
                nud => nud.Value,
                _process,
                proc => proc.BbmdPort,
                DualBindingMode.TwoWay);

            this.BeginVertical();
            this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name);
            this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId);
            this.EndVertical();

            this.BeginVertical();
            this.AddRow(new Label() { Text = Constants.LocalHostLabel }, _localHost,
                new Label() { Text = Constants.LocalPortLabel }, _localPort);
            this.AddRow(new Label() { Text = Constants.BbmdHostLabel }, _bbmdHost,
                new Label() { Text = Constants.BbmdPortLabel }, _bbmdPort);
            this.EndVertical();

            this.AddRow();
        }
コード例 #5
0
        public NetworkDatabaseSettings(NetworkDatabaseProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            _databasePath = new TextBox();
            _databasePath.Bind(
                tb => tb.Text,
                _process,
                proc => proc.DatabasePath,
                DualBindingMode.TwoWay);

            this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name);
            this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId);

            this.AddRow();
        }
コード例 #6
0
		Control PenThicknessControl()
		{
			var control = new NumericUpDown { MinValue = 1, MaxValue = 100 };
			control.ValueBinding.Bind(() => PenThickness, val => { PenThickness = (float)val; Refresh(); });

			var layout = new DynamicLayout { Padding = Padding.Empty };
			layout.AddRow(new Label { Text = "Thickness:", VerticalAlign = VerticalAlign.Middle }, control);
			return layout;
		}
コード例 #7
0
ファイル: NumericUpDownSection.cs プロジェクト: hultqvist/Eto
		Control SetMinMax ()
		{
			var control = new NumericUpDown{
				Value = 24,
				MinValue = 20,
				MaxValue = 2000
			};
			LogEvents (control);
			return control;
		}
コード例 #8
0
ファイル: PenSection.cs プロジェクト: JohnACarruthers/Eto
		Control PenThicknessControl()
		{
			var control = new NumericUpDown { MinValue = 1, MaxValue = 10 };
			control.Bind(c => c.Value, this, r => r.PenThickness);
			control.ValueChanged += Refresh;
			
			var layout = new DynamicLayout(Padding.Empty);
			layout.AddRow(new Label { Text = "Thickness Step:", VerticalAlign = VerticalAlign.Middle }, control);
			return layout;
		}
コード例 #9
0
		Control GetWithDecimalPlaces()
		{
			var control = new NumericUpDown
			{
				Value = 24,
				DecimalPlaces = 5,
				Increment = 0.1
			};
			LogEvents(control);
			return control;
		}
コード例 #10
0
ファイル: NumericUpDownTests.cs プロジェクト: mhusen/Eto
		public void DefaultValuesShouldBeCorrect()
		{
			TestUtils.Invoke(() =>
			{
				var numeric = new NumericUpDown();
				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");
			});
		}
コード例 #11
0
ファイル: RouterSettings.cs プロジェクト: LorenVS/bacstack
        public RouterSettings(RouterProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            this.BeginVertical();
            this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name);
            this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId);
            this.EndVertical();

            GridView gv = new GridView();
            gv.DataStore = process.PortMappings;

            gv.Columns.Add(new GridColumn()
            {
                HeaderText = "Port Id",
                DataCell = new TextBoxCell("PortId"),
                Editable = true
            });
            gv.Columns.Add(new GridColumn()
            {
                HeaderText = "Network Number",
                DataCell = new TextBoxCell("Network"),
                Editable = true
            });

            this.BeginVertical();
            this.AddRow(gv);
            this.EndVertical();

            this.AddRow();
        }
コード例 #12
0
ファイル: NumericUpDownTests.cs プロジェクト: mhusen/Eto
		public void ValueShouldBeLimitedToMinMax()
		{
			TestUtils.Invoke(() =>
			{
				var numeric = new NumericUpDown();
				int valueChanged = 0;
				int currentValueChanged = 0;
				numeric.ValueChanged += (sender, e) => valueChanged++;

				numeric.MinValue = 0;
				numeric.MaxValue = 2000;
				Assert.AreEqual(0, numeric.MinValue, "Could not correctly set MinValue");
				Assert.AreEqual(2000, numeric.MaxValue, "Could not correctly set MaxValue");

				numeric.MinValue = 100;
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");
				Assert.AreEqual(100, numeric.Value, "Value should be set after MinValue is set");

				numeric.Value = 1000;
				Assert.AreEqual(1000, numeric.Value, "Could not correctly set Value after Min/Max is set");
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");

				numeric.Value = 2001;
				Assert.AreEqual(2000, numeric.Value, "Value should be limited to Min/Max value");
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");

				numeric.Value = -1000;
				Assert.AreEqual(100, numeric.Value, "Value should be limited to Min/Max value");
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");

				numeric.MinValue = 1000;
				Assert.AreEqual(1000, numeric.Value, "Value should be changed to match new MinValue");
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");

				numeric.MinValue = 0;
				numeric.MaxValue = 500;
				Assert.AreEqual(500, numeric.Value, "Value should be changed to match new MaxValue");
				Assert.AreEqual(++currentValueChanged, valueChanged, "ValueChanged event was not fired the correct number of times");
			});
		}
コード例 #13
0
        public PortManagerSettings(PortManagerProcess process)
        {
            _process = process;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _process,
                proc => proc.Name,
                DualBindingMode.TwoWay);

            _processId = new NumericUpDown();
            _processId.Bind(
                nud => nud.Value,
                _process,
                proc => proc.ProcessId,
                DualBindingMode.TwoWay);

            this.AddRow(new Label() { Text = Constants.ProcessNameLabel }, _name);
            this.AddRow(new Label() { Text = Constants.ProcessIdLabel }, _processId);

            this.AddRow();
        }
コード例 #14
0
ファイル: BrushSection.cs プロジェクト: picoe/Eto
		Control ScaleYControl()
		{
			var control = new NumericUpDown { MinValue = 1, MaxValue = 1000 };
			control.ValueBinding.Bind(() => ScaleY, v =>
			{
				ScaleY = (float)v;
				Refresh();
			});
			return control;
		}
コード例 #15
0
ファイル: WindowsSection.cs プロジェクト: GilbertoBotaro/Eto
		Control CreateMinimumSizeControls()
		{
			var setMinimumSize = new CheckBox { Text = "MinimumSize" };
			setMinimumSize.CheckedBinding.Bind(() => setInitialMinimumSize, v =>
			{
				setInitialMinimumSize = v ?? false;
				if (v == true && child != null)
					child.MinimumSize = initialMinimumSize;
			});

			var width = new NumericUpDown();
			width.Bind(c => c.Enabled, setMinimumSize, c => c.Checked);
			width.ValueBinding.Bind(() => initialMinimumSize.Width, v =>
			{
				initialMinimumSize.Width = (int)v;
				if (child != null)
					child.MinimumSize = initialMinimumSize;
			});

			var height = new NumericUpDown();
			height.Bind(c => c.Enabled, setMinimumSize, c => c.Checked);
			height.ValueBinding.Bind(() => initialMinimumSize.Height, v => initialMinimumSize.Height = (int)v);

			return new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Items = 
				{
					setMinimumSize,
					width,
					height
				}
			};

		}
コード例 #16
0
ファイル: WindowsSection.cs プロジェクト: GilbertoBotaro/Eto
		Control CreateClientSizeControls()
		{
			var setClientSize = new CheckBox { Text = "ClientSize" };
			setClientSize.CheckedBinding.Bind(() => setInitialClientSize, v => setInitialClientSize = v ?? false);

			var left = new NumericUpDown();
			left.Bind(c => c.Enabled, setClientSize, c => c.Checked);
			left.ValueBinding.Bind(() => initialClientSize.Width, v => initialClientSize.Width = (int)v);

			var top = new NumericUpDown();
			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
				}
			};

		}
コード例 #17
0
ファイル: WindowsSection.cs プロジェクト: GilbertoBotaro/Eto
		Control CreateInitialLocationControls()
		{
			var setLocationCheckBox = new CheckBox { Text = "Initial Location" };
			setLocationCheckBox.CheckedBinding.Bind(() => setInitialLocation, v => setInitialLocation = v ?? false);

			var left = new NumericUpDown();
			left.Bind(c => c.Enabled, setLocationCheckBox, c => c.Checked);
			left.ValueBinding.Bind(() => initialLocation.X, v => initialLocation.X = (int)v);

			var top = new NumericUpDown();
			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
				}
			};
		}
コード例 #18
0
ファイル: AllControlsBase.cs プロジェクト: Exe0/Eto
		Control NumericUpDownControl()
		{
			var control = new NumericUpDown();
			LogEvents(control);
			return control;
		}
コード例 #19
0
ファイル: NumericUpDownSection.cs プロジェクト: mhusen/Eto
		public NumericUpDownSection()
		{
			var numeric = new NumericUpDown { Width = 200 };

			LogEvents(numeric);

			var enabled = new CheckBox { Text = "Enabled" };
			enabled.CheckedBinding.Bind(numeric, n => n.Enabled);

			var readOnly = new CheckBox { Text = "ReadOnly" };
			readOnly.CheckedBinding.Bind(numeric, n => n.ReadOnly);

			var minValue = new NumericUpDown { Enabled = false, Value = -1000 };
			var minBinding = minValue.ValueBinding.Bind(numeric, n => n.MinValue, DualBindingMode.Manual);

			var chkMinValue = new CheckBox { Text = "MinValue" };
			chkMinValue.CheckedBinding.Convert(r => r == true ? DualBindingMode.OneWayToSource : DualBindingMode.Manual).Bind(minBinding, m => m.Mode);
			chkMinValue.CheckedBinding.Bind(minValue, m => m.Enabled);
			chkMinValue.CheckedBinding.Convert(r => r == false ? double.NegativeInfinity : minValue.Value).Bind(numeric, m => m.MinValue);

			var maxValue = new NumericUpDown { Enabled = false, Value = 1000 };
			var maxBinding = maxValue.ValueBinding.Bind(numeric, (n) => n.MaxValue, DualBindingMode.Manual);

			var chkMaxValue = new CheckBox { Text = "MaxValue" };
			chkMaxValue.CheckedBinding.Convert(r => r == true ? DualBindingMode.OneWayToSource : DualBindingMode.Manual).Bind(maxBinding, m => m.Mode);
			chkMaxValue.CheckedBinding.Bind(maxValue, m => m.Enabled);
			chkMaxValue.CheckedBinding.Convert(r => r == false ? double.PositiveInfinity : maxValue.Value).Bind(numeric, m => m.MaxValue);

			var decimalPlaces = new NumericUpDown { MaxValue = 15, MinValue = 0 };
			var decimalBinding = decimalPlaces.ValueBinding.Convert(r => (int)r, r => r).Bind(numeric, n => n.DecimalPlaces);

			var maxDecimalPlaces = new NumericUpDown { MaxValue = 15, MinValue = 0 };
			var maxDecimalBinding = maxDecimalPlaces.ValueBinding.Convert(r => (int)r, r => r).Bind(numeric, n => n.MaximumDecimalPlaces);

			maxDecimalBinding.Changed += (sender, e) => decimalBinding.Update(BindingUpdateMode.Destination);
			decimalBinding.Changed += (sender, e) => maxDecimalBinding.Update(BindingUpdateMode.Destination);

			var increment = new NumericUpDown { MaximumDecimalPlaces = 15 };
			increment.ValueBinding.Bind(numeric, n => n.Increment);

			var options1 = new StackLayout
			{
				Spacing = 5,
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Items =
				{
					enabled,
					readOnly
				}
			};
			var options2 = new StackLayout
			{
				Spacing = 5,
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Items =
				{
					chkMinValue, minValue,
					chkMaxValue, maxValue,
					"Increment", increment
				}
			};
			var options3 = new StackLayout
			{
				Spacing = 5,
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Items =
				{
					"DecimalPlaces", decimalPlaces,
					"MaximumDecimalPlaces", maxDecimalPlaces
				}
			};

			Content = new StackLayout
			{
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Center,
				Items = { options1, options2, options3, "Result:", numeric }
			};
		}
コード例 #20
0
		Control MaximumEnd()
		{
			var control = maximumEnd = new NumericUpDown { MinValue = 1 };
			control.DataContextChanged += delegate
			{
				control.Value = settings.MaximumPageRange.End;
			};
			control.ValueChanged += delegate
			{
				var range = settings.MaximumPageRange;
				range.End = (int)control.Value;
				settings.MaximumPageRange = range;
			};
			return control;
		}
コード例 #21
0
ファイル: BrushSection.cs プロジェクト: picoe/Eto
		Control RotationControl()
		{
			var control = new NumericUpDown { MinValue = 0, MaxValue = 360 };
			control.ValueBinding.Bind(() => Rotation, v =>
			{
				Rotation = (float)v;
				Refresh();
			});
			return control;
		}
コード例 #22
0
ファイル: BrushSection.cs プロジェクト: picoe/Eto
		Control PointControl(Func<PointF> getValue, Action<PointF> setValue)
		{
			var xpoint = new NumericUpDown();
			xpoint.ValueBinding.Bind(() => getValue().X, v =>
			{
				var p = getValue();
				p.X = (float)v;
				setValue(p);
				Refresh();
			});

			var ypoint = new NumericUpDown();
			ypoint.ValueBinding.Bind(() => getValue().Y, v =>
			{
				var p = getValue();
				p.Y = (float)v;
				setValue(p);
				Refresh();
			});

			return new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Items = { "X:", xpoint, "Y:", ypoint }
			};
		}
コード例 #23
0
		Control SelectedEnd()
		{
			var control = selectedEnd = new NumericUpDown { MinValue = 1 };
			control.DataContextChanged += delegate
			{
				control.Value = settings.SelectedPageRange.End;
			};
			control.ValueChanged += delegate
			{
				var range = settings.SelectedPageRange;
				settings.SelectedPageRange = new Range<int>(range.Start, (int)control.Value);
			};
			return control;
		}
コード例 #24
0
		Control SelectedStart()
		{
			var control = new NumericUpDown { MinValue = 1 };
			control.DataContextChanged += delegate
			{
				control.Value = settings.SelectedPageRange.Start;
			};
			control.ValueChanged += delegate
			{
				var range = settings.SelectedPageRange;
				var end = range.End;
				range = new Range<int>((int)control.Value, Math.Max(range.Start, end));
				selectedEnd.MinValue = control.Value;
				selectedEnd.Value = range.End;
				settings.SelectedPageRange = range;
			};
			return control;
		}
コード例 #25
0
		Control MaximumStart()
		{
			var control = new NumericUpDown { MinValue = 1 };
			control.DataContextChanged += delegate
			{
				control.Value = settings.MaximumPageRange.Start;
			};
			control.ValueChanged += delegate
			{
				var range = settings.MaximumPageRange;
				var end = range.End;
				range = new Range<int>((int)control.Value, Math.Max(end, range.Start));
				maximumEnd.MinValue = control.Value;
				maximumEnd.Value = range.End;
				settings.MaximumPageRange = range;
			};
			return control;
		}
コード例 #26
0
		static Control Copies()
		{
			var control = new NumericUpDown { MinValue = 1 };
			control.ValueBinding.BindDataContext<PrintSettings>(r => r.Copies, (r, v) => r.Copies = (int)v, defaultGetValue: 1);
			return control;
		}
コード例 #27
0
ファイル: BrushSection.cs プロジェクト: picoe/Eto
		Control OffsetYControl()
		{
			var control = new NumericUpDown();
			control.ValueBinding.Bind(() => OffsetY, v =>
			{
				OffsetY = (float)v;
				Refresh();
			});
			return control;
		}
コード例 #28
0
		Control Copies()
		{
			var control = new NumericUpDown { MinValue = 1 };
			control.Bind(r => r.Value, (PrintSettings s) => s.Copies, defaultControlValue: 1);
			return control;
		}
コード例 #29
0
ファイル: BrushSection.cs プロジェクト: picoe/Eto
		Control SizeControl(Func<SizeF> getValue, Action<SizeF> setValue)
		{
			var xpoint = new NumericUpDown();
			xpoint.ValueBinding.Bind(() => getValue().Width, v =>
			{
				var p = getValue();
				p.Width = (float)v;
				setValue(p);
				Refresh();
			});

			var ypoint = new NumericUpDown();
			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 }
			};
		}
コード例 #30
0
		Control Default()
		{
			var control = new NumericUpDown();
			LogEvents(control);
			return control;
		}