Example #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!this._mutex.WaitOne(0, false))
            {
                IntPtr hMWnd = NativeMethods.FindWindow(null, AppCommon.GetAppName());
                if (hMWnd != null && NativeMethods.IsWindow(hMWnd))
                {
                    var hCWnd = NativeMethods.GetLastActivePopup(hMWnd);
                    if (hCWnd != null && NativeMethods.IsWindow(hCWnd) && NativeMethods.IsWindowVisible(hCWnd))
                    {
                        NativeMethods.ShowWindow(hCWnd, (int)NativeMethods.SW.SHOWNORMAL);
                        NativeMethods.SetForegroundWindow(hCWnd);
                    }
                }

                this._mutex.Close();
                this._mutex = null;
                Shutdown();
            }
            else
            {
                this._mainWindow = new UI.MySimpleLauncherMain();
                this._mainWindow.Show();
            }
        }
Example #2
0
        public MySimpleLauncherMain()
        {
            InitializeComponent();

            using (var key = new FileOperator(AppCommon.GetAppPath() + "key")) {
                if (key.Exists())
                {
                    key.OpenForRead();
                    ProfileDatabase.Password = key.ReadLine();
                }
            }

            this.CreateContextMenu();
            this.SetUpNotifyIcon();
            this._settings = AppSettings.GetInstance();
            this._settings.Load();
            this.Title    = AppCommon.GetAppName();
            _self         = this;
            _assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            this._hotkey = new HotKeyHelper(this);
            this._hotkey.Register(ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt,
                                  Key.A,
                                  (_, __) => {
                if (!this.ShowInTaskbar)
                {
                    NotifyMenuShow_Click(null, null);
                }
                else
                {
                    if (this.WindowState == WindowState.Minimized)
                    {
                        this.WindowState = WindowState.Normal;
                    }
                    this.Activate();
                }
            }
                                  );

            if (0 <= this._settings.WindowPosX && (this._settings.WindowPosX + this._settings.WindowSizeW) < SystemParameters.VirtualScreenWidth)
            {
                this.Left = this._settings.WindowPosX;
            }
            if (0 <= this._settings.WindowPosY && (this._settings.WindowPosY + this._settings.WindowSizeH) < SystemParameters.VirtualScreenHeight)
            {
                this.Top = this._settings.WindowPosY;
            }
            if (0 < this._settings.WindowSizeW && this._settings.WindowSizeW <= SystemParameters.WorkArea.Width)
            {
                this.Width = this._settings.WindowSizeW;
            }
            if (0 < this._settings.WindowSizeH && this._settings.WindowSizeH <= SystemParameters.WorkArea.Height)
            {
                this.Height = this._settings.WindowSizeH;
            }
            if (0 < this._settings.CategoryListW && this._settings.CategoryListW < this.Width)
            {
                this.cMainGrid.ColumnDefinitions[0].Width = new GridLength(this._settings.CategoryListW);
                // this.cCategoryList.Width = this._settings.CategoryListW;
            }
        }