From: <nic...@us...> - 2014-04-27 19:40:30
|
Revision: 4789 http://sourceforge.net/p/mp-plugins/code/4789 Author: nicsergio Date: 2014-04-27 19:40:27 +0000 (Sun, 27 Apr 2014) Log Message: ----------- Modified Paths: -------------- trunk/plugins/ShortCuter&SkinEditor/Source/MediaPortalPlugins.sln trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.csproj trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs trunk/plugins/ShortCuter&SkinEditor/Source/XtremeMenuEditor/XtremeMenuEditor.csproj Modified: trunk/plugins/ShortCuter&SkinEditor/Source/MediaPortalPlugins.sln =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/MediaPortalPlugins.sln 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/MediaPortalPlugins.sln 2014-04-27 19:40:27 UTC (rev 4789) @@ -24,7 +24,7 @@ EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Debug|Any CPU.ActiveCfg = DLL|x86 - {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Debug|Mixed Platforms.ActiveCfg = DLL|x86 + {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Debug|Mixed Platforms.ActiveCfg = EXE|x86 {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Debug|x86.ActiveCfg = DLL|x86 {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Debug|x86.Build.0 = DLL|x86 {350D17A6-0F6B-43C4-898F-33CC68EBCD75}.Release|Any CPU.ActiveCfg = DLL|x86 Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-04-27 19:40:27 UTC (rev 4789) @@ -196,7 +196,7 @@ #region Consumazione Eventi private void rawInput_KeyDown(object sender, KeyEventArgs e) //Evento di pressione tasto { - if (!ShortCut.ModifierKeys.Contains(e.KeyCode)) //Verifica se il tasto premuto non corrisponde ad un modificatore + if (!KeyCombination.IsModifier(e.KeyCode)) //Verifica se il tasto premuto non corrisponde ad un modificatore { List<ShortCut> scList = myShortCuts.Items.ToList().FindAll(x => x.Key == e.KeyCode.ToString() Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.csproj =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.csproj 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.csproj 2014-04-27 19:40:27 UTC (rev 4789) @@ -175,7 +175,9 @@ <ItemGroup> <Content Include="Resources\Images\SkinNav.png" /> <Content Include="Resources\Images\SkinNavAdd.png" /> - <EmbeddedResource Include="Resources\XmlFiles\DefaultConfig.xml" /> + <EmbeddedResource Include="Resources\XmlFiles\DefaultConfig.xml"> + <SubType>Designer</SubType> + </EmbeddedResource> <Content Include="..\Common\Resources\Images\ArrowDown.png"> <Link>Resources\Images\ArrowDown.png</Link> </Content> Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuterKeyConfig.cs 2014-04-27 19:40:27 UTC (rev 4789) @@ -12,7 +12,7 @@ #endregion #region Costruttore - public ShortCuterKeyConfig(ShortCut currentShortCut, Point startLocation) + internal ShortCuterKeyConfig(ShortCut currentShortCut, Point startLocation) { InitializeComponent(); Location = startLocation; //--> impostazione posizione form @@ -41,7 +41,7 @@ } private void keyboardHook_KeyDown(object sender, KeyEventArgs e) //Evento KeyDown intercettato dall'hook { - if (!ShortCut.ModifierKeys.Contains(e.KeyCode)) + if (!KeyCombination.IsModifier(e.KeyCode)) keyLabel.Text = e.KeyCode.ToString(); //--> visualizzazione tasto premuto, se non corrisponde ad un modificatore e.Handled = true; //--> il tasto premuto viene ignorato } Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-04-27 19:40:27 UTC (rev 4789) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using MediaPortal.GUI.Library; using System.IO; using System.Reflection; using System.Text; @@ -11,63 +12,105 @@ namespace ProcessPlugins.ShortCuter { - private struct Destination + internal class ScreenLink //Classe collegamento ad una finestra di MediaPortal { - public int _windowID; //Id finestra per visualizzazione in MediaPortal - public string _loadParameter; //Eventuali parametri di caricamento per visualizzazione (sotto-categorie, ecc.) - public override string ToString() + #region Dati + private string _caption; //Titolo link + private int _windowID; //Id finestra per visualizzazione in MediaPortal + private string _loadParameter; //Eventuali parametri di caricamento per visualizzazione (sotto-categorie, ecc.) + + private const int TrailersPluginControlID = 11899; //Id controllo per attivazione plugin Trailers + internal delegate void LoadParamChgEventHandler(string loadParam); //Delegato per evento di modifica parametri di caricamento + #endregion + + #region Costruttore + public ScreenLink() //Costruttore classe ScreenLink { - return "WindowID=" + _windowID.ToString() + ((_loadParameter.Length > 0) ? " LoadParameter=[" + _loadParameter + "]" : ""); + _caption = "Link"; //--> inizializzazione titolo + _windowID = 0; //--> inizializzazione window ID + _loadParameter = ""; //--> inizializzazione parametri di caricamento per visualizzazione } - } + #endregion - private struct KeyCombination - { - public string _key; //Tasto (stringa corrispondente a KeyCode) - public bool _ctrl; //Utilizzo del modificatore "Ctrl" - combinazione di tasti - public bool _alt; //Utilizzo del modificatore "Alt" - combinazione di tasti - public bool _shift; //Utilizzo del modificatore "Shift" - combinazione di tasti - public override string ToString() + #region Metodi Pubblici + public void Go() //Visualizzazione finestra del collegamento { - return "Key=" + ((_ctrl) ? "<CTRL>" : "") - + ((_alt) ? "<ALT>" : "") - + ((_shift) ? "<SHIFT>" : "") - + "<" + _key + ">"; + if (_loadParameter.Length > 0) //Se richiesti parametri di caricamento + { + bool loadParameterChange = false; + string loadParameter = _loadParameter; + while (true) //Ricerca eventuali GUIProperties + { + int i = loadParameter.IndexOf("(#"), ii = 0; + if (i >= 0) + ii = loadParameter.IndexOf(")", i); + if (i >= 0 && (ii > i)) + { + string propName = loadParameter.Remove(ii).Remove(0, i + 1); + if (propName.Length > 0) + { + loadParameter = loadParameter.Remove(i) + GUIPropertyManager.GetProperty(propName).Trim() + loadParameter.Remove(0, ii + 1); + loadParameterChange = true; + } + else + break; + } + else + break; + } + if (loadParameterChange && (LoadParamChg != null)) + LoadParamChg(loadParameter); //--> richiamo dell'evento di modifica parametri di caricamento + + GUIWindowManager.ActivateWindow(_windowID, loadParameter, true); //--> richiamo schermata con parametri di caricamento + } + else //Richiamo schermata senza parametri di caricamento + { + GUIMessage msg; + if (_windowID == TrailersPluginControlID) //Se richiesta di attivazione plugin Trailers + msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, 0, TrailersPluginControlID, TrailersPluginControlID, 0, 0, null); + else //Caso normale di attivazione finesta MediaPortal + msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, _windowID, 0, null); + + GUIWindowManager.SendMessage(msg); //--> invio messaggio per attivazione finestra + } } - } - - internal class SimpleShortCut - { - protected string _caption; //Titolo - protected Destination _destination; + public override string ToString() //Override metodo ToString per stampare le proprietà del link + { + return ((_caption.Length > 0) ? "Link " + _caption + " " : "") + "--> WindowID=" + _windowID.ToString() + ((_loadParameter.Length > 0) ? " LoadParameter=[" + _loadParameter + "]" : ""); + } + #endregion - public override string ToString() + #region Eventi + public event LoadParamChgEventHandler LoadParamChg; //Evento di modifica parametri di caricamento + #endregion + + #region Proprietà + public bool IsValid { - return "ShortCut " + _caption + " --> " + _destination.ToString(); + get + { + return (this._windowID >= 0); //L'ID della finestra di MediaPortal deve essere valido + } } - + public string Caption { get { return this._caption; } set { this._caption = value; } } + public int WindowID { get { return this._windowID; } set { this._windowID = value; } } + public string LoadParameter { get { return this._loadParameter; } set { this._loadParameter = value; } } + #endregion } - - - public class ShortCut : INotifyPropertyChanged //Classe shortcut (scorciatoia da tastiera) con notifica variazione proprietà + internal class KeyCombination //Classe combinazione di tasti { #region Dati - private string _caption; //Titolo private string _key; //Tasto (stringa corrispondente a KeyCode) private bool _ctrl; //Utilizzo del modificatore "Ctrl" - combinazione di tasti private bool _alt; //Utilizzo del modificatore "Alt" - combinazione di tasti private bool _shift; //Utilizzo del modificatore "Shift" - combinazione di tasti - private int _windowID; //Id finestra per visualizzazione in MediaPortal - private string _loadParameter; //Eventuali parametri di caricamento per visualizzazione (sotto-categorie, ecc.) - private bool _return; //Ritorno a finestra precedente se si è già a destinazione - private string _soundEffect; //File relativo all'eventuale effetto sonoro - private Destination _destination; - public static readonly List<Keys> ModifierKeys = new List<Keys>(); //Lista dei tasti modificatori + + private static readonly List<Keys> ModifierKeys = new List<Keys>(); //Lista dei tasti modificatori #endregion #region Costruttore - static ShortCut() //Costruttore statico classe ShortCut + static KeyCombination() //Costruttore statico classe KeyCombination { ModifierKeys.Add(Keys.ControlKey); //--> aggiunta del tasto Control tra i modificatori ModifierKeys.Add(Keys.LControlKey); //--> aggiunta del tasto Control (sinistro) tra i modificatori @@ -79,102 +122,127 @@ ModifierKeys.Add(Keys.LShiftKey); //--> aggiunta del tasto Shift (sinistro) tra i modificatori ModifierKeys.Add(Keys.RShiftKey); //--> aggiunta del tasto Shift (destro) tra i modificatori } - public ShortCut() //Costruttore classe ShortCut + public KeyCombination() //Costruttore classe KeyCombination { - _caption = "ShortCut"; //--> inizializzazione titolo - _key = "A"; //--> inizializzazione tasto - _ctrl = true; //--> inizializzazione utilizzo del modificatore "Ctrl" - _alt = false; //--> inizializzazione utilizzo del modificatore "Alt" - _shift = true; //--> inizializzazione utilizzo del modificatore "Shift" - _windowID = 0; //--> inizializzazione window ID - _loadParameter = ""; //--> inizializzazione parametri di caricamento per visualizzazione - _return = false; //--> inizializzazione ritorno a finestra precedente se si è già a destinazione - _soundEffect = "click.wav"; //--> inizializzazione effetto sonoro + _key = "A"; //--> inizializzazione tasto + _ctrl = true; //--> inizializzazione utilizzo del modificatore "Ctrl" + _alt = false; //--> inizializzazione utilizzo del modificatore "Alt" + _shift = true; //--> inizializzazione utilizzo del modificatore "Shift" } } #endregion - - #region Metodi Privati - private void NotifyPropertyChanged(string name) //Notifica variazione proprietà + + #region Metodi Pubblici + public static bool IsModifier(Keys key) //Verifica se un tasto corrisponde ad un modificatore { - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs(name)); //--> pubblicazione evento + return ModifierKeys.Contains(key); } + public override string ToString() //Override metodo ToString per stampare la combinazione di tasti + { + return "Key=" + ((_ctrl) ? "<CTRL>" : "") + ((_alt) ? "<ALT>" : "") + ((_shift) ? "<SHIFT>" : "") + "<" + _key + ">"; + } #endregion - #region Metodi Pubblici & Eventi - public bool IsValid() //Verifica validità dello shortcut - { - //if ((_ctrl || _alt || _shift) && _windowID >= 0) //(fino a V2.0.1) Per validare lo shortcut deve esserci almeno un modificatore nella combinazione di tasti e l'ID della finestra di MediaPortal deve essere valido - if (_windowID >= 0) //Per validare lo shortcut l'ID della finestra di MediaPortal deve essere valido + #region Proprietà + public bool IsValid + { + get { KeysConverter kc = new KeysConverter(); Keys key = new Keys(); - try { key = (Keys)kc.ConvertFromString(_key); } + try { key = (Keys)kc.ConvertFromString(_key); } catch { } return (key != Keys.None && !ModifierKeys.Contains(key)); //--> verifica se la stringa corrisponde ad un tasto e che il tasto non sia un modificatore } - else - return false; } + public string Key { get { return this._key; } set { this._key = value; } } + public bool Ctrl { get { return this._ctrl; } set { this._ctrl = value; } } + public bool Alt { get { return this._alt; } set { this._alt = value; } } + public bool Shift { get { return this._shift; } set { this._shift = value; } } + #endregion + } + + internal class ShortCut : INotifyPropertyChanged //Classe shortcut (scorciatoia da tastiera) con notifica variazione proprietà + { + #region Dati + private string _caption; //Titolo link + private KeyCombination _keys; //Combinazione di tasti per attivazione shortcut + private ScreenLink _destination; //Destinazione dello shortcut + private bool _return; //Ritorno a finestra precedente se si è già a destinazione + private string _soundEffect; //File relativo all'eventuale effetto sonoro + #endregion + + #region Costruttore + public ShortCut() //Costruttore classe ShortCut + { + _caption = "ShortCut"; //--> inizializzazione titolo + _keys = new KeyCombination(); //--> istanziazione classe KeyCombination + _destination = new ScreenLink(); //--> istanziazione classe Screenlink + _destination.Caption = ""; //--> reset caption destinazione (gestita caption shortcut) + _return = false; //--> inizializzazione ritorno a finestra precedente se si è già a destinazione + _soundEffect = "click.wav"; //--> inizializzazione effetto sonoro + } + #endregion + + #region Metodi Privati + private void NotifyPropertyChanged(string name) //Notifica variazione proprietà + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(name)); //--> pubblicazione evento + } + #endregion + + #region Metodi Pubblici public ShortCut Clone() //Clonazione shortcut { ShortCut sc = new ShortCut(); - sc.Caption = _caption; - sc.Key = _key; - sc.Ctrl = _ctrl; - sc.Alt = _alt; - sc.Shift = _shift; - sc.WindowID = _windowID; - sc.LoadParameter = _loadParameter; - sc.Return = _return; - sc.SoundEffect = _soundEffect; + sc.Caption = _caption; + sc.Key = _keys.Key; + sc.Ctrl = _keys.Ctrl; + sc.Alt = _keys.Alt; + sc.Shift = _keys.Shift; + sc.WindowID = _destination.WindowID; + sc.LoadParameter = _destination.LoadParameter; + sc.Return = _return; + sc.SoundEffect = _soundEffect; return sc; } public override string ToString() //Override metodo ToString per stampare le proprietà dello shortcut { - string ret; - ret = "ShortCut " + _caption + ": Key="; - if (_ctrl) - ret += "<CTRL>"; - if (_alt) - ret += "<ALT>"; - if (_shift) - ret += "<SHIFT>"; - ret += "<" + _key + ">" + " --> WindowID=" + _windowID.ToString(); - if (_loadParameter.Length > 0) - ret += " LoadParameter=[" + _loadParameter + "]"; - if (_soundEffect.Length > 0) - ret += " SoundEffect=" + _soundEffect; - return ret; + return "ShortCut " + _caption + " " + _keys.ToString() + " " + _destination.ToString(); } + #endregion + + #region Eventi public event PropertyChangedEventHandler PropertyChanged; //Implementazione INotifyPropertyChanged: evento di notifica variazione proprietà #endregion #region Proprietà - public string Caption { get { return this._caption; } set { this._caption = value; this.NotifyPropertyChanged("Caption"); } } - public string Key { get { return this._key; } set { this._key = value; this.NotifyPropertyChanged("Key"); } } - public bool Ctrl { get { return this._ctrl; } set { this._ctrl = value; this.NotifyPropertyChanged("Ctrl"); } } - public bool Alt { get { return this._alt; } set { this._alt = value; this.NotifyPropertyChanged("Alt"); } } - public bool Shift { get { return this._shift; } set { this._shift = value; this.NotifyPropertyChanged("Shift"); } } - public int WindowID { get { return this._destination._windowID; } set { this._destination._windowID = value; this.NotifyPropertyChanged("WindowID"); } } - public string LoadParameter { get { return this._loadParameter; } set { this._loadParameter = value; this.NotifyPropertyChanged("LoadParameter"); } } - public bool Return { get { return this._return; } set { this._return = value; this.NotifyPropertyChanged("Return"); } } - public string SoundEffect { get { return this._soundEffect; } set { this._soundEffect = value; this.NotifyPropertyChanged("SoundEffect"); } } + public bool IsValid { get { return this._keys.IsValid && _destination.IsValid; } } + public string Caption { get { return this._caption; } set { this._caption = value; this.NotifyPropertyChanged("Caption"); } } + public string Key { get { return this._keys.Key; } set { this._keys.Key = value; this.NotifyPropertyChanged("Key"); } } + public bool Ctrl { get { return this._keys.Ctrl; } set { this._keys.Ctrl = value; this.NotifyPropertyChanged("Ctrl"); } } + public bool Alt { get { return this._keys.Alt; } set { this._keys.Alt = value; this.NotifyPropertyChanged("Alt"); } } + public bool Shift { get { return this._keys.Shift; } set { this._keys.Shift = value; this.NotifyPropertyChanged("Shift"); } } + public int WindowID { get { return this._destination.WindowID; } set { this._destination.WindowID = value; this.NotifyPropertyChanged("WindowID"); } } + public string LoadParameter { get { return this._destination.LoadParameter; } set { this._destination.LoadParameter = value; this.NotifyPropertyChanged("LoadParameter"); } } + public bool Return { get { return this._return; } set { this._return = value; this.NotifyPropertyChanged("Return"); } } + public string SoundEffect { get { return this._soundEffect; } set { this._soundEffect = value; this.NotifyPropertyChanged("SoundEffect"); } } #endregion } - - - + internal class ShortCuts //Classe di gestione degli shortcuts configurati { - #region Dati - private readonly string SettingsFile; //File di salvataggio impostazioni - private readonly bool ConfigContext; //Utilizzo nella fase di configurazione (altrimenti plugin in esecuzione) + #region Strutture private struct GeneralSettings //Struttura impostazioni generali { public LockKeys.LockKeyActions ForcingCapsLock; //Tipologia di forzatura Caps-Lock all'avvio public LockKeys.LockKeyActions ForcingNumLock; //Tipologia di forzatura Num-Lock all'avvio } + #endregion + + #region Dati + private readonly string SettingsFile; //File di salvataggio impostazioni + private readonly bool ConfigContext; //Utilizzo nella fase di configurazione (altrimenti plugin in esecuzione) private GeneralSettings _general = new GeneralSettings(); //Impostazioni generali plugin private BindingList<ShortCut> _items = new BindingList<ShortCut>(); //Lista (con associazione dati) degli shortcuts configurati private bool _initialized; //Classe inizializzata @@ -227,7 +295,7 @@ sc.Ctrl = ctrl; sc.Alt = false; sc.Shift = shift; - if (sc.IsValid()) //Se shortcut valido + if (sc.IsValid) //Se shortcut valido _items.Add(sc); //--> aggiunta dello shortcut nella lista } return (_items.Count > 0); @@ -338,7 +406,7 @@ innerNode = node.SelectSingleNode("SoundEffect"); if (innerNode != null) sc.SoundEffect = innerNode.InnerText; - if (sc.IsValid()) //Se shortcut valido + if (sc.IsValid) //Se shortcut valido _items.Add(sc); //--> aggiunta dello shortcut nella lista } if (_items.Count > 0) Modified: trunk/plugins/ShortCuter&SkinEditor/Source/XtremeMenuEditor/XtremeMenuEditor.csproj =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/XtremeMenuEditor/XtremeMenuEditor.csproj 2014-04-27 19:13:03 UTC (rev 4788) +++ trunk/plugins/ShortCuter&SkinEditor/Source/XtremeMenuEditor/XtremeMenuEditor.csproj 2014-04-27 19:40:27 UTC (rev 4789) @@ -6,7 +6,7 @@ <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{350D17A6-0F6B-43C4-898F-33CC68EBCD75}</ProjectGuid> - <OutputType>Library</OutputType> + <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>ProcessPlugins.XtremeMenuEditor</RootNamespace> <AssemblyName>XtremeMenuEditor</AssemblyName> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |