Ejemplo n.º 1
0
        /// <summary>
        /// アプリケーションを終了します。
        /// </summary>
        public void End()
        {
            KeyCollector.Current.SaveCollection();
            MouseCollector.Current.SaveCollection();

            WpfNotifyIcon.Dispose();
            this.Shutdown();
        }
        private void WindowMain_Loaded(object sender, RoutedEventArgs e)
        {
            AeroGlassHelper.ExtendGlass(this, (int)windowContent.Margin.Left, (int)windowContent.Margin.Right, (int)windowContent.Margin.Top, (int)windowContent.Margin.Bottom);

            txtSSID.Text     = Settings.Default.SSID;
            txtPassword.Text = Settings.Default.Password;
            // Составляем список доступных коннектов
            FillSharedConnection(Settings.Default.SharedConnectionGuid);

            // This line is for testing purposes
            //panelConnections.Children.Add(new PeerDeviceView(new ConnectedPeer() { MacAddress = "AA-22-33-EE-EE-FF" }));

            var args   = Environment.GetCommandLineArgs();
            var minarg = (from a in args
                          where a.ToLowerInvariant().Contains("/min")
                          select a).FirstOrDefault();

            if (!string.IsNullOrEmpty(minarg))
            {
                WindowState   = WindowState.Minimized;
                ShowInTaskbar = false;
            }

            AddSystemMenuItems();

            _threadUpdateUI = new Thread(new ThreadStart(UpdateUIThread));
            _threadUpdateUI.Start();

            Closed += new EventHandler(WindowMain_Closed);

            // Show System Tray Icon
            var stream = Application.GetResourceStream(new Uri("/icons/virtualrouterdisabled.ico", UriKind.Relative)).Stream;
            var icon   = new System.Drawing.Icon(stream);

            _trayIcon      = new WpfNotifyIcon();
            _trayIcon.Icon = icon;
            _trayIcon.Show();
            _trayIcon.Text         = "Virtual Router (Disabled)";
            _trayIcon.DoubleClick += new EventHandler(TrayIcon_DoubleClick);

            var trayMenu = new ContextMenuStrip();

            trayMenu.Items.Add("&Manage Virtual Router...", null, new EventHandler(TrayIcon_Menu_Manage));
            trayMenu.Items.Add(new ToolStripSeparator());
            trayMenu.Items.Add("Check for &Updates...", null, new EventHandler(TrayIcon_Menu_Update));
            trayMenu.Items.Add("&About...", null, new EventHandler(TrayIcon_Menu_About));
            _trayIcon.ContextMenuStrip = trayMenu;

            StateChanged += new EventHandler(WindowMain_StateChanged);

            UpdateDisplay();
        }