/// <summary> /// 打开XML /// </summary> /// <param name="xml">XML</param> public void openXml(String xml) { //获取选中控件的名称 List <FCView> targets = m_resizeDiv.getTargets(); int targetsSize = targets.Count; List <String> names = new List <String>(); for (int i = 0; i < targetsSize; i++) { names.Add(targets[i].Name); } int namesSize = names.Count; //移动控件 List <FCView> controls = m_designerTabPage.getControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { FCView control = controls[i]; if (control != m_resizeDiv) { m_designerTabPage.removeControl(control); controlsSize--; i--; } } targets.Clear(); m_resizeDiv.clearTargets(); //加载XML m_xml.loadXml(xml, m_designerTabPage); if (namesSize > 0) { for (int i = 0; i < namesSize; i++) { FCView target = m_xml.findControl(names[i]); if (target != null) { targets.Add(target); } } if (targets.Count > 0) { m_designer.setCurrentControl(targets[0]); } targets.Clear(); } else { m_resizeDiv.Visible = false; } m_designerTabPage.update(); invalidate(); }
/// <summary> /// 创建控件名称 /// </summary> /// <param name="control">控件</param> /// <param name="xml">XML对象</param> /// <returns>控件名称</returns> public static String CreateControlName(FCView control, UIXmlEx xml) { int count = 0; String controlType = control.getControlType(); String controlName = controlType; while (xml.findControl(controlName) != null) { if (count > 0) { controlName = controlType + (count + 1).ToString(); } count++; } return(controlName); }