private void AddCommand(TreeNodeCollection nodes, int insertPos, CommandJsonStorage.Item item) { var _list = new MyLayoutClass(new VerticalLayout(), splitContainer.Panel2); var _search = new Searcher(); var _input = new List <UserControlInput> { _search.getInputDisplayOfType("ASCII"). SetFont(FONT). SetName("Name"). SetRange(new Range <int>(MAX_TEXT)). SetValue(item.Name). GetInputDisplay(), _search.getInputDisplayOfType("DEC"). SetFont(FONT). SetName("Length"). SetRange(new Range <int>(ushort.MaxValue)). SetValue(item.Length.ToString()). GetInputDisplay() }; _list.Layout(_input); TreeNode nodeItem = new TreeNode(); nodeItem.NodeFont = FONT; nodeItem.Name = item.Name; nodeItem.Text = item.Name; nodeItem.Tag = _list; nodes.Insert(insertPos, nodeItem); AddDetail(nodeItem.Nodes); }
private void AddCommand(TreeNodeCollection nodes, int insertPos) { string commandName = new FormInputTextBox("コマンド名を入力して下さい。", "コマンド名の入力", "Command" ).GetInputText(); if (commandName != "") { try { if (nodes.Find(commandName, false).Length != 0) { throw new Exception(); } CommandJsonStorage.Item item = new CommandJsonStorage.Item(); item.Name = commandName; item.Length = 1; AddCommand(nodes, insertPos, item); } catch { MessageBox.Show("名前が重複しています。\nコマンド作成を中断します。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private CommandCsvStorage.Item ConvertJsonItemToCsvItem(CommandJsonStorage.Item src) { var dst = new CommandCsvStorage.Item(); dst.Command = string.Join("", src.MessageGeneration().ToArray()); dst.Length = (ulong)src.Length; dst.Type = src.Name; dst.Tag = src; return(dst); }
private void CommandListBox_Select(object sender, EventArgs e) { if (FormEdit == null) { return; } int index = ((ListBox)sender).SelectedIndex; if (index < 0) { return; } CommandJsonStorage.Item item = CommandObj.Controls[index]; FormEdit.Add(item); }
private void Save() { var obj = new CommandJsonStorage.CommandJsonObject(); obj.Name = textBoxName.Text; obj.Version = textBoxVersion.Text; foreach (TreeNode item in treeView.Nodes) { var input_items = (MyLayoutClass)item.Tag; var items = new CommandJsonStorage.Item(); items.Name = input_items.Search("Name").Text; items.Length = int.Parse(input_items.Search("Length").Text); foreach (TreeNode detail in item.Nodes) { var input_details = (MyLayoutClass)detail.Tag; var details = new CommandJsonStorage.Detail(); details.Name = input_details.Search("Name").Text; details.Offset = int.Parse(input_details.Search("Offset").Text); details.Size = int.Parse(input_details.Search("Size").Text); foreach (TreeNode parameter in detail.Nodes) { var input_parameter = (MyLayoutClass)parameter.Tag; var parameters = new CommandJsonStorage.Parameter(); parameters.Name = input_parameter.Search("Name").Text; parameters.Offset = int.Parse(input_parameter.Search("Offset").Text); parameters.Size = int.Parse(input_parameter.Search("Size").Text); parameters.Type = input_parameter.Search("Type").Text; parameters.Value = input_parameter.Search("Value").Text; parameters.Fixed = input_parameter.Search("Fixed").Text == "True" ? true : false; details.Controls.Add(parameters); } items.Controls.Add(details); } obj.Controls.Add(items); } CommandObj = obj.Clone(); }
public void Add(object obj) { if (obj.GetType().Name != "Item") { return; } CommandJsonStorage.Item item = (CommandJsonStorage.Item)obj; var csvObj = ConvertJsonItemToCsvItem(item); csvObj.Name = new FormInputTextBox("表示名を入力して下さい。", "表示名の入力", item.Name ).GetInputText(); if (csvObj.Name != "") { //for (int i = 0; i < 100; i++) CommandListBox.Items.Add(csvObj.Clone()); // リストボックスの一番上を選択 CommandListBox.SetSelected(CommandListBox.Items.Count - 1, true); } }