7
7
using System . Windows . Media ;
8
8
using System . Windows . Media . Imaging ;
9
9
using Color = System . Drawing . Color ;
10
+ using IC = Flow . Launcher . Plugin . OneNote . Icons . IconConstants ;
10
11
11
12
namespace Flow . Launcher . Plugin . OneNote . Icons
12
13
{
13
14
public class IconProvider : BaseModel , IDisposable
14
15
{
15
- public const string Logo = "Images/logo.png" ;
16
- public string Sync => GetIconLocal ( "sync" ) ;
17
- public string Search => GetIconLocal ( "search" ) ;
18
- public string Recent => GetIconLocal ( "page_recent" ) ;
19
- public string NotebookExplorer => GetIconLocal ( "notebook_explorer" ) ;
16
+ public const string Logo = IC . ImagesDirectory + IC . Logo ;
17
+ public string Sync => GetIconLocal ( IC . Sync ) ;
18
+ public string Search => GetIconLocal ( IC . Search ) ;
19
+ public string Recent => GetIconLocal ( IC . Recent ) ;
20
+ public string NotebookExplorer => GetIconLocal ( IC . NotebookExplorer ) ;
20
21
public string QuickNote => NewPage ;
21
- public string NewPage => GetIconLocal ( "page_new" ) ;
22
- public string NewSection => GetIconLocal ( "section_new" ) ;
23
- public string NewSectionGroup => GetIconLocal ( "section_group_new" ) ;
24
- public string NewNotebook => GetIconLocal ( "notebook_new" ) ;
22
+ public string NewPage => GetIconLocal ( IC . NewPage ) ;
23
+ public string NewSection => GetIconLocal ( IC . NewSection ) ;
24
+ public string NewSectionGroup => GetIconLocal ( IC . NewSectionGroup ) ;
25
+ public string NewNotebook => GetIconLocal ( IC . NewNotebook ) ;
25
26
public string Warning => settings . IconTheme == IconTheme . Color
26
- ? $ "Images/warning. { GetPluginThemeString ( IconTheme . Light ) } .png"
27
- : GetIconLocal ( "warning" ) ;
27
+ ? $ "{ IC . ImagesDirectory } { IC . Warning } . { GetIconThemeString ( IconTheme . Light ) } .png"
28
+ : GetIconLocal ( IC . Warning ) ;
28
29
29
30
private readonly Settings settings ;
30
31
// May need this? https://stackoverflow.com/questions/21867842/concurrentdictionarys-getoradd-is-not-atomic-any-alternatives-besides-locking
@@ -36,18 +37,16 @@ public class IconProvider : BaseModel, IDisposable
36
37
37
38
private readonly PluginInitContext context ;
38
39
39
- private readonly WindowsThemeWatcher windowsThemeWatcher ;
40
+ private readonly WindowsThemeWatcher windowsThemeWatcher = new ( ) ;
40
41
41
42
public IconProvider ( PluginInitContext context , Settings settings )
42
43
{
43
- imagesDirectory = $ "{ context . CurrentPluginMetadata . PluginDirectory } /Images/ ";
44
+ imagesDirectory = $ "{ context . CurrentPluginMetadata . PluginDirectory } /{ IC . ImagesDirectory } ";
44
45
45
- GeneratedImagesDirectoryInfo = Directory . CreateDirectory ( $ "{ context . CurrentPluginMetadata . PluginDirectory } /Images/Generated/ ") ;
46
+ GeneratedImagesDirectoryInfo = Directory . CreateDirectory ( $ "{ context . CurrentPluginMetadata . PluginDirectory } /{ IC . GeneratedImagesDirectory } ") ;
46
47
47
48
this . context = context ;
48
49
this . settings = settings ;
49
-
50
- windowsThemeWatcher = new WindowsThemeWatcher ( ) ;
51
50
52
51
if ( settings . IconTheme == IconTheme . System )
53
52
{
@@ -77,9 +76,9 @@ private void OnIconThemeChanged(object sender, PropertyChangedEventArgs args)
77
76
}
78
77
}
79
78
80
- private string GetIconLocal ( string icon ) => $ "Images/{ icon } .{ GetPluginThemeString ( settings . IconTheme ) } .png";
79
+ private string GetIconLocal ( string icon ) => $ "Images/{ icon } .{ GetIconThemeString ( settings . IconTheme ) } .png";
81
80
82
- private string GetPluginThemeString ( IconTheme iconTheme )
81
+ private string GetIconThemeString ( IconTheme iconTheme )
83
82
{
84
83
if ( iconTheme == IconTheme . System )
85
84
{
@@ -93,8 +92,8 @@ public Result.IconDelegate GetIcon(IconGeneratorInfo info)
93
92
{
94
93
return ( ) =>
95
94
{
96
- bool generate = ( string . CompareOrdinal ( info . Prefix , IconGeneratorInfo . Notebook ) == 0
97
- || string . CompareOrdinal ( info . Prefix , IconGeneratorInfo . Section ) == 0 )
95
+ bool generate = ( string . CompareOrdinal ( info . Prefix , IC . Notebook ) == 0
96
+ || string . CompareOrdinal ( info . Prefix , IC . Section ) == 0 )
98
97
&& settings . CreateColoredIcons
99
98
&& info . Color . HasValue ;
100
99
@@ -106,7 +105,7 @@ public Result.IconDelegate GetIcon(IconGeneratorInfo info)
106
105
return imageSource ;
107
106
}
108
107
109
- return iconCache . GetOrAdd ( $ "{ info . Prefix } .{ GetPluginThemeString ( settings . IconTheme ) } .png", key =>
108
+ return iconCache . GetOrAdd ( $ "{ info . Prefix } .{ GetIconThemeString ( settings . IconTheme ) } .png", key =>
110
109
{
111
110
var path = Path . Combine ( imagesDirectory , key ) ;
112
111
return BitmapImageFromPath ( path ) ;
0 commit comments