internal static IPanelInfo CreatePanelInfo (IControlFactory controlFactory, IClassDef classDef, string uiDefName, IBOEditorControl iboEditorControl) { IUIForm uiForm = GetUiForm(classDef, uiDefName); PanelBuilder panelBuilder = new PanelBuilder(controlFactory); IPanelInfo panelInfo = panelBuilder.BuildPanelForForm(uiForm); BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(iboEditorControl); layoutManager.AddControl(panelInfo.Panel, BorderLayoutManager.Position.Centre); return(panelInfo); }
///<summary> /// Constructor for <see cref="BusinessObjectPanelVWG{T}"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="uiDefName"></param> public BusinessObjectPanelVWG(IControlFactory controlFactory, string uiDefName) { PanelBuilder panelBuilder = new PanelBuilder(controlFactory); _panelInfo = panelBuilder.BuildPanelForForm(ClassDef.Get <T>().UIDefCol[uiDefName].UIForm); BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this); layoutManager.AddControl(_panelInfo.Panel, BorderLayoutManager.Position.Centre); this.Size = _panelInfo.Panel.Size; this.MinimumSize = _panelInfo.Panel.Size; }
public void TestEnableControls() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); MyBO myBO = new MyBO(); PanelBuilder factory = new PanelBuilder(GetControlFactory()); IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm); panelInfo.BusinessObject = myBO; panelInfo.ControlsEnabled = false; //---------------Execute Test ---------------------- panelInfo.ControlsEnabled = true; //---------------Test Result ----------------------- Assert.IsTrue(panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Enabled); Assert.IsTrue(panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Enabled); //---------------Tear Down ------------------------- }
private void CreateBOPanel(IControlFactory controlFactory, string uiDefName) { if (controlFactory == null) { throw new ArgumentNullException("controlFactory"); } if (string.IsNullOrEmpty(uiDefName)) { throw new ArgumentNullException("uiDefName"); } PanelBuilder panelBuilder = new PanelBuilder(controlFactory); _panelInfo = panelBuilder.BuildPanelForForm(ClassDef.Get <T>().UIDefCol[uiDefName].UIForm); BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this); layoutManager.AddControl(_panelInfo.Panel, BorderLayoutManager.Position.Centre); this.Size = _panelInfo.Panel.Size; this.MinimumSize = _panelInfo.Panel.Size; }
public void TestPanelSetup() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); MyBO myBO = new MyBO(); myBO.TestProp = START_VALUE_1; myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2); PanelBuilder factory = new PanelBuilder(GetControlFactory()); //---------------Execute Test ---------------------- IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm); panelInfo.BusinessObject = myBO; //---------------Test Result ----------------------- Assert.AreEqual(START_VALUE_1, panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Text); Assert.AreEqual(START_VALUE_2, panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Text); }
public void TestApplyChangesToBusinessObject() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); MyBO myBO = new MyBO(); myBO.TestProp = START_VALUE_1; myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2); PanelBuilder factory = new PanelBuilder(GetControlFactory()); IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm); panelInfo.BusinessObject = myBO; ChangeValuesInControls(panelInfo); //---------------Execute Test ---------------------- panelInfo.ApplyChangesToBusinessObject(); //---------------Test Result ----------------------- Assert.AreEqual(CHANGED_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1)); Assert.AreEqual(CHANGED_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2)); }
/// <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()); }