Esempio n. 1
0
        public MainWindow()
        {
            executableConfigName = commonSet.configurationExecutableName;
            configFileName       = commonSet.configFileName;
            floatingWindowName   = commonSet.floatingWindowExecutableName;

            InitializeComponent();

            initCompleted = true;

            // check if the background process is running, if no, show message and end the program
            if (!commonSet.CheckIfRunning(commonSet.baseProgramProcessName))
            {
                // **** removed

                /*if (this.LanguageSelectionBox.SelectedIndex == 1)
                 * {
                 *  MessageBox.Show("請運行 \"StartProcess.exe\" 後進入配置視窗。");
                 * }
                 * else
                 * {
                 *  MessageBox.Show("Please run \"StartProcess.exe\" and use it to access the Configuration Window.");
                 * }*/
                MessageBox.Show("Please run \"StartProcess.exe\" and use it to access the Configuration Window.");
                this.Close();
            }

            // check if any same process running, if yes, close all of them
            if (commonSet.CheckIfRunningSameProcess(commonSet.configurationProcessName))
            {
                // *** removed

                /*if (this.LanguageSelectionBox.SelectedIndex == 1)
                 * {
                 *  MessageBox.Show("配置視窗已開啟。");
                 * }
                 * else
                 * {
                 *  MessageBox.Show("Configuration Window is opened already.");
                 * }*/
                MessageBox.Show("Configuration Window is opened already.");
                this.Close();
            }

            // check if the program name is changed
            if (commonSet.CheckIfNameChanged(commonSet.configurationProcessName))
            {
                // *** removed

                /*if (this.LanguageSelectionBox.SelectedIndex == 1)
                 * {
                 *  MessageBox.Show("執行檔 \".exe\" 已損壞或其檔案名稱已更改。\n請重新下載整個程式。");
                 * }
                 * else
                 * {
                 *  MessageBox.Show("Executable file name changed or corrupted.\nPlease download the program again.");
                 * }*/
                MessageBox.Show("Executable file name changed or corrupted.\nPlease download the program again.");
                this.Close();
            }

            // get parameters from commonset
            minFrequency = commonSet.minFrequency;
            maxFrequency = commonSet.maxFrequency;

            // set the range of value of slider
            this.UpdateFrequencySlider.Minimum = minFrequency;
            this.UpdateFrequencySlider.Maximum = maxFrequency;

            // set the index of speed unit
            this.SpeedUnitSelectionBox.SelectedIndex = 1;

            // init common set
            commonSet.InitCommonSet();

            GetInterfaceInformation();
            LoadSetting();
            GetTrafficInformation();
        }
Esempio n. 2
0
        public MainWindow()
        {
            // set the floating window always on top
            this.Topmost = true;

            executableConfigName = commonSet.configurationExecutableName;
            configFileName       = commonSet.configFileName;

            InitializeComponent();

            // check if the background process is running, if no, show message and end the program
            if (!commonSet.CheckIfRunning(commonSet.baseProgramProcessName))
            {
                MessageBox.Show("Please run \"StartProcess.exe\" and use it to access the Floating Window.");
                this.Close();
            }

            // check if any same programm is running
            if (commonSet.CheckIfRunningSameProcess(commonSet.floatingWindowProcessName))
            {
                MessageBox.Show("Floating Window is opened already.");
                this.Close();
            }

            // check if the program name is changed
            if (commonSet.CheckIfNameChanged(commonSet.floatingWindowProcessName))
            {
                MessageBox.Show("Executable file name changed or corrupted.\nPlease download the program again.");
                this.Close();
            }

            // do not show in taskbar
            this.ShowInTaskbar = false;

            // init common set
            commonSet.InitCommonSet();

            // get Interface information
            GetInterfaceInformation();

            // load setting
            LoadSetting();

            // apply auto start setting
            commonSet.ApplyAutoStartSetting(loadedAutoStartCheck);

            // resize window
            ResizeWindow();

            // Get Traffic information
            GetTrafficInformation();

            // Load and set the position of floating window
            LoadPosition();

            // Save position of floating window
            SavePosition();

            // check minized
            CheckMinimized();
        }