Revision 0eea575a trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs
b/trunk/Pithos.ShellExtensions/Overlays/IconOverlayBase.cs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
public IconOverlayBase(string iconName) |
27 | 27 |
{ |
28 |
Trace.Write("Icon Overlay Instance created"); |
|
28 |
if (String.IsNullOrWhiteSpace(iconName)) |
|
29 |
throw new ArgumentNullException("iconName","Empty iconName"); |
|
30 |
|
|
31 |
Debug.WriteLine("Icon Overlay Instance created", LogCategories.ShellOverlays); |
|
29 | 32 |
IoC.Current.Compose(this); |
30 | 33 |
|
31 | 34 |
|
... | ... | |
46 | 49 |
public int IsMemberOf(string path, uint attributes) |
47 | 50 |
{ |
48 | 51 |
if (String.IsNullOrWhiteSpace(path)) |
49 |
throw new ArgumentNullException("Empty path"); |
|
52 |
throw new ArgumentNullException("path","Empty path");
|
|
50 | 53 |
|
51 |
Trace.Write(String.Format("ICON Status check for {0} - {1}",path,GetType().Name));
|
|
54 |
Debug.WriteLine(String.Format("ICON Status check for {0} - {1}", path, GetType().Name), LogCategories.ShellOverlays);
|
|
52 | 55 |
|
53 | 56 |
if (!path.StartsWith(Settings.PithosPath,true,null)) |
54 | 57 |
return WinError.S_FALSE; |
55 | 58 |
|
56 | 59 |
var status=StatusChecker.GetFileOverlayStatus(path); |
57 | 60 |
var isMember = (PithosPrefix + status == OverlayName); |
58 |
Trace.Write(String.Format("Status check for {0} is {1}",path,isMember));
|
|
61 |
Debug.WriteLine(String.Format("[STATUS] Was {0}, expected {1} for {2}", status, OverlayName,path ), LogCategories.ShellOverlays);
|
|
59 | 62 |
return isMember ? WinError.S_OK : WinError.S_FALSE; |
60 | 63 |
} |
61 | 64 |
|
... | ... | |
65 | 68 |
out int iconIndex, |
66 | 69 |
out uint flags) |
67 | 70 |
{ |
68 |
Trace.Write("Looking for icons"); |
|
69 |
|
|
70 |
Trace.WriteLine(string.Format("ICON file {0}", IconPath)); |
|
71 |
Contract.Requires(iconFileBuffer!=IntPtr.Zero); |
|
72 |
Contract.Requires(iconFileBufferSize>0); |
|
73 |
|
|
74 |
if (iconFileBuffer == IntPtr.Zero) |
|
75 |
throw new ArgumentNullException("iconFileBuffer","iconFileBuffer not initialized"); |
|
76 |
if (iconFileBufferSize<=0) |
|
77 |
throw new ArgumentException("iconFileBufferSize", "iconFileBufferSize must be greatere than 0"); |
|
78 |
Debug.WriteLine("Looking for icons", LogCategories.ShellOverlays); |
|
79 |
Debug.WriteLine(string.Format("ICON file {0}", IconPath), LogCategories.ShellOverlays); |
|
71 | 80 |
|
72 | 81 |
int bytesCount = System.Text.Encoding.Unicode.GetByteCount(IconPath); |
73 |
|
|
74 |
Trace.WriteLine(string.Format(" GetOverlayInfo::{0}",bytesCount)); |
|
82 |
Debug.WriteLine(string.Format(" GetOverlayInfo::{0}", bytesCount), LogCategories.ShellOverlays); |
|
75 | 83 |
|
76 | 84 |
MarshalHelpers.CopyToBuffer(IconPath, iconFileBuffer, iconFileBufferSize); |
77 | 85 |
|
... | ... | |
82 | 90 |
|
83 | 91 |
public int GetPriority(out int priority) |
84 | 92 |
{ |
85 |
Trace.Write("Checking for priority");
|
|
93 |
Debug.WriteLine("Checking for priority");
|
|
86 | 94 |
priority = 0; |
87 | 95 |
return WinError.S_OK; |
88 | 96 |
} |
89 | 97 |
|
90 | 98 |
|
91 |
public static void RegisterOverlay(Type t,string iconName) |
|
99 |
public static void RegisterOverlay(Type type,string iconName)
|
|
92 | 100 |
{ |
101 |
Contract.Requires(type != null); |
|
102 |
Contract.Requires(!String.IsNullOrWhiteSpace(iconName)); |
|
103 |
|
|
104 |
if (type == null) |
|
105 |
throw new ArgumentNullException("type", "type can't be null"); |
|
106 |
if (String.IsNullOrWhiteSpace(iconName)) |
|
107 |
throw new ArgumentNullException("iconName", "iconName can't be null"); |
|
108 |
|
|
93 | 109 |
try |
94 | 110 |
{ |
95 | 111 |
|
96 |
ShellExtReg.RegisterIconOverlayIdentifier(t.GUID, iconName); |
|
112 |
ShellExtReg.RegisterIconOverlayIdentifier(type.GUID, iconName);
|
|
97 | 113 |
|
98 | 114 |
NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_IDLIST, |
99 | 115 |
IntPtr.Zero, IntPtr.Zero); |
100 |
Trace.Write("Registered icon handler");
|
|
116 |
Debug.WriteLine("Registered icon handler");
|
|
101 | 117 |
} |
102 | 118 |
catch (Exception ex) |
103 | 119 |
{ |
104 |
Trace.WriteLine(ex.Message); // Log the error
|
|
120 |
Debug.WriteLine(ex.Message); // Log the error
|
|
105 | 121 |
throw; // Re-throw the exception |
106 | 122 |
} |
107 | 123 |
} |
108 | 124 |
|
109 | 125 |
|
110 |
public static void UnregisterOverlay(Type t,string iconName) |
|
126 |
public static void UnregisterOverlay(Type type,string iconName)
|
|
111 | 127 |
{ |
128 |
Contract.Requires(type!=null); |
|
129 |
Contract.Requires(!String.IsNullOrWhiteSpace(iconName)); |
|
130 |
|
|
131 |
if (type==null) |
|
132 |
throw new ArgumentNullException("type","type can't be null"); |
|
133 |
if (String.IsNullOrWhiteSpace(iconName)) |
|
134 |
throw new ArgumentNullException("iconName","iconName can't be null"); |
|
112 | 135 |
try |
113 | 136 |
{ |
114 |
ShellExtReg.UnregisterIconOverlayIdentifier(t.GUID, iconName); |
|
115 |
Trace.Write("UnRegistered icon handler");
|
|
137 |
ShellExtReg.UnregisterIconOverlayIdentifier(type.GUID, iconName);
|
|
138 |
Debug.WriteLine(String.Format("UnRegistered icon handler {0}:{1}",iconName,type.GUID), LogCategories.ShellOverlays);
|
|
116 | 139 |
} |
117 | 140 |
catch (Exception ex) |
118 | 141 |
{ |
119 |
Trace.WriteLine(ex.Message); // Log the error |
|
120 |
throw; // Re-throw the exception |
|
142 |
//Log and rethrow |
|
143 |
Trace.TraceError("Failed to unregister overlay {0}:{1} with error {2}",iconName,type.GUID,ex.Message); |
|
144 |
throw; |
|
121 | 145 |
} |
122 | 146 |
} |
123 | 147 |
} |
Also available in: Unified diff