Ejemplo n.º 1
0
 ///<summary>
 ///Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
 ///</summary>
 ///
 ///<returns>
 ///true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
 ///</returns>
 ///
 ///<param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>. </param><filterpriority>2</filterpriority>
 public bool Equals(IUIFormColumn obj)
 {
     if (ReferenceEquals(null, obj))
     {
         return(false);
     }
     if (ReferenceEquals(this, obj))
     {
         return(true);
     }
     return(this.Equals((object)obj));
 }
Ejemplo n.º 2
0
        private void AddFieldsToLayoutManager(UIFormTab formTab, IPanelInfo panelInfo)
        {
            int numberOfColumns = formTab.Count;

            int[] currentFieldPositionInColumns = new int[numberOfColumns];
            int[] rowSpanTrackerForColumn       = new int[numberOfColumns];
            int   maxRowsInColumns = formTab.GetMaxRowsInColumns();

            int[] columnSpanTrackerForRow = new int[maxRowsInColumns];
            for (int currentRowNo = 0; currentRowNo < maxRowsInColumns; currentRowNo++)
            {
                for (int currentColumnNo = 0; currentColumnNo < numberOfColumns; currentColumnNo++)
                {
                    IUIFormColumn currentFormColumn = formTab[currentColumnNo];

                    if (--rowSpanTrackerForColumn[currentColumnNo] > 0)
                    {
                        continue;
                    }
                    // keep skipping this grid position until a previous row span in this column has been decremented
                    if (--columnSpanTrackerForRow[currentRowNo] > 0)
                    {
                        continue;
                    }
                    // keep skipping this grid position until a previous column span in this row has been decremented

                    int currentFieldNoInColumn = currentFieldPositionInColumns[currentColumnNo];
                    int totalFieldsInColumn    = currentFormColumn.Count;
                    if (currentFieldNoInColumn < totalFieldsInColumn) // there exists a field in this row in this column
                    {
                        UIFormField formField = (UIFormField)currentFormColumn[currentFieldNoInColumn];
                        rowSpanTrackerForColumn[currentColumnNo] = formField.RowSpan;
                        for (int i = currentRowNo; i < currentRowNo + formField.RowSpan; i++)
                        {
                            // update colspan of all rows that this field spans into.
                            columnSpanTrackerForRow[i] = formField.ColSpan;
                        }

                        PanelInfo.FieldInfo fieldInfo = AddControlsForField(formField, panelInfo);
                        fieldInfo.InputControl.TabIndex = currentColumnNo * maxRowsInColumns + currentRowNo;
                    }
                    else
                    {
                        AddNullControlsForEmptyField(panelInfo);
                    }
                    currentFieldPositionInColumns[currentColumnNo]++;
                }
            }
        }
Ejemplo n.º 3
0
        public void TestLoadColumn()
        {
            IUIFormColumn col =
                loader.LoadUIFormColumn(
                    @"
							<columnLayout width=""123"">
								<field label=""testlabel1"" property=""testpropname1"" type=""Button"" mapperType=""testmappertypename1"" />
								<field label=""testlabel2"" property=""testpropname2"" type=""Button"" mapperType=""testmappertypename2"" />
							</columnLayout>"                            );

            Assert.AreEqual(2, col.Count);
            Assert.AreEqual(123, col.Width);
            Assert.AreEqual("testlabel1", col[0].Label);
            Assert.AreEqual("testlabel2", col[1].Label);
        }
Ejemplo n.º 4
0
        public void TestCloneUIFormColumn()
        {
            //---------------Set up test pack-------------------
            UIFormField  field1       = CreateUIFormField();
            UIFormField  field2       = CreateUIFormField();
            UIFormColumn uiFormColumn = new UIFormColumn();

            uiFormColumn.Add(field1);
            uiFormColumn.Add(field2);
            uiFormColumn.Width = 44;

            //---------------Execute Test ----------------------
            IUIFormColumn clonedFormColumn = uiFormColumn.Clone();

            //---------------Test Result -----------------------
            Assert.IsTrue(uiFormColumn == (UIFormColumn)clonedFormColumn);

            Assert.IsTrue(uiFormColumn.Equals(clonedFormColumn));
            Assert.AreSame(uiFormColumn[0], clonedFormColumn[0]);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads form column data from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
			_column = _defClassFactory.CreateUIFormColumn();
			//_column = new UIFormColumn();

            //_reader.Read();
            //string className = _reader.GetAttribute("class");
            //string assemblyName = _reader.GetAttribute("assembly");
            //_collection.Class = TypeLoader.LoadType(assemblyName, className);
            //_collection.Name = new UIPropertyCollectionName(_collection.Class, _reader.GetAttribute("name"));

            _reader.Read();
            try
            {
                _column.Width = Convert.ToInt32(_reader.GetAttribute("width"));
            }
            catch (Exception ex)
            {
                throw new InvalidXmlDefinitionException("In a 'columnLayout' " + 
                    "element, the 'width' attribute has been given " +
                    "an invalid integer pixel value.", ex);
            }

            _reader.Read();
            while (_reader.Name == "field")
            {
                XmlUIFormFieldLoader propLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory);
                _column.Add(propLoader.LoadUIProperty(_reader.ReadOuterXml()));
            }

            if (_column.Count == 0)
            {
                throw new InvalidXmlDefinitionException("No 'field' " +
                    "elements were specified in a 'columnLayout' element.  Ensure " +
                    "that the element " +
                    "contains one or more 'field' elements, which " +
                    "specify the property editing controls to appear in the " +
                    "editing form column.");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads form column data from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
            _column = _defClassFactory.CreateUIFormColumn();
            //_column = new UIFormColumn();

            //_reader.Read();
            //string className = _reader.GetAttribute("class");
            //string assemblyName = _reader.GetAttribute("assembly");
            //_collection.Class = TypeLoader.LoadType(assemblyName, className);
            //_collection.Name = new UIPropertyCollectionName(_collection.Class, _reader.GetAttribute("name"));

            _reader.Read();
            try
            {
                _column.Width = Convert.ToInt32(_reader.GetAttribute("width"));
            }
            catch (Exception ex)
            {
                throw new InvalidXmlDefinitionException("In a 'columnLayout' " +
                                                        "element, the 'width' attribute has been given " +
                                                        "an invalid integer pixel value.", ex);
            }

            _reader.Read();
            while (_reader.Name == "field")
            {
                XmlUIFormFieldLoader propLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory);
                _column.Add(propLoader.LoadUIProperty(_reader.ReadOuterXml()));
            }

            if (_column.Count == 0)
            {
                throw new InvalidXmlDefinitionException("No 'field' " +
                                                        "elements were specified in a 'columnLayout' element.  Ensure " +
                                                        "that the element " +
                                                        "contains one or more 'field' elements, which " +
                                                        "specify the property editing controls to appear in the " +
                                                        "editing form column.");
            }
        }
Ejemplo n.º 7
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.");
            }
        }
Ejemplo n.º 8
0
 ///<summary>
 ///Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
 ///</summary>
 ///
 ///<returns>
 ///true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
 ///</returns>
 ///
 ///<param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>. </param><filterpriority>2</filterpriority>
 public bool Equals(IUIFormColumn obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return this.Equals((object) obj);
 }