Esempio n. 1
0
 void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
 {
     if (updateflag == 1)
     {
         updateflag = 0; /* Reset the flag */
         System.Diagnostics.Process.Start(UpdateChecker.SHELL_URL);
     }
     else if (updateflag == 2)
     {
         updateflag = 0;
         var download = new DownloadProgress();
         var dg       = download.ShowDialog();
         if (dg == DialogResult.Abort || dg == DialogResult.Cancel)
         {
             MessageBox.Show(I18N.GetString("download fail!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         controller.RestartCore();
     }
     else if (updateflag == 3)
     {
         updateflag = 0;
         System.Diagnostics.Process.Start(UpdateChecker.SHELL_URL);
         var download = new DownloadProgress();
         var dg       = download.ShowDialog();
         if (dg == DialogResult.Abort || dg == DialogResult.Cancel)
         {
             MessageBox.Show(I18N.GetString("download fail!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         controller.RestartCore();
     }
 }
Esempio n. 2
0
        static void Main()
        {
            Utils.ReleaseMemory(true);
            using (Mutex mutex = new Mutex(false, "Global\\V2RayShell_" + Application.StartupPath.GetHashCode()))
            {
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.ApplicationExit += Application_ApplicationExit;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var processesName = Process.GetCurrentProcess().MainModule?.ModuleName ?? "V2RayShell.exe";
                var processesNameWithoutExtension = Path.GetFileNameWithoutExtension(processesName);
                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName(processesNameWithoutExtension);
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show(I18N.GetString("Find V2RayShell icon in your notify tray.") + "\n" +
                                    I18N.GetString("If you want to start multiple V2RayShell, make a copy in another directory."),
                                    I18N.GetString("V2RayShell is already running."));
                    return;
                }

                Logging.OpenLogFile();
                //check
                if (V2Ray.CoreExsis)
                {
                    if (V2Ray.Version != null)
                    {
                        Logging.Info("V2RayCore version : " + V2Ray.Version);
                    }
                    else
                    {
                        throw new Exception(I18N.GetString("v2ray.exe -version parse fail!"));
                    }
                }
                else
                {
                    //need do sth
                    var download = new DownloadProgress();
                    var result   = download.ShowDialog();
                    if (result == DialogResult.Abort || result == DialogResult.Cancel)
                    {
                        MessageBox.Show(I18N.GetString("download fail!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Logging.Info("V2RayCore version : " + V2Ray.Version);
                }

                var controller     = new V2RayShellController();
                var viewController = new MenuViewController(controller);
                Hotkeys.HotKeys.Init(controller, viewController);
                controller.StartAsync();
                Application.Run();
            }
        }
Esempio n. 3
0
        private void StartDownload(List <DownloadFileInfo> downloadList)
        {
            DownloadProgress dp = new DownloadProgress(downloadList);

            if (dp.ShowDialog() == DialogResult.OK)
            {
                new frmMessageBox(Properties.Settings.Default.SoftwareUpdate_Restart_Text, "Close Operator Station to apply this update.", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
            }
        }
Esempio n. 4
0
 // Redownload a fresh copy of Components.json.
 private void resetComponentsjsonToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (File.Exists(PrgmSelfCheck.ComponentsJson) == true)
     {
         File.Delete(PrgmSelfCheck.ComponentsJson);
         DownloadProgress downloadProgress = new DownloadProgress("https://raw.githubusercontent.com/GreenJamesDev/RsMapper/master/RsMapper/Components.json", PrgmSelfCheck.ComponentsJson);
         downloadProgress.ShowDialog();
         downloadProgress.Dispose();
     }
     MessageBox.Show("You must restart RsMapper for these changes to take effect.", "Restart Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Esempio n. 5
0
        private void StartDownload(List <DownloadFileInfo> downloadList)
        {
            DownloadProgress dp = new DownloadProgress(downloadList);

            if (dp.ShowDialog() == DialogResult.OK)
            {
                if (DialogResult.Cancel == dp.ShowDialog())
                {
                    return;
                }
                //Update successfully
                CommonUnitity.GlobalConfig.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));

                if (bNeedRestart)
                {
                    //Delete the temp folder
                    Directory.Delete(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.TEMPFOLDERNAME), true);

                    MessageBox.Show(ConstFile.APPLYTHEUPDATE, ConstFile.MESSAGETITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CommonUnitity.RestartApplication();
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Check for any missing files that are required to start the program.
        /// </summary>
        public async void CheckAll()
        {
            // Components.json
            if (File.Exists(ComponentsJson) == false)
            {
                Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RsMapper"));
                DownloadProgress downloadProgress = new DownloadProgress("https://raw.githubusercontent.com/GreenJamesDev/RsMapper/master/RsMapper/Components.json", ComponentsJson);
                downloadProgress.ShowDialog();
                downloadProgress.Dispose();
            }

            // Modpacks folder.
            if (Directory.Exists(Modpacks) == false)
            {
                Directory.CreateDirectory(Modpacks);
            }
        }
Esempio n. 7
0
        public bool DoDownloadsFg(bool showProgress, bool showMsgBox, ICollection <SeriesSpecifier> shows)
        {
            if (TVSettings.Instance.OfflineMode)
            {
                return(true); // don't do internet in offline mode!
            }

            Logger.Info("Doing downloads in the foreground...");

            StartBgDownloadThread(true, shows, showMsgBox);

            const int DELAY_STEP = 100;
            int       count      = 1000 / DELAY_STEP; // one second

            while (count-- > 0 && !DownloadDone)
            {
                Thread.Sleep(DELAY_STEP);
            }

            if (!DownloadDone && showProgress) // downloading still going on, so time to show the dialog if we're not in /hide mode
            {
                DownloadProgress dp = new DownloadProgress(this);
                dp.ShowDialog();
                dp.Update();
            }

            WaitForBgDownloadDone();

            if (!downloadOk)
            {
                Logger.Warn(LocalCache.Instance.LastErrorMessage);
                if (showErrorMsgBox)
                {
                    CannotConnectForm ccform   = new CannotConnectForm("Error while downloading", LocalCache.Instance.LastErrorMessage);
                    DialogResult      ccresult = ccform.ShowDialog();
                    if (ccresult == DialogResult.Abort)
                    {
                        TVSettings.Instance.OfflineMode = true;
                    }
                }

                LocalCache.Instance.LastErrorMessage = "";
            }

            return(downloadOk);
        }
Esempio n. 8
0
 void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
 {
     if (updateflag == 1)
     {
         updateflag = 0;
         var download = new DownloadProgress(1);
         download.ShowDialog();
         //if (dg == DialogResult.Abort || dg == DialogResult.Cancel) MessageBox.Show(I18N.GetString("download fail!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (updateflag == 2)
     {
         updateflag = 0;
         var download = new DownloadProgress(2);
         download.ShowDialog();
         controller.RestartCore();
     }
     else if (updateflag == 3)
     {
         updateflag = 0;
         var download = new DownloadProgress(3);
         download.ShowDialog();
         controller.RestartCore();
     }
 }