Ejemplo n.º 1
0
        private void windowTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Window window = new Window(options.WindowClassName);

                if (!window.Visible) return;

                // システムボタンの表示(初検出時のみだとちゃんと表示されないので毎回やる)
                if (options.SystemButtonsEnabled) window.AddSystemButton();

                // 初検出の場合
                if (firstTime)
                {
                    // ウィンドウサイズを保存(最小化状態から戻らなくなる現象対策)
                    options.WindowSize = window.Size;

                    // 自動的にウィンドウの位置を復元
                    if (options.WindowAutoRestoreEnabled) window.Position = options.WindowPosition;

                    firstTime = false;
                }
            }
            catch (WindowNotFoundException)
            {
                // ウィンドウが無くなっていたら、次回起動時のためにtrueに戻す
                firstTime = true;
            }
            catch (WindowOperationException)
            {
                ShowBalloonTip(Properties.Resources.Error, Properties.Resources.WindowOperationFailed, ToolTipIcon.Error, 3);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ウィンドウの位置を復元
        /// </summary>
        private void menuWindowRestore_Click(object sender, System.EventArgs e)
        {
            try
            {
                Window window = new Window(options.WindowClassName);

                if (options.WindowSize.Width == 0 && options.WindowSize.Height == 0)
                {
                    // ウィンドウの位置を復元
                    window.Position = options.WindowPosition;
                }
                else
                {
                    // ウィンドウのサイズが保存されていたらサイズも復元(最小化状態から戻らなくなる現象対策)
                    window.SetPositionAndSize(options.WindowPosition, options.WindowSize);
                }

                window.SetForeground();
            }
            catch (WindowNotFoundException)
            {
                ShowBalloonTip(Properties.Resources.Error, Properties.Resources.WindowNotFound, ToolTipIcon.Error, 3);
            }
            catch (WindowOperationException)
            {
                ShowBalloonTip(Properties.Resources.Error, Properties.Resources.WindowOperationFailed, ToolTipIcon.Error, 3);
            }
        }