static List <NOTIFYITEM> getTrayItemsWin7(TrayNotify instance) { var notifier = (ITrayNotifyWin7)instance; var callback = new NotificationCb(); notifier.RegisterCallback(callback); notifier.RegisterCallback(null); return(callback.items); }
public void PromoteTrayItems(string exeToPromote) { var instance = new TrayNotify(); try { var items = default(List <NOTIFYITEM>); var legacy = useLegacyInterface(); if (legacy) { items = getTrayItemsWin7(instance); } else { items = getTrayItems(instance); } exeToPromote = exeToPromote.ToLowerInvariant(); for (int i = 0; i < items.Count; i++) { var item = items[i]; var exeName = item.exe_name.ToLowerInvariant(); // Ignore items not created by the specified EXE. if (!exeName.Contains(exeToPromote)) { continue; } // Ignore items that are not in the default state. We shouldn't overwrite the // user's preference if it is to never show an item, and we don't need to overwrite // the user's preference if it is to always show an item. if (item.preference != NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_WHEN_ACTIVE) { continue; } item.preference = NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_ALWAYS; var writable = NOTIFYITEM_Writable.fromNotifyItem(item); if (legacy) { var notifier = (ITrayNotifyWin7)instance; notifier.SetPreference(ref writable); } else { var notifier = (ITrayNotify)instance; notifier.SetPreference(ref writable); } } } catch (Exception ex) { Console.WriteLine("Failed to promote Tray icon: " + ex.ToString()); } finally { Marshal.ReleaseComObject(instance); } }
private static List <NOTIFYITEM> getTrayItemsWin7(TrayNotify instance) { NotificationCb callback = new NotificationCb(); ITrayNotifyWin7 win1 = (ITrayNotifyWin7)instance; win1.RegisterCallback(callback); win1.RegisterCallback(null); return(callback.items); }
static List <NOTIFYITEM> getTrayItems(TrayNotify instance) { var notifier = (ITrayNotify)instance; var callback = new NotificationCb(); var handle = default(ulong); notifier.RegisterCallback(callback, out handle); notifier.UnregisterCallback(handle); return(callback.items); }
private static List <NOTIFYITEM> getTrayItems(TrayNotify instance) { NotificationCb callback = new NotificationCb(); ulong handle = 0UL; ITrayNotify notify1 = (ITrayNotify)instance; notify1.RegisterCallback(callback, out handle); notify1.UnregisterCallback(handle); return(callback.items); }
public void PromoteTrayItem(string exeToPromote) { var instance = new TrayNotify(); try { var items = default(List <NOTIFYITEM>); var legacy = useLegacyInterface(); if (legacy) { items = getTrayItemsWin7(instance); } else { items = getTrayItems(instance); } exeToPromote = exeToPromote.ToLowerInvariant(); for (int i = 0; i < items.Count; i++) { var item = items[i]; var exeName = item.exe_name.ToLowerInvariant(); if (!exeName.Contains(exeToPromote)) { continue; } if (item.preference != NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_WHEN_ACTIVE) { continue; } item.preference = NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_ALWAYS; var writable = NOTIFYITEM_Writable.fromNotifyItem(item); if (legacy) { var notifier = (ITrayNotifyWin7)instance; notifier.SetPreference(ref writable); } else { var notifier = (ITrayNotify)instance; notifier.SetPreference(ref writable); } } } catch (Exception ex) { Console.WriteLine("Failed to promote Tray icon: " + ex.ToString()); } finally { Marshal.ReleaseComObject(instance); } }
public List<NOTIFYITEM> GetTrayItems() { var instance = new TrayNotify(); try { if (useLegacyInterface()) { return getTrayItemsWin7(instance); } else { return getTrayItems(instance); } } finally { Marshal.ReleaseComObject(instance); } }
public List <NOTIFYITEM> GetTrayItems() { List <NOTIFYITEM> list; TrayNotify instance = new TrayNotify(); try { list = !useLegacyInterface() ? getTrayItems(instance) : getTrayItemsWin7(instance); } finally { Marshal.ReleaseComObject(instance); } return(list); }
public List <NOTIFYITEM> GetTrayItems() { var instance = new TrayNotify(); try { if (useLegacyInterface()) { return(getTrayItemsWin7(instance)); } else { return(getTrayItems(instance)); } } finally { Marshal.ReleaseComObject(instance); } }
public void PromoteTrayItems(string exeToPromote) { var instance = new TrayNotify(); try { var items = default(List<NOTIFYITEM>); var legacy = useLegacyInterface(); if (legacy) { items = getTrayItemsWin7(instance); } else { items = getTrayItems(instance); } exeToPromote = exeToPromote.ToLowerInvariant(); for (int i = 0; i < items.Count; i++) { var item = items[i]; var exeName = item.exe_name.ToLowerInvariant(); // Ignore items not created by the specified EXE. if (!exeName.Contains(exeToPromote)) continue; // Ignore items that are not in the default state. We shouldn't overwrite the // user's preference if it is to never show an item, and we don't need to overwrite // the user's preference if it is to always show an item. if (item.preference != NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_WHEN_ACTIVE) continue; item.preference = NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_ALWAYS; var writable = NOTIFYITEM_Writable.fromNotifyItem(item); if (legacy) { var notifier = (ITrayNotifyWin7)instance; notifier.SetPreference(ref writable); } else { var notifier = (ITrayNotify)instance; notifier.SetPreference(ref writable); } } } catch (Exception ex) { Console.WriteLine("Failed to promote Tray icon: " + ex.ToString()); } finally { Marshal.ReleaseComObject(instance); } }
private void SetAutoTrayEnabled(TrayNotify trayNotify, bool enabled) { try { if (Shell.IsWindows8OrBetter) { var trayNotifyInstance = (ITrayNotify)trayNotify; trayNotifyInstance.EnableAutoTray(enabled); } else { var trayNotifyInstance = (ITrayNotifyLegacy)trayNotify; trayNotifyInstance.EnableAutoTray(enabled); } } catch (Exception e) { CairoLogger.Instance.Debug($"ExplorerTrayService: Unable to set EnableAutoTray setting: {e.Message}"); } }
public void PromoteTrayItem(string exeToPromote) { var instance = new TrayNotify(); try { var items = default(List<NOTIFYITEM>); var legacy = useLegacyInterface(); if (legacy) { items = getTrayItemsWin7(instance); } else { items = getTrayItems(instance); } exeToPromote = exeToPromote.ToLowerInvariant(); for (int i = 0; i < items.Count; i++) { var item = items[i]; var exeName = item.exe_name.ToLowerInvariant(); if (!exeName.Contains(exeToPromote)) continue; if (item.preference != NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_WHEN_ACTIVE) continue; item.preference = NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_ALWAYS; var writable = NOTIFYITEM_Writable.fromNotifyItem(item); if (legacy) { var notifier = (ITrayNotifyWin7)instance; notifier.SetPreference(ref writable); } else { var notifier = (ITrayNotify)instance; notifier.SetPreference(ref writable); } } } catch (Exception ex) { Console.WriteLine("Failed to promote Tray icon: " + ex.ToString()); } finally { Marshal.ReleaseComObject(instance); } }
internal void Run() { if (!Shell.IsCairoRunningAsShell && trayDelegate != null) { bool autoTrayEnabled = GetAutoTrayEnabled(); if (autoTrayEnabled) { // we can't get tray icons that are in the hidden area, so disable that temporarily if enabled try { TrayNotify trayNotify = new TrayNotify(); SetAutoTrayEnabled(trayNotify, false); GetTrayItems(); SetAutoTrayEnabled(trayNotify, true); Marshal.ReleaseComObject(trayNotify); } catch (Exception e) { CairoLogger.Instance.Debug($"ExplorerTrayService: Unable to get items using ITrayNotify: {e.Message}"); } } else { try { GetTrayItems(); } catch (Exception e) { CairoLogger.Instance.Debug($"ExplorerTrayService: Unable to get items: {e.Message}"); } } } }
public void PromoteTrayItem(string exeToPromote) { TrayNotify instance = new TrayNotify(); try { List <NOTIFYITEM> list = null; bool flag = useLegacyInterface(); list = !flag?getTrayItems(instance) : getTrayItemsWin7(instance); exeToPromote = exeToPromote.ToLowerInvariant(); for (int i = 0; i < list.Count; i++) { NOTIFYITEM item = list[i]; if (item.exe_name.ToLowerInvariant().Contains(exeToPromote) && (item.preference == NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_WHEN_ACTIVE)) { item.preference = NOTIFYITEM_PREFERENCE.PREFERENCE_SHOW_ALWAYS; if (flag) { ((ITrayNotifyWin7)instance).SetPreference(ref NOTIFYITEM_Writable.fromNotifyItem(item)); } else { ((ITrayNotify)instance).SetPreference(ref NOTIFYITEM_Writable.fromNotifyItem(item)); } } } } catch (Exception exception) { Console.WriteLine("Failed to promote Tray icon: " + exception.ToString()); } finally { Marshal.ReleaseComObject(instance); } }
static List<NOTIFYITEM> getTrayItemsWin7(TrayNotify instance) { var notifier = (ITrayNotifyWin7)instance; var callback = new NotificationCb(); notifier.RegisterCallback(callback); notifier.RegisterCallback(null); return callback.items; }
static List<NOTIFYITEM> getTrayItems(TrayNotify instance) { var notifier = (ITrayNotify)instance; var callback = new NotificationCb(); var handle = default(ulong); notifier.RegisterCallback(callback, out handle); notifier.UnregisterCallback(handle); return callback.items; }