示例#1
0
            public OKCancelPanelVWG(IControlFactory controlFactory)
            {
                //_controlFactory = controlFactory;
                //// create content panel
                //_contentPanel = _controlFactory.CreatePanel();
                //_contentPanel.Dock = DockStyle.Fill;
                //this.Controls.Add((Control)_contentPanel);

                //// create buttons
                //IButtonGroupControl buttonGroupControl = _controlFactory.CreateButtonGroupControl();
                //buttonGroupControl.Dock = DockStyle.Bottom;
                //_okButton = buttonGroupControl.AddButton("OK");
                //_okButton.NotifyDefault(true);
                //_cancelButton = buttonGroupControl.AddButton("Cancel");
                //this.Controls.Add((Control)buttonGroupControl);

                _controlFactory = controlFactory;
                // create content panel
                _contentPanel = _controlFactory.CreatePanel();
                // create buttons
                _buttonGroupControl = _controlFactory.CreateButtonGroupControl();
                _cancelButton       = _buttonGroupControl.AddButton("Cancel");
                _okButton           = _buttonGroupControl.AddButton("OK");
                _okButton.NotifyDefault(true);

                BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

                layoutManager.AddControl(_contentPanel, BorderLayoutManager.Position.Centre);
                layoutManager.AddControl(_buttonGroupControl, BorderLayoutManager.Position.South);
            }
示例#2
0
        public void Test_Visually_Advanced()
        {
            //---------------Set up test pack-------------------
            IControlFactory controlFactory = GetControlFactory();
            IGroupBox       groupBox       = controlFactory.CreateGroupBox("Test Layout");
            IPanel          panel          = controlFactory.CreatePanel();

            panel.Dock = DockStyle.Fill;
            groupBox.Controls.Add(panel);
            ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(panel, controlFactory)
            {
                ColumnCount = 1
            };
            int    controlNumber = 1;
            IPanel panel1        = CreateColoredPanel(controlFactory, controlNumber++ + ":");

            panel1.Controls.Clear();
            GridLayoutManager gridLayoutManager = new GridLayoutManager(panel1, controlFactory);

            gridLayoutManager.SetGridSize(4, 3);
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "a:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "b:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "c:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "d:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "e:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "f:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "g:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "h:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "i:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "j:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "k:"));
            gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "l:"));


            columnLayoutManager.AddControl(panel1);
            columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":"));
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();

            buttonGroupControl.Dock = DockStyle.Top;
            groupBox.Controls.Add(buttonGroupControl);
            buttonGroupControl.AddButton("Add Control", (sender, e) => columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":")));
            buttonGroupControl.AddButton("-Columns", (sender, e) =>
            {
                if (columnLayoutManager.ColumnCount > 1)
                {
                    columnLayoutManager.ColumnCount--;
                    columnLayoutManager.Refresh();
                }
            });
            buttonGroupControl.AddButton("+Columns", (sender, e) => { columnLayoutManager.ColumnCount++; columnLayoutManager.Refresh(); });
            IFormHabanero form = controlFactory.CreateOKCancelDialogFactory().CreateOKCancelForm(groupBox, "Test Column Layout Manager");

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            form.ShowDialog();
            //---------------Test Result -----------------------
        }
 private void SetupButtonGroupControl()
 {
     _buttonGroupControl   = _controlFactory.CreateButtonGroupControl();
     _cancelButton         = _buttonGroupControl.AddButton("Cancel", CancelButtonClicked);
     _saveButton           = _buttonGroupControl.AddButton("Save", SaveClickHandler);
     _deleteButton         = _buttonGroupControl.AddButton("Delete", DeleteButtonClicked);
     _newButton            = _buttonGroupControl.AddButton("New", NewButtonClicked);
     _cancelButton.Enabled = false;
     _deleteButton.Enabled = false;
     _newButton.Enabled    = false;
 }
示例#4
0
        public void Test_AddButton_WithTwoButtons_ShouldHaveTwoControls()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();

            AddControlToForm(buttons);
            IButton btn = buttons.AddButton("Test");

            //---------------Execute Test ----------------------
            buttons.AddButton("Test2");
            //---------------Test Result -----------------------
            Assert.AreEqual(2, buttons.Controls.Count);
            Assert.AreSame(btn, buttons.Controls[0]);
        }
示例#5
0
/*
 *      ///<summary>
 *      /// Construct the Dialog form for any situation e.g. where the Form being closed has
 *      /// Mutliple Business Objects is a wizard etc.
 *      ///</summary>
 *      /// <param name="controlFactory">The control Factory used to construct buttons, labels etc by ths control</param>
 *      ///<param name="fullDisplayName">Full display name for the BusienssObject(s)</param>
 *      ///<param name="isInValidState">Are the BusinessObject(s) in a valid state</param>
 *      ///<param name="isDirty"></param>
 *      ///<exception cref="ArgumentNullException">control Factory must not be null</exception>
 *      public CloseBOEditorDialogWin(IControlFactory controlFactory, string fullDisplayName, bool isInValidState, bool isDirty)
 *      {
 *          if (controlFactory == null) throw new ArgumentNullException("controlFactory");
 *          ConstructControl(controlFactory, fullDisplayName, isInValidState, isDirty);
 *          SetSize();
 *      }*/



        private void ConstructControl(IControlFactory controlFactory)
        {
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();

            CancelCloseBtn        = buttonGroupControl.AddButton("CancelClose", "Cancel Close", ButtonClick);
            CloseWithoutSavingBtn = buttonGroupControl.AddButton("CloseWithoutSaving", "&Close without saving", ButtonClick);
            SaveAndCloseBtn       = buttonGroupControl.AddButton("SaveAndClose", "&Save & Close", ButtonClick);

            _label = controlFactory.CreateLabel();
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(_label, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South);
        }
示例#6
0
        public void Test_ButtonsIndexer_WhenManyButtons_ShouldReturnButtonByName()
        {
            //---------------Set up test pack-------------------
            const string        buttonName = "Test";
            IButtonGroupControl buttons    = CreateButtonGroupControl();

            buttons.AddButton(TestUtil.GetRandomString());
            IButton btn = buttons.AddButton(buttonName);

            buttons.AddButton(TestUtil.GetRandomString());
            //---------------Execute Test ----------------------
            IButton returnedButton = buttons[buttonName];

            //---------------Test Result -----------------------
            Assert.AreSame(btn, returnedButton);
        }
        ///<summary>
        /// Constructor for the <see cref="HelpAboutBoxManager"/>
        ///</summary>
        ///<param name="controlFactory"></param>
        ///<param name="formHabanero"></param>
        ///<param name="programName"></param>
        ///<param name="producedForName"></param>
        ///<param name="producedByName"></param>
        ///<param name="versionNumber"></param>
        public HelpAboutBoxManager(IControlFactory controlFactory, IFormHabanero formHabanero, string programName, string producedForName, string producedByName, string versionNumber)
        {
            _FormHabanero = formHabanero;
            _mainPanel    = controlFactory.CreatePanel();
            GridLayoutManager mainPanelManager = new GridLayoutManager(_mainPanel, controlFactory);

            mainPanelManager.SetGridSize(4, 2);
            mainPanelManager.FixAllRowsBasedOnContents();
            mainPanelManager.FixColumnBasedOnContents(0);
            mainPanelManager.FixColumnBasedOnContents(1);
            mainPanelManager.AddControl(controlFactory.CreateLabel("Programme Name:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(programName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced For:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedForName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Produced By:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(producedByName, false));
            mainPanelManager.AddControl(controlFactory.CreateLabel("Version:", false));
            mainPanelManager.AddControl(controlFactory.CreateLabel(versionNumber, false));

            IButtonGroupControl buttons = controlFactory.CreateButtonGroupControl();

            buttons.AddButton("OK", new EventHandler(OKButtonClickHandler));

            BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(formHabanero);

            manager.AddControl(_mainPanel, BorderLayoutManager.Position.Centre);
            manager.AddControl(buttons, BorderLayoutManager.Position.South);
            formHabanero.Width  = 300;
            formHabanero.Height = 200;
            formHabanero.Text   = "About";
        }
        ///<summary>
        /// A constructor for the <see cref="ErrorDescriptionForm"/>
        ///</summary>
        public ErrorDescriptionForm()
        {
            IControlFactory controlFactory = GlobalUIRegistry.ControlFactory;
            ILabel          label          = controlFactory.CreateLabel("Please enter further details regarding the error : ");

            _errorDescriptionTextBox          = controlFactory.CreateTextBox();
            ErrorDescriptionTextBox.Multiline = true;
            IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();

            buttonGroupControl.AddButton("OK", delegate { this.Close(); });
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(label, BorderLayoutManager.Position.North);
            layoutManager.AddControl(ErrorDescriptionTextBox, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South);
            this.Text     = "Error Description";
            this.Width    = 500;
            this.Height   = 400;
            this.Closing += delegate(object sender, CancelEventArgs e)
            {
                if (ErrorDescriptionFormClosing == null)
                {
                    return;
                }
                ErrorDescriptionFormClosing(sender, e);
            };
        }
            /// <summary>
            /// Constructor that sets up the error message form
            /// </summary>
            public CollapsibleExceptionNotifyForm(Exception ex, string furtherMessage, string title)
            {
                this._exception = ex;

                this._summary        = _controlFactory.CreatePanel();
                this._summary.Text   = title;
                this._summary.Height = SUMMARY_HEIGHT;
                ITextBox messageTextBox = GetSimpleMessage(ex.Message);

                messageTextBox.ScrollBars = ScrollBars.Vertical;
                ILabel messageLabel = GetErrorLabel(furtherMessage);
                BorderLayoutManager summaryManager = _controlFactory.CreateBorderLayoutManager(_summary);

                summaryManager.AddControl(messageLabel, BorderLayoutManager.Position.North);
                summaryManager.AddControl(messageTextBox, BorderLayoutManager.Position.Centre);

                this._buttonsOK = _controlFactory.CreateButtonGroupControl();
                this._buttonsOK.AddButton("&OK", new EventHandler(OKButtonClickHandler));

                this._buttonsDetail = _controlFactory.CreateButtonGroupControl();
                this._buttonsDetail.AddButton("Email Error", EmailErrorClickHandler);
                this._moreDetailButton    = _buttonsDetail.AddButton("More Detail »", MoreDetailClickHandler);
                this._buttonsDetail.Width = 2 * (_moreDetailButton.Width + 9);
                this._fullDetailsVisible  = false;

                this.SetFullDetailsPanel();
                this.LayoutForm();

                this.Text          = title;
                this.Width         = 600;
                this.Height        = SUMMARY_HEIGHT + BUTTONS_HEIGHT + 16;
                this.StartPosition = FormStartPosition.CenterScreen;
                //this.Resize += ResizeForm;
            }
            /// <summary>
            /// Constructor that sets up the error message form
            /// </summary>
            public CollapsibleExceptionNotifyForm(Exception ex, string furtherMessage, string title)
            {
                _exception = ex;

                _summaryPanel        = new PanelVWG();
                _summaryPanel.Text   = title;
                _summaryPanel.Height = SUMMARY_HEIGHT;
                ITextBox            messageTextBox = GetSimpleMessage(ex.Message);
                ILabel              messageLabel   = GetErrorLabel(furtherMessage);
                BorderLayoutManager summaryManager = new BorderLayoutManagerVWG(_summaryPanel, GlobalUIRegistry.ControlFactory);

                summaryManager.AddControl(messageLabel, BorderLayoutManager.Position.North);
                summaryManager.AddControl(messageTextBox, BorderLayoutManager.Position.Centre);

                IButtonGroupControl buttonsOK = GlobalUIRegistry.ControlFactory.CreateButtonGroupControl();

                buttonsOK.AddButton("&OK", OKButtonClickHandler);
                buttonsOK.Height = BUTTONS_HEIGHT;

                IButtonGroupControl buttonsDetail = GlobalUIRegistry.ControlFactory.CreateButtonGroupControl();

                buttonsDetail.AddButton("Email Error", EmailErrorClickHandler);
                _moreDetailButton    = buttonsDetail.AddButton("More Detail »", MoreDetailClickHandler);
                buttonsDetail.Height = BUTTONS_HEIGHT;
                buttonsDetail.Width  = 2 * (_moreDetailButton.Width + 9);

                SetFullDetailsPanel();

                BorderLayoutManager manager = //new BorderLayoutManagerVWG(this, GlobalUIRegistry.ControlFactory);
                                              GlobalUIRegistry.ControlFactory.CreateBorderLayoutManager(this);

                manager.AddControl(_summaryPanel, BorderLayoutManager.Position.North);
                manager.AddControl(buttonsDetail, BorderLayoutManager.Position.West);
                manager.AddControl(buttonsOK, BorderLayoutManager.Position.East);
                manager.AddControl(_fullDetailPanel, BorderLayoutManager.Position.South);


                Text          = title;
                Width         = 600;
                Height        = SUMMARY_HEIGHT + BUTTONS_HEIGHT + 16;
                StartPosition = FormStartPosition.Manual;
                Location      = new Point(50, 50);
                Resize       += ResizeForm;
            }
        public void Test_UseMnemonic_WinOnly()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();

            //---------------Execute Test ----------------------
            System.Windows.Forms.Button btn = (System.Windows.Forms.Button)buttons.AddButton("Test", delegate { });
            //---------------Test Result -----------------------
            Assert.IsTrue(btn.UseMnemonic);
        }
        public void Test_ButtonIndexer_WithASpecialCharactersInTheName_Failing()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();
            //---------------Execute Test ----------------------
            const string buttonText = "T est@";
            IButton      btn        = buttons.AddButton(buttonText);

            //---------------Test Result -----------------------
            Assert.AreSame(btn, buttons["T est@"]);
        }
示例#13
0
        public void Test_ButtonIndexer_WithSpecialCharactersInTheName_ShouldReturnCorrectButton()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();
            //---------------Execute Test ----------------------
            const string buttonText = "T est%_&^ #$�<>()!:;.,?[]+-=*/'";
            IButton      btn        = buttons.AddButton(buttonText);

            //---------------Test Result -----------------------
            Assert.AreSame(btn, buttons[buttonText]);
        }
示例#14
0
        // Note: Mark- This test seems pointless. Why do we need it?
        public void Test_HideButton()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();
            //---------------Execute Test ----------------------
            IButton btn = buttons.AddButton("Test");

            //---------------Test Result -----------------------
            Assert.IsTrue(btn.Visible);
            buttons["Test"].Visible = false;
            Assert.IsFalse(btn.Visible);
        }
示例#15
0
        public void Test_ButtonSizePolicy_ShouldBeUsedByButtonGroupControl()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttonGroupControl = CreateButtonGroupControl();
            IButtonSizePolicy   buttonSizePolicy   = MockRepository.GenerateStub <IButtonSizePolicy>();

            buttonGroupControl.ButtonSizePolicy = buttonSizePolicy;
            //---------------Execute Test ----------------------
            buttonGroupControl.AddButton("");
            //---------------Test Result -----------------------
            buttonSizePolicy.AssertWasCalled(policy => policy.RecalcButtonSizes(Arg <IControlCollection> .Is.NotNull));
        }
示例#16
0
        public void Test_CustomButtonEventHandler()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons      = CreateButtonGroupControl();
            EventHandler        eventHandler = MockRepository.GenerateStub <EventHandler>();
            IButton             btn          = buttons.AddButton("Test", eventHandler);

            //---------------Execute Test ----------------------
            btn.PerformClick();
            //---------------Test Result -----------------------
            eventHandler.AssertWasCalled(handler => handler(Arg <object> .Is.Same(btn), Arg <EventArgs> .Is.NotNull));
        }
示例#17
0
        public void Test_ButtonsIndexer_WhenNotFound_ShouldReturnNull()
        {
            //---------------Set up test pack-------------------
            const string        buttonName = "Test";
            IButtonGroupControl buttons    = CreateButtonGroupControl();
            IButton             btn        = buttons.AddButton(buttonName);
            //---------------Execute Test ----------------------
            IButton returnedButton = buttons["NotFound"];

            //---------------Test Result -----------------------
            Assert.IsNull(returnedButton);
        }
        public void Test_SetDefaultButton_WinOnly()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();
            IButton             btn     = buttons.AddButton("Test");

            System.Windows.Forms.Form frm = new System.Windows.Forms.Form();
            frm.Controls.Add((System.Windows.Forms.Control)buttons);
            //---------------Execute Test ----------------------
            buttons.SetDefaultButton("Test");
            //---------------Test Result -----------------------
            Assert.AreSame(btn, frm.AcceptButton);
        }
示例#19
0
        public void TestButtonWidthPolicy_UserDefined()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttonGroupControl = GetControlFactory().CreateButtonGroupControl();

            DisposeOnTearDown(buttonGroupControl);
            Size buttonSize = new Size(20, 50);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            buttonGroupControl.ButtonSizePolicy = new ButtonSizePolicyUserDefined();
            IButton btnTest1 = buttonGroupControl.AddButton("");

            DisposeOnTearDown(btnTest1);
            btnTest1.Size = buttonSize;

            buttonGroupControl.AddButton("Bigger button");
            //---------------Test Result -----------------------

            Assert.AreEqual(buttonSize, btnTest1.Size);
        }
示例#20
0
        public void Test_AddButton_WithCustomButtonEventHandler()
        {
            //---------------Set up test pack-------------------
            const string        buttonName = "Test";
            IButtonGroupControl buttons    = CreateButtonGroupControl();
            //---------------Execute Test ----------------------
            IButton btnTest = buttons.AddButton(buttonName, delegate {  });

            //---------------Test Result -----------------------
            Assert.IsNotNull(btnTest);
            Assert.AreEqual(buttonName, btnTest.Text);
            Assert.AreEqual(1, buttons.Controls.Count);
            Assert.AreEqual(buttonName, btnTest.Name);
        }
示例#21
0
        public void Test_SetDefaultButton()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl buttons = CreateButtonGroupControl();

            buttons.AddButton("Test");
            Gizmox.WebGUI.Forms.Form frm = new Gizmox.WebGUI.Forms.Form();
            frm.Controls.Add((Gizmox.WebGUI.Forms.Control)buttons);
            //---------------Execute Test ----------------------
            buttons.SetDefaultButton("Test");
            //---------------Test Result -----------------------
            Assert.AreSame(null, frm.AcceptButton);
            //Assert.AreSame(btn, frm.AcceptButton);
        }
示例#22
0
        public void Test_AddButton_ShouldLinkUpClickDelegate()
        {
            //---------------Set up test pack-------------------
            const string        buttonText = "Test";
            const string        buttonname = "buttonName";
            IButtonGroupControl buttons    = CreateButtonGroupControl();
            bool clicked = false;
            //---------------Execute Test ----------------------
            IButton btnTest = buttons.AddButton(buttonname, buttonText, delegate { clicked = true; });

            ////---------------Test Result -----------------------
            btnTest.PerformClick();
            Assert.IsTrue(clicked);
        }
示例#23
0
        public void Test_AddButton_ShouldBeRightAligned()
        {
            //---------------Set up test pack-------------------

            IButtonGroupControl buttonGroupControl = CreateButtonGroupControl();

            buttonGroupControl.Width = 200;
            //---------------Execute Test ----------------------
            IButton btnTest = buttonGroupControl.AddButton("Test");

            ////---------------Test Result -----------------------

            Assert.AreEqual(buttonGroupControl.Width - 5 - btnTest.Width, btnTest.Left,
                            "Button should be right aligned.");
        }
示例#24
0
        public void Test_AddButton_WhenButtonBiggerthanGroup_ShouldBeRightAligned()
        {
            //---------------Set up test pack-------------------

            IButtonGroupControl buttonGroupControl = CreateButtonGroupControl();

            buttonGroupControl.Width = 50;
            //---------------Execute Test ----------------------
            IButton btnTest = buttonGroupControl.AddButton("Test");

            ////---------------Test Result -----------------------
            //Wierd the button gonna be off the screen to the left maybe flow layout manager should do something else maybe not who knows
            Assert.AreEqual(buttonGroupControl.Width - 5 - btnTest.Width, btnTest.Left,
                            "Button should be right aligned.");
        }
示例#25
0
        public void Test_AddButton_ShouldCreateButtonAndAddToControl()
        {
            //---------------Set up test pack-------------------
            const string        buttonText = "Test";
            IButtonGroupControl buttons    = CreateButtonGroupControl();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, buttons.Controls.Count);
            //---------------Execute Test ----------------------
            IButton btnTest = buttons.AddButton(buttonText);

            ////---------------Test Result -----------------------
            Assert.IsNotNull(btnTest);
            Assert.AreEqual(buttonText, btnTest.Text);
            Assert.AreEqual(buttonText, btnTest.Name);
            Assert.AreEqual(1, buttons.Controls.Count);
            Assert.AreSame(btnTest, buttons.Controls[0]);
        }
示例#26
0
        public void Test_AddButton_WhenTextDifferentThanName_ShouldHaveCorrectTextAndName()
        {
            //---------------Set up test pack-------------------
            const string        buttonText = "Test";
            const string        buttonName = "buttonName";
            IButtonGroupControl buttons    = CreateButtonGroupControl();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, buttons.Controls.Count);
            //---------------Execute Test ----------------------
            IButton btnTest = buttons.AddButton(buttonName, buttonText, null);

            //---------------Test Result -----------------------
            Assert.IsNotNull(btnTest);
            Assert.AreEqual(buttonText, btnTest.Text);
            Assert.AreEqual(buttonName, btnTest.Name);
            Assert.AreEqual(1, buttons.Controls.Count);
        }
示例#27
0
        public void Test_CustomButtonEventHandler_WhenExceptionThrown_ShouldBeCaughtByUIExceptionNotifier()
        {
            //---------------Set up test pack-------------------
            IButtonGroupControl        buttons = CreateButtonGroupControl();
            RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier();

            GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier;
            bool      clickEventFired = false;
            Exception exception       = new Exception();
            IButton   btn             = buttons.AddButton("Test", delegate
            {
                clickEventFired = true;
                throw exception;
            });

            //---------------Execute Test ----------------------
            btn.PerformClick();
            //---------------Test Result -----------------------
            Assert.IsTrue(clickEventFired, "The click event should have fired");
            Assert.AreEqual(1, recordingExceptionNotifier.Exceptions.Count);
            Assert.AreSame(exception, recordingExceptionNotifier.Exceptions[0].Exception);
            Assert.AreSame("Error performing action", recordingExceptionNotifier.Exceptions[0].FurtherMessage);
            Assert.AreSame("Error", recordingExceptionNotifier.Exceptions[0].Title);
        }
            /// <summary>
            /// Constructor that sets up the error message form
            /// </summary>
            public CollapsibleExceptionNotifyForm(Exception ex, string furtherMessage, string title)
            {
                this._exception = ex;

                this._summary = _controlFactory.CreatePanel();
                this._summary.Text = title;
                this._summary.Height = SUMMARY_HEIGHT;
                ITextBox messageTextBox = GetSimpleMessage(ex.Message);
                messageTextBox.ScrollBars = ScrollBars.Vertical;
                ILabel messageLabel = GetErrorLabel(furtherMessage);
                BorderLayoutManager summaryManager = _controlFactory.CreateBorderLayoutManager(_summary);
                summaryManager.AddControl(messageLabel, BorderLayoutManager.Position.North);
                summaryManager.AddControl(messageTextBox, BorderLayoutManager.Position.Centre);

                this._buttonsOK = _controlFactory.CreateButtonGroupControl();
                this._buttonsOK.AddButton("&OK", new EventHandler(OKButtonClickHandler));

                this._buttonsDetail = _controlFactory.CreateButtonGroupControl();
                this._buttonsDetail.AddButton("Email Error", EmailErrorClickHandler);
                this._moreDetailButton = _buttonsDetail.AddButton("More Detail »", MoreDetailClickHandler);
                this._buttonsDetail.Width = 2 * (_moreDetailButton.Width + 9);
                this._fullDetailsVisible = false;

                this.SetFullDetailsPanel();
                this.LayoutForm();

                this.Text = title;
                this.Width = 600;
                this.Height = SUMMARY_HEIGHT + BUTTONS_HEIGHT + 16;
                this.StartPosition = FormStartPosition.CenterScreen;
                //this.Resize += ResizeForm;
            }
示例#29
0
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormWin"/> class  with
        /// the specified businessObject, uiDefName and post edit action.
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        /// <param name="creator">The Creator used to Create the Group Control.</param>
        public DefaultBOEditorFormWin(BusinessObject bo, string uiDefName, IControlFactory controlFactory, GroupControlCreator creator)
        {
            _bo                 = bo;
            _controlFactory     = controlFactory;
            GroupControlCreator = creator;
            _uiDefName          = uiDefName;

            BOMapper mapper = new BOMapper(bo);

            IUIForm def;

            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);

            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm, this.GroupControlCreator);
            _panelInfo = panelBuilder.BuildPanelForForm(def, this.GroupControlCreator);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;

            _buttons = _controlFactory.CreateButtonGroupControl();
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OkButtonHandler);

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonWin)okbutton;
            this.Load        += delegate { FocusOnFirstControl(); };
            this.FormClosing += OnFormClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }
            public OKCancelPanelVWG(IControlFactory controlFactory)
            {
                //_controlFactory = controlFactory;
                //// create content panel
                //_contentPanel = _controlFactory.CreatePanel();
                //_contentPanel.Dock = DockStyle.Fill;
                //this.Controls.Add((Control)_contentPanel);

                //// create buttons
                //IButtonGroupControl buttonGroupControl = _controlFactory.CreateButtonGroupControl();
                //buttonGroupControl.Dock = DockStyle.Bottom;
                //_okButton = buttonGroupControl.AddButton("OK");
                //_okButton.NotifyDefault(true);
                //_cancelButton = buttonGroupControl.AddButton("Cancel");
                //this.Controls.Add((Control)buttonGroupControl);

                _controlFactory = controlFactory;
                // create content panel
                _contentPanel = _controlFactory.CreatePanel();
                // create buttons
                _buttonGroupControl = _controlFactory.CreateButtonGroupControl();
                _cancelButton = _buttonGroupControl.AddButton("Cancel");
                _okButton = _buttonGroupControl.AddButton("OK");
                _okButton.NotifyDefault(true);

                BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);
                layoutManager.AddControl(_contentPanel, BorderLayoutManager.Position.Centre);
                layoutManager.AddControl(_buttonGroupControl, BorderLayoutManager.Position.South);
            }
 private void SetupSelectButtonGroupControl()
 {
     SelectButtonGroupControl = ControlFactory.CreateButtonGroupControl();
     SelectButtonGroupControl.AddButton("Cancel", CancelClickHandler);
     SelectButtonGroupControl.AddButton("Select", SelectClickHandler);
 }
示例#32
0
 private void SetupSelectButtonGroupControl()
 {
     SelectButtonGroupControl = ControlFactory.CreateButtonGroupControl();
     SelectButtonGroupControl.AddButton("Cancel", CancelClickHandler);
     SelectButtonGroupControl.AddButton("Select", SelectClickHandler);
 }
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormVWG"/> class  with
        /// the specified <see cref="BusinessObject"/>, uiDefName and <see cref="IControlFactory"/>.
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        public DefaultBOEditorFormVWG(BusinessObject bo, string uiDefName, IControlFactory controlFactory)
        {
            _bo                 = bo;
            _controlFactory     = controlFactory;
            _uiDefName          = uiDefName;
            GroupControlCreator = _controlFactory.CreateTabControl;
            BOMapper mapper = new BOMapper(bo);

            IUIForm def;

            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);

            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm);
            _panelInfo = panelBuilder.BuildPanelForForm(def);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;
            _buttons = _controlFactory.CreateButtonGroupControl();
            // These buttons used to be "&Cancel" and "&OK", but they are missing the "&" in win, so I took them out for VWG
            //  Soriya had originally removed them from Win in revision 2854, but I'm not sure of the reason other than
            //  externally, when fetching the button from the button control, it would be fetched using the text only.
            //  I would prefer to have the "&" in the control, but it may break existing code that uses the buttons on this form.
            //  Also, it seems that VWG does not do anything with the "&"
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OKButtonHandler);

            okbutton.TabStop = false;
            //okbutton.TabIndex = 3;
            //okbutton.TabStop = true;
            //cancelButton.TabIndex = 4;
            //cancelButton.TabStop = true;

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonVWG)okbutton;
            this.Load        += delegate { FocusOnFirstControl(); };
            this.Closing     += OnClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormWin"/> class  with 
        /// the specified businessObject, uiDefName and post edit action. 
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        /// <param name="creator">The Creator used to Create the Group Control.</param>
        public DefaultBOEditorFormWin(BusinessObject bo, string uiDefName, IControlFactory controlFactory, GroupControlCreator creator)
        {
            _bo = bo;
            _controlFactory = controlFactory;
            GroupControlCreator = creator;
            _uiDefName = uiDefName;

            BOMapper mapper = new BOMapper(bo);

            IUIForm def;
            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm, this.GroupControlCreator);
            _panelInfo = panelBuilder.BuildPanelForForm(def, this.GroupControlCreator);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;

            _buttons = _controlFactory.CreateButtonGroupControl();
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OkButtonHandler);

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonWin) okbutton;
            this.Load += delegate { FocusOnFirstControl(); };
            this.FormClosing += OnFormClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormVWG"/> class  with 
        /// the specified <see cref="BusinessObject"/>, uiDefName and <see cref="IControlFactory"/>. 
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        public DefaultBOEditorFormVWG(BusinessObject bo, string uiDefName, IControlFactory controlFactory)
        {
            _bo = bo;
            _controlFactory = controlFactory;
            _uiDefName = uiDefName;
            GroupControlCreator = _controlFactory.CreateTabControl;
            BOMapper mapper = new BOMapper(bo);

            IUIForm def;
            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm);
            _panelInfo = panelBuilder.BuildPanelForForm(def);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;
            _buttons = _controlFactory.CreateButtonGroupControl();
            // These buttons used to be "&Cancel" and "&OK", but they are missing the "&" in win, so I took them out for VWG
            //  Soriya had originally removed them from Win in revision 2854, but I'm not sure of the reason other than 
            //  externally, when fetching the button from the button control, it would be fetched using the text only.
            //  I would prefer to have the "&" in the control, but it may break existing code that uses the buttons on this form.
            //  Also, it seems that VWG does not do anything with the "&"
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OKButtonHandler);
            okbutton.TabStop = false;
            //okbutton.TabIndex = 3;
            //okbutton.TabStop = true;
            //cancelButton.TabIndex = 4;
            //cancelButton.TabStop = true;

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonVWG)okbutton;
            this.Load += delegate { FocusOnFirstControl(); };
            this.Closing += OnClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }
 private void SetupButtonGroupControl()
 {
     _buttonGroupControl = _controlFactory.CreateButtonGroupControl();
     _cancelButton = _buttonGroupControl.AddButton("Cancel", CancelButtonClicked);
     _saveButton = _buttonGroupControl.AddButton("Save", SaveClickHandler);
     _deleteButton = _buttonGroupControl.AddButton("Delete", DeleteButtonClicked);
     _newButton = _buttonGroupControl.AddButton("New", NewButtonClicked);
     _cancelButton.Enabled = false;
     _deleteButton.Enabled = false;
     _newButton.Enabled = false;
 }