Beispiel #1
0
    public SystemTray()
    {
        trayMenu = new System.Windows.Forms.ContextMenu();

        trayIcon = new NotifyIcon();
        //trayIcon.Text = UnityEngine.Application.productName;

        if (UnityEngine.Application.isEditor)
        {
            trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40);
        }
        else
        {
            ushort        uicon, uicon2;
            StringBuilder strB   = new StringBuilder(AppDomain.CurrentDomain.BaseDirectory + "\\icons\\icon_run.ico");
            IntPtr        handle = StaticPinvoke.ExtractAssociatedIcon(IntPtr.Zero, strB, out uicon);
            ico_run       = Icon.FromHandle(handle);
            trayIcon.Icon = ico_run;
            strB.Clear();

            strB      = new StringBuilder(AppDomain.CurrentDomain.BaseDirectory + "\\icons\\icon_pause.ico");
            handle    = StaticPinvoke.ExtractAssociatedIcon(IntPtr.Zero, strB, out uicon2);
            ico_pause = Icon.FromHandle(handle);
            strB.Clear();
        }
        trayIcon.ContextMenu = trayMenu;
    }