Exemplo n.º 1
0
 public static NOTIFYITEM_Writable fromNotifyItem(NOTIFYITEM item) =>
 new NOTIFYITEM_Writable
 {
     exe_name   = Marshal.StringToCoTaskMemAuto(item.exe_name),
     tip        = Marshal.StringToCoTaskMemAuto(item.tip),
     icon       = item.icon,
     hwnd       = item.hwnd,
     preference = item.preference,
     id         = item.id,
     guid       = item.guid
 };
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public Guid guid;  // The GUID specified by the application, alternative to
                           // uID.

        public static NOTIFYITEM_Writable fromNotifyItem(NOTIFYITEM item)
        {
            return new NOTIFYITEM_Writable {
                exe_name = Marshal.StringToCoTaskMemAuto(item.exe_name),
                tip = Marshal.StringToCoTaskMemAuto(item.tip),
                icon = item.icon,
                hwnd = item.hwnd,
                preference = item.preference,
                id = item.id,
                guid = item.guid
            };
        }
Exemplo n.º 4
0
 public void Notify([In] uint nEvent, [In] ref NOTIFYITEM notifyItem)
 {
     items.Add(notifyItem);
 }