コード例 #1
0
ファイル: ModUiTools.cs プロジェクト: 0ks3ii/IronWASP
 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;
 }
コード例 #2
0
ファイル: ModUiTools.cs プロジェクト: 0ks3ii/IronWASP
        static string XmlFromModTextBoxControl(ModTextBox C)
        {
            StringBuilder SB = new StringBuilder();
            SB.Append(StartTag(ModUiTags.ModTextBox));
            SB.Append(XmlFromControlNameProperty(C));
            SB.Append(StartTag(ModUiTags.Properties));
            //basic properties
            SB.Append(XmlFromBasicProperties(C));
            //textbox specific properties
            SB.Append(XmlFromControlBorderStyleProperty(C.BorderStyle));
            SB.Append(XmlFromControlReadOnlyProperty(C.ReadOnly));
            SB.Append(XmlFromControlScrollBarsProperty(C.ScrollBars));
            SB.Append(XmlFromControlFontProperty(C.Font));
            SB.Append(XmlFromControlMultiLineProperty(C.Multiline));
            SB.Append(XmlFromControlPasswordCharProperty(C.PasswordChar));
            SB.Append(XmlFromControlWordWrapProperty(C.WordWrap));
            SB.Append(XmlFromControlTextAlignProperty(C.TextAlign));
            SB.Append(XmlFromControlTextProperty(C.Text));
            SB.Append(EndTag(ModUiTags.Properties));

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

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

            return SB.ToString();
        }