private Node GetNodeFromCmd(ObjectBankDataCommand cmd) { var nCmd = new Node() { Text = $"<font face=\"Consolas\">{SM64Lib.General.CommandByteArrayToString(cmd.Command)}</font>", Tag = cmd, ContextMenu = ButtonItem_CM_Cmd }; nCmd.NodeDoubleClick += this.CmdNodeDoubleClick; return(nCmd); }
private void AddCmd(Node nCmds) { var bytesStartCount = default(int); bool allowOpenHexEditor = true; // Set start bytes count if (General.GetCurrentHexEditMode() == HexEditModes.BuildInHexEditor) { var valueInputDialog = new ValueInputDialog(); valueInputDialog.InfoLabel.Text = "Count of Bytes"; valueInputDialog.ValueTextBox.Text = Conversions.ToString(8); if (valueInputDialog.ShowDialog() == DialogResult.OK) { bytesStartCount = TextValueConverter.ValueFromText(valueInputDialog.ValueTextBox.Text); } allowOpenHexEditor = bytesStartCount > 0; } else { bytesStartCount = 0; } // Create Buffer var cmdBuf = new byte[bytesStartCount]; // Create new if (allowOpenHexEditor) { General.OpenHexEditor(ref cmdBuf); } if (cmdBuf?.Any() == true) { ObjectBankData obd = (ObjectBankData)nCmds.Tag; var cmd = new ObjectBankDataCommand(cmdBuf); var nCmd = GetNodeFromCmd(cmd); // Add cmd obd.Commands.Add(cmd); // Add node BeginTreeUpdate(); nCmds.Nodes.Add(nCmd); nCmds.Expand(); EndTreeUpdate(); // Raise event ChangedObjectBankDataCommand?.Invoke(obd); } }
private void RemoveCmd(Node nCmd) { var nCmds = nCmd.Parent; ObjectBankData obd = (ObjectBankData)nCmds.Tag; ObjectBankDataCommand cmd = (ObjectBankDataCommand)nCmd.Tag; // Remove Cmd obd.Commands.Remove(cmd); // Remove Node BeginTreeUpdate(); nCmds.Nodes.Remove(nCmd); EndTreeUpdate(); // Raise event ChangedObjectBankDataCommand?.Invoke(obd); }
private void EditCmd(Node nCmd) { var nCmds = nCmd.Parent; ObjectBankData obd = (ObjectBankData)nCmds.Tag; ObjectBankDataCommand cmd = (ObjectBankDataCommand)nCmd.Tag; // Edit cmd var argbuffer = cmd.Command; General.OpenHexEditor(ref argbuffer); cmd.Command = argbuffer; // Update ObdTree nCmd.Text = $"<font face=\"Consolas\">{SM64Lib.General.CommandByteArrayToString(cmd.Command)}</font>"; ObdTree.Refresh(); // Raise event ChangedObjectBankDataCommand?.Invoke(obd); }