Represents a window or dialog box that makes up an application's user interface
상속: System.Windows.Forms.Form, IFormHabanero
 public void TestDialogResultWin_None()
 {
     //---------------Set up test pack-------------------
     FormWin formWin = new FormWin();
     DisposeOnTearDown(formWin);
     //---------------Execute Test ----------------------
     formWin.DialogResult = Habanero.Faces.Base.DialogResult.None;
     //---------------Test Result -----------------------
     Assert.AreEqual((int)DialogResult.None, (int)formWin.DialogResult);
     Assert.AreEqual(Habanero.Faces.Base.DialogResult.None.ToString(), formWin.DialogResult.ToString());
     //---------------Tear Down -------------------------
 }
예제 #2
0
 public void Test_DataSource_WhenSet_ShouldLoadComboBox()
 {
     //---------------Set up test pack-------------------
     FormWin form = new FormWin();
     DisposeOnTearDown(form);
     List<string> defs = new List<string> {"AA", "BBB"};
     IComboBox selector = CreateComboBox();
     form.Controls.Add((System.Windows.Forms.Control)selector);
     System.Windows.Forms.ComboBox winCombo = (System.Windows.Forms.ComboBox)selector;
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, winCombo.Items.Count);
     Assert.AreEqual(0, selector.Items.Count);
     //---------------Execute Test ----------------------
     selector.DataSource = defs;
     //---------------Test Result -----------------------
     Assert.AreEqual(2, winCombo.Items.Count);
     Assert.AreEqual(2, selector.Items.Count);
 }
예제 #3
0
        /// <summary>
        /// Creates a form containing OK and Cancel buttons
        /// </summary>
        /// <param name="nestedControl">The control to place above the buttons</param>
        /// <param name="formTitle">The title shown on the form</param>
        /// <returns>Returns the created form</returns>
        public IFormHabanero CreateOKCancelForm(IControlHabanero nestedControl, string formTitle)
        {
            IOKCancelPanel mainPanel = CreateOKCancelPanel(nestedControl);
            FormWin        form      = (FormWin)_controlFactory.CreateForm();

            form.Text       = formTitle;
            form.ClientSize = mainPanel.Size;
            mainPanel.Dock  = DockStyle.Fill;
            form.Controls.Add((Control)mainPanel);
            form.AcceptButton         = (IButtonControl)mainPanel.OKButton;
            mainPanel.OKButton.Click += delegate
            {
                OkButton_ClickHandler(form);
            };
            mainPanel.CancelButton.Click += delegate
            {
                CancelButton_ClickHandler(form);
            };
            return(form);
        }
        public void TestShowDatePickerForm()
        {
            //---------------Set up test pack-------------------
            IFormHabanero formWin = new FormWin();
            IDateTimePicker dateTimePicker = GetControlFactory().CreateDateTimePicker();
            dateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Custom;
            dateTimePicker.CustomFormat = @"Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: dd MMM yyyy";
            dateTimePicker.NullDisplayValue = "Please Click";
            //dateTimePicker.ShowCheckBox = true;
            ITextBox textBox = GetControlFactory().CreateTextBox();
            IButton button = GetControlFactory().CreateButton("Check/Uncheck", delegate
                                                                                   {
                                                                                       //dateTimePicker.Checked = !dateTimePicker.Checked;
                                                                                       if (dateTimePicker.ValueOrNull.HasValue)
                                                                                       {
                                                                                           dateTimePicker.ValueOrNull = null;
                                                                                       }
                                                                                       else
                                                                                       {
                                                                                           dateTimePicker.ValueOrNull = dateTimePicker.Value;
                                                                                       }
                                                                                   });
            IButton enableButton = GetControlFactory().CreateButton("Enable/Disable", delegate
                                                                                          {
                                                                                              dateTimePicker.Enabled = !dateTimePicker.Enabled;
                                                                                          });
            GridLayoutManager gridLayoutManager = new GridLayoutManager(formWin, GetControlFactory());
            gridLayoutManager.SetGridSize(5, 1);
            gridLayoutManager.AddControl(dateTimePicker);
            gridLayoutManager.AddControl(button);
            gridLayoutManager.AddControl(textBox);
            gridLayoutManager.AddControl(enableButton);
            gridLayoutManager.AddControl(GetControlFactory().CreateButton("ChangeColor", delegate
                                                                                             {
                                                                                                 Random random = new Random();
                                                                                                 dateTimePicker.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
                                                                                                 dateTimePicker.BackColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
                                                                                             }));
            dateTimePicker.ValueChanged += delegate
                                               {
                                                   textBox.Text = dateTimePicker.ValueOrNull.HasValue ? dateTimePicker.Value.ToString() : "";
                                               };
            //---------------Execute Test ----------------------
            formWin.ShowDialog();
            //---------------Test Result -----------------------

            //---------------Tear down -------------------------

        }
		public void TestShowDatePickersFormWithVisualStyles()
		{
			//---------------Set up test pack-------------------
			//Application.EnableVisualStyles();
			IFormHabanero formWin = new FormWin();
			IControlFactory controlFactory = GetControlFactory();
			IDateTimePicker dateTimePicker = controlFactory.CreateDateTimePicker();
			dateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Custom;
			dateTimePicker.CustomFormat = @"dddd MMMM yyyy";
			dateTimePicker.NullDisplayValue = "Please Click";
			//dateTimePicker.ShowCheckBox = true;
			ITextBox textBox = controlFactory.CreateTextBox();
			IButton button = controlFactory.CreateButton("Check/Uncheck", delegate
			{
				//dateTimePicker.Checked = !dateTimePicker.Checked;
				if (dateTimePicker.ValueOrNull.HasValue)
				{
					dateTimePicker.ValueOrNull = null;
				}
				else
				{
					dateTimePicker.ValueOrNull = dateTimePicker.Value;
				}
			});
			IButton enableButton = controlFactory.CreateButton("Enable/Disable", delegate
			{
				dateTimePicker.Enabled = !dateTimePicker.Enabled;
			});
			

			IPanel panel = controlFactory.CreatePanel();
			panel.Dock = DockStyle.Fill;
			formWin.Controls.Add(panel);

			GridLayoutManager gridLayoutManager = new GridLayoutManager(panel, controlFactory);
			gridLayoutManager.SetGridSize(9, 1);
			gridLayoutManager.BorderSize = 25;
			gridLayoutManager.AddControl(dateTimePicker);
			gridLayoutManager.AddControl(button);
			gridLayoutManager.AddControl(textBox);
			gridLayoutManager.AddControl(enableButton);
			gridLayoutManager.AddControl(controlFactory.CreateButton("ChangeColor", delegate
			{
				Random random = new Random();
				dateTimePicker.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
				dateTimePicker.BackColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
			}));


			IDateTimePicker anotherDateTimePicker;
			anotherDateTimePicker = controlFactory.CreateDateTimePicker();
			anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long;
			gridLayoutManager.AddControl(anotherDateTimePicker);
			anotherDateTimePicker = controlFactory.CreateDateTimePicker();
			anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Short;
			gridLayoutManager.AddControl(anotherDateTimePicker);
			anotherDateTimePicker = controlFactory.CreateDateTimePicker();
			anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Time;
			gridLayoutManager.AddControl(anotherDateTimePicker);

			anotherDateTimePicker = controlFactory.CreateDateTimePicker();
			anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long;
			anotherDateTimePicker.Font = new Font(FontFamily.GenericSansSerif, 18);
			anotherDateTimePicker.Height = 60;
			gridLayoutManager.AddControl(anotherDateTimePicker);

			dateTimePicker.ValueChanged += delegate
			{
				textBox.Text = dateTimePicker.ValueOrNull.HasValue ? dateTimePicker.Value.ToString() : "";
			};
			//---------------Execute Test ----------------------
			formWin.ShowDialog();
			//---------------Test Result -----------------------

			//---------------Tear down -------------------------

		}