From: <nic...@us...> - 2014-01-09 15:50:17
|
Revision: 4718 http://sourceforge.net/p/mp-plugins/code/4718 Author: nicsergio Date: 2014-01-09 15:50:13 +0000 (Thu, 09 Jan 2014) Log Message: ----------- Modified Paths: -------------- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/LockKeys.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultConfig.xml trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.Designer.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/LockKeys.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/LockKeys.cs 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/LockKeys.cs 2014-01-09 15:50:13 UTC (rev 4718) @@ -1,11 +1,10 @@ using System; using System.Runtime.InteropServices; using System.Windows.Forms; -using System.ComponentModel; namespace ProcessPlugins.ShortCuter { - internal static class LockKeys //Classe per disattivazione blocco maiuscole/numeri + internal static class LockKeys //Classe per modifica stato blocco maiuscole/numeri { #region Costanti const int KEYEVENTF_EXTENDEDKEY = 0x1; //Da impostare come flag per far precedere il codice per la scansione HW dal byte 0xE0 (tasti estesi) @@ -15,38 +14,36 @@ const int VK_CAPITAL = 0x14; //Codice VirtualKey di CapsLock const int SC_CAPITAL = 0x3A; //Codice HardwareKey di CapsLock (per scansione HW -> bScan) - public enum LockKeyTypes + public enum LockKeyActions //Tipologie di azioni di modica stato { - ForceOff = 0, - [Description("Force OFF (reccomended)")] - HereIsAnother = 2, - [Description("Last one")] - LastOne = 3 + Off = 0, //--> reset blocco + On = 1, //--> forzatura blocco + None = 2 //--> nessuna modifica (stato invariato) } - - #endregion #region Metodi Pubblici - public static bool ResetCapsLock() //Richesta di disattivazione CapsLock + public static bool ChangeCapsLock(LockKeyActions forcing) //Richiesta di modifica stato CapsLock { - if (Control.IsKeyLocked(Keys.CapsLock)) //Se CapsLock attivo + if ((Control.IsKeyLocked(Keys.CapsLock) & forcing == LockKeyActions.On) || + (!Control.IsKeyLocked(Keys.CapsLock) & forcing == LockKeyActions.Off)) //Se richiesta una variazione di stato { keybd_event(VK_CAPITAL, SC_CAPITAL, 0, (UIntPtr)0); //--> simulazione pressione del tasto CapsLock keybd_event(VK_CAPITAL, SC_CAPITAL, KEYEVENTF_KEYUP, (UIntPtr)0); //--> simulazione rilascio del tasto CapsLock - return true; //--> CapsLock disattivato + return true; //--> stato CapsLock modificato } else return false; //--> stato CapsLock non modificato } - public static bool ResetNumLock() //Richesta di disattivazione NumLock + public static bool ChangeNumLock(LockKeyActions forcing) //Richesta di modifica stato NumLock { - if (Control.IsKeyLocked(Keys.NumLock)) //Se NumLock attivo + if ((Control.IsKeyLocked(Keys.NumLock) & forcing == LockKeyActions.On) || + (!Control.IsKeyLocked(Keys.NumLock) & forcing == LockKeyActions.Off)) //Se richiesta una variazione di stato { keybd_event(VK_NUMLOCK, HK_NUMLOCK, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0); //--> simulazione pressione del tasto NumLock keybd_event(VK_NUMLOCK, HK_NUMLOCK, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0); //--> simulazione rilascio del tasto NumLock - return true; //--> NumLock disattivato + return true; //--> stato NumLock modificato } else return false; //--> stato NumLock non modificato Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultConfig.xml =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultConfig.xml 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultConfig.xml 2014-01-09 15:50:13 UTC (rev 4718) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <ShortCuter> <General> - <ResetCapsLock>1</ResetCapsLock> - <ResetNumLock>0</ResetNumLock> + <ForcingCapsLock>Off</ForcingCapsLock> + <ForcingNumLock>None</ForcingNumLock> </General> <Items> <Item> Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-01-09 15:50:13 UTC (rev 4718) @@ -30,12 +30,12 @@ string settingsFile = Config.GetFile(Config.Dir.Config, Tools.MyAssembly.Name + ".xml"); myShortCuts = new ShortCuts(settingsFile, false); //--> lettura configurazione relativa agli shortcuts - if (myShortCuts.GeneralResetCapsLock) - if (LockKeys.ResetCapsLock()) - MpLog(false, "CapsLock deactivated"); //--> disattivazione CapsLock - if (myShortCuts.GeneralResetNumLock) - if (LockKeys.ResetNumLock()) - MpLog(false, "NumLock deactivated"); //--> disattivazione NumLock + + if (LockKeys.ChangeCapsLock(myShortCuts.GeneralForcingCapsLock)) + MpLog(false, "CapsLock deactivated"); //--> disattivazione CapsLock + if (LockKeys.ChangeNumLock(myShortCuts.GeneralForcingNumLock)) + MpLog(false, "NumLock deactivated"); //--> disattivazione NumLock + if (myShortCuts.Initialized) //Se classe di gestione shortcut inizializzata { try Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.Designer.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.Designer.cs 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.Designer.cs 2014-01-09 15:50:13 UTC (rev 4718) @@ -55,7 +55,10 @@ this.propLeftPictureBox = new System.Windows.Forms.PictureBox(); this.saveButton = new System.Windows.Forms.Button(); this.overridesGroupBox = new System.Windows.Forms.GroupBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.capsLockGroupBox = new System.Windows.Forms.GroupBox(); + this.numLockGroupBox = new System.Windows.Forms.GroupBox(); + this.capsLockComboBox = new System.Windows.Forms.ComboBox(); + this.numLockComboBox = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.shortCutsDataGridView)).BeginInit(); this.itemsTabControl.SuspendLayout(); this.linksTabPage.SuspendLayout(); @@ -67,6 +70,8 @@ ((System.ComponentModel.ISupportInitialize)(this.infoPictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.propLeftPictureBox)).BeginInit(); this.overridesGroupBox.SuspendLayout(); + this.capsLockGroupBox.SuspendLayout(); + this.numLockGroupBox.SuspendLayout(); this.SuspendLayout(); // // shortCutsDataGridView @@ -347,7 +352,8 @@ // // overridesGroupBox // - this.overridesGroupBox.Controls.Add(this.groupBox1); + 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(6, 200); this.overridesGroupBox.Name = "overridesGroupBox"; @@ -356,16 +362,46 @@ this.overridesGroupBox.TabStop = false; this.overridesGroupBox.Text = "Overrides at Start-Up"; // - // groupBox1 + // capsLockGroupBox // - this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox1.Location = new System.Drawing.Point(4, 13); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(152, 42); - this.groupBox1.TabIndex = 37; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Window ID:"; + 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:"; // + // 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(164, 15); + 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:"; + // + // 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; + // + // 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; + // // ShortCuterForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -405,6 +441,8 @@ ((System.ComponentModel.ISupportInitialize)(this.infoPictureBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.propLeftPictureBox)).EndInit(); this.overridesGroupBox.ResumeLayout(false); + this.capsLockGroupBox.ResumeLayout(false); + this.numLockGroupBox.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -436,7 +474,10 @@ private System.Windows.Forms.Button saveButton; private System.Windows.Forms.TextBox loadParameterTextBox; private System.Windows.Forms.GroupBox overridesGroupBox; - private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox capsLockGroupBox; + private System.Windows.Forms.GroupBox numLockGroupBox; + private System.Windows.Forms.ComboBox capsLockComboBox; + private System.Windows.Forms.ComboBox numLockComboBox; } } \ No newline at end of file Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.cs 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterForm.cs 2014-01-09 15:50:13 UTC (rev 4718) @@ -36,9 +36,11 @@ skinLinksTreeView.CollapseAll(); FormatShortCutsGrid(); - resetCapsLockCheckBox.Checked = myShortCuts.GeneralResetCapsLock; - resetNumLockCheckBox.Checked = myShortCuts.GeneralResetNumLock; - + capsLockComboBox.DataSource = Enum.GetNames(typeof(LockKeys.LockKeyActions)); + capsLockComboBox.SelectedItem = Enum.GetName(typeof(LockKeys.LockKeyActions), myShortCuts.GeneralForcingCapsLock); + numLockComboBox.DataSource = Enum.GetNames(typeof(LockKeys.LockKeyActions)); + numLockComboBox.SelectedItem = Enum.GetName(typeof(LockKeys.LockKeyActions), myShortCuts.GeneralForcingNumLock); + toolTip.SetToolTip(skinFilesListBox, "Double click to set the link's parameter to shortcut"); toolTip.SetToolTip(skinLinksTreeView, "Double click to set the link's parameter to shortcut"); toolTip.SetToolTip(rowAddButton, "Add shortcut to list"); @@ -222,8 +224,8 @@ } private bool Save() //Salvataggio configurazione plugin { - myShortCuts.GeneralResetCapsLock = resetCapsLockCheckBox.Checked; - myShortCuts.GeneralResetNumLock = resetNumLockCheckBox.Checked; + myShortCuts.GeneralForcingCapsLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), capsLockComboBox.SelectedItem.ToString()); + myShortCuts.GeneralForcingNumLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), numLockComboBox.SelectedItem.ToString()); return myShortCuts.SaveConfig(); } #endregion Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-01-08 18:11:03 UTC (rev 4717) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-01-09 15:50:13 UTC (rev 4718) @@ -113,8 +113,8 @@ private readonly bool ConfigContext; //Utilizzo nella fase di configurazione (altrimenti plugin in esecuzione) private struct GeneralSettings //Struttura impostazioni generali { - public bool ResetCapsLock; //Reset attivazione Caps-Lock all'avvio - public bool ResetNumLock; //Reset attivazione Num-Lock all'avvio + public LockKeys.LockKeyActions ForcingCapsLock; //Tipologia di forzatura Caps-Lock all'avvio + public LockKeys.LockKeyActions ForcingNumLock; //Tipologia di forzatura Num-Lock all'avvio } private GeneralSettings _general = new GeneralSettings(); //Impostazioni generali plugin private BindingList<ShortCut> _items = new BindingList<ShortCut>(); //Lista (con associazione dati) degli shortcuts configurati @@ -126,6 +126,8 @@ { SettingsFile = settingsFile; //--> percorso & nome file delle impostazioni ConfigContext = configContext; //--> utilizzo nella fase di configurazione (altrimenti plugin in esecuzione) + _general.ForcingCapsLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Caps-Lock + _general.ForcingNumLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Num-Lock _initialized = LoadConfig(false); //--> caricamento configurazione (standard) shortcuts if (!_initialized) { @@ -214,13 +216,25 @@ XmlNode innerNode; XmlNode generalNode = xmlFile.DocumentElement.SelectSingleNode("/ShortCuter/General"); if (generalNode != null) //Se presente sezione "General" (implementata da V2.0.5) - { - innerNode = generalNode.SelectSingleNode("ResetCapsLock"); + { + innerNode = generalNode.SelectSingleNode("ForcingCapsLock"); if (innerNode != null) - _general.ResetCapsLock = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); - innerNode = generalNode.SelectSingleNode("ResetNumLock"); + _general.ForcingCapsLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), innerNode.InnerText); + else + { + innerNode = generalNode.SelectSingleNode("ResetCapsLock"); //Necessario per compatibilità con file di configurazione V2.0.5.0 + if (innerNode != null && Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText))) + _general.ForcingCapsLock = LockKeys.LockKeyActions.Off; + } + innerNode = generalNode.SelectSingleNode("ForcingNumLock"); if (innerNode != null) - _general.ResetNumLock = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); + _general.ForcingNumLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), innerNode.InnerText); + else + { + innerNode = generalNode.SelectSingleNode("ResetNumLock"); //Necessario per compatibilità con file di configurazione V2.0.5.0 + if (innerNode != null && Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText))) + _general.ForcingNumLock = LockKeys.LockKeyActions.Off; + } } XmlNodeList nodeList = xmlFile.DocumentElement.SelectNodes("/ShortCuter/Items/Item"); foreach (XmlNode node in nodeList) //Iterazione per memorizzazione impostazioni shortcuts @@ -303,8 +317,8 @@ xmlSettings.WriteStartElement("ShortCuter"); xmlSettings.WriteStartElement("General"); - xmlSettings.WriteElementString("ResetCapsLock", Convert.ToInt16(_general.ResetCapsLock).ToString()); - xmlSettings.WriteElementString("ResetNumLock", Convert.ToInt16(_general.ResetNumLock).ToString()); + xmlSettings.WriteElementString("ForcingCapsLock", _general.ForcingCapsLock.ToString()); + xmlSettings.WriteElementString("ForcingNumLock", _general.ForcingNumLock.ToString()); xmlSettings.WriteEndElement(); xmlSettings.WriteStartElement("Items"); foreach (ShortCut sc in _items) //Iterazione per salvataggio sortcuts @@ -342,10 +356,10 @@ #endregion #region Proprietà - public bool Initialized { get { return this._initialized; } } - public bool GeneralResetCapsLock { get { return this._general.ResetCapsLock; } set { this._general.ResetCapsLock = value; } } - public bool GeneralResetNumLock { get { return this._general.ResetNumLock; } set { this._general.ResetNumLock = value; } } - public BindingList<ShortCut> Items { get { return this._items; } } + public bool Initialized { get { return this._initialized; } } + public LockKeys.LockKeyActions GeneralForcingCapsLock { get { return this._general.ForcingCapsLock; } set { this._general.ForcingCapsLock = value; } } + public LockKeys.LockKeyActions GeneralForcingNumLock { get { return this._general.ForcingNumLock; } set { this._general.ForcingNumLock = value; } } + public BindingList<ShortCut> Items { get { return this._items; } } #endregion } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |