示例#1
0
        public static void Initialize()
        {
            PackageManager = new PackageManager();

            PackageManager.UpdatesAvailable += OnUpdatesAvailable;

            TrayIcon = new NotifyIcon
            {
                Icon = Resources.CoApp
            };

            TrayIcon.BalloonTipClicked += OnTrayIconBalloonTipClosed;
            TrayIcon.BalloonTipClosed += OnTrayIconBalloonTipClosed;
            TrayIcon.DoubleClick += OnTrayIconDoubleClicked;

            TrayIcon.ContextMenu = new ContextMenu();
            TrayIcon.ContextMenu.MenuItems.Add("Package Manager...", (sender, args) => { ShowMainControl(); ShowMainWindow(); });
            TrayIcon.ContextMenu.MenuItems.Add("Options...", (sender, args) => { ShowOptionsControl(); ShowMainWindow(); });

            if (!IsDTELoaded)
                TrayIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => { IsShutdownForced = true; MainWindow.Close(); });

            // Check for updates once in an hour
            var dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += (sender, args) =>
            {
                if (PackageManager.Settings["#update"].IntValue == 2)
                    return;

                PackageManager.SetAllFeedsStale();
                PackageManager.GetPackages("updatable");
            };
            dispatcherTimer.Interval = new TimeSpan(0, 1, 0, 0);
            dispatcherTimer.Start();
        }