@@ -17,10 +17,14 @@ public static ApplicationSettings Read(string fileName, string languageFileName)
1717 var document = XDocument . Load ( fileName ) ;
1818 var languageDocument = XDocument . Load ( languageFileName ) ;
1919
20- settings . ExcludedProcessNames = document
20+ settings . ExcludedProcessItems = document
2121 . XPathSelectElements ( "/smartSystemMenu/processExclusions/processName" )
2222 . Where ( x => ! string . IsNullOrWhiteSpace ( x . Value ) )
23- . Select ( x => x . Value . ToLower ( ) )
23+ . Select ( x => new ExcludedProcessItem
24+ {
25+ Name = x . Value . ToLower ( ) ,
26+ IgnoreHook = x . Attribute ( "ignoreHook" ) != null && x . Attribute ( "ignoreHook" ) . Value . ToLower ( ) == "true" ,
27+ } )
2428 . ToList ( ) ;
2529
2630 settings . InitEventProcessNames = document
@@ -39,7 +43,7 @@ public static ApplicationSettings Read(string fileName, string languageFileName)
3943 . XPathSelectElements ( "/smartSystemMenu/menuItems/windowSizeItems/item" )
4044 . Select ( x => new WindowSizeMenuItem
4145 {
42- Title = x . Attribute ( "title" ) != null ? x . Attribute ( "title" ) . Value : "" ,
46+ Title = x . Attribute ( "title" ) != null ? x . Attribute ( "title" ) . Value : string . Empty ,
4347 Left = ! string . IsNullOrEmpty ( x . Attribute ( "left" ) . Value ) ? int . Parse ( x . Attribute ( "left" ) . Value ) : null ,
4448 Top = ! string . IsNullOrEmpty ( x . Attribute ( "top" ) . Value ) ? int . Parse ( x . Attribute ( "top" ) . Value ) : null ,
4549 Width = ! string . IsNullOrEmpty ( x . Attribute ( "width" ) . Value ) ? int . Parse ( x . Attribute ( "width" ) . Value ) : null ,
@@ -54,11 +58,11 @@ public static ApplicationSettings Read(string fileName, string languageFileName)
5458 . XPathSelectElements ( "/smartSystemMenu/menuItems/startProgramItems/item" )
5559 . Select ( x => new StartProgramMenuItem
5660 {
57- Title = x . Attribute ( "title" ) != null ? x . Attribute ( "title" ) . Value : "" ,
58- FileName = x . Attribute ( "fileName" ) != null ? x . Attribute ( "fileName" ) . Value : "" ,
59- Arguments = x . Attribute ( "arguments" ) != null ? x . Attribute ( "arguments" ) . Value : "" ,
60- BeginParameter = x . Attribute ( "beginParameter" ) != null ? x . Attribute ( "beginParameter" ) . Value : "" ,
61- EndParameter = x . Attribute ( "endParameter" ) != null ? x . Attribute ( "endParameter" ) . Value : "" ,
61+ Title = x . Attribute ( "title" ) != null ? x . Attribute ( "title" ) . Value : string . Empty ,
62+ FileName = x . Attribute ( "fileName" ) != null ? x . Attribute ( "fileName" ) . Value : string . Empty ,
63+ Arguments = x . Attribute ( "arguments" ) != null ? x . Attribute ( "arguments" ) . Value : string . Empty ,
64+ BeginParameter = x . Attribute ( "beginParameter" ) != null ? x . Attribute ( "beginParameter" ) . Value : string . Empty ,
65+ EndParameter = x . Attribute ( "endParameter" ) != null ? x . Attribute ( "endParameter" ) . Value : string . Empty ,
6266 RunAs = x . Attribute ( "runAs" ) != null && ! string . IsNullOrEmpty ( x . Attribute ( "runAs" ) . Value ) ? ( UserType ) Enum . Parse ( typeof ( UserType ) , x . Attribute ( "runAs" ) . Value , true ) : UserType . Normal ,
6367 ShowWindow = x . Attribute ( "showWindow" ) == null || string . IsNullOrEmpty ( x . Attribute ( "showWindow" ) . Value ) || x . Attribute ( "showWindow" ) . Value . ToLower ( ) == "true" ,
6468 UseWindowWorkingDirectory = x . Attribute ( "useWindowWorkingDirectory" ) != null && ! string . IsNullOrEmpty ( x . Attribute ( "useWindowWorkingDirectory" ) . Value ) && x . Attribute ( "useWindowWorkingDirectory" ) . Value . ToLower ( ) == "true"
@@ -70,7 +74,7 @@ public static ApplicationSettings Read(string fileName, string languageFileName)
7074 . Select ( x => {
7175 var menuItem = new MenuItem
7276 {
73- Name = x . Attribute ( "name" ) != null ? x . Attribute ( "name" ) . Value : "" ,
77+ Name = x . Attribute ( "name" ) != null ? x . Attribute ( "name" ) . Value : string . Empty ,
7478 Show = x . Attribute ( "show" ) != null ? x . Attribute ( "show" ) . Value . ToLower ( ) != "false" : true ,
7579 Type = x . Attribute ( "type" ) != null && ! string . IsNullOrEmpty ( x . Attribute ( "type" ) . Value ) ? ( MenuItemType ) Enum . Parse ( typeof ( MenuItemType ) , x . Attribute ( "type" ) . Value , true ) : MenuItemType . Item ,
7680 Key1 = x . Attribute ( "key1" ) != null && ! string . IsNullOrEmpty ( x . Attribute ( "key1" ) . Value ) ? ( VirtualKeyModifier ) int . Parse ( x . Attribute ( "key1" ) . Value ) : VirtualKeyModifier . None ,
@@ -81,7 +85,7 @@ public static ApplicationSettings Read(string fileName, string languageFileName)
8185 x . XPathSelectElements ( "./items/item" )
8286 . Select ( y => new MenuItem
8387 {
84- Name = y . Attribute ( "name" ) != null ? y . Attribute ( "name" ) . Value : "" ,
88+ Name = y . Attribute ( "name" ) != null ? y . Attribute ( "name" ) . Value : string . Empty ,
8589 Show = y . Attribute ( "show" ) != null ? y . Attribute ( "show" ) . Value . ToLower ( ) != "false" : true ,
8690 Type = y . Attribute ( "type" ) != null && ! string . IsNullOrEmpty ( y . Attribute ( "type" ) . Value ) ? ( MenuItemType ) Enum . Parse ( typeof ( MenuItemType ) , y . Attribute ( "type" ) . Value , true ) : MenuItemType . Item ,
8791 Key1 = y . Attribute ( "key1" ) != null && ! string . IsNullOrEmpty ( y . Attribute ( "key1" ) . Value ) ? ( VirtualKeyModifier ) int . Parse ( y . Attribute ( "key1" ) . Value ) : VirtualKeyModifier . None ,
@@ -168,34 +172,35 @@ public static void Save(string fileName, ApplicationSettings settings)
168172 {
169173 var document = new XDocument ( ) ;
170174 document . Add ( new XElement ( "smartSystemMenu" ,
171- new XElement ( "processExclusions" , settings . ExcludedProcessNames . Select ( x => new XElement ( "processName" , x ) ) ) ,
175+ new XElement ( "processExclusions" , settings . ExcludedProcessItems . Select ( x => new XElement ( "processName" ,
176+ x . IgnoreHook ? new XAttribute ( "ignoreHook" , x . IgnoreHook . ToString ( ) . ToLower ( ) ) : null , x . Name ) ) ) ,
172177 new XElement ( "createMenuOnInitEvent" , settings . InitEventProcessNames . Select ( x => new XElement ( "processName" , x ) ) ) ,
173178 new XElement ( "noRestoreMenuOnExit" , settings . NoRestoreMenuProcessNames . Select ( x => new XElement ( "processName" , x ) ) ) ,
174179 new XElement ( "menuItems" ,
175180 new XElement ( "items" , settings . MenuItems . Items . Select ( x => new XElement ( "item" ,
176181 new XAttribute ( "type" , x . Type . ToString ( ) ) ,
177182 x . Type == MenuItemType . Item || x . Type == MenuItemType . Group ? new XAttribute ( "name" , x . Name ) : null ,
178183 x . Show == false ? new XAttribute ( "show" , x . Show . ToString ( ) . ToLower ( ) ) : null ,
179- x . Type == MenuItemType . Item ? new XAttribute ( "key1" , x . Key1 == VirtualKeyModifier . None ? "" : ( ( int ) x . Key1 ) . ToString ( ) ) : null ,
180- x . Type == MenuItemType . Item ? new XAttribute ( "key2" , x . Key2 == VirtualKeyModifier . None ? "" : ( ( int ) x . Key2 ) . ToString ( ) ) : null ,
181- x . Type == MenuItemType . Item ? new XAttribute ( "key3" , x . Key3 == VirtualKey . None ? "" : ( ( int ) x . Key3 ) . ToString ( ) ) : null ,
184+ x . Type == MenuItemType . Item ? new XAttribute ( "key1" , x . Key1 == VirtualKeyModifier . None ? string . Empty : ( ( int ) x . Key1 ) . ToString ( ) ) : null ,
185+ x . Type == MenuItemType . Item ? new XAttribute ( "key2" , x . Key2 == VirtualKeyModifier . None ? string . Empty : ( ( int ) x . Key2 ) . ToString ( ) ) : null ,
186+ x . Type == MenuItemType . Item ? new XAttribute ( "key3" , x . Key3 == VirtualKey . None ? string . Empty : ( ( int ) x . Key3 ) . ToString ( ) ) : null ,
182187 x . Items . Any ( ) ?
183188 new XElement ( "items" , x . Items . Select ( y => new XElement ( "item" ,
184189 new XAttribute ( "type" , y . Type . ToString ( ) ) ,
185190 y . Type == MenuItemType . Item || y . Type == MenuItemType . Group ? new XAttribute ( "name" , y . Name ) : null ,
186191 y . Show == false ? new XAttribute ( "show" , y . Show . ToString ( ) . ToLower ( ) ) : null ,
187- y . Type == MenuItemType . Item ? new XAttribute ( "key1" , y . Key1 == VirtualKeyModifier . None ? "" : ( ( int ) y . Key1 ) . ToString ( ) ) : null ,
188- y . Type == MenuItemType . Item ? new XAttribute ( "key2" , y . Key2 == VirtualKeyModifier . None ? "" : ( ( int ) y . Key2 ) . ToString ( ) ) : null ,
189- y . Type == MenuItemType . Item ? new XAttribute ( "key3" , y . Key3 == VirtualKey . None ? "" : ( ( int ) y . Key3 ) . ToString ( ) ) : null ) ) ) : null ) ) ) ,
192+ y . Type == MenuItemType . Item ? new XAttribute ( "key1" , y . Key1 == VirtualKeyModifier . None ? string . Empty : ( ( int ) y . Key1 ) . ToString ( ) ) : null ,
193+ y . Type == MenuItemType . Item ? new XAttribute ( "key2" , y . Key2 == VirtualKeyModifier . None ? string . Empty : ( ( int ) y . Key2 ) . ToString ( ) ) : null ,
194+ y . Type == MenuItemType . Item ? new XAttribute ( "key3" , y . Key3 == VirtualKey . None ? string . Empty : ( ( int ) y . Key3 ) . ToString ( ) ) : null ) ) ) : null ) ) ) ,
190195 new XElement ( "windowSizeItems" , settings . MenuItems . WindowSizeItems . Select ( x => new XElement ( "item" ,
191196 new XAttribute ( "title" , x . Title ) ,
192- new XAttribute ( "left" , x . Left == null ? "" : x . Left . Value . ToString ( ) ) ,
193- new XAttribute ( "top" , x . Top == null ? "" : x . Top . Value . ToString ( ) ) ,
194- new XAttribute ( "width" , x . Width == null ? "" : x . Width . ToString ( ) ) ,
195- new XAttribute ( "height" , x . Height == null ? "" : x . Height . ToString ( ) ) ,
196- new XAttribute ( "key1" , x . Key1 == VirtualKeyModifier . None ? "" : ( ( int ) x . Key1 ) . ToString ( ) ) ,
197- new XAttribute ( "key2" , x . Key2 == VirtualKeyModifier . None ? "" : ( ( int ) x . Key2 ) . ToString ( ) ) ,
198- new XAttribute ( "key3" , x . Key3 == VirtualKey . None ? "" : ( ( int ) x . Key3 ) . ToString ( ) ) ) ) ) ,
197+ new XAttribute ( "left" , x . Left == null ? string . Empty : x . Left . Value . ToString ( ) ) ,
198+ new XAttribute ( "top" , x . Top == null ? string . Empty : x . Top . Value . ToString ( ) ) ,
199+ new XAttribute ( "width" , x . Width == null ? string . Empty : x . Width . ToString ( ) ) ,
200+ new XAttribute ( "height" , x . Height == null ? string . Empty : x . Height . ToString ( ) ) ,
201+ new XAttribute ( "key1" , x . Key1 == VirtualKeyModifier . None ? string . Empty : ( ( int ) x . Key1 ) . ToString ( ) ) ,
202+ new XAttribute ( "key2" , x . Key2 == VirtualKeyModifier . None ? string . Empty : ( ( int ) x . Key2 ) . ToString ( ) ) ,
203+ new XAttribute ( "key3" , x . Key3 == VirtualKey . None ? string . Empty : ( ( int ) x . Key3 ) . ToString ( ) ) ) ) ) ,
199204 new XElement ( "startProgramItems" , settings . MenuItems . StartProgramItems . Select ( x => new XElement ( "item" ,
200205 new XAttribute ( "title" , x . Title ) ,
201206 new XAttribute ( "fileName" , x . FileName ) ,
@@ -207,9 +212,9 @@ public static void Save(string fileName, ApplicationSettings settings)
207212 new XAttribute ( "endParameter" , x . EndParameter ) ) ) ) ) ,
208213 new XElement ( "closer" ,
209214 new XAttribute ( "type" , ( ( int ) settings . Closer . Type ) . ToString ( ) ) ,
210- new XAttribute ( "key1" , settings . Closer . Key1 == VirtualKeyModifier . None ? "" : ( ( int ) settings . Closer . Key1 ) . ToString ( ) ) ,
211- new XAttribute ( "key2" , settings . Closer . Key2 == VirtualKeyModifier . None ? "" : ( ( int ) settings . Closer . Key2 ) . ToString ( ) ) ,
212- new XAttribute ( "mouseButton" , settings . Closer . MouseButton == MouseButton . None ? "" : ( ( int ) settings . Closer . MouseButton ) . ToString ( ) )
215+ new XAttribute ( "key1" , settings . Closer . Key1 == VirtualKeyModifier . None ? string . Empty : ( ( int ) settings . Closer . Key1 ) . ToString ( ) ) ,
216+ new XAttribute ( "key2" , settings . Closer . Key2 == VirtualKeyModifier . None ? string . Empty : ( ( int ) settings . Closer . Key2 ) . ToString ( ) ) ,
217+ new XAttribute ( "mouseButton" , settings . Closer . MouseButton == MouseButton . None ? string . Empty : ( ( int ) settings . Closer . MouseButton ) . ToString ( ) )
213218 ) ,
214219 new XElement ( "dimmer" ,
215220 new XAttribute ( "color" , settings . Dimmer . Color ) ,
0 commit comments