private void InitializeList(string MacroType) { MacroSpecifierData TableData = SettingsFunctionLibrary.GetMacroSpecifierData(MacroType); // 通常指定子のリストを初期化 Cl_MacroSpecifiers.Items.AddRange(TableData.MacroSpecifiers); for (int Index = 0; Index < TableData.MacroSpecifiers.Length; Index++) { CachedMacroSpecifiersUI.Add(TableData.MacroSpecifiers[Index], Index); } // 詳細指定子のリストを初期化 Tlp_AdvancedSettings.Dock = DockStyle.Top; Tlp_AdvancedSettings.SuspendLayout(); Tlp_AdvancedSettings.RowCount = 0; Tlp_AdvancedSettings.RowStyles.Clear(); Tlp_AdvancedSettings.AutoSize = true; Tlp_AdvancedSettings.AutoSizeMode = AutoSizeMode.GrowAndShrink; Tlp_AdvancedSettings.Padding = new Padding(0, 0, SystemInformation.VerticalScrollBarWidth, 0); foreach (var AdvancedSetting in TableData.AdvancedSettings) { Label Title = new Label(); Title.Text = AdvancedSetting; Title.ForeColor = SettingsFunctionLibrary.GetTextColor(); Title.Margin = new Padding(3, 5, 3, 0); Title.AutoSize = true; TextBox Input = new TextBox(); Input.ScrollBars = ScrollBars.Horizontal; Input.BorderStyle = BorderStyle.FixedSingle; Tlp_AdvancedSettings.RowCount++; Tlp_AdvancedSettings.RowStyles.Add(new RowStyle(SizeType.Absolute, 25F)); Tlp_AdvancedSettings.Controls.Add(Title); Tlp_AdvancedSettings.Controls.Add(Input); CachedAdvancedSettingsUI.Add(AdvancedSetting, Input); } Tlp_AdvancedSettings.ResumeLayout(); // メタ指定子のリストを初期化 Tlp_MetaSpecifiers.Dock = DockStyle.Top; Tlp_MetaSpecifiers.SuspendLayout(); Tlp_MetaSpecifiers.RowCount = 0; Tlp_MetaSpecifiers.RowStyles.Clear(); Tlp_MetaSpecifiers.AutoSize = true; Tlp_MetaSpecifiers.AutoSizeMode = AutoSizeMode.GrowAndShrink; Tlp_MetaSpecifiers.Padding = new Padding(0, 0, SystemInformation.VerticalScrollBarWidth, 0); foreach (var MetaSpecifier in TableData.MetaSpecifiers) { Label Name = new Label(); Name.Text = MetaSpecifier.Data; Name.ForeColor = SettingsFunctionLibrary.GetTextColor(); Name.Margin = new Padding(3, 5, 3, 0); Name.AutoSize = true; Tlp_MetaSpecifiers.RowCount++; Tlp_MetaSpecifiers.RowStyles.Add(new RowStyle(SizeType.Absolute, 25F)); Tlp_MetaSpecifiers.Controls.Add(Name); if (MetaSpecifier.Type == InputType.NoInput) { CheckBox Input = new CheckBox(); Input.Tag = InputType.NoInput; Input.ForeColor = SettingsFunctionLibrary.GetTextColor(); Name.Tag = Input; Name.Click += new EventHandler(OnCheckBoxLabelClicked); Tlp_MetaSpecifiers.Controls.Add(Input); CachedMetaSpecifiersUI.Add(MetaSpecifier.Data, Input); } else if (MetaSpecifier.Type == InputType.String) { TextBox Input = new TextBox(); Input.Tag = InputType.String; Input.ScrollBars = ScrollBars.Horizontal; Input.BorderStyle = BorderStyle.FixedSingle; Tlp_MetaSpecifiers.Controls.Add(Input); CachedMetaSpecifiersUI.Add(MetaSpecifier.Data, Input); } else if (MetaSpecifier.Type == InputType.Bool) { CheckBox Input = new CheckBox(); Input.Tag = InputType.Bool; Input.ForeColor = SettingsFunctionLibrary.GetTextColor(); Name.Tag = Input; Name.Click += new EventHandler(OnCheckBoxLabelClicked); Tlp_MetaSpecifiers.Controls.Add(Input); CachedMetaSpecifiersUI.Add(MetaSpecifier.Data, Input); } else if (MetaSpecifier.Type == InputType.Int) { NumericUpDown Input = new NumericUpDown(); Input.Tag = InputType.Int; Input.BorderStyle = BorderStyle.FixedSingle; Input.Text = string.Empty; Tlp_MetaSpecifiers.Controls.Add(Input); CachedMetaSpecifiersUI.Add(MetaSpecifier.Data, Input); } else if (MetaSpecifier.Type == InputType.Float) { NumericUpDown Input = new NumericUpDown(); Input.Tag = InputType.Float; Input.BorderStyle = BorderStyle.FixedSingle; Input.DecimalPlaces = 2; Input.Text = string.Empty; Input.Increment = (decimal)0.5; Tlp_MetaSpecifiers.Controls.Add(Input); CachedMetaSpecifiersUI.Add(MetaSpecifier.Data, Input); } } Tlp_MetaSpecifiers.ResumeLayout(); }
private void OnOKButtonClicked(object Sender, EventArgs Args) { // 通常指定子の連結 string MacroSpecifirsString = string.Empty; var CheckedItems = Cl_MacroSpecifiers.CheckedItems; foreach (var Item in CheckedItems) { MacroSpecifirsString += Item.ToString() + ", "; } // 詳細指定子の連結 string AdvancedSettingsString = string.Empty; for (int Row = 0; Row < Tlp_AdvancedSettings.RowCount; Row++) { TextBox Input = Tlp_AdvancedSettings.GetControlFromPosition(1, Row) as TextBox; if (Input != null && !string.IsNullOrWhiteSpace(Input.Text) && !string.IsNullOrEmpty(Input.Text)) { Label Name = Tlp_AdvancedSettings.GetControlFromPosition(0, Row) as Label; if (Name != null) { AdvancedSettingsString += Name.Text + "=\"" + Input.Text + "\","; } } } // メタ指定子の連結 string MetaSpecifiersString = string.Empty; for (int Row = 0; Row < Tlp_MetaSpecifiers.RowCount; Row++) { Label Name = Tlp_MetaSpecifiers.GetControlFromPosition(0, Row) as Label; if (Name != null) { Control Input = Tlp_MetaSpecifiers.GetControlFromPosition(1, Row); InputType Tag = (InputType)Input.Tag; // Specifier if (Tag == InputType.NoInput && Input is CheckBox Specifier) { if (Specifier.Checked) { MetaSpecifiersString += Name.Text + ","; } } // TextBox else if (Tag == InputType.String && Input is TextBox TextBox) { if (!string.IsNullOrWhiteSpace(TextBox.Text) && !string.IsNullOrEmpty(TextBox.Text)) { MetaSpecifiersString += Name.Text + "=\"" + TextBox.Text + "\","; } } // CheckBox else if (Tag == InputType.Bool && Input is CheckBox CheckBox) { if (CheckBox.Checked) { MetaSpecifiersString += Name.Text + "=true,"; } } // NumericUpDown else if (Tag == InputType.Int && Input is NumericUpDown NumericUpDown) { if (!string.IsNullOrWhiteSpace(NumericUpDown.Text) && !string.IsNullOrEmpty(NumericUpDown.Text)) { MetaSpecifiersString += Name.Text + "=" + NumericUpDown.Text + ","; } } // NumericUpDownFloat else if (Tag == InputType.Float && Input is NumericUpDown NumericUpDownFloat) { if (!string.IsNullOrWhiteSpace(NumericUpDownFloat.Text) && !string.IsNullOrEmpty(NumericUpDownFloat.Text)) { MetaSpecifiersString += Name.Text + "=" + NumericUpDownFloat.Text + ","; } } } } MetaSpecifiersString = MetaSpecifiersString.TrimEnd(',', ' '); // 全て連結させてマクロを完成させる MacroString += MacroName + "("; MacroString += MacroSpecifirsString + AdvancedSettingsString; if (!string.IsNullOrWhiteSpace(MetaSpecifiersString) && !string.IsNullOrEmpty(MetaSpecifiersString)) { MacroString += "meta=(" + MetaSpecifiersString + ")"; } else { MacroString = MacroString.TrimEnd(',', ' '); } MacroString += ")"; // 生成モードならテンプレートもつける if (string.IsNullOrEmpty(EditTarget) && Cb_WithTemplate.Checked && !string.IsNullOrEmpty(TemplateString)) { MacroString += "\n" + TemplateString; } }