Ejemplo n.º 1
0
        /// <summary>
        ///     Executes the action specified for this button
        /// </summary>
        /// <param name="button">The BoxButton that owns this MenuDef object</param>
        /// <param name="clickPoint">The location of the click</param>
        /// <param name="mouseButton">The mouse button clicked</param>
        public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
        {
            switch (mouseButton)
            {
            case MouseButtons.Left:

                if (m_Left != null)
                {
                    m_Left.DoAction(button, clickPoint, mouseButton);
                }
                else if (m_Right != null && !m_Right.AllowsSecondButton)
                {
                    m_Right.DoAction(button, clickPoint, mouseButton);
                }
                break;

            case MouseButtons.Right:

                if (m_Right != null)
                {
                    m_Right.DoAction(button, clickPoint, mouseButton);
                }
                else if (m_Left != null && !m_Left.AllowsSecondButton)
                {
                    m_Left.DoAction(button, clickPoint, mouseButton);
                }
                break;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Does the action specified by the function
 /// </summary>
 /// <param name="button">The button owner of the action</param>
 /// <param name="clickPoint">The location of the user click on the button</param>
 /// <param name="mouseButton">The mouse button clicked</param>
 public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
 {
     if (mouseButton == MouseButtons.Left)
     {
         OnSendCommand(new SendCommandEventArgs(DefaultCommand.Command, DefaultCommand.UsePrefix));
     }
     else if (mouseButton == MouseButtons.Right)
     {
         Menu.Show(button, clickPoint);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Localizes the text of a control and all of its children controls
        /// </summary>
        /// <param name="control">The control that should be localized</param>
        public void LocalizeControl(Control control)
        {
            if (control is Form)
            {
                // Set options on controls
                Form f = control as Form;

                f.TopMost = Pandora.Profile.General.TopMost;
                f.Opacity = (double)Pandora.Profile.General.Opacity / 100.0;
            }

            if (control is TheBox.Buttons.BoxButton)
            {
                // Box button
                TheBox.Buttons.BoxButton b = control as TheBox.Buttons.BoxButton;

                ButtonDef def = null;

                if (b.ButtonID >= 0)
                {
                    def = Pandora.Buttons[b];
                }

                Pandora.Profile.ButtonIndex.DoButton(b);
            }
            else
            {
                // Classic control
                string text = control.Text;

                string[] path = text.Split(new char[] { '.' });

                if (path.Length == 2)
                {
                    control.Text = Pandora.Localization.TextProvider[text];
                }

                if (control is LinkLabel)
                {
                    (control as LinkLabel).LinkColor        = Pandora.Profile.General.Links.Color;
                    (control as LinkLabel).VisitedLinkColor = Pandora.Profile.General.Links.Color;
                    (control as LinkLabel).LinkBehavior     = System.Windows.Forms.LinkBehavior.HoverUnderline;
                }

                if (control.Controls.Count > 0)
                {
                    foreach (Control c in control.Controls)
                    {
                        LocalizeControl(c);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
 {
     if (mouseButton == MouseButtons.Left)
     {
         if (SendCommand != null)
         {
             SendCommand(this, new SendCommandEventArgs(Command, true));
         }
     }
     else
     {
         Pandora.cmModifiers.Show(button, clickPoint);
     }
 }
Ejemplo n.º 5
0
 public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
 {
     if (mouseButton == MouseButtons.Left)
     {
         if (SendCommand != null)
         {
             SendCommand(this, new SendCommandEventArgs(m_Command, true));
         }
     }
     else
     {
         Pandora.cmModifiers.Show(button, clickPoint);
     }
 }
Ejemplo n.º 6
0
		public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
		{
			if ( mouseButton == MouseButtons.Left )
			{
				if ( SendCommand != null )
				{
					SendCommand( this, new SendCommandEventArgs( m_Command, true ) );
				}
			}
			else
			{
				Pandora.cmModifiers.Show( button, clickPoint );
			}
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Gets the ButtonDef object given the button's ID
		/// </summary>
		public ButtonDef this[ BoxButton button ]
		{
			get
			{
				string filename = GetFile( button.ButtonID );

				if ( File.Exists( filename ) )
				{
					// There's a custom def

					try
					{
						ButtonDef def = Load( filename );
						button.Def = def;
						return def;
					}
					catch ( Exception err )
					{
						Pandora.Log.WriteError( err, string.Format( "Custom file for button {0} was corrupted. It has been renamed to {0}.old.xml", filename ) );

						try
						{
							File.Move( filename, string.Format( "{0}.old.xml", filename ) );
						}
						catch
						{
							Pandora.Log.WriteError( null, "Cannot rename file" );
						}
					}
				}
				// Get default

				string resource = string.Format( "DefaultButtons.{0}.xml", button.ButtonID );

				try
				{
					Stream stream = DefaultAssembly.GetManifestResourceStream( resource );

					if ( stream != null )
					{
						XmlSerializer serializer = new XmlSerializer( typeof( ButtonDef ) );
						button.Def = serializer.Deserialize( stream ) as ButtonDef;
						stream.Close();

						return button.Def;
					}
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, "Error when loading defaults for button {0}", button.ButtonID );
				}

				button.Def = null;
				return null;
			}
			set
			{
				string filename = GetFile( button.ButtonID );

				try
				{
					Save( filename, value );
					button.Def = value;
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, string.Format( "Error occurred when setting the def object for button #{0}", button.ButtonID ) );
					button.Def = null;
				}
			}
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Processes a button fixing its default index if appliable
		/// </summary>
		/// <param name="button"></param>
		public void DoButton( BoxButton button )
		{
			if ( button.Def != null && button.Def.MultiDef != null && button.ButtonID >= 0 )
			{
				// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
				int i;
				m_Table.TryGetValue(button.ButtonID, out i);

				button.Def.MultiDef.DefaultIndex = i;
				
				// Issue 10 - End
			}
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Restores the default value to a BoxButton
		/// </summary>
		/// <param name="button">The BoxButton that should be restored</param>
		public void ResetDefault( BoxButton button )
		{
			string filename = GetFile( button.ButtonID );

			if ( File.Exists( filename ) )
			{
				try
				{
					File.Delete( filename );
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, string.Format( "Cannot delete file {0}", filename ) );
					return;
				}
			}

			button.Def = this[ button ];
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Sets the button in a blank state
		/// </summary>
		/// <param name="button">The BoxButton object to set</param>
		public void ClearButton( BoxButton button )
		{
			this[ button ] = new ButtonDef();
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Does the action specified by the function
		/// </summary>
		/// <param name="button">The button owner of the action</param>
		/// <param name="clickPoint">The location of the user click on the button</param>
		/// <param name="mouseButton">The mouse button clicked</param>
		public void DoAction(BoxButton button, Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
		{
			Menu.Show( button, clickPoint );
		}
Ejemplo n.º 12
0
 public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
 {
     OnSendLastCommand(new EventArgs());
 }
Ejemplo n.º 13
0
		public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
		{
			OnSendCommand( new SendCommandEventArgs( m_Command, m_UsePrefix ) );
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Gets the ButtonDef object given the button's ID
		/// </summary>
		public ButtonDef this[ BoxButton button ]
		{
			get
			{
				string filename = GetFile( button.ButtonID );

				if ( File.Exists( filename ) )
				{
					// There's a custom def

					try
					{
						ButtonDef def = Load( filename );
						button.Def = def;
						return def;
					}
					catch ( Exception err )
					{
						Pandora.Log.WriteError( err, string.Format( "Custom file for button {0} was corrupted. It has been renamed to {0}.old.xml", filename ) );

						try
						{
							File.Move( filename, string.Format( "{0}.old.xml", filename ) );
						}
						catch
						{
							Pandora.Log.WriteError( null, "Cannot rename file" );
						}
					}
				}
				// Get default

				// TODO : Read the def from the correct memory location instead for the release

				try
				{
					string defaultFile = string.Format( @"D:\Dev\Pandora 2.0\Data\Buttons\{0}.xml", button.ButtonID );
					ButtonDef def = Load( defaultFile );
					button.Def = def;
					return def;
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, string.Format( "Cannot read default def file for button #{0}", button.ButtonID ) );
				}

				button.Def = null;
				return null;
			}
			set
			{
				// TODO : Add correct code to save in custom folder
				string filename = string.Format( @"D:\Dev\Pandora 2.0\Data\Buttons\{0}.xml", button.ButtonID );

				try
				{
					Save( filename, value );
					button.Def = value;
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, string.Format( "Error occurred when setting the def object for button #{0}", button.ButtonID ) );
					button.Def = null;
				}
			}
		}
Ejemplo n.º 15
0
 public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
 {
     OnSendCommand(new SendCommandEventArgs(m_Command, m_UsePrefix));
 }
Ejemplo n.º 16
0
 public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
 {
     OnSendLastCommand(new EventArgs());
 }
Ejemplo n.º 17
0
		/// <summary>
		/// Does the action specified by the function
		/// </summary>
		/// <param name="button">The button owner of the action</param>
		/// <param name="clickPoint">The location of the user click on the button</param>
		/// <param name="mouseButton">The mouse button clicked</param>
		public void DoAction(BoxButton button, Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
		{
			if ( mouseButton == MouseButtons.Left )
			{
				OnSendCommand( new SendCommandEventArgs( DefaultCommand.Command, DefaultCommand.UsePrefix ) );
			}
			else if ( mouseButton == MouseButtons.Right )
			{
				Menu.Show( button, clickPoint );
			}
		}
Ejemplo n.º 18
0
 /// <summary>
 /// Does the action specified by the function
 /// </summary>
 /// <param name="button">The button owner of the action</param>
 /// <param name="clickPoint">The location of the user click on the button</param>
 /// <param name="mouseButton">The mouse button clicked</param>
 public void DoAction(BoxButton button, Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
 {
     Menu.Show(button, clickPoint);
 }
Ejemplo n.º 19
0
 public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
 {
     OnSendCommand(new SendCommandEventArgs(m_Command, m_UsePrefix));
 }
Ejemplo n.º 20
0
		/// <summary>
		/// Executes the action specified for this button
		/// </summary>
		/// <param name="button">The BoxButton that owns this MenuDef object</param>
		/// <param name="clickPoint">The location of the click</param>
		/// <param name="mouseButton">The mouse button clicked</param>
		public void DoAction( BoxButton button, System.Drawing.Point clickPoint, MouseButtons mouseButton )
		{
			switch ( mouseButton )
			{
				case MouseButtons.Left:

					if ( m_Left != null )
					{
						m_Left.DoAction( button, clickPoint, mouseButton );
					}
					else if ( m_Right != null && !m_Right.AllowsSecondButton )
					{
						m_Right.DoAction( button, clickPoint, mouseButton );
					}
					break;

				case MouseButtons.Right:

					if ( m_Right != null )
					{
						m_Right.DoAction( button, clickPoint, mouseButton );
					}
					else if ( m_Left != null && !m_Left.AllowsSecondButton )
					{
						m_Left.DoAction( button, clickPoint, mouseButton );
					}
					break;
			}
		}
Ejemplo n.º 21
0
 /// <summary>
 ///     Required method for Designer support - do not modify
 ///     the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ButtonEditor));
     this.groupBox1         = new System.Windows.Forms.GroupBox();
     this.linkLeft          = new System.Windows.Forms.LinkLabel();
     this.groupBox2         = new System.Windows.Forms.GroupBox();
     this.linkRight         = new System.Windows.Forms.LinkLabel();
     this.groupBox3         = new System.Windows.Forms.GroupBox();
     this.bPreview          = new TheBox.Buttons.BoxButton();
     this.bCancel           = new System.Windows.Forms.Button();
     this.bOk               = new System.Windows.Forms.Button();
     this.textBox1          = new System.Windows.Forms.TextBox();
     this.label1            = new System.Windows.Forms.Label();
     this.txCaption         = new System.Windows.Forms.TextBox();
     this.cMenu             = new System.Windows.Forms.ContextMenu();
     this.mNone             = new System.Windows.Forms.MenuItem();
     this.mSingleCommand    = new System.Windows.Forms.MenuItem();
     this.mMenu             = new System.Windows.Forms.MenuItem();
     this.mLastCommand      = new System.Windows.Forms.MenuItem();
     this.mMultiCommand     = new System.Windows.Forms.MenuItem();
     this.mModifiersCommand = new System.Windows.Forms.MenuItem();
     this.groupBox1.SuspendLayout();
     this.groupBox2.SuspendLayout();
     this.groupBox3.SuspendLayout();
     this.SuspendLayout();
     //
     // groupBox1
     //
     this.groupBox1.Controls.Add(this.linkLeft);
     this.groupBox1.Location = new System.Drawing.Point(16, 8);
     this.groupBox1.Name     = "groupBox1";
     this.groupBox1.Size     = new System.Drawing.Size(200, 80);
     this.groupBox1.TabIndex = 0;
     this.groupBox1.TabStop  = false;
     this.groupBox1.Text     = "Buttons.LeftMouse";
     //
     // linkLeft
     //
     this.linkLeft.Location   = new System.Drawing.Point(16, 32);
     this.linkLeft.Name       = "linkLeft";
     this.linkLeft.Size       = new System.Drawing.Size(176, 23);
     this.linkLeft.TabIndex   = 0;
     this.linkLeft.TabStop    = true;
     this.linkLeft.Text       = "Common.None";
     this.linkLeft.TextAlign  = System.Drawing.ContentAlignment.MiddleCenter;
     this.linkLeft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.linkLeft_MouseDown);
     //
     // groupBox2
     //
     this.groupBox2.Controls.Add(this.linkRight);
     this.groupBox2.Location = new System.Drawing.Point(240, 8);
     this.groupBox2.Name     = "groupBox2";
     this.groupBox2.Size     = new System.Drawing.Size(200, 80);
     this.groupBox2.TabIndex = 1;
     this.groupBox2.TabStop  = false;
     this.groupBox2.Text     = "Buttons.RightMouse";
     //
     // linkRight
     //
     this.linkRight.Location   = new System.Drawing.Point(16, 32);
     this.linkRight.Name       = "linkRight";
     this.linkRight.Size       = new System.Drawing.Size(176, 23);
     this.linkRight.TabIndex   = 0;
     this.linkRight.TabStop    = true;
     this.linkRight.Text       = "Common.None";
     this.linkRight.TextAlign  = System.Drawing.ContentAlignment.MiddleCenter;
     this.linkRight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.linkRight_MouseDown);
     //
     // groupBox3
     //
     this.groupBox3.Controls.Add(this.bPreview);
     this.groupBox3.Location = new System.Drawing.Point(16, 96);
     this.groupBox3.Name     = "groupBox3";
     this.groupBox3.Size     = new System.Drawing.Size(200, 100);
     this.groupBox3.TabIndex = 0;
     this.groupBox3.TabStop  = false;
     this.groupBox3.Text     = "Common.Preview";
     //
     // bPreview
     //
     this.bPreview.AllowEdit = false;
     this.bPreview.ButtonID  = -1;
     this.bPreview.Def       = null;
     this.bPreview.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.bPreview.IsActive  = false;
     this.bPreview.Location  = new System.Drawing.Point(64, 40);
     this.bPreview.Name      = "bPreview";
     this.bPreview.Size      = new System.Drawing.Size(80, 23);
     this.bPreview.TabIndex  = 0;
     this.bPreview.Text      = "Common.Preview";
     //
     // bCancel
     //
     this.bCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.bCancel.Location  = new System.Drawing.Point(288, 384);
     this.bCancel.Name      = "bCancel";
     this.bCancel.Size      = new System.Drawing.Size(75, 23);
     this.bCancel.TabIndex  = 2;
     this.bCancel.Text      = "Common.Cancel";
     this.bCancel.Click    += new System.EventHandler(this.bCancel_Click);
     //
     // bOk
     //
     this.bOk.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.bOk.Location  = new System.Drawing.Point(376, 384);
     this.bOk.Name      = "bOk";
     this.bOk.Size      = new System.Drawing.Size(75, 23);
     this.bOk.TabIndex  = 1;
     this.bOk.Text      = "Common.Ok";
     this.bOk.Click    += new System.EventHandler(this.bOk_Click);
     //
     // textBox1
     //
     this.textBox1.Location   = new System.Drawing.Point(16, 208);
     this.textBox1.Multiline  = true;
     this.textBox1.Name       = "textBox1";
     this.textBox1.ReadOnly   = true;
     this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     this.textBox1.Size       = new System.Drawing.Size(432, 168);
     this.textBox1.TabIndex   = 3;
     this.textBox1.Text       = "Buttons.Intstructions";
     //
     // label1
     //
     this.label1.Location = new System.Drawing.Point(240, 104);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(200, 23);
     this.label1.TabIndex = 4;
     this.label1.Text     = "ButtonMenuEditor.Caption";
     //
     // txCaption
     //
     this.txCaption.Location     = new System.Drawing.Point(240, 128);
     this.txCaption.Name         = "txCaption";
     this.txCaption.Size         = new System.Drawing.Size(200, 23);
     this.txCaption.TabIndex     = 5;
     this.txCaption.TextChanged += new System.EventHandler(this.txCaption_TextChanged);
     //
     // cMenu
     //
     this.cMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.mNone,
         this.mSingleCommand,
         this.mMenu,
         this.mLastCommand,
         this.mMultiCommand,
         this.mModifiersCommand
     });
     this.cMenu.Popup += new System.EventHandler(this.cMenu_Popup);
     //
     // mNone
     //
     this.mNone.Index  = 0;
     this.mNone.Text   = "Common.None";
     this.mNone.Click += new System.EventHandler(this.mNone_Click);
     //
     // mSingleCommand
     //
     this.mSingleCommand.Index  = 1;
     this.mSingleCommand.Text   = "Buttons.Single";
     this.mSingleCommand.Click += new System.EventHandler(this.mSingleCommand_Click);
     //
     // mMenu
     //
     this.mMenu.Index  = 2;
     this.mMenu.Text   = "Common.Menu";
     this.mMenu.Click += new System.EventHandler(this.mMenu_Click);
     //
     // mLastCommand
     //
     this.mLastCommand.Index  = 3;
     this.mLastCommand.Text   = "Buttons.LastCommand";
     this.mLastCommand.Click += new System.EventHandler(this.mLastCommand_Click);
     //
     // mMultiCommand
     //
     this.mMultiCommand.Index  = 4;
     this.mMultiCommand.Text   = "Buttons.Multi";
     this.mMultiCommand.Click += new System.EventHandler(this.mMultiCommand_Click);
     //
     // mModifiersCommand
     //
     this.mModifiersCommand.Index  = 5;
     this.mModifiersCommand.Text   = "Buttons.Modifiers";
     this.mModifiersCommand.Click += new System.EventHandler(this.mModifiersCommand_Click);
     //
     // ButtonEditor
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
     this.ClientSize        = new System.Drawing.Size(458, 416);
     this.Controls.Add(this.txCaption);
     this.Controls.Add(this.textBox1);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.bOk);
     this.Controls.Add(this.bCancel);
     this.Controls.Add(this.groupBox3);
     this.Controls.Add(this.groupBox2);
     this.Controls.Add(this.groupBox1);
     this.Font            = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name            = "ButtonEditor";
     this.ShowInTaskbar   = false;
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text            = "Buttons.Title";
     this.Closing        += new System.ComponentModel.CancelEventHandler(this.ButtonEditor_Closing);
     this.groupBox1.ResumeLayout(false);
     this.groupBox2.ResumeLayout(false);
     this.groupBox3.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Ejemplo n.º 22
0
		public void DoAction(BoxButton button, System.Drawing.Point clickPoint, System.Windows.Forms.MouseButtons mouseButton)
		{
			OnSendLastCommand( new EventArgs() );
		}
Ejemplo n.º 23
0
 /// <summary>
 ///     Does the action specified by the function
 /// </summary>
 /// <param name="button">The button owner of the action</param>
 /// <param name="clickPoint">The location of the user click on the button</param>
 /// <param name="mouseButton">The mouse button clicked</param>
 public void DoAction(BoxButton button, Point clickPoint, MouseButtons mouseButton)
 {
     Menu.Show(button, clickPoint);
 }