/// <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; }
/// <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> eventNames = target.getEventNames(); Dictionary <String, String> attributes = m_xml.getAttributes(m_xml.Nodes[target]); eventNames.Sort(); int psize = eventNames.Count; for (int i = 0; i < psize; i++) { String name = eventNames[i]; String eventName = "on" + name.ToLower(); String value = ""; if (attributes.ContainsKey(eventName)) { value = attributes[eventName]; } 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); FCGridStringCell textCell = new FCGridStringCell(); textCell.AllowEdit = true; row.addCell("PROPERTYVALUE", textCell); textCell.Text = value; } eventNames.Clear(); update(); invalidate(); } host.LoadingDesigner = false; }