/// <summary> /// Add a new command (disabled when a command node is selected) /// </summary> private void bNewCommand_Click(object sender, System.EventArgs e) { if ( Tree.SelectedNode != null && Tree.SelectedNode.Tag is MenuCommand ) return; else if ( Tree.SelectedNode != null ) { if ( txCaption.Text.Length == 0 || txCommand.Text.Length == 0 ) { MessageBox.Show( Pandora.Localization.TextProvider[ "ButtonMenuEditor.ErrCommand" ] ); return; } TreeNode node = new TreeNode( txCaption.Text ); MenuCommand mc = new MenuCommand(); mc.Caption = txCaption.Text; mc.Command = txCommand.Text; mc.UsePrefix = chkPrefix.Checked; node.Tag = mc; Tree.SelectedNode.Nodes.Add( node ); Tree.SelectedNode.Expand(); txCaption.Text = ""; txCommand.Text = ""; txCaption.Focus(); } }
/// <summary> /// Creates a new CommandChangedEventArgs object /// </summary> /// <param name="command">The command that should be applied to the button</param> public CommandChangedEventArgs( MenuCommand command ) { m_Command = command; }
/// <summary> /// Single command /// </summary> private void mSingleCommand_Click(object sender, System.EventArgs e) { if ( ConfirmErase() ) { SimpleCommand sc = new SimpleCommand(); if ( sc.ShowDialog() == DialogResult.OK ) { MenuCommand mc = new MenuCommand(); mc.Command = sc.Command; mc.UsePrefix = sc.UsePrefix; if ( m_EditLeft ) { m_Def.Left = mc; linkLeft.Text = Pandora.Localization.TextProvider[ "Buttons.Single" ]; } else { m_Def.Right = mc; linkRight.Text = Pandora.Localization.TextProvider[ "Buttons.Single" ]; } } } }
/// <summary> /// Add new menu command /// </summary> private void bAdd_Click(object sender, System.EventArgs e) { if ( txCaption.Text.Length == 0 || txCommand.Text.Length == 0 ) { MessageBox.Show( Pandora.Localization.TextProvider[ "ButtonMenuEditor.ErrCommand" ] ); return; } MenuCommand mc = new MenuCommand(); mc.Caption = txCaption.Text; mc.Command = txCommand.Text; mc.UsePrefix = chkPrefix.Checked; TreeNode node = new TreeNode( mc.Caption ); node.Tag = mc; Tree.Nodes.Add( node ); m_Edit = false; txCaption.Text = ""; txCommand.Text = ""; if ( Tree.Nodes.Count == 1 ) { // First node, make it default Tree.Nodes[ 0 ].Checked = true; } txCaption.Focus(); }
/// <summary> /// Creates a new BoxMenuItem that can be used to send a command to UO /// </summary> /// <param name="command">The MenuCommand object that defines the command that should be sent to UO</param> public BoxMenuItem( MenuCommand command ) { m_Command = command; Text = m_Command.Caption; }
/// <summary> /// Clones the current object /// </summary> /// <returns>A MenuCommand object initialized to the same values as the original one</returns> public object Clone() { MenuCommand mc = new MenuCommand(); if ( m_Caption != null ) mc.m_Caption = string.Copy( m_Caption ); if ( m_Command != null ) mc.m_Command = string.Copy( m_Command ); mc.m_UsePrefix = m_UsePrefix; return mc; }