private List <string> GetItem() { List <string> lstType = new List <string>(); //if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow is FormDesignerWorkbenchWindow) //{ //if (((FormDesignerWorkbenchWindow)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow).SelectedControl.formItemID.ToString() != "0" // && ((FormDesignerWorkbenchWindow)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow).SelectedControl.formItemID.ToString() != null) //{ DockFormDesigner win = (DockFormDesigner)DockWindowFactory.Instance.CurrDockWindow; foreach (XmlNode item in ControlMapping.GetInstance().GetControlExtention(win.SelectedControl.formItemType.ToString())) { if (item.Attributes == null) { continue; } if (item.Attributes["name"] != null) { lstType.Add(item.Attributes["name"].Value); } } //} //} return(lstType); }
/// <summary> /// 获取控件信息集 /// </summary> /// <param name="xPath"></param> /// <returns></returns> public ControlCollection GetControls(DockFormDesigner dockFormDesigner, string xPath, out Dictionary <string, string> panelProperty) { _dockFormDesigner = dockFormDesigner; ControlCollection controlCollection = new ControlCollection(); XmlNode contorlNodes = formXmlParser.GetNode(xPath); panelProperty = new Dictionary <string, string>(); //textBoxsType = new TextBoxsType(); panelProperty.Add("width", contorlNodes.Attributes["width"].Value); panelProperty.Add("height", contorlNodes.Attributes["height"].Value); DockFormDesigner.controlDictionary.Clear(); foreach (XmlNode xmlnode in contorlNodes) { GeneralAttribute generalAttribute = new GeneralAttribute(); Int16 ItemType = 0; ItemType = Convert.ToInt16(ControlMapping.GetInstance().GetFormItemType(xmlnode.Name)); switch (ItemType) { case 5: #region ItemType=5 TableContorlAttribute tableContorlAttribute = new TableContorlAttribute(); BindGeneralAttribute(tableContorlAttribute, xmlnode, Convert.ToInt16(ControlMapping.GetInstance().GetFormItemType(xmlnode.Name))); foreach (XmlNode groupNode in xmlnode) { Group group = new Group(); group.Name = groupNode.Attributes["name"].Value; foreach (XmlNode childNode in groupNode) { Int16 ItemTypec; //if (childNode.Name == "DateTimePicker") //{ // ItemTypec = 1; // textBoxsType.AddTextBox(childNode.Attributes["id"].Value); //} //else ItemTypec = Convert.ToInt16(ControlMapping.GetInstance().GetFormItemType(childNode.Name)); switch (ItemTypec) { case 7: DataGridControlAttribute DataGridControlAttribute = AppendGrid(childNode); group.AddGroupControl(DataGridControlAttribute.ControlId, DataGridControlAttribute); break; case 20: RadioButtonListAttribute rbtlist = AppendRadioButton(childNode); group.AddGroupControl(rbtlist.ControlId, rbtlist); break; default: GeneralAttribute childContrlAttribute = new GeneralAttribute(); BindGeneralAttribute(childContrlAttribute, childNode, ItemTypec); group.AddGroupControl(childContrlAttribute.ControlId, childContrlAttribute); break; } } tableContorlAttribute.AddGroup(group.Name, group); } generalAttribute = tableContorlAttribute; #endregion break; case 7: generalAttribute = AppendGrid(xmlnode); break; case 20: generalAttribute = AppendRadioButton(xmlnode); break; default: BindGeneralAttribute(generalAttribute, xmlnode, ItemType); break; } controlCollection.Add(xmlnode.Attributes["id"].Value, generalAttribute); } return(controlCollection); }
public void FormItemProperty() { try { ControlItemAttribute attr = new ControlItemAttribute(); if (_selectedControl.formItemType != 0) { attr.FormItemInfo = _selectedControl; StringBuilder windowtext = new StringBuilder(2560); FormProvoider.GetStaticText(_selectedControl.formItemID, windowtext, windowtext.Capacity); attr.Left = _selectedControl.left; attr.Top = _selectedControl.top; attr.Width = _selectedControl.width; attr.Height = _selectedControl.height; attr.FormItemId = _selectedControl.formItemID; attr.FormItemType = _selectedControl.formItemType; attr.Text = windowtext.ToString(); attr.ControlType = ControlMapping.GetInstance().GetExtensionTypeName(_selectedControl.formItemType.ToString(), _selectedControl.extension.ToString()); if (_selectedControl.formItemType != 0) //==4 { //get the contorl's font FormProvoider.FontWnd fontWnd = new FormProvoider.FontWnd(); FormProvoider.GetFormItemFont(_selectedControl.formItemID, out fontWnd); if (!string.IsNullOrEmpty(fontWnd.itemName)) { Font font = GeneralAttribute.SetFontStyle(new FontFamily(fontWnd.itemName), fontWnd.ftSize , fontWnd.ftStyle); attr.SetAttributeFont(font); } //点击控件显示其 绑定信息 if (_selectedControl.formItemType == 1 && FormProvoider.GetSelectedFormItemsCount() == 1) { attr.Text = attr.DataItem; } //get the contorl's color Int32 oldColor; FormProvoider.GetFormItemColor(_selectedControl.formItemID, out oldColor); attr.SetAttributeColor(ColorTranslator.FromOle(oldColor)); attr.Border = FormProvoider.BorderStyle(_selectedControl); } //_focusedControl = FormParameter.FormId + "_" + _selectedControl.formItemID.ToString(); DockFormDesigner.controlDictionary.AddValue(_selectedControl.formItemID, _selectedControl.formItemID.ToString()); } else { attr.IsPrint = PageProperty.IsPrint.ToString(); //SelectedItemId = _selectedControl.formItemID.ToString(); //_selectedItemType = _selectedControl.formItemType.ToString(); } propertyGridControl1.SelectedObject = attr; //propertyGridControl1.RetrieveFields(); //FormParameter.ControlsCollection = controlsDictionary; } catch (Exception E) { //XtraMessageBox.Show(E.Message, "系统提示", MessageBoxButtons.OK); MainForm.ERROR(E.Message); } }
/// <summary> /// 控件一般属性解析 /// </summary> /// <param name="ContrlAttribute"></param> /// <param name="xmlNode"></param> /// <param name="ItemType"></param> private void BindGeneralAttribute(GeneralAttribute ContrlAttribute, XmlNode xmlNode, Int16 ItemType) { AddControl(xmlNode); ContrlAttribute.Left = Convert.ToInt32(xmlNode.Attributes["x"].Value); ContrlAttribute.Top = Convert.ToInt32(xmlNode.Attributes["y"].Value); ContrlAttribute.Height = Convert.ToInt32(xmlNode.Attributes["height"].Value); ContrlAttribute.Width = Convert.ToInt32(xmlNode.Attributes["width"].Value); ContrlAttribute.FormItemId = Convert.ToInt32(xmlNode.Attributes["id"].Value); ContrlAttribute.FormItemType = ItemType; if (xmlNode.Attributes["text"] != null) { ContrlAttribute.Text = xmlNode.Attributes["text"].Value; } if (xmlNode.Attributes["multiline"] != null) { ContrlAttribute.Multiline = xmlNode.Attributes["multiline"].Value == "true" ? true : false; } if (xmlNode.Attributes["font"] != null) { string[] strFont = xmlNode.Attributes["font"].Value.Split('|'); ContrlAttribute.WindowTextFont = GeneralAttribute.SetFontStyle(new FontFamily(strFont[0]), Convert.ToInt16(strFont[1]), Convert.ToInt32(strFont[2])); } if (xmlNode.Attributes["color"] != null) { ContrlAttribute.WindowTextColor = ColorTranslator.FromOle(Convert.ToInt32(xmlNode.Attributes["color"].Value)); } if (xmlNode.Attributes["readonly"] != null) { if (xmlNode.Attributes["readonly"].Value == "true") { ControlMapping.ReadControls.Add(ContrlAttribute.FormItemId.ToString()); } } if (xmlNode.Attributes["isprint"] != null) { if (xmlNode.Attributes["isprint"].Value == "false") { ControlMapping.NotPrintControls.Add(ContrlAttribute.FormItemId.ToString()); } } //// 新增解析isprintwhenarchive的代码 //if (xmlNode.Attributes["isprintwhenarchive"] != null) //{ // DAP2ControlMapping.PrintWhenArchiveControls.Add(ContrlAttribute.FormItemId, // xmlNode.Attributes["isprintwhenarchive"].Value); //} //if (xmlNode.Attributes["relationControl"]!=null) //{ // DAP2ControlMapping.ControlRelation.Add(ContrlAttribute.FormItemId, // xmlNode.Attributes["relationControl"].Value); //} if (xmlNode.Attributes["extensionType"] != null) { string enttype = ControlMapping.GetInstance().GetExtensionTypeId(ContrlAttribute.FormItemType.ToString() , xmlNode.Attributes["extensionType"].Value); if (!string.IsNullOrEmpty(enttype)) { ContrlAttribute.ExtensionType = Convert.ToInt16(enttype); } } if (xmlNode.Attributes["tip"] != null) { ControlMapping.ControlTip.Add(ContrlAttribute.FormItemId, xmlNode.Attributes["tip"].Value); } //if (xmlNode.Attributes["numberDefine"] != null) //{ // DAP2ControlMapping.ControlNumberDefine.Add(ContrlAttribute.FormItemId, // xmlNode.Attributes["numberDefine"].Value); //} if (xmlNode.Attributes["defaultValue"] != null) { ControlMapping.DefaultValues.Add(ContrlAttribute.FormItemId, xmlNode.Attributes["defaultValue"].Value); } if (xmlNode.Attributes["expression"] != null) { ControlMapping.ExpressionControls.Add(ContrlAttribute.FormItemId, xmlNode.Attributes["expression"].Value); } if (xmlNode.Attributes["border"] != null) { ContrlAttribute.Border = bool.Parse(xmlNode.Attributes["border"].Value); } if (ContrlAttribute.FormItemType == 2) { if (xmlNode.Attributes["comboxEdit"] != null) { if (xmlNode.Attributes["comboxEdit"].Value == "true") { ControlMapping.ComboxEditControls.Add(ContrlAttribute.ControlId); } } } }