From: <nic...@us...> - 2014-05-23 13:36:17
|
Revision: 4813 http://sourceforge.net/p/mp-plugins/code/4813 Author: nicsergio Date: 2014-05-23 13:36:12 +0000 (Fri, 23 May 2014) Log Message: ----------- Modified Paths: -------------- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Program.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultConfig.xml trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.csproj trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs Added Paths: ----------- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/KeyboardHook.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.Designer.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.resx trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterKeyConfig.Designer.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterKeyConfig.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterKeyConfig.resx trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/SkinNavigatorConfig.Designer.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/SkinNavigatorConfig.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/SkinNavigatorConfig.resx trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/SkinWithSounds.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/LogHandler.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Plugin/ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Plugin/RawInputHook.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Plugin/ShortCuter.cs Added: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/KeyboardHook.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/KeyboardHook.cs (rev 0) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/KeyboardHook.cs 2014-05-23 13:36:12 UTC (rev 4813) @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace ProcessPlugins.ShortCuter.Configuration +{ + internal class KeyboardHook //Classe per gestione hook di sistema + { + #region Delegati/Strutture + /// Delegato da richiamare all'intercettazione del messaggio + /// Parametri: + /// code : codice hook + /// wParam: ID evento intercettato + /// lParam: informazioni sull'evento intercettato + public delegate int HookProc(int code, int wParam, ref HookStruct lParam); + + public struct HookStruct //Struttura hook + { + public int vkCode; + public int scanCode; + public int flags; + public int time; + public int dwExtraInfo; + } + #endregion + + #region Dati + #region Costanti + private const int WH_KEYBOARD_LL = 13; //Id evento per hook di tastiera di basso livello + private const int WM_KEYDOWN = 0x100; //Id messaggio KeyDown + private const int WM_KEYUP = 0x101; //Id messaggio KeyUp + private const int WM_SYSKEYDOWN = 0x104; //Id messaggio KeyDown (tasto di sistema) + private const int WM_SYSKEYUP = 0x105; //Id messaggio KeyUp (tasto di sistema) + #endregion + + public List<Keys> HookedKeys = new List<Keys>(); //Eventuale lista dei tasti da monitorare/intercettare + private IntPtr hHook = IntPtr.Zero; //Handle dell'hook + private IntPtr hInstance = IntPtr.Zero; //Handle dell'istanza della libreria esterna + private bool _hooked = false; //Hook attivato + #endregion + + #region Costruttore/Distruttore + public KeyboardHook() + { + hInstance = LoadLibrary("User32"); //--> caricamento libreria esterna e memorizzazione handle + } + ~KeyboardHook() + { + unhook(); //--> eventuale disinstallazione dell'hook di sistema + } + #endregion + + #region Metodi Privati + private int hookProc(int code, int wParam, ref HookStruct lParam) //Metodo richiamato per l'hook di tastiera + { + if (code >= 0) //Se codice hook valorizzato + { + Keys key = (Keys)lParam.vkCode; + if (HookedKeys == null || HookedKeys.Count == 0 || HookedKeys.Contains(key)) //Se il tasto appartiene alla lista dei tasti da intercettare (o lista non utilizzata) + { + KeyEventArgs kea = new KeyEventArgs(key); + if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null)) + { + KeyDown(this, kea); //--> richiamo dell'evento KeyDown + } + else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null)) + { + KeyUp(this, kea); //--> richiamo dell'evento KeyUp + } + if (kea.Handled) //Se l'evento \xE8 stato gestito + return 1; //--> il tasto non viene passato al sistema + } + } + return CallNextHookEx(hHook, code, wParam, ref lParam); + } + #endregion + + #region Metodi Pubblici + public void hook() //Installazione dell'hook di sistema + { + unhook(); //--> eventuale disinstallazione hook + hHook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0); //--> installazione hook + _hooked = true; //--> memorizzazione hook attivo + } + public void unhook() //Disinstallazione dell'hook di sistema + { + if (_hooked) //Se hook attivo + { + UnhookWindowsHookEx(hHook); //--> disinstallazione hook + _hooked = false; //--> memorizzazione hook disattivo + } + } + #endregion + + #region Eventi + public event KeyEventHandler KeyDown; //Evento di pressione di uno dei tasti da monitorare + public event KeyEventHandler KeyUp; //Evento di rilascio di uno dei tasti da monitorare + #endregion + + #region Propriet\xE0 + public bool Hooked { get { return this._hooked; } } + #endregion + + #region Importazione DLL + //Installazione dell'hook, esecuzione dell'evento desiderato [uno dei parametri hInstance o threadId deve essere valorizzato] + [DllImport("user32.dll")] + static extern IntPtr SetWindowsHookEx(int idHook, HookProc callback, IntPtr hInstance, uint threadId); + + //Disinstallazione dell'hook (ritorna true se esecuzione con successo) + [DllImport("user32.dll")] + static extern bool UnhookWindowsHookEx(IntPtr hInstance); + + //Chiamata a hook successivo + [DllImport("user32.dll")] + static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref HookStruct lParam); + + //Caricamento di una libreria (ritorna l'handle associato) + [DllImport("kernel32.dll")] + static extern IntPtr LoadLibrary(string lpFileName); + #endregion + } +} Added: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.Designer.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.Designer.cs (rev 0) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.Designer.cs 2014-05-23 13:36:12 UTC (rev 4813) @@ -0,0 +1,468 @@ +namespace ProcessPlugins.ShortCuter.Configuration +{ + partial class ShortCuterConfig + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShortCuterConfig)); + this.shortCutsDataGridView = new System.Windows.Forms.DataGridView(); + this.linkPropertiesGroupBox = new System.Windows.Forms.GroupBox(); + this.loadParameterGroupBox = new System.Windows.Forms.GroupBox(); + this.loadParameterTextBox = new System.Windows.Forms.TextBox(); + this.windowIdGroupBox = new System.Windows.Forms.GroupBox(); + this.windowIdLabel = new System.Windows.Forms.Label(); + this.skinFileGroupBox = new System.Windows.Forms.GroupBox(); + this.skinFileLabel = new System.Windows.Forms.Label(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.updateButton = new System.Windows.Forms.Button(); + this.resetButton = new System.Windows.Forms.Button(); + this.rowDownButton = new System.Windows.Forms.Button(); + this.rowUpButton = new System.Windows.Forms.Button(); + this.infoPictureBox = new System.Windows.Forms.PictureBox(); + this.rowRemoveButton = new System.Windows.Forms.Button(); + this.rowAddButton = new System.Windows.Forms.Button(); + this.propLeftPictureBox = new System.Windows.Forms.PictureBox(); + this.saveButton = new System.Windows.Forms.Button(); + this.overridesGroupBox = new System.Windows.Forms.GroupBox(); + this.numLockGroupBox = new System.Windows.Forms.GroupBox(); + this.numLockComboBox = new System.Windows.Forms.ComboBox(); + this.capsLockGroupBox = new System.Windows.Forms.GroupBox(); + this.capsLockComboBox = new System.Windows.Forms.ComboBox(); + this.rowCopyButton = new System.Windows.Forms.Button(); + this.skinNavAddButton = new System.Windows.Forms.Button(); + this.skinNavConfigButton = new System.Windows.Forms.Button(); + this.skinItems = new My.Common.SkinItems(); + ((System.ComponentModel.ISupportInitialize)(this.shortCutsDataGridView)).BeginInit(); + this.linkPropertiesGroupBox.SuspendLayout(); + this.loadParameterGroupBox.SuspendLayout(); + this.windowIdGroupBox.SuspendLayout(); + this.skinFileGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.infoPictureBox)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.propLeftPictureBox)).BeginInit(); + this.overridesGroupBox.SuspendLayout(); + this.numLockGroupBox.SuspendLayout(); + this.capsLockGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // shortCutsDataGridView + // + this.shortCutsDataGridView.AllowUserToAddRows = false; + this.shortCutsDataGridView.AllowUserToDeleteRows = false; + this.shortCutsDataGridView.AllowUserToResizeRows = false; + this.shortCutsDataGridView.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(220)))), ((int)(((byte)(227))))); + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.shortCutsDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.shortCutsDataGridView.ColumnHeadersHeight = 30; + this.shortCutsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.shortCutsDataGridView.Location = new System.Drawing.Point(6, 304); + this.shortCutsDataGridView.MultiSelect = false; + this.shortCutsDataGridView.Name = "shortCutsDataGridView"; + this.shortCutsDataGridView.RowHeadersWidth = 20; + this.shortCutsDataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.shortCutsDataGridView.Size = new System.Drawing.Size(1006, 429); + this.shortCutsDataGridView.TabIndex = 0; + this.shortCutsDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.shortCutsDataGridView_CellDoubleClick); + this.shortCutsDataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.shortCutsDataGridView_CellEndEdit); + this.shortCutsDataGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.shortCutsDataGridView_CellFormatting); + this.shortCutsDataGridView.CurrentCellChanged += new System.EventHandler(this.shortCutsDataGridView_CurrentCellChanged); + this.shortCutsDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.shortCutsDataGridView_DataError); + this.shortCutsDataGridView.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.shortCutsDataGridView_EditingControlShowing); + this.shortCutsDataGridView.Enter += new System.EventHandler(this.shortCutsDataGridView_Enter); + // + // linkPropertiesGroupBox + // + this.linkPropertiesGroupBox.Controls.Add(this.loadParameterGroupBox); + this.linkPropertiesGroupBox.Controls.Add(this.windowIdGroupBox); + this.linkPropertiesGroupBox.Controls.Add(this.skinFileGroupBox); + this.linkPropertiesGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.linkPropertiesGroupBox.Location = new System.Drawing.Point(602, 30); + this.linkPropertiesGroupBox.Name = "linkPropertiesGroupBox"; + this.linkPropertiesGroupBox.Size = new System.Drawing.Size(320, 175); + this.linkPropertiesGroupBox.TabIndex = 31; + this.linkPropertiesGroupBox.TabStop = false; + this.linkPropertiesGroupBox.Text = "Link Properties"; + // + // loadParameterGroupBox + // + this.loadParameterGroupBox.Controls.Add(this.loadParameterTextBox); + this.loadParameterGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.loadParameterGroupBox.Location = new System.Drawing.Point(4, 103); + this.loadParameterGroupBox.Name = "loadParameterGroupBox"; + this.loadParameterGroupBox.Size = new System.Drawing.Size(312, 68); + this.loadParameterGroupBox.TabIndex = 37; + this.loadParameterGroupBox.TabStop = false; + this.loadParameterGroupBox.Text = "Load Parameter:"; + // + // loadParameterTextBox + // + this.loadParameterTextBox.BackColor = System.Drawing.SystemColors.Control; + this.loadParameterTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.loadParameterTextBox.ForeColor = System.Drawing.Color.Blue; + this.loadParameterTextBox.Location = new System.Drawing.Point(6, 19); + this.loadParameterTextBox.Multiline = true; + this.loadParameterTextBox.Name = "loadParameterTextBox"; + this.loadParameterTextBox.ReadOnly = true; + this.loadParameterTextBox.Size = new System.Drawing.Size(300, 43); + this.loadParameterTextBox.TabIndex = 39; + this.loadParameterTextBox.Text = "-"; + this.loadParameterTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // windowIdGroupBox + // + this.windowIdGroupBox.Controls.Add(this.windowIdLabel); + this.windowIdGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.windowIdGroupBox.Location = new System.Drawing.Point(4, 63); + this.windowIdGroupBox.Name = "windowIdGroupBox"; + this.windowIdGroupBox.Size = new System.Drawing.Size(312, 34); + this.windowIdGroupBox.TabIndex = 36; + this.windowIdGroupBox.TabStop = false; + this.windowIdGroupBox.Text = "Window ID:"; + // + // windowIdLabel + // + this.windowIdLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.windowIdLabel.ForeColor = System.Drawing.Color.Blue; + this.windowIdLabel.Location = new System.Drawing.Point(6, 16); + this.windowIdLabel.Name = "windowIdLabel"; + this.windowIdLabel.Size = new System.Drawing.Size(300, 13); + this.windowIdLabel.TabIndex = 6; + this.windowIdLabel.Text = "-"; + this.windowIdLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // skinFileGroupBox + // + this.skinFileGroupBox.Controls.Add(this.skinFileLabel); + this.skinFileGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.skinFileGroupBox.Location = new System.Drawing.Point(4, 23); + this.skinFileGroupBox.Name = "skinFileGroupBox"; + this.skinFileGroupBox.Size = new System.Drawing.Size(312, 34); + this.skinFileGroupBox.TabIndex = 6; + this.skinFileGroupBox.TabStop = false; + this.skinFileGroupBox.Text = "Skin File:"; + // + // skinFileLabel + // + this.skinFileLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.skinFileLabel.ForeColor = System.Drawing.Color.Blue; + this.skinFileLabel.Location = new System.Drawing.Point(6, 16); + this.skinFileLabel.Name = "skinFileLabel"; + this.skinFileLabel.Size = new System.Drawing.Size(300, 13); + this.skinFileLabel.TabIndex = 2; + this.skinFileLabel.Text = "-"; + this.skinFileLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // toolTip + // + this.toolTip.ShowAlways = true; + // + // updateButton + // + this.updateButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.updateButton.Location = new System.Drawing.Point(67, 84); + this.updateButton.Name = "updateButton"; + this.updateButton.Size = new System.Drawing.Size(135, 38); + this.updateButton.TabIndex = 32; + this.updateButton.Text = "Save and Close"; + this.updateButton.UseVisualStyleBackColor = false; + this.updateButton.Click += new System.EventHandler(this.updateButton_Click); + // + // resetButton + // + this.resetButton.Location = new System.Drawing.Point(67, 8); + this.resetButton.Name = "resetButton"; + this.resetButton.Size = new System.Drawing.Size(133, 23); + this.resetButton.TabIndex = 33; + this.resetButton.Text = "Reset Configuration"; + this.resetButton.UseVisualStyleBackColor = true; + this.resetButton.Click += new System.EventHandler(this.resetButton_Click); + // + // rowDownButton + // + this.rowDownButton.AutoSize = true; + this.rowDownButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.rowDownButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.RowDown; + this.rowDownButton.Location = new System.Drawing.Point(226, 264); + this.rowDownButton.Name = "rowDownButton"; + this.rowDownButton.Size = new System.Drawing.Size(38, 38); + this.rowDownButton.TabIndex = 35; + this.rowDownButton.UseVisualStyleBackColor = true; + this.rowDownButton.Click += new System.EventHandler(this.rowDownButton_Click); + // + // rowUpButton + // + this.rowUpButton.AutoSize = true; + this.rowUpButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.rowUpButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.RowUp; + this.rowUpButton.Location = new System.Drawing.Point(186, 264); + this.rowUpButton.Name = "rowUpButton"; + this.rowUpButton.Size = new System.Drawing.Size(38, 38); + this.rowUpButton.TabIndex = 34; + this.rowUpButton.UseVisualStyleBackColor = true; + this.rowUpButton.Click += new System.EventHandler(this.rowUpButton_Click); + // + // infoPictureBox + // + this.infoPictureBox.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.Info; + this.infoPictureBox.Location = new System.Drawing.Point(990, 5); + this.infoPictureBox.Name = "infoPictureBox"; + this.infoPictureBox.Size = new System.Drawing.Size(24, 24); + this.infoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.infoPictureBox.TabIndex = 30; + this.infoPictureBox.TabStop = false; + this.infoPictureBox.Click += new System.EventHandler(this.infoPictureBox_Click); + // + // rowRemoveButton + // + this.rowRemoveButton.AutoSize = true; + this.rowRemoveButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.rowRemoveButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.RowRemove; + this.rowRemoveButton.Location = new System.Drawing.Point(46, 264); + this.rowRemoveButton.Name = "rowRemoveButton"; + this.rowRemoveButton.Size = new System.Drawing.Size(38, 38); + this.rowRemoveButton.TabIndex = 26; + this.rowRemoveButton.UseVisualStyleBackColor = true; + this.rowRemoveButton.Click += new System.EventHandler(this.rowRemoveButton_Click); + // + // rowAddButton + // + this.rowAddButton.AutoSize = true; + this.rowAddButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.rowAddButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.RowAdd; + this.rowAddButton.Location = new System.Drawing.Point(6, 264); + this.rowAddButton.Name = "rowAddButton"; + this.rowAddButton.Size = new System.Drawing.Size(38, 38); + this.rowAddButton.TabIndex = 25; + this.rowAddButton.UseVisualStyleBackColor = true; + this.rowAddButton.Click += new System.EventHandler(this.rowAddButton_Click); + // + // propLeftPictureBox + // + this.propLeftPictureBox.Enabled = false; + this.propLeftPictureBox.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.ArrowDown; + this.propLeftPictureBox.Location = new System.Drawing.Point(360, 257); + this.propLeftPictureBox.Name = "propLeftPictureBox"; + this.propLeftPictureBox.Size = new System.Drawing.Size(131, 56); + this.propLeftPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.propLeftPictureBox.TabIndex = 23; + this.propLeftPictureBox.TabStop = false; + this.propLeftPictureBox.Visible = false; + // + // saveButton + // + this.saveButton.Location = new System.Drawing.Point(67, 35); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(133, 23); + this.saveButton.TabIndex = 36; + this.saveButton.Text = "Save Configuration"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // + // overridesGroupBox + // + this.overridesGroupBox.Controls.Add(this.numLockGroupBox); + this.overridesGroupBox.Controls.Add(this.capsLockGroupBox); + this.overridesGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.overridesGroupBox.Location = new System.Drawing.Point(50, 133); + this.overridesGroupBox.Name = "overridesGroupBox"; + this.overridesGroupBox.Size = new System.Drawing.Size(165, 111); + this.overridesGroupBox.TabIndex = 37; + this.overridesGroupBox.TabStop = false; + this.overridesGroupBox.Text = "Overrides at Start-Up"; + // + // numLockGroupBox + // + this.numLockGroupBox.Controls.Add(this.numLockComboBox); + this.numLockGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.numLockGroupBox.Location = new System.Drawing.Point(6, 63); + this.numLockGroupBox.Name = "numLockGroupBox"; + this.numLockGroupBox.Size = new System.Drawing.Size(152, 42); + this.numLockGroupBox.TabIndex = 38; + this.numLockGroupBox.TabStop = false; + this.numLockGroupBox.Text = "Num-Lock Forcing:"; + // + // numLockComboBox + // + this.numLockComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.numLockComboBox.FormattingEnabled = true; + this.numLockComboBox.Location = new System.Drawing.Point(9, 15); + this.numLockComboBox.Name = "numLockComboBox"; + this.numLockComboBox.Size = new System.Drawing.Size(133, 21); + this.numLockComboBox.TabIndex = 1; + // + // capsLockGroupBox + // + this.capsLockGroupBox.Controls.Add(this.capsLockComboBox); + this.capsLockGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.capsLockGroupBox.Location = new System.Drawing.Point(6, 15); + this.capsLockGroupBox.Name = "capsLockGroupBox"; + this.capsLockGroupBox.Size = new System.Drawing.Size(152, 42); + this.capsLockGroupBox.TabIndex = 37; + this.capsLockGroupBox.TabStop = false; + this.capsLockGroupBox.Text = "Caps-Lock Forcing:"; + // + // capsLockComboBox + // + this.capsLockComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.capsLockComboBox.FormattingEnabled = true; + this.capsLockComboBox.Location = new System.Drawing.Point(9, 15); + this.capsLockComboBox.Name = "capsLockComboBox"; + this.capsLockComboBox.Size = new System.Drawing.Size(133, 21); + this.capsLockComboBox.TabIndex = 0; + // + // rowCopyButton + // + this.rowCopyButton.AutoSize = true; + this.rowCopyButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.rowCopyButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.RowCopy; + this.rowCopyButton.Location = new System.Drawing.Point(96, 264); + this.rowCopyButton.Name = "rowCopyButton"; + this.rowCopyButton.Size = new System.Drawing.Size(38, 38); + this.rowCopyButton.TabIndex = 38; + this.rowCopyButton.UseVisualStyleBackColor = true; + this.rowCopyButton.Click += new System.EventHandler(this.rowCopyButton_Click); + // + // skinNavAddButton + // + this.skinNavAddButton.AutoSize = true; + this.skinNavAddButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.skinNavAddButton.Image = global::ProcessPlugins.ShortCuter.Properties.Resources.SkinNavAdd; + this.skinNavAddButton.Location = new System.Drawing.Point(136, 264); + this.skinNavAddButton.Name = "skinNavAddButton"; + this.skinNavAddButton.Size = new System.Drawing.Size(38, 38); + this.skinNavAddButton.TabIndex = 40; + this.skinNavAddButton.UseVisualStyleBackColor = true; + this.skinNavAddButton.Click += new System.EventHandler(this.skinNavAddButton_Click); + // + // skinNavConfigButton + // + this.skinNavConfigButton.BackgroundImage = global::ProcessPlugins.ShortCuter.Properties.Resources.SkinNav; + this.skinNavConfigButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.skinNavConfigButton.Location = new System.Drawing.Point(726, 220); + this.skinNavConfigButton.Name = "skinNavConfigButton"; + this.skinNavConfigButton.Size = new System.Drawing.Size(70, 70); + this.skinNavConfigButton.TabIndex = 41; + this.skinNavConfigButton.UseVisualStyleBackColor = true; + this.skinNavConfigButton.Click += new System.EventHandler(this.skinNavConfigButton_Click); + // + // skinItems + // + this.skinItems.Location = new System.Drawing.Point(266, 8); + this.skinItems.Name = "skinItems"; + this.skinItems.SelectedIndex = -1; + this.skinItems.SelectedTab = My.Common.SkinItems.SkinItemsType.Links; + this.skinItems.Size = new System.Drawing.Size(330, 260); + this.skinItems.TabIndex = 39; + this.skinItems.Enter += new System.EventHandler(this.skinItems_Enter); + this.skinItems.DoubleClick += new System.EventHandler(this.skinItems_DoubleClick); + this.skinItems.SelectedIndexChanged += new System.EventHandler(this.skinItems_SelectedIndexChanged); + // + // ShortCuterConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1018, 740); + this.Controls.Add(this.skinNavConfigButton); + this.Controls.Add(this.skinNavAddButton); + this.Controls.Add(this.skinItems); + this.Controls.Add(this.rowCopyButton); + this.Controls.Add(this.overridesGroupBox); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.rowDownButton); + this.Controls.Add(this.linkPropertiesGroupBox); + this.Controls.Add(this.rowUpButton); + this.Controls.Add(this.resetButton); + this.Controls.Add(this.updateButton); + this.Controls.Add(this.infoPictureBox); + this.Controls.Add(this.rowRemoveButton); + this.Controls.Add(this.rowAddButton); + this.Controls.Add(this.shortCutsDataGridView); + this.Controls.Add(this.propLeftPictureBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.Name = "ShortCuterConfig"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ShortCut\'er Plugin Configuration"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShortCuterConfig_FormClosing); + this.Load += new System.EventHandler(this.ShortCuterConfig_Load); + this.Shown += new System.EventHandler(this.ShortCuterConfig_Shown); + ((System.ComponentModel.ISupportInitialize)(this.shortCutsDataGridView)).EndInit(); + this.linkPropertiesGroupBox.ResumeLayout(false); + this.loadParameterGroupBox.ResumeLayout(false); + this.loadParameterGroupBox.PerformLayout(); + this.windowIdGroupBox.ResumeLayout(false); + this.skinFileGroupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.infoPictureBox)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.propLeftPictureBox)).EndInit(); + this.overridesGroupBox.ResumeLayout(false); + this.numLockGroupBox.ResumeLayout(false); + this.capsLockGroupBox.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.DataGridView shortCutsDataGridView; + private System.Windows.Forms.PictureBox propLeftPictureBox; + private System.Windows.Forms.Button rowAddButton; + private System.Windows.Forms.Button rowRemoveButton; + private System.Windows.Forms.PictureBox infoPictureBox; + private System.Windows.Forms.GroupBox linkPropertiesGroupBox; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.Button updateButton; + private System.Windows.Forms.Button resetButton; + private System.Windows.Forms.Button rowDownButton; + private System.Windows.Forms.Button rowUpButton; + private System.Windows.Forms.GroupBox windowIdGroupBox; + private System.Windows.Forms.Label windowIdLabel; + private System.Windows.Forms.GroupBox skinFileGroupBox; + private System.Windows.Forms.Label skinFileLabel; + private System.Windows.Forms.GroupBox loadParameterGroupBox; + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.TextBox loadParameterTextBox; + private System.Windows.Forms.GroupBox overridesGroupBox; + private System.Windows.Forms.GroupBox capsLockGroupBox; + private System.Windows.Forms.GroupBox numLockGroupBox; + private System.Windows.Forms.ComboBox capsLockComboBox; + private System.Windows.Forms.ComboBox numLockComboBox; + private System.Windows.Forms.Button rowCopyButton; + private My.Common.SkinItems skinItems; + private System.Windows.Forms.Button skinNavAddButton; + private System.Windows.Forms.Button skinNavConfigButton; + + } +} \ No newline at end of file Added: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.cs (rev 0) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Configuration/ShortCuterConfig.cs 2014-05-23 13:36:12 UTC (rev 4813) @@ -0,0 +1,517 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; +using MediaPortal.Profile; +using My.Common; + +namespace ProcessPlugins.ShortCuter.Configuration +{ + [PluginIcons("ProcessPlugins.ShortCuter.Resources.Images.ShortCuterEnable.png", "ProcessPlugins.ShortCuter.Resources.Images.ShortCuterDisable.png")] + public partial class ShortCuterConfig : Form, ISetupForm //Form per la configurazione del plugin, con implementazione interfaccia ISetupForm (per lancio da configurazione MediaPortal) + { + #region Dati + private Skin mySkin; //Istanza classe Skin (dati relativi alla skin di MediaPortal) + private ShortCuts myShortCuts; //Istanza classe ShortCuts (dati relativi ai shortcuts configurati) + private bool unsavedChanges; //Presenza modifiche da salvare + private bool forceCell; //Azione di forzatura valore cella WindowID dello shortcut + #endregion + + #region Costruttore + public ShortCuterConfig() + { + InitializeComponent(); + } + #endregion + + #region Metodi Privati + private void InitializeGUI() //Inizializzazione interfaccia + { + skinItems.Populate(mySkin.SkinFiles, mySkin.SkinLinks, false, true); + FormatShortCutsGrid(); + + capsLockComboBox.DataSource = Enum.GetNames(typeof(LockKeys.LockKeyActions)); + capsLockComboBox.SelectedItem = Enum.GetName(typeof(LockKeys.LockKeyActions), myShortCuts.General.ForcingCapsLock); + numLockComboBox.DataSource = Enum.GetNames(typeof(LockKeys.LockKeyActions)); + numLockComboBox.SelectedItem = Enum.GetName(typeof(LockKeys.LockKeyActions), myShortCuts.General.ForcingNumLock); + + toolTip.SetToolTip(skinItems, "Double click to set the link's parameter to shortcut"); + toolTip.SetToolTip(rowAddButton, "Add shortcut to list"); + toolTip.SetToolTip(rowRemoveButton, "Remove selected shortcut from list"); + toolTip.SetToolTip(rowCopyButton, "Copy selected shortcut to list"); + toolTip.SetToolTip(skinNavAddButton, "Add a shortcut to Skin Navigator in list"); + toolTip.SetToolTip(rowUpButton, "Move up selected shortcut in list"); + toolTip.SetToolTip(rowDownButton, "Move down selected shortcut in list"); + toolTip.SetToolTip(resetButton, "Reset actual settings and load the default configuration"); + toolTip.SetToolTip(saveButton, "Save actual settings"); + toolTip.SetToolTip(updateButton, "Save actual setting and close the application"); + toolTip.SetToolTip(capsLockComboBox, "Set forcing for Caps-Lock when MediaPortal starts (OFF is recommended)"); + toolTip.SetToolTip(numLockComboBox, "Set forcing for Num-Lock when MediaPortal starts"); + toolTip.SetToolTip(skinNavConfigButton, "Configure Skin Navigator"); + toolTip.SetToolTip(infoPictureBox, "Version information"); + + unsavedChanges = false; //--> necessario a fine aggiornamento controlli grafici + } + private void FormatShortCutsGrid() //Formattazione (e popolazione) tabella shortcuts + { + shortCutsDataGridView.AutoGenerateColumns = false; + + DataGridViewTextBoxColumn captionColumn = new DataGridViewTextBoxColumn(); + captionColumn.DataPropertyName = "Caption"; + captionColumn.HeaderText = "Caption"; + captionColumn.Width = 155; + captionColumn.MaxInputLength = 32; + captionColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + captionColumn.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); + captionColumn.ToolTipText = "Shortcut's title"; + + DataGridViewTextBoxColumn keyColumn = new DataGridViewTextBoxColumn(); + keyColumn.DataPropertyName = "Key"; + keyColumn.HeaderText = "Key [KeyCode]"; + keyColumn.Width = 120; + keyColumn.MaxInputLength = 24; + keyColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + keyColumn.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); + keyColumn.DefaultCellStyle.BackColor = Color.Yellow; + keyColumn.ReadOnly = true; + keyColumn.ToolTipText = "Key assigned to the shortcut (double click on the cell)"; + + DataGridViewCheckBoxColumn ctrlColumn = new DataGridViewCheckBoxColumn(); + ctrlColumn.DataPropertyName = "Ctrl"; + ctrlColumn.HeaderText = "Ctrl"; + ctrlColumn.Width = 30; + ctrlColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + ctrlColumn.DefaultCellStyle.BackColor = Color.LightCyan; + ctrlColumn.ToolTipText = "Use CTRL modifier + Key assigned"; + + DataGridViewCheckBoxColumn altColumn = new DataGridViewCheckBoxColumn(); + altColumn.DataPropertyName = "Alt"; + altColumn.HeaderText = "Alt"; + altColumn.Width = 30; + altColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + altColumn.DefaultCellStyle.BackColor = Color.LightCyan; + altColumn.ToolTipText = "Use ALT modifier + Key assigned"; + + DataGridViewCheckBoxColumn shiftColumn = new DataGridViewCheckBoxColumn(); + shiftColumn.DataPropertyName = "Shift"; + shiftColumn.HeaderText = "Shift"; + shiftColumn.Width = 30; + shiftColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + shiftColumn.DefaultCellStyle.BackColor = Color.LightCyan; + shiftColumn.ToolTipText = "Use SHIFT modifier + Key assigned"; + + DataGridViewTextBoxColumn windowIdColumn = new DataGridViewTextBoxColumn(); + windowIdColumn.DataPropertyName = "WindowID"; + windowIdColumn.HeaderText = "Window ID"; + windowIdColumn.Width = 70; + windowIdColumn.MaxInputLength = 10; + windowIdColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + windowIdColumn.ToolTipText = "MediaPortal window ID for the shortcut's destination"; + + DataGridViewTextBoxColumn loadParameterColumn = new DataGridViewTextBoxColumn(); + loadParameterColumn.DataPropertyName = "LoadParameter"; + loadParameterColumn.HeaderText = "Load Parameter"; + loadParameterColumn.Width = 358; + loadParameterColumn.MaxInputLength = 300; + loadParameterColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + loadParameterColumn.ToolTipText = "Any parameter for load window (see destination plugin's documentation)"; + + DataGridViewCheckBoxColumn returnColumn = new DataGridViewCheckBoxColumn(); + returnColumn.DataPropertyName = "Return"; + returnColumn.HeaderText = "Return"; + returnColumn.Width = 50; + returnColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + returnColumn.ToolTipText = "If you're already on the window ID, another activation of the shortcut will display the previous window"; + + DataGridViewComboBoxColumn soundEffectColumn = new DataGridViewComboBoxColumn(); + soundEffectColumn.DataPropertyName = "SoundEffect"; + soundEffectColumn.HeaderText = "Sound Effect"; + soundEffectColumn.Width = 140; + soundEffectColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; + soundEffectColumn.FlatStyle = FlatStyle.Flat; //--> necessario con Win7 per aggiornare il colore di sfondo se selezionato + soundEffectColumn.DataSource = mySkin.SkinSounds; + soundEffectColumn.ToolTipText = "Sound effect played on the shortcut"; + + shortCutsDataGridView.Columns.Add(captionColumn); + shortCutsDataGridView.Columns.Add(keyColumn); + shortCutsDataGridView.Columns.Add(ctrlColumn); + shortCutsDataGridView.Columns.Add(altColumn); + shortCutsDataGridView.Columns.Add(shiftColumn); + shortCutsDataGridView.Columns.Add(windowIdColumn); + shortCutsDataGridView.Columns.Add(loadParameterColumn); + shortCutsDataGridView.Columns.Add(returnColumn); + shortCutsDataGridView.Columns.Add(soundEffectColumn); + + shortCutsDataGridView.DataSource = myShortCuts.Items; + } + private void ShowLinkProperties() //Visualizzazione proprietà link + { + if (skinItems.SelectedIndex < 0) //Se indice invalido --> reset proprietà + { + skinFileLabel.Text = "-"; + windowIdLabel.Text = "-"; + loadParameterTextBox.Text = "-"; + } + else //Visualizzazione proprietà elemento selezionato + { + switch (skinItems.SelectedTab) + { + case SkinItems.SkinItemsType.Files: //Lista files della skin + skinFileLabel.Text = mySkin.SkinFiles[skinItems.SelectedIndex].Name; + windowIdLabel.Text = mySkin.SkinFiles[skinItems.SelectedIndex].Id.ToString(); + loadParameterTextBox.Text = "-"; + break; + + case SkinItems.SkinItemsType.Links: //Lista links predefiniti della skin + skinFileLabel.Text = mySkin.SkinLinks[skinItems.SelectedIndex].XmlFile; + windowIdLabel.Text = mySkin.SkinLinks[skinItems.SelectedIndex].WindowID.ToString(); + loadParameterTextBox.Text = mySkin.SkinLinks[skinItems.SelectedIndex].LoadParameter; + break; + } + } + } + private void ShowLinkItem() //Visualizzazione link corrispondente allo shortcut + { + if (shortCutsDataGridView.CurrentCell != null) + { + if (!forceCell) //Non nel caso di forzatura valore cella WindowID (doppio click da lista links) + { + int showIndex; + int windowID = Convert.ToInt32(shortCutsDataGridView.Rows[shortCutsDataGridView.CurrentRow.Index].Cells[5].Value); + + if (skinItems.SelectedTab == SkinItems.SkinItemsType.Links) + { + //Selezione eventuale link corrispondente a WindowID & LoadParameter + string loadParameter = Convert.ToString(shortCutsDataGridView.Rows[shortCutsDataGridView.CurrentRow.Index].Cells[6].Value); + showIndex = mySkin.SkinLinks.FindIndex(x => x.WindowID == windowID && x.LoadParameter == loadParameter); + } + else + //Selezione eventuale file corrispondente a WindowID + showIndex = mySkin.SkinFiles.FindLastIndex(x => x.Id == windowID); + + skinItems.SelectedIndex = showIndex; + } + } + } + private void MoveItemList(bool dirUp) //Spostamento shortcut + { + if (shortCutsDataGridView.CurrentCell != null) + { + forceCell = true; + int index = shortCutsDataGridView.CurrentRow.Index; + shortCutsDataGridView.CurrentCell = shortCutsDataGridView[0, index]; //Importante cambiare la colonna prima di muovere la riga se posizionati su KeyCode (Hook attivo) + ShortCut sc = myShortCuts.Items[index]; + myShortCuts.Items.RemoveAt(index); + if (dirUp) + index--; + else + index++; + myShortCuts.Items.Insert(index, sc); + shortCutsDataGridView.CurrentCell = shortCutsDataGridView[0, index]; + shortCutsDataGridView.Rows[index].Selected = true; + shortCutsDataGridView.Focus(); + forceCell = false; + } + } + private void MoveItemsListButtonsEnable() //Abilitazione/disabilitazione pulsanti di spostamento shortcuts + { + if (shortCutsDataGridView.CurrentCell != null) + { + rowUpButton.Enabled = (shortCutsDataGridView.CurrentRow.Index > 0); + rowDownButton.Enabled = (shortCutsDataGridView.CurrentRow.Index < myShortCuts.Items.Count - 1); + } + else + { + rowUpButton.Enabled = false; + rowDownButton.Enabled = false; + } + } + private bool Save() //Salvataggio configurazione plugin + { + myShortCuts.General.ForcingCapsLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), capsLockComboBox.SelectedItem.ToString()); + myShortCuts.General.ForcingNumLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), numLockComboBox.SelectedItem.ToString()); + return myShortCuts.SaveConfig(); + } + #endregion + + #region Consumazione Eventi + #region Eventi Form + private void ShortCuterConfig_Load(object sender, EventArgs e) + { + using (Settings confReader = new MPSettings()) + { + //Raccolta dati relativi alla skin + mySkin = new Skin(confReader.GetValueAsString("skin", "name", "DefaultWide"), Config.GetFolder(Config.Dir.Skin) + @"\", Config.GetFolder(Config.Dir.Cache) + @"\"); + } + if (mySkin.Initialized) + { + string settingsFile = Config.GetFile(Config.Dir.Config, Tools.MyAssembly.Name + ".xml"); + + myShortCuts = new ShortCuts(settingsFile); //Creazione classe per gestione shorcuts + myShortCuts.Log += new LogEventHandler(myShortCuts_Log); //Sottoscrizione evento di log shortuts + if (myShortCuts.Initialize()) //Inizializzazione & lettura impostazioni shorcuts + { + //Sottoscrizione evento di modifica lista shortcuts + myShortCuts.Items.ListChanged += new ListChangedEventHandler(myShortCutsItems_ListChanged); + + //Inizializzazione interfaccia grafica + InitializeGUI(); + } + } + //Se inizializzazione classi non completata + if (!mySkin.Initialized || !myShortCuts.Initialized) + { + this.Close(); + this.Dispose(); + } + } + private void ShortCuterConfig_Shown(object sender, EventArgs e) + { + shortCutsDataGridView.Focus(); + } + private void ShortCuterConfig_FormClosing(object sender, FormClosingEventArgs e) + { + //Se presenti modifiche non salvate: richiesta conferma per chiusura applicazione + if (unsavedChanges && !Tools.QuestionMessage("Unsaved changes will be lost...\nDo you want to proceed?")) + e.Cancel = true; //--> annullamento chiusura form + } + #endregion + #region Evento di Log Shortcuts + private void myShortCuts_Log(object sender, LogEventArgs e) + { + switch (e.LogLevel) + { + case LogEventArgs.LogLevels.Error: + if (e.LogException != null) + Tools.ErrorMessage(e.LogMessage, e.LogException.Message); //--> emissione finestra di errore (con descrizione errore) + else + Tools.ErrorMessage(e.LogMessage); //--> emissione finestra di errore + break; + case LogEventArgs.LogLevels.Info: + Tools.InfoMessage(e.LogMessage); //--> emissione finestra informativa + break; + } + } + #endregion + #region Eventi Modifica Griglia + private void shortCutsDataGridView_Enter(object sender, EventArgs e) + { + propLeftPictureBox.Visible = true; //--> il link è collegato allo shortcut selezionato + ShowLinkItem(); + MoveItemsListButtonsEnable(); + } + private void shortCutsDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) + { + e.Control.KeyPress -= idTextBox_KeyPress; + + if (e.Control is TextBox && ((DataGridView)(sender)).CurrentCell.ColumnIndex == 5) + e.Control.KeyPress += new KeyPressEventHandler(idTextBox_KeyPress); //--> sottoscrizione evento KeyPress per la cella WindowID + } + void idTextBox_KeyPress(object sender, KeyPressEventArgs e) + { + if ((int)shortCutsDataGridView.CurrentCell.Value <= 0) //Se WindowID negativo (possibile solo con Skin Navigator) + e.Handled = true; //--> carattere inputato da ignorare + else + { + if (!(char.IsDigit(e.KeyChar))) //Filtro per input numerico per la cella WindowID + { + Keys key = (Keys)e.KeyChar; + if (!(key == Keys.Back || key == Keys.Delete)) + { + e.Handled = true; //--> carattere inputato da ignorare + } + } + } + } + private void shortCutsDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + //Eventuale visualizzazione form per assegnazione key allo shortcut corrente + if (shortCutsDataGridView.CurrentCell != null && shortCutsDataGridView.CurrentCell.ColumnIndex == 1) + new ShortCuterKeyConfig(myShortCuts.Items[shortCutsDataGridView.CurrentCell.RowIndex], + new Point(Location.X + shortCutsDataGridView.Location.X + 305, + Location.Y + shortCutsDataGridView.Location.Y + shortCutsDataGridView.CurrentRow.Height * shortCutsDataGridView.CurrentCell.RowIndex) + ).ShowDialog(); + } + private void shortCutsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) + { + ShowLinkItem(); + } + private void shortCutsDataGridView_CurrentCellChanged(object sender, EventArgs e) + { + ShowLinkItem(); + MoveItemsListButtonsEnable(); + } + private void shortCutsDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + shortCutsDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = shortCutsDataGridView.Columns[e.ColumnIndex].ToolTipText; + } + private void shortCutsDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e) + { + //Gestione evento per evitare messaggi di errore (esempio se file effetto sonoro non disponibile nella skin) + } + #endregion + #region Eventi Modifica Impostazioni Plugin & Shortcuts + private void myShortCutsItems_ListChanged(object sender, EventArgs e) + { + unsavedChanges = true; + rowRemoveButton.Enabled = (myShortCuts.Items.Count > 0); + rowCopyButton.Enabled = (myShortCuts.Items.Count > 0); + MoveItemsListButtonsEnable(); + } + private void rowAddButton_Click(object sender, EventArgs e) + { + ShortCut sc = new ShortCut(); + myShortCuts.Items.Add(sc); + shortCutsDataGridView.CurrentCell = shortCutsDataGridView[0, shortCutsDataGridView.RowCount - 1]; + shortCutsDat... [truncated message content] |