Exemplo n.º 1
0
        public AddResourceWindow(IEditor <CampaignFile> editor)
        {
            this.editor = editor;

            Title = "Add new resource";

            Size      = MinimumSize = new Size(400, 250);
            Resizable = false;

            Content = new StackLayout()
            {
                Style   = "vertical",
                Spacing = 8,

                Items =
                {
                    new StackLayoutItem(new GroupBox()
                    {
                        Text    = "Select a resource type to add",
                        Content = (dropDown = new EnumRadioButtonList <ResourceType>()
                        {
                            Orientation = Orientation.Vertical,
                            Spacing = new Size(8, 8)
                        })
                    }, true),
                    new StackLayoutItem(new StackLayout()
                    {
                        Style   = "horizontal",
                        Spacing = 8,

                        Items =
                        {
                            null,
                            (DefaultButton = new Button(OnConfirm)
                            {
                                Text = "OK",
                                Image = Resources.GetIcon("CheckGreen.ico", 16),
                                Enabled = false
                            }),
                            (AbortButton = new Button(OnCancel)
                            {
                                Text = "Cancel",
                                Image = Resources.GetIcon("CloseRed.ico", 16)
                            })
                        }
                    }, false),
                }
            };

            const ResourceType typeToRemove = ResourceType.None;

            dropDown.Items.Remove(dropDown.Items.First(item =>
            {
                return(Equals(item.Key, ((int)typeToRemove).ToString()) &&
                       Equals(item.Text, typeToRemove.ToString()));
            }));

            dropDown.SelectedValueChanged += (sender, e) => DefaultButton.Enabled = true;
        }
Exemplo n.º 2
0
        Control EnumCombo()
        {
            var control = new EnumRadioButtonList <TestEnum>();

            LogEvents(control);
            control.SelectedValue = TestEnum.Enum2;
            return(control);
        }
Exemplo n.º 3
0
		Control TestProperties()
		{
			var min = new DateTimePicker();
			var max = new DateTimePicker();
			var setValue = new DateTimePicker();
			var toValue = new DateTimePicker();
			var modeSelect = new EnumRadioButtonList<CalendarMode>();
			var current = new Calendar();
			var setButton = new Button { Text = "Set" };
			var toValueSection = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Visible = false,
				Spacing = 5,
				Items = { " to ", toValue }
			};

			var layout = new TableLayout
			{
				Spacing = new Size(5, 5),
				Padding = new Padding(10),
				Rows = 
				{
					new TableRow("Min Value", min),
					new TableRow("Max Value", max),
					new TableRow("Mode", modeSelect),
					new TableRow("Set to value",
						new StackLayout
						{
							Orientation = Orientation.Horizontal,
							Spacing = 5,
							Items = { setValue, toValueSection, setButton }
						}
					),
					new TableRow("Value", TableLayout.AutoSized(current), null),
					null
				}
			};

			modeSelect.SelectedValueBinding.Bind(() => current.Mode, v =>
			{
				toValueSection.Visible = v == CalendarMode.Range;
				current.Mode = v;
			});
			min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
			max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
			setButton.Click += (sender, e) =>
			{
				if (current.Mode == CalendarMode.Range)
					current.SelectedRange = (setValue.Value != null && toValue.Value != null) ? new Range<DateTime>(setValue.Value.Value, toValue.Value.Value) : current.SelectedRange;
				else
					current.SelectedDate = setValue.Value ?? current.SelectedDate;
			};
			LogEvents(current);

			return layout;
		}
Exemplo n.º 4
0
        Control CreateModeControl()
        {
            var control = new EnumRadioButtonList <DrawMode>();

            control.SelectedValueBinding.Bind(() => Mode, v =>
            {
                Mode = v;
                Refresh();
            });
            return(control);
        }
Exemplo n.º 5
0
		Control WindowState()
		{
			stateCombo = new EnumRadioButtonList<WindowState>
			{
				SelectedValue = Forms.WindowState.Normal
			};
			stateCombo.SelectedIndexChanged += (sender, e) => {
				if (child != null)
					child.WindowState = stateCombo.SelectedValue;
			};
			return stateCombo;
		}
Exemplo n.º 6
0
		Control WindowStyle()
		{
			styleCombo = new EnumRadioButtonList<WindowStyle>
			{
				SelectedValue = Forms.WindowStyle.Default
			};
			styleCombo.SelectedIndexChanged += (sender, e) => {
				if (child != null)
					child.WindowStyle = styleCombo.SelectedValue;
			};
			return styleCombo;
		}
Exemplo n.º 7
0
        public void EnabledShouldBeToggleable(bool initiallyEnabled)
        {
            int  incorrectTableLayoutEnabledState = 0;
            int  changedCount = 0;
            bool initialStateMatchesInitiallyEnabled = false;

            ManualForm("You should be able to toggle the radio buttons between enabled and disabled.\nChange the check box twice and verify the result.",
                       form =>
            {
                var label = new Label {
                    TextAlignment = TextAlignment.Left
                };
                var radio = new EnumRadioButtonList <TestEnum> {
                    Orientation = Orientation.Vertical
                };
                var check = new CheckBox {
                    Text = "Enable radio buttons", Checked = initiallyEnabled
                };
                radio.EnabledChanged += (sender, e) => label.Text = $"EnabledChanged->radio.Enabled({radio.Enabled})";
                radio.Enabled         = initiallyEnabled;
                Assert.AreEqual(initiallyEnabled, radio.Enabled, "#1.1");
                check.CheckedChanged += (sender, e) => {
                    var isChecked = check.Checked == true;
                    radio.Enabled = isChecked;
                    changedCount++;
                    // check visual child enabled state
                    var tableLayout = radio.VisualChildren.OfType <TableLayout>().FirstOrDefault();
                    if (tableLayout?.Enabled != isChecked)
                    {
                        incorrectTableLayoutEnabledState++;
                    }
                };

                radio.LoadComplete += (sender, e) =>
                {
                    var theButton = radio.VisualChildren.OfType <RadioButton>().FirstOrDefault();
                    if (theButton?.Enabled == initiallyEnabled)
                    {
                        initialStateMatchesInitiallyEnabled = true;
                    }
                };

                form.ClientSize = new Size(450, -1);
                form.Resizable  = true;
                return(new TableLayout {
                    Rows = { check, radio, label }
                });
            });

            Assert.AreEqual(0, incorrectTableLayoutEnabledState, "#2.1 - internal TableLayout did not have the correct enabled state");
            Assert.GreaterOrEqual(changedCount, 2, "#2.2 - The check box was not toggled at least twice");
            Assert.IsTrue(initialStateMatchesInitiallyEnabled, "#2.3 - initial state of radio button did not match");
        }
Exemplo n.º 8
0
 Control WindowState()
 {
     stateCombo = new EnumRadioButtonList <WindowState>
     {
         SelectedValue = Forms.WindowState.Normal
     };
     stateCombo.SelectedIndexChanged += (sender, e) => {
         if (child != null)
         {
             child.WindowState = stateCombo.SelectedValue;
         }
     };
     return(stateCombo);
 }
Exemplo n.º 9
0
		Control TestProperties()
		{
			var min = new DateTimePicker();
			var max = new DateTimePicker();
			var setValue = new DateTimePicker();
			var toValue = new DateTimePicker();
			var modeSelect = new EnumRadioButtonList<CalendarMode>();
			var current = new Calendar();
			var setButton = new Button { Text = "Set" };
			TableLayout toValueSection;

			var layout = new TableLayout(
				new TableRow(new Label { Text = "Min Value" }, min),
				new TableRow(new Label { Text = "Max Value" }, max),
				new TableRow(new Label { Text = "Mode" }, modeSelect), 
				new TableRow(new Label { Text = "Set to value" },
					new TableLayout(new TableRow(setValue,
						toValueSection = new TableLayout(new TableRow(new Label { Text = " to " }, toValue)) { Visible = false, Padding = Padding.Empty },
						setButton
					)) { Padding = Padding.Empty }
				),
				new TableRow(new Label { Text = "Value" }, TableLayout.AutoSized(current), null),
				null
			);

			modeSelect.SelectedValueBinding.Bind(() => current.Mode, v => {
				toValueSection.Visible = v == CalendarMode.Range;
				current.Mode = v;
			});
			min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
			max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
			setButton.Click += (sender, e) =>
			{
				if (current.Mode == CalendarMode.Range)
					current.SelectedRange = (setValue.Value != null && toValue.Value != null) ? new Range<DateTime>(setValue.Value.Value, toValue.Value.Value) : current.SelectedRange;
				else
					current.SelectedDate = setValue.Value ?? current.SelectedDate;
			};
			LogEvents(current);

			return layout;
		}
Exemplo n.º 10
0
        Control WindowStyle()
        {
            var enableStyle = new CheckBox {
                Checked = false
            };

            styleCombo = new EnumRadioButtonList <WindowStyle>
            {
                SelectedValue = Forms.WindowStyle.Default
            };
            styleCombo.SelectedIndexChanged += (sender, e) =>
            {
                if (child != null)
                {
                    child.WindowStyle = styleCombo.SelectedValue;
                }
            };

            styleCombo.Bind(c => c.Enabled, enableStyle, c => c.Checked);
            return(new TableLayout(new TableRow(enableStyle, styleCombo)));
        }
Exemplo n.º 11
0
		Control EnumCombo()
		{
			var control = new EnumRadioButtonList<TestEnum>();
			LogEvents(control);
			control.SelectedValue = TestEnum.Enum2;
			return control;
		}
Exemplo n.º 12
0
        Control TestProperties()
        {
            var min        = new DateTimePicker();
            var max        = new DateTimePicker();
            var setValue   = new DateTimePicker();
            var toValue    = new DateTimePicker();
            var modeSelect = new EnumRadioButtonList <CalendarMode>();
            var current    = new Calendar();
            var setButton  = new Button {
                Text = "Set"
            };
            var toValueSection = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                Visible     = false,
                Spacing     = 5,
                Items       = { " to ", toValue }
            };

            var layout = new TableLayout
            {
                Spacing = new Size(5, 5),
                Padding = new Padding(10),
                Rows    =
                {
                    new TableRow("Min Value",    min),
                    new TableRow("Max Value",    max),
                    new TableRow("Mode",         modeSelect),
                    new TableRow("Set to value",
                                 new StackLayout
                    {
                        Orientation = Orientation.Horizontal,
                        Spacing     = 5,
                        Items       = { setValue, toValueSection,               setButton   }
                    }
                                 ),
                    new TableRow("Value",        TableLayout.AutoSized(current),null),
                    null
                }
            };

            modeSelect.SelectedValueBinding.Bind(() => current.Mode, v =>
            {
                toValueSection.Visible = v == CalendarMode.Range;
                current.Mode           = v;
            });
            min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
            max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
            setButton.Click  += (sender, e) =>
            {
                if (current.Mode == CalendarMode.Range)
                {
                    current.SelectedRange = (setValue.Value != null && toValue.Value != null) ? new Range <DateTime>(setValue.Value.Value, toValue.Value.Value) : current.SelectedRange;
                }
                else
                {
                    current.SelectedDate = setValue.Value ?? current.SelectedDate;
                }
            };
            LogEvents(current);

            return(layout);
        }
Exemplo n.º 13
0
        Control TestProperties()
        {
            var min        = new DateTimePicker();
            var max        = new DateTimePicker();
            var setValue   = new DateTimePicker();
            var toValue    = new DateTimePicker();
            var modeSelect = new EnumRadioButtonList <CalendarMode>();
            var current    = new Calendar();
            var setButton  = new Button {
                Text = "Set"
            };
            TableLayout toValueSection;

            var layout = new TableLayout(
                new TableRow(new Label {
                Text = "Min Value"
            }, min),
                new TableRow(new Label {
                Text = "Max Value"
            }, max),
                new TableRow(new Label {
                Text = "Mode"
            }, modeSelect),
                new TableRow(new Label {
                Text = "Set to value"
            },
                             new TableLayout(new TableRow(setValue,
                                                          toValueSection = new TableLayout(new TableRow(new Label {
                Text = " to "
            }, toValue))
            {
                Visible = false, Padding = Padding.Empty
            },
                                                          setButton
                                                          ))
            {
                Padding = Padding.Empty
            }
                             ),
                new TableRow(new Label {
                Text = "Value"
            }, TableLayout.AutoSized(current), null),
                null
                );

            modeSelect.SelectedValueBinding.Bind(() => current.Mode, v => {
                toValueSection.Visible = v == CalendarMode.Range;
                current.Mode           = v;
            });
            min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
            max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
            setButton.Click  += (sender, e) =>
            {
                if (current.Mode == CalendarMode.Range)
                {
                    current.SelectedRange = (setValue.Value != null && toValue.Value != null) ? new Range <DateTime>(setValue.Value.Value, toValue.Value.Value) : current.SelectedRange;
                }
                else
                {
                    current.SelectedDate = setValue.Value ?? current.SelectedDate;
                }
            };
            LogEvents(current);

            return(layout);
        }