Exemplo n.º 1
0
 private static void AddProperty(StringBuilder stringBuilder, string type, string name, string desc, int index)
 {
     if (null == name)
     {
         stringBuilder.AppendLine("public " + type + " " + FormatUtility.BuildPropertyName(name, desc, index) + " => " + "(" + type + ")GetControlTemplate(" + index + ");");
     }
     else
     {
         stringBuilder.AppendLine("public " + type + " " + FormatUtility.BuildPropertyName(name, desc, index) + " => " + "(" + type + ")GetControlTemplate(\"" + name + "\");");
     }
 }
Exemplo n.º 2
0
 private static void AddProperty(StringBuilder stringBuilder, string type, string name, string desc, int index)
 {
     if (null == name)
     {
         stringBuilder.AppendLine("public " + type + " " + FormatUtility.BuildPropertyName(name, desc, index) + " => " + "(" + type + ")GetValue(" + index + ");");
     }
     else
     {
         stringBuilder.AppendLine("public " + type + " " + FormatUtility.BuildPropertyName(name, desc, index));
         stringBuilder.AppendLine("{");
         stringBuilder.AppendLine("get => " + "(" + type + ")GetValue(" + index + ");");
         stringBuilder.AppendLine("set => " + "SetValue(\"" + name + "\", value);");
         stringBuilder.AppendLine("}");
     }
 }
Exemplo n.º 3
0
        private static int ProcessColumn(StringBuilder stringBuilder, List <ControlTemplate> controls, int controlNumber)
        {
            foreach (var controlTemplate in controls)
            {
                switch (controlTemplate.Type)
                {
                case ControlType.TextBox:
                case ControlType.TextBoxWithButton:
                case ControlType.ComboBox:
                {
                    AddProperty(stringBuilder, "string", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);

                    // Добавляем константы
                    if (ControlType.ComboBox.Equals(controlTemplate.Type))
                    {
                        var comboBoxTemplate = (ComboBoxTemplate)controlTemplate;

                        var propertyName = FormatUtility.BuildPropertyName(controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);

                        foreach (var comboBoxItemTemplate in comboBoxTemplate.Items)
                        {
                            var valueName = comboBoxItemTemplate.Value;
                            valueName = valueName.Replace(".", " ");
                            valueName = FormatUtility.ToCamelCase(valueName);

                            stringBuilder.AppendLine("public const string " + propertyName + "Value" +
                                                     valueName + " = \"" + comboBoxItemTemplate.Value +
                                                     "\";");
                        }
                    }

                    // Добавляем константы
                    if (ControlType.TextBoxWithButton.Equals(controlTemplate.Type))
                    {
                        var textBoxWithButtonTemplate = (TextBoxWithButtonTemplate)controlTemplate;

                        var propertyName = FormatUtility.BuildPropertyName(controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);

                        foreach (var textBoxWithButtonBehaviorRule in textBoxWithButtonTemplate.BehaviorRules)
                        {
                            if (textBoxWithButtonBehaviorRule.Trigger.Equals("ButtonClick"))
                            {
                                stringBuilder.AppendLine("public const string " + propertyName + "Command" +
                                                         textBoxWithButtonBehaviorRule.Action + " = \"" + textBoxWithButtonBehaviorRule.Action + "\";");
                            }
                        }
                    }
                }
                break;

                case ControlType.NumericUpDown:
                case WMControlType.AmountNumericUpDown:
                    AddProperty(stringBuilder, "decimal?", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);
                    break;

                case ControlType.CheckBox:
                    AddProperty(stringBuilder, "bool?", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);
                    break;

                case ControlType.DateTimePicker:
                    AddProperty(stringBuilder, "DateTime?", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);
                    break;

                case ControlType.Table:
                    AddProperty(stringBuilder, "object", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);
                    break;

                case WMControlType.AccountDropDownList:
                    AddProperty(stringBuilder, "string", controlTemplate.Name, controlTemplate.Desc, controlNumber - 1);
                    break;

                case ControlType.GroupBox:
                    controlNumber = ProcessColumn(stringBuilder,
                                                  ((GroupBoxTemplate <WMColumnTemplate>)controlTemplate).Column.Controls,
                                                  controlNumber);
                    controlNumber--;
                    break;

                default:
                    throw new InvalidOperationException("controlTemplate.Type = " + controlTemplate.Type);
                }

                controlNumber++;
            }

            return(controlNumber);
        }