|
From: <nic...@us...> - 2014-01-16 13:19:47
|
Revision: 4731
http://sourceforge.net/p/mp-plugins/code/4731
Author: nicsergio
Date: 2014-01-16 13:19:41 +0000 (Thu, 16 Jan 2014)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/KeyboardHook.cs
trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.Designer.cs
trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.cs
trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs
Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/KeyboardHook.cs
===================================================================
--- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/KeyboardHook.cs 2014-01-15 21:09:04 UTC (rev 4730)
+++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/KeyboardHook.cs 2014-01-16 13:19:41 UTC (rev 4731)
@@ -35,30 +35,22 @@
#endregion
public List<Keys> HookedKeys = new List<Keys>(); //Eventuale lista dei tasti da monitorare/intercettare
- private IntPtr hHook = IntPtr.Zero; //Handle dell'hook
- #endregion
+ private IntPtr hHook = IntPtr.Zero; //Handle dell'hook
+ private IntPtr hInstance = IntPtr.Zero; //Handle dell'istanza della libreria esterna
+ #endregion
#region Costruttore/Distruttore
public KeyboardHook()
{
- hook(); //--> installazione dell'hook di sistema
+ hInstance = LoadLibrary("User32"); //--> caricamento libreria esterna e memorizzazione handle
}
~KeyboardHook()
{
- unhook(); //--> disinstallazione dell'hook di sistema
+ unhook(); //--> eventuale disinstallazione dell'hook di sistema
}
#endregion
#region Metodi Privati
- private void hook() //Installazione dell'hook di sistema
- {
- IntPtr hInstance = LoadLibrary("User32");
- hHook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0);
- }
- public void unhook() //Disinstallazione dell'hook di sistema
- {
- UnhookWindowsHookEx(hHook);
- }
private int hookProc(int code, int wParam, ref HookStruct lParam) //Metodo richiamato per l'hook di tastiera
{
if (code >= 0) //Se codice hook valorizzato
@@ -83,8 +75,20 @@
}
#endregion
- #region Eventi
- public event KeyEventHandler KeyDown; //Evento di pressione di uno dei tasti da monitorare
+ #region Metodi Pubblici
+ public void hook() //Installazione dell'hook di sistema
+ {
+ hHook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0);
+ }
+ public void unhook() //Disinstallazione dell'hook di sistema
+ {
+ try { UnhookWindowsHookEx(hHook); }
+ catch { }
+ }
+ #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
Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.Designer.cs
===================================================================
--- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.Designer.cs 2014-01-15 21:09:04 UTC (rev 4730)
+++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.Designer.cs 2014-01-16 13:19:41 UTC (rev 4731)
@@ -100,6 +100,7 @@
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);
Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.cs
===================================================================
--- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.cs 2014-01-15 21:09:04 UTC (rev 4730)
+++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterConfig.cs 2014-01-16 13:19:41 UTC (rev 4731)
@@ -335,6 +335,10 @@
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)
Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs
===================================================================
--- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs 2014-01-15 21:09:04 UTC (rev 4730)
+++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs 2014-01-16 13:19:41 UTC (rev 4731)
@@ -19,24 +19,24 @@
mySc = currentShortCut; //--> impostazione riferimento a shortcut corrente
Text = "'" + mySc.Caption + "' ShortCut"; //--> titolo della finestra corrispondente a nome shorcut
keyLabel.Text = mySc.Key; //--> visualizzazione tasto correntemente assegnato
+
+ keyboardHook = new KeyboardHook(); //--> creazione oggetto per gestione hook di tastiera
+ keyboardHook.KeyDown += new KeyEventHandler(keyboardHook_KeyDown); //--> sottoscrizione evento di KeyDown
}
#endregion
#region Consumazione Eventi
private void ShortCuterKeyConfig_Load(object sender, EventArgs e)
{
- keyboardHook = new KeyboardHook(); //--> creazione hook di tastiera
- keyboardHook.KeyDown += new KeyEventHandler(keyboardHook_KeyDown); //--> sottoscrizione evento di KeyDown
+ keyboardHook.hook(); //--> attivazione hook di tastiera
}
private void ShortCuterKeyConfig_FormClosing(object sender, FormClosingEventArgs e)
{
- if (keyboardHook != null)
- keyboardHook = null; //--> distruzione hook
+ keyboardHook.unhook(); //--> disattivazione hook di tastiera
}
private void okPictureBox_Click(object sender, EventArgs e)
{
mySc.Key = keyLabel.Text; //--> memorizzazione tasto assegnato allo shortcut
- keyboardHook.unhook();
this.Close(); //--> chiusura form
}
private void keyboardHook_KeyDown(object sender, KeyEventArgs e) //Evento KeyDown intercettato dall'hook
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|