From: <nic...@us...> - 2014-05-09 22:39:16
|
Revision: 4801 http://sourceforge.net/p/mp-plugins/code/4801 Author: nicsergio Date: 2014-05-09 22:39:13 +0000 (Fri, 09 May 2014) Log Message: ----------- Modified Paths: -------------- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-05-09 15:07:50 UTC (rev 4800) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuter.cs 2014-05-09 22:39:13 UTC (rev 4801) @@ -17,7 +17,7 @@ #region Costruttore static ShortCuter() //Costruttore classe ShortCuter { - LogPrefix = Tools.MyAssembly.Title + " - "; //Header per log su file (titolo assembly) + LogPrefix = Tools.MyAssembly.Title + ": "; //Header per log su file (titolo assembly) } #endregion Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-05-09 15:07:50 UTC (rev 4800) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-05-09 22:39:13 UTC (rev 4801) @@ -282,6 +282,15 @@ if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(name)); //--> pubblicazione evento } + private void Play(bool back) //Manda effetto sonoro (da specificare eventuale ritorno a finestra precedente) + { + try + { + if (_soundEffect.Length > 0 && !g_Player.Playing) + Utils.PlaySound(back ? "back.wav" : _soundEffect, false, true); //--> eventuale effetto sonoro + } + catch { } + } #endregion #region Metodi Pubblici @@ -291,13 +300,7 @@ if (_caption.Length > 0 && Log != null) Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Go to shortcut destination, " + this.ToString())); - try - { - if (_soundEffect.Length > 0 && !g_Player.Playing) - Utils.PlaySound(_soundEffect, false, true); //--> eventuale effetto sonoro - } - catch { } - + Play(); //--> eventuale effetto sonoro return _destination.Go(Log); //--> visualizzazione finestra di destinazione } public bool GoPrevious() { return GoPrevious(null); } //Ritorno alla finestra precedente (senza log) @@ -306,15 +309,10 @@ if (_caption.Length > 0 && Log != null) Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Go to previous window")); - try - { - if (_soundEffect.Length > 0 && !g_Player.Playing) - Utils.PlaySound("back.wav", false, true); //--> eventuale effetto sonoro - } - catch { } - + Play(true); //--> eventuale effetto sonoro return _destination.GoPrevious(Log); //--> visualizzazione finestra precedente } + public void Play() { Play(false); } //Manda effetto sonoro dello shortcut public ShortCut Clone() //Clonazione shortcut { ShortCut sc = new ShortCut(); @@ -353,92 +351,249 @@ public string SoundEffect { get { return this._soundEffect; } set { this._soundEffect = value; this.NotifyPropertyChanged("SoundEffect"); } } #endregion } - - internal class Window //Classe finestra di MediaPortal + internal class ShortCuts //Classe di gestione degli shortcuts configurati { - #region Dati - private string _caption; //Titolo finestra - private int _windowID; //Id finestra - private string _xmlFile; //Nome del file xml corrispondente - #endregion + #region Classi + public class GeneralSettings //Sotto-classe di gestione impostazioni generali + { + #region Dati + private LockKeys.LockKeyActions _forcingCapsLock; //Tipologia di forzatura Caps-Lock all'avvio + private LockKeys.LockKeyActions _forcingNumLock; //Tipologia di forzatura Num-Lock all'avvio + #endregion - #region Costruttore - public Window() //Costruttore classe Window + #region Costruttore + public GeneralSettings() //Costruttore classe GeneralSettings + { + _forcingCapsLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Caps-Lock + _forcingNumLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Num-Lock + } + #endregion + + #region Proprietà + public LockKeys.LockKeyActions ForcingCapsLock { get { return this._forcingCapsLock; } set { this._forcingCapsLock = value; } } + public LockKeys.LockKeyActions ForcingNumLock { get { return this._forcingNumLock; } set { this._forcingNumLock = value; } } + #endregion + } + public class SkinNavigator //Sotto-classe di gestione Skin Navigator { - _caption = ""; //--> inizializzazione titolo - _windowID = 0; //--> inizializzazione Id finestra - _xmlFile = ""; //--> inizializzazione nome file xml - } - #endregion + #region Classi + public class Item //Sotto-classe elemento per navigazione + { + #region Classi + public class Window //Sotto-classe finestra di abilitazione alla navigazione + { + #region Dati + private string _caption; //Titolo finestra + private int _windowID; //Id finestra + #endregion - #region Metodi Pubblici - public override string ToString() { return (_caption); } //Override metodo ToString per riempire classi ListControl - #endregion + #region Costruttore + public Window() //Costruttore classe Window + { + _caption = ""; //--> inizializzazione titolo + _windowID = 0; //--> inizializzazione Id finestra + } + #endregion - #region Proprietà - public string Caption { get { return this._caption; } set { this._caption = value; } } - public int WindowID { get { return this._windowID; } set { this._windowID = value; } } - public string XmlFile { get { return this._xmlFile; } set { this._xmlFile = value; } } - #endregion - } - internal class NavItem //Classe elemento per navigazione - { - #region Dati - private string _caption; //Titolo link - private BindingList<Window> _windows = new BindingList<Window>(); - private BindingList<WindowLink> _destinations = new BindingList<WindowLink>(); - #endregion + #region Metodi Pubblici + public override string ToString() { return (_caption); } //Override metodo ToString per riempire classi ListControl + #endregion - #region Costruttore - public NavItem() //Costruttore classe Window - { - _caption = "Navigator Group"; //--> inizializzazione titolo - } - #endregion + #region Proprietà + public string Caption { get { return this._caption; } set { this._caption = value; } } + public int WindowID { get { return this._windowID; } set { this._windowID = value; } } + #endregion + } + public class Destination : WindowLink //Sotto-classe destinazione di navigazione + { + #region Dati + private bool _force; //Forzatura destinazione + #endregion - #region Proprietà - public string Caption { get { return this._caption; } set { this._caption = value; } } - public BindingList<Window> Windows { get { return this._windows; } } - public BindingList<WindowLink> Destinations { get { return this._destinations; } } - #endregion - } + #region Costruttore + public Destination() : base() //Costruttore classe Destination + { + _force = false; //--> inizializzazione forzatura destinazione + } + #endregion - internal class ShortCuts //Classe di gestione degli shortcuts configurati - { - #region Strutture - - public 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 + #region Metodi Pubblici + public override string ToString() { return (base.Caption); } //Override metodo ToString per riempire classi ListControl + #endregion + + #region Proprietà + public bool Force { get { return this._force; } set { this._force = value; } } + #endregion + } + #endregion + + #region Dati + private string _caption; //Titolo elemento di navigazione + private BindingList<Window> _windows; //Lista (con associazione dati) delle finestre di abilitazione alle destinazioni + private BindingList<Destination> _destinations; //Lista (con associazione dati) delle destinazioni + #endregion + + #region Costruttore + public Item() //Costruttore classe Item + { + _caption = "Navigator Group"; //--> inizializzazione titolo + _windows = new BindingList<Window>(); //--> istanziazione finestre di abilitazione alle destinazioni + _destinations = new BindingList<Destination>(); //--> istanziazione destinazioni + } + #endregion + + #region Proprietà + public string Caption { get { return this._caption; } set { this._caption = value; } } + public BindingList<Window> Windows { get { return this._windows; } } + public BindingList<Destination> Destinations { get { return this._destinations; } } + #endregion + } + #endregion + + #region Dati + private string _menuHeader; //Titolo menu di navigazione + private bool _showSeparator; //Visualizzazione separatore gruppi di destinazioni + private string _separator; //Eventuale separatore da visualizzare + private bool _removeDuplicates; //Rimozione destinazioni duplicate + private BindingList<Item> _items; //Lista (con associazione dati) elementi di navigazione + #endregion + + #region Costruttore + public SkinNavigator() //Costruttore classe NavigatorSettings + { + _menuHeader = "Skin Navigator"; //--> titolo menu di navigazione + _showSeparator = true; //--> visualizzazione separatore attiva + _separator = "-- -- -- -- -- --"; //--> separatore da visualizzare + _removeDuplicates = true; //--> rimozione di destinazioni duplicate + _items = new BindingList<Item>(); //--> istanziazione lista elementi di navigazione + + + + Item iii1 = new Item(); + Item.Destination ddd1 = new Item.Destination(); + iii1.Caption = "www"; + ddd1.Caption = "Home"; + ddd1.WindowID = 35; + iii1.Destinations.Add(ddd1); + Item.Destination ddd2 = new Item.Destination(); + ddd2.Caption = "Movie"; + ddd2.WindowID =96742; + iii1.Destinations.Add(ddd2); + _items.Add(iii1); + + Item.Window www = new Item.Window(); + www.WindowID = 1; + Item iii2 = new Item(); + iii2.Caption = "www"; + iii2.Windows.Add(www); + Item.Destination ddd3 = new Item.Destination(); + ddd3.Caption = "Music"; + ddd3.WindowID = 501; + iii2.Destinations.Add(ddd3); + _items.Add(iii2); + + + + } + #endregion + + #region Metodi Pubblici + public WindowLink Go(LogEventHandler Log) //Gestione finestra di dialogo e navigazione alla destinazione selezionata + { + if (Log != null) + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Request Skin Navigator dialog menu")); + + try + { + int actWindowID = (int)GUIWindowManager.ActiveWindow; //--> id finestra attuale + GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); + dlgMenu.Reset(); + dlgMenu.SetHeading(_menuHeader); //--> titolo menu + dlgMenu.ShowQuickNumbers = false; + + List<WindowLink> dlgLinks = new List<WindowLink>(); //--> lista links corrispondenti agli elementi di menu + foreach (Item item in _items) //Iterazione per valutazione elementi di navigazione impostati + { + if (item.Windows.Count == 0 || item.Windows.ToList().Find(x => x.WindowID == actWindowID) != null) + { //Controllo se finestra attuale contenuta nel gruppo di finestre di abilitazione destinazioni + bool first = true; + foreach (Item.Destination dst in item.Destinations) //Iterazione di aggiunta destinazioni + { + if ((dlgLinks.Find(x => x.WindowID == dst.WindowID && x.LoadParameter == dst.LoadParameter) == null || !_removeDuplicates) && (dst.WindowID != actWindowID || dst.Force)) + { //Controllo destinazione duplicata o corrispondente a finestra attuale + if (_showSeparator && first && dlgLinks.Count > 0) //Eventuale inserzione separatore destinazioni + { + dlgMenu.Add(_separator); + dlgLinks.Add(null); + } + dlgMenu.Add(dst.Caption); //--> aggiunta voce di menu + + WindowLink lnk = new WindowLink(); + lnk.WindowID = dst.WindowID; + lnk.Caption = dst.Caption; + lnk.LoadParameter = dst.LoadParameter; + dlgLinks.Add(lnk); //--> aggiunta destinazione corrispondente + first = false; + } + } + } + } + + if (dlgLinks.Count > 0) //Se selezionabile almeno una destinazione + { + dlgMenu.DoModal(actWindowID); //--> visualizzazione menu + if (dlgMenu.SelectedLabel >= 0 && dlgMenu.SelectedLabel < dlgLinks.Count && dlgLinks[dlgMenu.SelectedLabel] != null) + { + if (dlgLinks[dlgMenu.SelectedLabel].Go(Log)) //--> attivazione destinazione selezionata + return dlgLinks[dlgMenu.SelectedLabel]; //--> ritorno destinazione attivata + } + else + if (Log != null) + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "No links selected from Skin Navigator dialog menu, WindowID=" + actWindowID)); + } + else + if (Log != null) + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "No links found for Skin Navigator, WindowID=" + actWindowID)); + return null; + } + catch (Exception e) + { + if (Log != null) + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Error, "Error opening Skin Navigator dialog menu", e)); + return null; + } + } + #endregion + + #region Proprietà + public string MenuHeader { get { return this._menuHeader; } set { this._menuHeader = value; } } + public bool ShowSeparator { get { return this._showSeparator; } set { this._showSeparator = value; } } + public string Separator { get { return this._separator; } set { this._separator = value; } } + public bool RemoveDuplicates { get { return this._removeDuplicates; } set { this._removeDuplicates = value; } } + public BindingList<Item> Items { get { return this._items; } } + #endregion } - public struct NavigatorSettings - { - public string Header ; //Tipologia di forzatura Caps-Lock all'avvio - public bool ShowSeparator; //Tipologia di forzatura Num-Lock all'avvio - public string Separator; - public bool RemoveDuplicates; - } #endregion #region Dati private readonly string SettingsFile; //File di salvataggio impostazioni - private GeneralSettings _general = new GeneralSettings(); //Impostazioni generali plugin - private BindingList<ShortCut> _items = new BindingList<ShortCut>(); //Lista (con associazione dati) degli shortcuts configurati - private BindingList<NavItem> _navItems = new BindingList<NavItem>(); - private bool _initialized; //Classe inizializzata - - private WindowLink lastDestination = new WindowLink(); //Dati ultima destinazione attivata dal plugin - + private GeneralSettings _general; //Impostazioni generali + private BindingList<ShortCut> _items; //Lista (con associazione dati) degli shortcuts configurati + private SkinNavigator _navigator; //Skin Navigator + private bool _initialized; //Classe inizializzata + private WindowLink lastDestination; //Dati ultima destinazione attivata #endregion #region Costruttore public ShortCuts(string settingsFile) //Costruttore classe ShortCuts { SettingsFile = settingsFile; //--> percorso & nome file delle impostazioni - _general.ForcingCapsLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Caps-Lock - _general.ForcingNumLock = LockKeys.LockKeyActions.None; //--> default: nessuna modifica stato Num-Lock + _general = new GeneralSettings(); //--> istanziazione impostazioni generali + _items = new BindingList<ShortCut>(); //--> istanziazione lista shortcuts + _navigator = new SkinNavigator(); //--> istanziazione Skin Navigator _initialized = false; //--> reset classe inizializzata + + lastDestination = new WindowLink(); //--> istanziazione ultima destinazione attivata dal plugin lastDestination.Caption = "Last destination"; //--> titolo ultima destinazione lastDestination.Reset(); //--> reset ultima destinazione attivata dal plugin } @@ -507,62 +662,6 @@ else return false; //--> finestra attuale non corrispondente a destinazione shortcut } - private void Navigation() //Gestione finestra di dialogo e navigazione alla destinazione selezionata - { - if (Log != null) - Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Request Skin Navigator dialog menu")); - - try - { - int actWindowID = (int)GUIWindowManager.ActiveWindow; - GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); - dlgMenu.Reset(); - dlgMenu.SetHeading("Skin Navigator"); - dlgMenu.ShowQuickNumbers = false; - - List<WindowLink> dlgLinks = new List<WindowLink>(); - foreach (NavItem item in _navItems) //Iterazione per memorizzazione impostazioni shortcuts - { - if ((item.Windows.First(x => x.WindowID == actWindowID)) != null || item.Windows.Count == 0) - { - bool first = true; - foreach (WindowLink link in item.Destinations) //Iterazione per memorizzazione impostazioni shortcuts - { - if (first && dlgLinks.Count > 0) - { - dlgMenu.Add("---- ----"); - dlgLinks.Add(null); - first = false; - } - dlgMenu.Add(link.Caption); - dlgLinks.Add(link); - } - } - } - - if (dlgLinks.Count > 0) - { - dlgMenu.DoModal(actWindowID); - if (dlgMenu.SelectedLabel >= 0 && dlgMenu.SelectedLabel < dlgLinks.Count) - if (dlgLinks[dlgMenu.SelectedLabel].Go(Log)) - { - lastDestination.WindowID = dlgLinks[dlgMenu.SelectedLabel].WindowID; - lastDestination.LoadParameter = dlgLinks[dlgMenu.SelectedLabel].LoadParameter; - } - else - if (Log != null) - Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "No links selected from Skin Navigator dialog menu, ID = " + actWindowID)); - } - else - if (Log != null) - Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "No links found for Skin Navigator, window ID = " + actWindowID)); - } - catch (Exception e) - { - if (Log != null) - Log(this, new LogEventArgs(LogEventArgs.LogLevels.Error, "Error opening Skin Navigator dialog menu", e)); - } - } #endregion #region Metodi Pubblici @@ -755,10 +854,21 @@ { List<ShortCut> scList = GetShortCutsGroup(k); //--> raccolta lista shortcut associati alla combinazione di tasti attuale if (scList != null && scList.Count > 0) //Se trovato almeno uno shortcut - if (scList.Find(x => x.IsNavigator) != null) //Se combinazione di tasti corrispondente a Skin Navigator - Navigation(); //--> gestione navigazione alla destinazione selezionata + { + ShortCut sc = scList.Find(x => x.IsNavigator); //Ricerca eventuali corrispondenze a Skin Navigator + if (sc != null) //Se combinazione di tasti corrispondente a Skin Navigator + { + sc.Play(); //--> eventuale effetto sonoro + WindowLink dst = Navigator.Go(Log); //--> gestione navigazione alla destinazione selezionata + if (dst != null) //Se attivata correttamente una destinazione + { + lastDestination.WindowID = dst.WindowID; //--> memorizzazione id finestra + lastDestination.LoadParameter = dst.LoadParameter; //--> memorizzazione parametri di caricamento utilizzati + } + } else //Shortcuts normali if (scList.Count == 1) //Shortcut a destinazione singola + { if (scList[0].Return && AlreadyAtDestination(scList[0])) //Se impostato flag di ritorno e finestra attuale corrispondente a destinazione scList[0].GoPrevious(Log); //--> visualizzazione finestra precedente else @@ -767,6 +877,7 @@ lastDestination.WindowID = scList[0].WindowID; //--> memorizzazione id finestra lastDestination.LoadParameter = scList[0].LoadParameter; //--> memorizzazione parametri di caricamento utilizzati } + } else //Shortcut a destinazione multipla (ciclico) { int scIndex = 0; @@ -784,6 +895,7 @@ lastDestination.LoadParameter = scList[scIndex].LoadParameter; //--> memorizzazione parametri di caricamento utilizzati } } + } else //Combinazione di tasti non corrispondente a nessuno shortcut if (Log != null) Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Key not mapped: " + k.ToString())); @@ -801,13 +913,10 @@ #endregion #region Proprietà - public bool Initialized { get { return this._initialized; } } - - public GeneralSettings General { get { return this._general; } set { this._general = value; } } - - //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; } } + public bool Initialized { get { return this._initialized; } } + public GeneralSettings General { get { return this._general; } } + public BindingList<ShortCut> Items { get { return this._items; } } + public SkinNavigator Navigator { get { return this._navigator; } } #endregion } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |