示例#1
0
        /// <summary>
        /// 创建表格行
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="control">控件</param>
        protected virtual void createGridRow(XmlNode node, FCView control)
        {
            FCGrid    grid = control as FCGrid;
            FCGridRow row  = new FCGridRow();

            grid.addRow(row);
            setAttributesBefore(node, row);
            //单元格
            int col = 0;

            foreach (XmlNode node3 in node.ChildNodes)
            {
                String subNodeName  = node3.Name.ToLower();
                String subNodeValue = node3.InnerText;
                if (subNodeName == "cell" || subNodeName == "td")
                {
                    String cellType = "string";
                    HashMap <String, String> attributes = getAttributes(node3);
                    if (attributes.containsKey("type"))
                    {
                        cellType = attributes.get("type");
                    }
                    attributes.clear();
                    FCGridCell cell = null;
                    if (cellType == "bool")
                    {
                        cell = new FCGridBoolCell();
                    }
                    else if (cellType == "button")
                    {
                        cell = new FCGridButtonCell();
                    }
                    else if (cellType == "checkbox")
                    {
                        cell = new FCGridCheckBoxCell();
                    }
                    else if (cellType == "combobox")
                    {
                        cell = new FCGridComboBoxCell();
                    }
                    else if (cellType == "double")
                    {
                        cell = new FCGridDoubleCell();
                    }
                    else if (cellType == "float")
                    {
                        cell = new FCGridFloatCell();
                    }
                    else if (cellType == "string")
                    {
                        cell = new FCGridStringCell();
                    }
                    else if (cellType == "int")
                    {
                        cell = new FCGridIntCell();
                    }
                    else if (cellType == "long")
                    {
                        cell = new FCGridLongCell();
                    }
                    else if (cellType == "textbox")
                    {
                        cell = new FCGridTextBoxCell();
                    }
                    row.addCell(col, cell);
                    setAttributesBefore(node3, cell);
                    cell.setString(subNodeValue);
                    setAttributesAfter(node3, cell);
                    col++;
                }
            }
            setAttributesAfter(node, row);
        }
示例#2
0
        /// <summary>
        /// 创建属性
        /// </summary>
        public void createProperties()
        {
            WinHostEx host = Native.Host as WinHostEx;

            host.LoadingDesigner = true;
            int rowSize = m_rows.Count;

            if (rowSize > 0)
            {
                //清除所有行
                for (int i = 0; i < rowSize; i++)
                {
                    m_rows[i].clearCells();
                    m_rows[i].delete();
                }
                m_rows.Clear();
            }
            int targetsSize = m_targets.Count;

            if (targetsSize > 0)
            {
                FCView target = m_targets[0];
                //获取属性名称
                List <String> propertiesName = UIXmlEx.getUnionProperties(m_targets);
                Dictionary <String, String> addProperties = new Dictionary <String, String>();
                if (targetsSize == 1)
                {
                    if (target is FCTabControl)
                    {
                        addProperties["TabPages"] = "collection";
                    }
                    else if (target is FCGrid)
                    {
                        addProperties["Columns"] = "collection";
                    }
                    foreach (String addName in addProperties.Keys)
                    {
                        propertiesName.Add(addName);
                    }
                }
                propertiesName.Sort();
                int psize = propertiesName.Count;
                for (int i = 0; i < psize; i++)
                {
                    String name  = propertiesName[i];
                    String value = "";
                    String type  = "";
                    if (addProperties.ContainsKey(name))
                    {
                        value = "单击以编辑...";
                        type  = addProperties[name];
                    }
                    else
                    {
                        target.getProperty(name.ToLower(), ref value, ref type);
                    }
                    String text = name;
                    if (m_chNames.ContainsKey(name.ToLower()))
                    {
                        text = m_chNames[name.ToLower()];
                    }
                    if (value == null)
                    {
                        value = "";
                    }
                    FCGridRow row = new FCGridRow();
                    addRow(row);
                    //序号
                    GridNoCell orderCell = new GridNoCell();
                    row.addCell("NO", orderCell);
                    //属性名称
                    FCGridStringCell nameCell = new FCGridStringCell(text);
                    nameCell.Name = name;
                    row.addCell("PROPERTYNAME", nameCell);
                    //英文名称
                    FCGridStringCell enNameCell = new FCGridStringCell(name);
                    row.addCell("ENNAME", enNameCell);
                    //属性值
                    //布尔
                    if (type == "bool")
                    {
                        FCGridCheckBoxCell checkBoxCell = new FCGridCheckBoxCell();
                        checkBoxCell.Control = new CheckBoxM();
                        row.addCell("PROPERTYVALUE", checkBoxCell);
                        checkBoxCell.setBool(value.ToLower() == "true" ? true : false);
                        checkBoxCell.CheckBox.Tag         = name;
                        checkBoxCell.CheckBox.ButtonAlign = FCHorizontalAlign.Left;
                        checkBoxCell.CheckBox.addEvent(new FCEvent(checkBoxCheckedChanged), FCEventID.CHECKEDCHANGED);
                    }
                    //枚举
                    else if (type.StartsWith("enum:"))
                    {
                        String             strEnum      = "FaceCat." + type.Replace("enum:", "");
                        String[]           names        = Enum.GetNames(m_assembly.GetType(strEnum));
                        FCGridComboBoxCell comboBoxCell = new FCGridComboBoxCell();
                        row.addCell("PROPERTYVALUE", comboBoxCell);
                        comboBoxCell.ComboBox.BackColor = FCColor.None;
                        int nameSize = names.Length;
                        for (int j = 0; j < nameSize; j++)
                        {
                            comboBoxCell.ComboBox.DropDownMenu.addItem(new FCMenuItem(names[j]));
                        }
                        comboBoxCell.ComboBox.SelectedText = value;
                        comboBoxCell.ComboBox.ReadOnly     = true;
                        comboBoxCell.ComboBox.Tag          = name;
                        comboBoxCell.ComboBox.addEvent(new FCEvent(comboBoxSelectedIndexChanged), FCEventID.SELECTEDINDEXCHANGED);
                    }
                    //集合
                    else if (type == "collection")
                    {
                        FCGridButtonCell buttonCell = new FCGridButtonCell();
                        row.addCell("PROPERTYVALUE", buttonCell);
                        buttonCell.setString(value);
                        buttonCell.Button.Tag       = name;
                        buttonCell.Button.BackColor = FCColor.None;
                        buttonCell.Button.TextAlign = FCContentAlignment.MiddleLeft;
                        buttonCell.Button.Font      = new FCFont("微软雅黑", 12, false, false, false);
                    }
                    //颜色
                    else if (type == "color")
                    {
                        GridColorCell colorCell = new GridColorCell();
                        colorCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", colorCell);
                        colorCell.setString(value);
                        colorCell.Button.Font = new FCFont("微软雅黑", 12, true, false, false);
                    }
                    //字体
                    else if (type == "font")
                    {
                        GridFontCell fontCell = new GridFontCell();
                        fontCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", fontCell);
                        fontCell.setString(value);
                        fontCell.Button.Font = new FCFont("微软雅黑", 12, true, false, false);
                    }
                    //输入框
                    else
                    {
                        FCGridStringCell textCell = new FCGridStringCell();
                        textCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", textCell);
                        textCell.Text = value;
                    }
                }
                propertiesName.Clear();
                update();
                invalidate();
            }
            host.LoadingDesigner = false;
        }