From: <nic...@us...> - 2014-05-18 16:40:14
|
Revision: 4806 http://sourceforge.net/p/mp-plugins/code/4806 Author: nicsergio Date: 2014-05-18 16:40:08 +0000 (Sun, 18 May 2014) Log Message: ----------- Modified Paths: -------------- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultNavigatorConfig.xml trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultNavigatorConfig.xml =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultNavigatorConfig.xml 2014-05-16 13:19:01 UTC (rev 4805) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/Resources/XmlFiles/DefaultNavigatorConfig.xml 2014-05-18 16:40:08 UTC (rev 4806) @@ -3,8 +3,7 @@ <General> <MenuHeader>Skin Navigator</MenuHeader> <ShowSeparator>1</ShowSeparator> - <Separator>1</Separator> - <ShowSeparator>--------------------------------</ShowSeparator> + <Separator>--------------------------------</Separator> <ShowNumbers>1</ShowNumbers> <RemoveDuplicates>1</RemoveDuplicates> </General> Modified: trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs =================================================================== --- trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-05-16 13:19:01 UTC (rev 4805) +++ trunk/plugins/ShortCuter&SkinEditor/Source/ShortCuter/ShortCuts.cs 2014-05-18 16:40:08 UTC (rev 4806) @@ -461,9 +461,9 @@ #endregion #region Proprietà - public new bool IsValid { get { return (base.IsValid && !base.IsNavigator); } } - private new bool IsNavigator { get { return false; } } - public bool Force { get { return this._force; } set { this._force = value; } } + public new bool IsValid { get { return (base.IsValid && !base.IsNavigator); } } + public new bool IsNavigator { get { return false; } } + public bool Force { get { return this._force; } set { this._force = value; } } #endregion } #endregion @@ -508,97 +508,109 @@ #endregion #region Metodi Pubblici + public bool LoadConfig() { return LoadConfig(string.Empty); } //Caricamento configurazione predefinita public bool LoadConfig(string settingsFile) //Caricamento configurazione { _items.Clear(); //--> pulizia lista elementi di navigazione + string nodeHeader; FileStream userConfig = null; try { XmlDocument xmlFile = new XmlDocument(); - if (settingsFile.Length>0) + if (settingsFile.Length > 0) { userConfig = new FileStream(settingsFile, FileMode.Open, FileAccess.Read); xmlFile.Load(userConfig); //Lettura file xml delle ultime impostazioni userConfig.Close(); //--> chiusura file + nodeHeader = "/ShortCuter/Navigator/"; } else + { using (Stream defaultConfig = Assembly.GetExecutingAssembly().GetManifestResourceStream("ProcessPlugins.ShortCuter.Resources.XmlFiles.DefaultNavigatorConfig.xml")) { xmlFile.Load(defaultConfig); //Configurazione predefinita --> lettura file xml incapsulato } + nodeHeader = "/Navigator/"; + } - XmlNode innerNode; - XmlNode generalNode = xmlFile.DocumentElement.SelectSingleNode("/ShortCuter/Navigator/General"); + XmlNode generalNode = xmlFile.DocumentElement.SelectSingleNode(nodeHeader + "General"); if (generalNode != null) //Se presente sezione "General" { - innerNode = generalNode.SelectSingleNode("ForcingCapsLock"); + innerNode = generalNode.SelectSingleNode("MenuHeader"); if (innerNode != null) - _general.ForcingCapsLock = (LockKeys.LockKeyActions)Enum.Parse(typeof(LockKeys.LockKeyActions), innerNode.InnerText); - else + _general.MenuHeader = innerNode.InnerText; + innerNode = generalNode.SelectSingleNode("ShowSeparator"); + if (innerNode != null) + _general.ShowSeparator = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); + innerNode = generalNode.SelectSingleNode("Separator"); + if (innerNode != null) + _general.Separator = innerNode.InnerText; + innerNode = generalNode.SelectSingleNode("ShowNumbers"); + if (innerNode != null) + _general.ShowNumbers = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); + innerNode = generalNode.SelectSingleNode("RemoveDuplicates"); + if (innerNode != null) + _general.RemoveDuplicates = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); + } + else + { + if (settingsFile.Length > 0) { - innerNode = generalNode.SelectSingleNode("ResetCapsLock"); //Necessario per compatibilità con file di configurazione V2.0.5 - if (innerNode != null && Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText))) - _general.ForcingCapsLock = LockKeys.LockKeyActions.Off; + if (Log != null) //Se impostazioni non trovate --> si carica la configurazione predefinita + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Debug, "Navigator settings not found: default config will be loaded..")); + return LoadConfig(); //--> caricamento configurazione predefinita } - innerNode = generalNode.SelectSingleNode("ForcingNumLock"); - if (innerNode != null) - _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 - if (innerNode != null && Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText))) - _general.ForcingNumLock = LockKeys.LockKeyActions.Off; + if (Log != null) //Se impostazioni non trovate nella configurazione predefinita + Log(this, new LogEventArgs(LogEventArgs.LogLevels.Info, "Navigator settings not found loading DefaultNavigatorConfig.xml.")); + return false; } } - else - return false; //--> altrimenti configurazione non presente - XmlNodeList nodeList = xmlFile.DocumentElement.SelectNodes("/ShortCuter/Items/Item"); - foreach (XmlNode node in nodeList) //Iterazione per memorizzazione impostazioni shortcuts + + XmlNodeList nodeList = xmlFile.DocumentElement.SelectNodes(nodeHeader + "Items/Item"); + foreach (XmlNode node in nodeList) //Iterazione per memorizzazione elementi di navigazione { - ShortCut sc = new ShortCut(); + Item navItem = new Item(); innerNode = node.SelectSingleNode("Caption"); if (innerNode != null) - sc.Caption = innerNode.InnerText; - innerNode = node.SelectSingleNode("Key"); - if (innerNode != null) - sc.Key = innerNode.InnerText; - innerNode = node.SelectSingleNode("Ctrl"); - if (innerNode != null) - sc.Ctrl = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); - innerNode = node.SelectSingleNode("Alt"); - if (innerNode != null) - sc.Alt = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); - innerNode = node.SelectSingleNode("Shift"); - if (innerNode != null) - sc.Shift = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); - innerNode = node.SelectSingleNode("WindowID"); - if (innerNode != null) - sc.WindowID = Convert.ToInt32(innerNode.InnerText); - else + navItem.Caption = innerNode.InnerText; + XmlNodeList wndList = node.SelectNodes("Windows/Window"); + foreach (XmlNode wndNode in wndList) //Iterazione per memorizzazione finestre di abilitazione alle destinazioni { - innerNode = node.SelectSingleNode("Hyperlink"); //Necessario per compatibilità con file di configurazione V2.0.0 + Item.Window wnd = new Item.Window(); + innerNode = wndNode.SelectSingleNode("Caption"); if (innerNode != null) - sc.WindowID = Convert.ToInt32(innerNode.InnerText); + wnd.Caption = innerNode.InnerText; + innerNode = wndNode.SelectSingleNode("WindowID"); + if (innerNode != null) + wnd.WindowID = Convert.ToInt32(innerNode.InnerText); + navItem.Windows.Add(wnd); //--> } - innerNode = node.SelectSingleNode("LoadParameter"); - if (innerNode != null) - sc.LoadParameter = innerNode.InnerText; - else + XmlNodeList dstList = node.SelectNodes("Destinations/Destination"); + foreach (XmlNode dstNode in dstList) //Iterazione per memorizzazione destinazioni { - innerNode = node.SelectSingleNode("HyperlinkParameter"); //Necessario per compatibilità con file di configurazione V2.0.0 + Item.Destination dst = new Item.Destination(); + innerNode = dstNode.SelectSingleNode("Caption"); if (innerNode != null) - sc.LoadParameter = innerNode.InnerText; + dst.Caption = innerNode.InnerText; + innerNode = dstNode.SelectSingleNode("WindowID"); + if (innerNode != null) + dst.WindowID = Convert.ToInt32(innerNode.InnerText); + innerNode = dstNode.SelectSingleNode("LoadParameter"); + if (innerNode != null) + dst.LoadParameter = innerNode.InnerText; + innerNode = dstNode.SelectSingleNode("Force"); + if (innerNode != null) + dst.Force = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); + if (dst.IsValid) + navItem.Destinations.Add(dst); } - innerNode = node.SelectSingleNode("Return"); - if (innerNode != null) - sc.Return = Convert.ToBoolean(Convert.ToInt16(innerNode.InnerText)); - innerNode = node.SelectSingleNode("SoundEffect"); - if (innerNode != null) - sc.SoundEffect = innerNode.InnerText; - if (sc.IsValid) //Se shortcut valido - _items.Add(sc); //--> aggiunta dello shortcut nella lista + _items.Add(navItem); //--> aggiunta elemento di navigazione } + + if (_items.Count > 0) return true; //--> lettura configurazione effettuata else @@ -884,7 +896,10 @@ _items.Add(sc); //--> aggiunta dello shortcut nella lista } if (_items.Count > 0) + { + _navigator.LoadConfig(defaultSettings ? null : SettingsFile); //--> caricamento configurazione Skin Navigator return true; //--> lettura configurazione effettuata + } else { if (defaultSettings && Log != null) //Se nessun shortcut trovato nella configurazione predefinita: emissione messaggio This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |