public void Test_Constructor_WithGroupCreator() { //---------------Set up test pack------------------- IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject(); GroupControlCreator groupControl = GetControlFactory().CreateCollapsiblePanelGroupControl; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)bo, "default", groupControl); //---------------Test Result ----------------------- Assert.IsNotNull(defaultBOEditorForm.PanelInfo); Assert.IsNotNull(defaultBOEditorForm.GroupControlCreator); Assert.AreSame(groupControl, defaultBOEditorForm.GroupControlCreator); }
///<summary> /// Builds a Panel for a single Tab as defined in the <see cref="UIForm"/>. /// There will be one <see cref="IPanelInfo"/> for the defined uiForm.<br/> /// If there are multiple tabs defined for the <paramref name="uiForm"/> then /// an actual <see cref="ITabPage"/> is created for each <see cref="UIFormTab"/> /// and the <see cref="IPanel"/> created by <see cref="BuildPanelForTab"/> will /// be placed on this TabPage.<br></br> /// Else the <see cref="IPanel"/> is placed on the form directly. ///</summary> /// <param name="uiForm">The UIForm object that indicates which controls /// to create and how the controls are laid out</param> ///<param name="groupControlCreator">The <see cref="GroupControlCreator"/></param> /// <returns>Returns an IPanelInfo object that contains access to the /// BusinessObject instance, the created panel, and all the controls, /// mappers, labels and error providers that were created. /// </returns> public IPanelInfo BuildPanelForForm(IUIForm uiForm, GroupControlCreator groupControlCreator) { if (uiForm == null) throw new ArgumentNullException("uiForm"); if (groupControlCreator == null) throw new ArgumentNullException("groupControlCreator"); var panelInfo = new PanelInfo(); // generic interface foreach (UIFormTab formTab in uiForm) { var tabPagePanelInfo = BuildPanelForTab(formTab); panelInfo.PanelInfos.Add(tabPagePanelInfo); foreach (PanelInfo.FieldInfo fieldInfo in tabPagePanelInfo.FieldInfos) { panelInfo.FieldInfos.Add(fieldInfo); } if (tabPagePanelInfo.MinimumPanelHeight > panelInfo.MinimumPanelHeight) { panelInfo.MinimumPanelHeight = tabPagePanelInfo.MinimumPanelHeight; } } IPanel mainPanel; if (panelInfo.PanelInfos.Count == 0) { mainPanel = ControlFactory.CreatePanel(); } else if (panelInfo.PanelInfos.Count == 1) { mainPanel = panelInfo.PanelInfos[0].Panel; int lesserHeight = panelInfo.MinimumPanelHeight; if (uiForm.Height < lesserHeight) lesserHeight = uiForm.Height; mainPanel.MinimumSize = new Size(uiForm.Width, lesserHeight); } else { var groupControl = groupControlCreator(); foreach (var childPanelInfo in panelInfo.PanelInfos) { var uiFormTab = childPanelInfo.UIFormTab; var childPanel = childPanelInfo.Panel; groupControl.AddControl(childPanel, uiFormTab.Name, childPanel.Height, childPanel.Width); } var panel = ControlFactory.CreatePanel(); groupControl.Dock = DockStyle.Fill; panel.MinimumSize = groupControl.Size; panel.Controls.Add(groupControl); mainPanel = panel; } panelInfo.Panel = mainPanel; mainPanel.Name = _controlNamingStrategy.GetUIFormControlName(uiForm); mainPanel.Size = new Size(uiForm.Width, uiForm.Height); panelInfo.UIForm = uiForm; return panelInfo; }
/// <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="DefaultBOEditorFormVWG"/> 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 DefaultBOEditorFormVWG(BusinessObject bo, string uiDefName, IControlFactory controlFactory, GroupControlCreator creator) : this(bo, uiDefName, controlFactory) { GroupControlCreator = creator; }
/// <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="DefaultBOEditorFormVWG"/> 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 DefaultBOEditorFormVWG(BusinessObject bo, string uiDefName, IControlFactory controlFactory, GroupControlCreator creator) : this(bo, uiDefName, controlFactory) { GroupControlCreator = creator; }
///<summary> /// Builds a Panel for a single Tab as defined in the <see cref="UIForm"/>. /// There will be one <see cref="IPanelInfo"/> for the defined uiForm.<br/> /// If there are multiple tabs defined for the <paramref name="uiForm"/> then /// an actual <see cref="ITabPage"/> is created for each <see cref="UIFormTab"/> /// and the <see cref="IPanel"/> created by <see cref="BuildPanelForTab"/> will /// be placed on this TabPage.<br></br> /// Else the <see cref="IPanel"/> is placed on the form directly. ///</summary> /// <param name="uiForm">The UIForm object that indicates which controls /// to create and how the controls are laid out</param> ///<param name="groupControlCreator">The <see cref="GroupControlCreator"/></param> /// <returns>Returns an IPanelInfo object that contains access to the /// BusinessObject instance, the created panel, and all the controls, /// mappers, labels and error providers that were created. /// </returns> public IPanelInfo BuildPanelForForm(IUIForm uiForm, GroupControlCreator groupControlCreator) { if (uiForm == null) { throw new ArgumentNullException("uiForm"); } if (groupControlCreator == null) { throw new ArgumentNullException("groupControlCreator"); } var panelInfo = new PanelInfo(); // generic interface foreach (UIFormTab formTab in uiForm) { var tabPagePanelInfo = BuildPanelForTab(formTab); panelInfo.PanelInfos.Add(tabPagePanelInfo); foreach (PanelInfo.FieldInfo fieldInfo in tabPagePanelInfo.FieldInfos) { panelInfo.FieldInfos.Add(fieldInfo); } if (tabPagePanelInfo.MinimumPanelHeight > panelInfo.MinimumPanelHeight) { panelInfo.MinimumPanelHeight = tabPagePanelInfo.MinimumPanelHeight; } } IPanel mainPanel; if (panelInfo.PanelInfos.Count == 0) { mainPanel = ControlFactory.CreatePanel(); } else if (panelInfo.PanelInfos.Count == 1) { mainPanel = panelInfo.PanelInfos[0].Panel; int lesserHeight = panelInfo.MinimumPanelHeight; if (uiForm.Height < lesserHeight) { lesserHeight = uiForm.Height; } mainPanel.MinimumSize = new Size(uiForm.Width, lesserHeight); } else { var groupControl = groupControlCreator(); foreach (var childPanelInfo in panelInfo.PanelInfos) { var uiFormTab = childPanelInfo.UIFormTab; var childPanel = childPanelInfo.Panel; groupControl.AddControl(childPanel, uiFormTab.Name, childPanel.Height, childPanel.Width); } var panel = ControlFactory.CreatePanel(); groupControl.Dock = DockStyle.Fill; panel.MinimumSize = groupControl.Size; panel.Controls.Add(groupControl); mainPanel = panel; } panelInfo.Panel = mainPanel; mainPanel.Name = _controlNamingStrategy.GetUIFormControlName(uiForm); mainPanel.Size = new Size(uiForm.Width, uiForm.Height); panelInfo.UIForm = uiForm; return(panelInfo); }
/// <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="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()); }