Beispiel #1
0
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, object uiFormInstance, bool isNewInstance, float duration)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, GetUIGroup, userData);
                if (uiForm == null)
                {

                }

                uiForm.OnInit(serialId, uiFormAssetName, GetUIGroup, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                GetUIGroup.Refresh();

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(uiForm, duration, userData));
                }
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(serialId, uiUIFormAssetName);
                    return;
                }
                throw;
            }
        }
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GameFrameworkException("UI form is invalid.");
            }

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            if (uiGroup == null)
            {
                throw new GameFrameworkException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                m_CloseUIFormCompleteEventHandler(this, new CloseUIFormCompleteEventArgs(uiForm.SerialId, uiForm.UIFormAssetName, uiGroup, userData));
            }

            m_RecycleQueue.Enqueue(uiForm);
        }
 private IUIFormField GetFormField(IUIForm uiForm, int index)
 {
     IUIFormTab uiFormTab = uiForm[0];
     IUIFormColumn uiFormColumn = uiFormTab[0];
     IUIFormField uiFormField = uiFormColumn[index];
     return uiFormField;
 }
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GameFrameworkException("UI form is invalid.");
            }

            UIGroup uiGroup = uiForm.UIGroup as UIGroup;

            if (uiGroup == null)
            {
                throw new GameFrameworkException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                m_CloseUIFormCompleteEventHandler(this, new CloseUIFormCompleteEventArgs(uiForm.TypeId, userData));
            }

            m_RecycleQueue.AddLast(new RecycleNode(uiForm));
        }
Beispiel #5
0
        public void Test_CreateUIForm_WhenNotHasViewAndHasStringProp_ShouldCreateUIField()
        {
            //---------------Set up test pack-------------------
            var       formCreator = new UIFormCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIForm returnedUIForm = formCreator.CreateUIForm(classDef);

            //---------------Test Result -----------------------
            Assert.IsNotNull(returnedUIForm);
            Assert.AreEqual(1, returnedUIForm.Count, "Should create tab");
            IUIFormTab returnedUIFormTab = returnedUIForm[0];

            Assert.AreSame(returnedUIForm, returnedUIFormTab.UIForm);
            Assert.AreEqual("default", returnedUIFormTab.Name);
            Assert.AreEqual(1, returnedUIFormTab.Count, "Should create col");
            IUIFormColumn returnedUIFormColumn = returnedUIFormTab[0];

            Assert.AreSame(returnedUIFormTab, returnedUIFormColumn.UIFormTab);
            Assert.AreEqual(1, returnedUIFormColumn.Count, "Should create field");
            IUIFormField returnedUIFormField = returnedUIFormColumn[0];

            Assert.AreEqual("Fake Bo Name", returnedUIFormField.Label);
            Assert.AreEqual("FakeBoName", returnedUIFormField.PropertyName);
        }
Beispiel #6
0
        public void TestLoadPropertyCollection()
        {
            IUIForm col =
                loader.LoadUIFormDef(
                    @"
					<form width=""100"" height=""120"" title=""testheading"">
						<tab name=""testtab"">
							<columnLayout>
								<field label=""testlabel1"" property=""testpropname1"" type=""Button"" mapperType=""testmappertypename1"" />
								<field label=""testlabel2"" property=""testpropname2"" type=""Button"" mapperType=""testmappertypename2"" />
							</columnLayout>
						</tab>
					</form>"                    );

            //Assert.AreEqual(typeof(MyBO), col.Class);
            //Assert.AreEqual("Habanero.Test.BO.MyBO_testName", col.Name.ToString() );
            Assert.AreEqual(1, col.Count, "There should be 1 tab"); // 1 tab
            Assert.AreEqual(1, col[0].Count, "There should be one column in that tab");
            Assert.AreEqual(2, col[0][0].Count, "There should be two propertys in that column");
            Assert.AreEqual("testlabel1", col[0][0][0].Label);
            Assert.AreEqual("testlabel2", col[0][0][1].Label);
            Assert.AreEqual(100, col.Width);
            Assert.AreEqual(120, col.Height);
            Assert.AreEqual("testheading", col.Title);
        }
Beispiel #7
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GXException("UI form is invalid.");
            }

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            if (uiGroup == null)
            {
                throw new GXException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(m_IsShutdown, userData);
            uiGroup.Refresh();

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                CloseUIFormCompleteEventArgs closeUIFormCompleteEventArgs = CloseUIFormCompleteEventArgs.Create(uiForm.SerialId, uiForm.UIFormAssetName, uiGroup, userData);
                m_CloseUIFormCompleteEventHandler(this, closeUIFormCompleteEventArgs);
                ReferencePool.Release(closeUIFormCompleteEventArgs);
            }

            m_RecycleQueue.Enqueue(uiForm);
        }
Beispiel #8
0
        public void TestFormWithTabsAndNoColumns()
        {
            IUIForm col =
                loader.LoadUIFormDef(
                    @"
					<form width=""100"" height=""120"" title=""testheading"">
						<tab name=""testtab"">
							<field label=""testlabel1"" property=""testpropname1"" type=""Button"" mapperType=""testmappertypename1"" />
							<field label=""testlabel2"" property=""testpropname2"" type=""Button"" mapperType=""testmappertypename2"" />
						</tab>
						<tab name=""testtab2"">
							<field label=""testlabel3"" property=""testpropname3"" type=""Button"" mapperType=""testmappertypename3"" />
						</tab>
                    </form>");

            Assert.AreEqual(2, col.Count, "There should be 2 tab");
            Assert.AreEqual(1, col[0].Count, "There should be one column in tab 1");
            Assert.AreEqual(1, col[0].Count, "There should be one column in tab 2");
            Assert.AreEqual(2, col[0][0].Count, "There should be two propertys in column 1 (tab 1)");
            Assert.AreEqual(1, col[1][0].Count, "There should be two propertys in column 1 (tab 2)");
            Assert.AreEqual("testlabel1", col[0][0][0].Label);
            Assert.AreEqual("testlabel2", col[0][0][1].Label);
            Assert.AreEqual("testlabel3", col[1][0][0].Label);
            Assert.AreEqual(100, col.Width);
            Assert.AreEqual(120, col.Height);
            Assert.AreEqual("testheading", col.Title);
        }
Beispiel #9
0
        public void TestUIFormSetOnUIFormTab()
        {
            //---------------Set up test pack-------------------

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

            //---------------Execute Test ----------------------
            IUIForm col =
                loader.LoadUIFormDef(
                    @"
					<form width=""100"" height=""120"" title=""testheading"">
						<tab name=""testtab"">
							<field label=""testlabel1"" property=""testpropname1"" type=""Button"" mapperType=""testmappertypename1"" />
						</tab>
						<tab name=""testtab2"">
							<field label=""testlabel2"" property=""testpropname2"" type=""Button"" mapperType=""testmappertypename3"" />
						</tab>
                    </form>");

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


            Assert.AreSame(col, col[0].UIForm);
            Assert.AreSame(col, col[1].UIForm);
        }
Beispiel #10
0
        public virtual IClassDef GetClassDef()
        {
            IUIFormColumn column = this.UIFormColumn;

            if (column == null)
            {
                return(null);
            }
            IUIFormTab tab = column.UIFormTab;

            if (tab == null)
            {
                return(null);
            }
            IUIForm form = tab.UIForm;

            if (form == null)
            {
                return(null);
            }
            IUIDef uiDef = form.UIDef;

            if (uiDef == null)
            {
                return(null);
            }
            if (uiDef.ClassDef != null)
            {
                return(uiDef.ClassDef);
            }
            return(uiDef.UIDefCol == null ? null : uiDef.UIDefCol.ClassDef);
        }
 /// <summary>
 /// 初始化打开界面成功事件的新实例。
 /// </summary>
 /// <param name="uiFormAssetName">界面资源名称。</param>
 /// <param name="uiForm">加载成功的界面。</param>
 /// <param name="duration">加载持续时间。</param>
 /// <param name="userData">用户自定义数据。</param>
 public OpenUIFormSuccessEventArgs(string uiFormAssetName, IUIForm uiForm, float duration, object userData)
 {
     UIFormAssetName = uiFormAssetName;
     UIForm          = uiForm;
     Duration        = duration;
     UserData        = userData;
 }
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);
                if (uiForm == null)
                {
                    throw new GameFrameworkException("Can not create UI form in helper.");
                }

                uiForm.OnInit(serialId, uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                uiGroup.Refresh();

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(uiForm, duration, userData));
                }
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormFailureEventHandler(this, new OpenUIFormFailureEventArgs(serialId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, exception.ToString(), userData));
                    return;
                }

                throw;
            }
        }
Beispiel #13
0
            /// <summary>
            /// 从界面组移除界面。
            /// </summary>
            /// <param name="uiForm">要移除的界面。</param>
            public void RemoveUIForm(IUIForm uiForm)
            {
                UIFormInfo uiFormInfo = GetUIFormInfo(uiForm);

                if (uiFormInfo == null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not find UI form info for serial id '{0}', UI form asset name is '{1}'.", uiForm.SerialId.ToString(), uiForm.UIFormAssetName));
                }

                if (!uiFormInfo.Covered)
                {
                    uiFormInfo.Covered = true;
                    uiForm.OnCover();
                }

                if (!uiFormInfo.Paused)
                {
                    uiFormInfo.Paused = true;
                    uiForm.OnPause();
                }

                if (m_CachedNode != null && m_CachedNode.Value.UIForm == uiForm)
                {
                    m_CachedNode = m_CachedNode.Next;
                }

                if (!m_UIFormInfos.Remove(uiFormInfo))
                {
                    throw new GameFrameworkException(Utility.Text.Format("UI group '{0}' not exists specified UI form '[{1}]{2}'.", m_Name, uiForm.SerialId.ToString(), uiForm.UIFormAssetName));
                }

                ReferencePool.Release(uiFormInfo);
            }
 /// <summary>
 /// A constructor to initialise a new instance, with a UIForm object 
 /// specified
 /// </summary>
 /// <param name="bo">The business object to be represented</param>
 /// <param name="uiForm"></param>
 /// <param name="controlFactory">the control factory used to create controls</param>
 public PanelFactory(BusinessObject bo, UIForm uiForm, IControlFactory controlFactory)
 {
     if (uiForm == null) throw new ArgumentNullException("uiForm");
     _uiForm = uiForm;
     _controlFactory = controlFactory;
     InitialiseFactory(bo);
 }
Beispiel #15
0
        public IUIForm GetUIForm(string name)
        {
            IUIForm target = null;

            m_UIForms.TryGetValue(name, out target);
            return(target);
        }
Beispiel #16
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiFormAssetName">要关闭界面的名称。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <param name="isRelease">是否释放</param>
        public void CloseUIForm(string uiFormAssetName, object userData, bool isRelease = false)
        {
            IUIForm uiForm = GetUIForm(uiFormAssetName);

            Guard.Verify <ArgumentException>(uiForm == null, $"Can not find UI form '{uiFormAssetName}'.");

            CloseUIForm(uiForm, userData, isRelease);
        }
Beispiel #17
0
        private IUIFormField GetFormField(IUIForm uiForm, int index)
        {
            IUIFormTab    uiFormTab    = uiForm[0];
            IUIFormColumn uiFormColumn = uiFormTab[0];
            IUIFormField  uiFormField  = uiFormColumn[index];

            return(uiFormField);
        }
Beispiel #18
0
        public void DestroyForm(IUIForm form)
        {
            CloseForm(form);

            m_Forms.Remove(form);
            form.OnBeforeDestroy();
            m_Creater.DestroyForm(form);
        }
Beispiel #19
0
 public void DestroyForm(IUIForm form)
 {
     if (form == null)
     {
         return;
     }
     Object.Destroy(((UIForm)form).gameObject);
 }
Beispiel #20
0
        ///<summary>
        /// Clones the collection of ui columns this performs a copy of all uicolumns but does not copy the uiFormFields.
        ///</summary>
        ///<returns>a new collection that is a shallow copy of this collection</returns>
        public IUIDef Clone()
        {
            IUIForm clonedForm = this.UIForm != null? ((UIForm)this.UIForm).Clone(): null;
            IUIGrid clonedGrid = this.UIGrid != null ? ((UIGrid)this.UIGrid).Clone() : null;
            UIDef   newUIForm  = new UIDef(this.Name, clonedForm, clonedGrid);

            return(newUIForm);
        }
Beispiel #21
0
                /// <summary>
                /// 初始化界面组界面信息的新实例。
                /// </summary>
                /// <param name="uiForm">界面。</param>
                public UIFormInfo(IUIForm uiForm)
                {
                    Guard.Verify <ArgumentException>(uiForm == null, "UI form is invalid.");

                    this.uiForm  = uiForm;
                    this.paused  = true;
                    this.covered = true;
                }
Beispiel #22
0
        /// <summary>
        /// 是否是合法的界面。
        /// </summary>
        /// <param name="uiForm">界面。</param>
        /// <returns>界面是否合法。</returns>
        public bool IsValidUIForm(IUIForm uiForm)
        {
            if (uiForm == null)
            {
                return(false);
            }

            return(HasUIForm(uiForm.UIFormAssetName));
        }
Beispiel #23
0
        public static void SetEntityTcs(int uiformID, IUIForm entity)
        {
            TaskCompletionSource <IUIForm> tcs = GetUIFormTcs(uiformID);

            if (tcs != null)
            {
                tcs.SetResult(entity);
            }
        }
 /// <summary>
 /// Get the name to use for a control representing a <see cref="IUIForm"/>.
 /// </summary>
 /// <param name="uiForm">The <see cref="IUIForm"/> to represent with the name.</param>
 /// <returns>The suggested name for the control</returns>
 public string GetUIFormControlName(IUIForm uiForm)
 {
     string name;
     if (uiForm.ClassDef != null) name = uiForm.ClassDef.ClassName;
     else if (uiForm.UIDef != null) name = uiForm.UIDef.ClassName;
     else name = uiForm.Title;
     if (string.IsNullOrWhiteSpace(name)) return "HabaneroPanel";
     return name.Replace(" ", "");
 }
Beispiel #25
0
        /// <summary>
        /// 是否是合法的界面。
        /// </summary>
        /// <param name="uiForm">界面。</param>
        /// <returns>界面是否合法。</returns>
        public bool IsValidUIForm(IUIForm uiForm)
        {
            if (uiForm == null)
            {
                return(false);
            }

            return(HasUIForm(uiForm.SerialId));
        }
        /// <summary>
        /// Sets up the forms size based on the BOPanel and the Buttons.
        /// </summary>
        /// <param name="def"></param>
        protected virtual void SetupFormSize(IUIForm def)
        {
            _boPanel.Size = new Size(def.Width, def.Height);
            int width  = _boPanel.Width;
            int height = _boPanel.Height + _buttons.Height;

            ClientSize  = new Size(width, height);
            MinimumSize = Size;
        }
Beispiel #27
0
        /// <summary>
        /// 设置界面是否被加锁。
        /// </summary>
        /// <param name="uiForm">要设置是否被加锁的界面。</param>
        /// <param name="locked">界面是否被加锁。</param>
        public void SetUIFormLocked(IUIForm uiForm, bool locked)
        {
            if (uiForm == null)
            {
                throw new System.Exception("UI form is invalid.");
            }

            m_InstancePool.SetLocked(uiForm, locked);
        }
Beispiel #28
0
        /// <summary>
        /// 设置界面的优先级。
        /// </summary>
        /// <param name="uiForm">要设置优先级的界面。</param>
        /// <param name="priority">界面优先级。</param>
        public void SetUIFormPriority(IUIForm uiForm, int priority)
        {
            if (uiForm == null)
            {
                throw new System.Exception("UI form is invalid.");
            }

            m_InstancePool.SetPriority(uiForm, priority);
        }
Beispiel #29
0
        private void AddFieldToClassDef(IClassDef classDef, IUIFormField uiFormField)
        {
            IUIDef        def    = classDef.UIDefCol["default"];
            IUIForm       form   = def.UIForm;
            IUIFormTab    tab    = form[0];
            IUIFormColumn column = tab[0];

            column.Add(uiFormField);
        }
            /// <summary>
            /// 激活界面。
            /// </summary>
            /// <param name="uiForm">要激活的界面。</param>
            /// <param name="userData">用户自定义数据。</param>
            public void RefocusUIForm(IUIForm uiForm, object userData)
            {
                UIFormInfo uiFormInfo = GetUIFormInfo(uiForm);

                Guard.Requires <ArgumentException>(uiFormInfo != null, "Can not find UI form info.");

                m_UIFormInfos.Remove(uiFormInfo);
                m_UIFormInfos.AddFirst(uiFormInfo);
            }
Beispiel #31
0
        /// <summary>
        /// 创建打开界面成功事件。
        /// </summary>
        /// <param name="uiForm">加载成功的界面。</param>
        /// <param name="duration">加载持续时间。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>创建的打开界面成功事件。</returns>
        public static OpenUIFormSuccessEventArgs Create(IUIForm uiForm, float duration, object userData)
        {
            OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = ReferencePool.Acquire <OpenUIFormSuccessEventArgs>();

            openUIFormSuccessEventArgs.UIForm   = uiForm;
            openUIFormSuccessEventArgs.Duration = duration;
            openUIFormSuccessEventArgs.UserData = userData;
            return(openUIFormSuccessEventArgs);
        }
Beispiel #32
0
        /// <summary>
        /// 设置界面的优先级。
        /// </summary>
        /// <param name="uiForm">要设置优先级的界面。</param>
        /// <param name="priority">界面优先级。</param>
        public void SetUIFormInstancePriority(IUIForm uiForm, int priority)
        {
            if (uiForm == null)
            {
                Log.Warning("UI form is invalid.");
                return;
            }

            m_UIManager.SetUIFormInstancePriority(uiForm.Handle, priority);
        }
Beispiel #33
0
        /// <summary>
        /// 设置界面是否被加锁。
        /// </summary>
        /// <param name="uiForm">要设置是否被加锁的界面。</param>
        /// <param name="locked">界面是否被加锁。</param>
        public void SetUIFormInstanceLocked(IUIForm uiForm, bool locked)
        {
            if (uiForm == null)
            {
                Log.Warning("UI form is invalid.");
                return;
            }

            m_UIManager.SetUIFormInstanceLocked(uiForm.Handle, locked);
        }
Beispiel #34
0
        /// <summary>
        /// Loads form definition data from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
			_uiForm = _defClassFactory.CreateUIFormDef();

            _reader.Read();
            _uiForm.Title = _reader.GetAttribute("title");
            try
            {
                _uiForm.Width = Convert.ToInt32(_reader.GetAttribute("width"));
                _uiForm.Height = Convert.ToInt32(_reader.GetAttribute("height"));
            }
            catch (Exception ex)
            {
                throw new InvalidXmlDefinitionException("In a 'form' element, " +
                    "either the 'width' or 'height' attribute has been given " +
                    "an invalid integer pixel value.", ex);
            }


            _reader.Read();
            List<IUIFormColumn> columns = new List<IUIFormColumn>();
            List<IUIFormField> fields = new List<IUIFormField>();
            string contentType = "";
            while (_reader.Name != "form") {
                if (_reader.Name == "tab") {
                    if (contentType.Length > 0 && contentType != "tab") {
                        throw new InvalidXmlDefinitionException(
                            "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture.");
                    }
                    contentType = "tab";
                    XmlUIFormTabLoader tabLoader = new XmlUIFormTabLoader(DtdLoader, _defClassFactory);
                    _uiForm.Add(tabLoader.LoadUIFormTab(_reader.ReadOuterXml()));
                }
                else if (_reader.Name == "columnLayout") {
                    if (contentType.Length > 0 && contentType != "columnLayout") {
                        throw new InvalidXmlDefinitionException(
                            "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture.");
                    }
                    contentType = "columnLayout";
                    XmlUIFormColumnLoader columnLoader = new XmlUIFormColumnLoader(DtdLoader, _defClassFactory);
                    columns.Add(columnLoader.LoadUIFormColumn(_reader.ReadOuterXml()));
                }
                else if (_reader.Name == "field") {
                    if (contentType.Length > 0 && contentType != "field") {
                        throw new InvalidXmlDefinitionException(
                            "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture.");
                    }
                    contentType = "field";
                    XmlUIFormFieldLoader fieldLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory);
                    fields.Add(fieldLoader.LoadUIProperty(_reader.ReadOuterXml()));

                } else {
                    throw new InvalidXmlDefinitionException(
                        "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes.");
                }
            }
            if (contentType == "columnLayout") {
                IUIFormTab tab = _defClassFactory.CreateUIFormTab();
                columns.ForEach(tab.Add);
                _uiForm.Add(tab);
            }
            else if (contentType == "field") {
                IUIFormTab tab = _defClassFactory.CreateUIFormTab();
                IUIFormColumn col = _defClassFactory.CreateUIFormColumn();
                fields.ForEach(col.Add);
                tab.Add(col);
                _uiForm.Add(tab);
            }

            if (_uiForm.Count == 0)
            {
                throw new InvalidXmlDefinitionException("No 'tab', 'columnLayout' or 'field' " +
                    "elements were specified in a 'form' element.  Ensure " +
                    "that the element contains one or more of either 'tab', 'columnLayout' or 'field' elements, " +
                    "which each define what must appear in the editing form for " +
                    "the business object.");
            }
        }
        /// <summary>
        /// A constructor as before, but with a UIDefName specified
        /// </summary>
        public PanelFactory(BusinessObject bo, string uiDefName, IControlFactory controlFactory)
        {
            _uiDefName = uiDefName;
            _controlFactory = controlFactory;
            BOMapper mapper = new BOMapper(bo);

            IUIDef uiDef = mapper.GetUIDef(uiDefName);
            if (uiDef == null)
            {
                string errMessage = "Cannot create a panel factory for '" + bo.ClassDef.ClassName
                                    + "' since the classdefs do not contain a uiDef '" + uiDefName + "'";
                throw new HabaneroDeveloperException
                    ("There is a serious application error please contact your system administrator"
                     + Environment.NewLine + errMessage, errMessage);
            }
            _uiForm = uiDef.GetUIFormProperties();
            if (_uiForm == null)
            {
                string errMsg = "Cannot create a panel factory for '" + bo.ClassDef.ClassName
                                + "' since the classdefs do not contain a form def for uidef '" + uiDefName + "'";
                throw new HabaneroDeveloperException
                    ("There is a serious application error please contact your system administrator"
                     + Environment.NewLine + errMsg, errMsg);
            }
            InitialiseFactory(bo);
        }
 /// <summary>
 /// Constructs a panel for editing the data of a single instance
 /// of a BusinessObject, using the control layout as specified in
 /// a <see cref="UIForm"/> object. 
 /// </summary>
 /// <param name="uiForm">The UIForm object that indicates which controls
 /// to create and how the controls are laid out</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)
 {
     return BuildPanelForForm(uiForm, this.GroupControlCreator);
 }
        /// <summary>
        /// Sets up the forms size based on the BOPanel and the Buttons.
        /// </summary>
        /// <param name="def"></param>
        protected virtual void SetupFormSize(IUIForm def)
        {
            _boPanel.Size = new Size(def.Width, def.Height);
            int width = _boPanel.Width;
            int height = _boPanel.Height + _buttons.Height;

            ClientSize = new Size(width, height);
            MinimumSize = Size;
        }
Beispiel #38
0
 /// <summary>
 /// Loads UI definition data from the reader
 /// </summary>
 protected override void LoadFromReader()
 {
     _reader.Read();
     _name = _reader.GetAttribute("name");
     _reader.Read();
     if (_reader.Name == "grid")
     {
         var loader = new XmlUIGridLoader(DtdLoader, _defClassFactory);
         _uiGrid = loader.LoadUIGridDef(_reader.ReadOuterXml());
     }
     if (_reader.Name == "form")
     {
         var loader = new XmlUIFormLoader(DtdLoader, _defClassFactory);
         _uiForm = loader.LoadUIFormDef(_reader.ReadOuterXml());
     }
 }
        ///<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>
        /// Creates one panel for each UI Form definition of a business object
        /// </summary>
        /// <returns>Returns the list of panel info objects created</returns>
        /// TODO: improve tab order (ie make all tabs use one sequence rather than each starting a new sequence)
        public List<IPanelInfo> CreateOnePanelPerUIFormTab(IUIForm uiForm)
        {
            List<IPanelInfo> panelInfoList = new List<IPanelInfo>();
            foreach (UIFormTab formTab in uiForm)
            {
                IPanelInfo onePanelInfo = BuildPanelForTab(formTab);

                panelInfoList.Add(onePanelInfo);
            }
            return panelInfoList;
        }
 private static void RemoveAllFormTabs(IUIForm uiForm)
 {
     foreach (var formTab in uiForm.ToArray())
     {
         uiForm.Remove(formTab);
     }
 }
Beispiel #42
0
		///<summary>
		///</summary>
		///<param name="name"></param>
		///<param name="uiForm"></param>
		///<param name="uiGrid"></param>
		///<returns></returns>
		public IUIDef CreateUIDef(string name, IUIForm uiForm, IUIGrid uiGrid)
		{
			return new UIDef(name, uiForm, uiGrid);
		}