Пример #1
0
        private void resetFloatingWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // save cursor position as floating window position
            commonSet.SaveFloatingWindowPosition(Control.MousePosition.X, Control.MousePosition.Y);

            // close floating window
            commonSet.EndProcess(commonSet.floatingWindowProcessName);

            // open floating window
            if (!commonSet.StartProcess(commonSet.floatingWindowExecutableName))
            {
                if (loadedLanguageIndex == 1)
                {
                    MessageBox.Show("不能顯示懸浮窗。\n請重新下載本程式。");
                }
                else if (loadedLanguageIndex == 2)
                {
                    MessageBox.Show("フローティング・ウィンドウが表示できない。\nもう一度プログラムをダウンロードしてください。");
                }
                else
                {
                    // show erroe message if the floating window cannot be shown
                    MessageBox.Show("Cannot show the floating window.\nPlease download the program again.");
                }
            }
        }
Пример #2
0
        private void SavePosition()
        {
            double xPosTemp = -100000.0;
            double yPosTemp = -100000.0;

            Task.Factory.StartNew(() => {
                // try to access the position file
                try
                {
                    while (true)
                    {
                        this.Dispatcher.Invoke(() => {
                            // record the position of this window
                            xPos = Application.Current.MainWindow.Left;
                            yPos = Application.Current.MainWindow.Top;

                            // check if the position is changed or not
                            if (xPos != xPosTemp && yPos != yPosTemp)
                            {
                                if (!commonSet.SaveFloatingWindowPosition(xPos, yPos))
                                {
                                    canRecordPos = false;
                                }
                            }

                            xPosTemp = xPos;
                            yPosTemp = yPos;
                        });
                        Thread.Sleep(500);
                    }
                }
                catch
                {
                    canRecordPos = false;
                }
                if (!canRecordPos)
                {
                    if (loadedLanguageIndex == 1)
                    {
                        MessageBox.Show("無法儲存懸浮窗的坐標。\n請重新下載本程式。");
                    }
                    else if (loadedLanguageIndex == 2)
                    {
                        MessageBox.Show("フローティング・ウィンドウの位置は保存できない。\nもう一度プログラムをダウンロードしてください。");
                    }
                    else
                    {
                        // if the position cannot be recorded, show error message and end the record loop
                        MessageBox.Show("The position of the floating window cannot be saved.\nPlease download the program again.");
                    }
                }
            });
        }