Exemple #1
0
 ModCodeAndControlHolder ConvertControlChildXmlNodesToCode(XmlNode ParentNode, string ParentName, Control ParentControl)
 {
     StringBuilder PyCode = new StringBuilder();
     StringBuilder RbCode = new StringBuilder();
     foreach (XmlNode ChildNode in ParentNode.ChildNodes)
     {
         string ReadControlName = GetControlNameFromControlXmlNode(ChildNode);
         string ControlName = GetControlName(ChildNode.Name, ReadControlName);
         Control C;
         switch (ChildNode.Name)
         {
             case ("ModLabel"):
                 PyCode.AppendLine(string.Format("{0} = ModLabel()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModLabel.new()", ControlName));
                 try
                 {
                     C = (ModLabel)ModUiDesigner.IDH.CreateComponent(typeof(ModLabel), ControlName);
                 }
                 catch { C = new ModLabel(); }
                 break;
             case ("ModTextBox"):
                 PyCode.AppendLine(string.Format("{0} = ModTextBox()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModTextBox.new()", ControlName));
                 try
                 {
                     C = (ModTextBox)ModUiDesigner.IDH.CreateComponent(typeof(ModTextBox), ControlName);
                 }
                 catch { C = new ModTextBox(); }
                 break;
             case ("ModRichTextBox"):
                 PyCode.AppendLine(string.Format("{0} = ModRichTextBox()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModRichTextBox.new()", ControlName));
                 try
                 {
                     C = (ModRichTextBox)ModUiDesigner.IDH.CreateComponent(typeof(ModRichTextBox), ControlName);
                 }
                 catch { C = new ModRichTextBox(); }
                 break;
             case ("ModButton"):
                 PyCode.AppendLine(string.Format("{0} = ModButton()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModButton.new()", ControlName));
                 try
                 {
                     C = (ModButton)ModUiDesigner.IDH.CreateComponent(typeof(ModButton), ControlName);
                 }
                 catch { C = new ModButton(); }
                 break;
             case ("ModCheckBox"):
                 PyCode.AppendLine(string.Format("{0} = ModCheckBox()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModCheckBox.new()", ControlName));
                 try
                 {
                     C = (ModCheckBox)ModUiDesigner.IDH.CreateComponent(typeof(ModCheckBox), ControlName);
                 }
                 catch { C = new ModCheckBox(); }
                 break;
             case ("ModRadioButton"):
                 PyCode.AppendLine(string.Format("{0} = ModRadioButton()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModRadioButton.new()", ControlName));
                 try
                 {
                     C = (ModRadioButton)ModUiDesigner.IDH.CreateComponent(typeof(ModRadioButton), ControlName);
                 }
                 catch { C = new ModRadioButton(); }
                 break;
             case ("ModDataGridView"):
                 PyCode.AppendLine(string.Format("{0} = ModDataGridView()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModDataGridView.new()", ControlName));
                 try
                 {
                     C = (ModDataGridView)ModUiDesigner.IDH.CreateComponent(typeof(ModDataGridView), ControlName);
                 }
                 catch { C = new ModDataGridView(); }
                 break;
             case ("ModPanel"):
                 PyCode.AppendLine(string.Format("{0} = ModPanel()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModPanel.new()", ControlName));
                 try
                 {
                     C = (ModPanel)ModUiDesigner.IDH.CreateComponent(typeof(ModPanel), ControlName);
                 }
                 catch { C = new ModPanel(); }
                 break;
             case ("ModTabControl"):
                 PyCode.AppendLine(string.Format("{0} = ModTabControl()", ControlName));
                 RbCode.AppendLine(string.Format("{0} = ModTabControl.new()", ControlName));
                 ModTabControl M = new ModTabControl();
                 try
                 {
                     C = (ModTabControl)ModUiDesigner.IDH.CreateComponent(typeof(ModTabControl), ControlName);
                 }
                 catch { C = new ModTabControl(); }
                 break;
             default:
                 continue;
         }
         SetNameInCode(PyCode, RbCode, ControlName, C);
         ModCodeAndControlHolder CPECC = ConvertControlPropertiesEventHandlersChildrenToCode(ChildNode, ControlName, C);
         PyCode.Append(CPECC.PyCode);
         RbCode.Append(CPECC.RbCode);
         PyCode.AppendLine(string.Format("{0}.Controls.Add({1})", ParentName, ControlName));
         RbCode.AppendLine(string.Format("{0}.Controls.Add({1})", ParentName, ControlName));
         PyCode.AppendLine(string.Format("ui.ModControls['{0}'] = {0}", ControlName));
         RbCode.AppendLine(string.Format("ui.mod_controls['{0}'] = {0}", ControlName));
         CPECC.Control.Parent = ParentControl;
     }
     ModCodeAndControlHolder Result = new ModCodeAndControlHolder();
     Result.PyCode = PyCode.ToString();
     Result.RbCode = RbCode.ToString();
     Result.Control = ParentControl;
     return Result;
 }
Exemple #2
0
        static string XmlFromModDataGridViewControl(ModDataGridView C)
        {
            StringBuilder SB = new StringBuilder();
            SB.Append(StartTag(ModUiTags.ModDataGridView));
            SB.Append(XmlFromControlNameProperty(C));
            SB.Append(StartTag(ModUiTags.Properties));
            //basic properties
            SB.Append(XmlFromBasicProperties(C));
            //textbox specific properties
            SB.Append(XmlFromAllowUserToAddRowsProperty(C.AllowUserToAddRows));
            SB.Append(XmlFromAllowUserToDeleteRowsProperty(C.AllowUserToDeleteRows));
            SB.Append(XmlFromAllowUserToOrderColumnsProperty(C.AllowUserToOrderColumns));
            SB.Append(XmlFromAllowUserToResizeColumnsProperty(C.AllowUserToResizeColumns));
            SB.Append(XmlFromAllowUserToResizeRowsProperty(C.AllowUserToResizeRows));
            SB.Append(XmlFromColumnHeadersVisibleProperty(C.ColumnHeadersVisible));
            SB.Append(XmlFromRowHeadersVisibleProperty(C.RowHeadersVisible));
            //SB.Append(XmlFromColumnHeadersDefaultCellStyleProperty(C.ColumnHeadersDefaultCellStyle));
            SB.Append(XmlFromColumnHeadersHeightSizeModeProperty(C.ColumnHeadersHeightSizeMode));
            SB.Append(XmlFromControlSelectionModeProperty(C.SelectionMode));
            SB.Append(XmlFromControlGridColorProperty(C.GridColor));
            SB.Append(XmlFromColumnsProperty(C.Columns));
            SB.Append(EndTag(ModUiTags.Properties));

            SB.Append(XmlFromEventHandlers(C.EventHandlers));

            SB.Append(EndTag(ModUiTags.ModDataGridView));

            return SB.ToString();
        }