public static void ShowText(string text)
        {
            DLicense dl = new DLicense();

            dl.SetShowText(text);
            dl.ShowDialog(null);
        }
Exemple #2
0
 private void DownForm_Load(object sender, EventArgs e)
 {
     if (invMode)
     {
         UIVisible = false;
     }
     Application.DoEvents();
     if (!invMode &&
         Config.Default.HasLicense &&
         !Config.Default.KeyStore.GetBool(KeyStoreIds.LicenseShownB, false, true))
     {
         DLicense     dl = new DLicense();
         DialogResult dr = dl.ShowDialog(this);
         dl = null;
         if (dr.Equals(DialogResult.Cancel))
         {
             Application.DoEvents();
             InnerClose();
         }
         else
         {
             Config.Default.KeyStore.SetBool(KeyStoreIds.LicenseShownB, true, true);
         }
     }
     DownThread.Default.Monitor.OnLog         += Log;
     DownThread.Default.Monitor.OnLogProgress += LogProgress;
     DownThread.Default.doneAction             = new DownThread.DDone(this.ThreadDone);
     DownThread.Default.beforeCallStart        = new Remote.DBeforeCallStart(this.BeforeCallStart);
     DownThread.Default.Start(null, !invMode || Config.Default.updateBeforeStart);
 }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                if (Utils.IsNetworkPath(Application.ExecutablePath))
                {
                    throw new Exception(Str.Def.Get(Str.NoNetPath));
                }
                SetExceptionHandler();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                try
                {
                    LoadSettings();
                }
                catch (Exception xx)
                {
                    // not alone may be
                    Utils.OnError(xx);
                    return;
                }
                StarterCommand starterCommand = StarterCommand.Default;
                if ((args != null) && (args.Length >= 1))
                {
                    starterCommand = Config.Default.GetCommand(args[0]);
                }

                if (!ExclusiveLocker.Default.Lock(2000))
                {
                    // not alone
                    if (starterCommand == StarterCommand.Default)
                    {
                        if (Config.Default.updateBeforeStart)
                        {
                            return;
                        }
                        try
                        {
                            Local.Start(false);
                        }
                        catch { }
                    }
                    else if (starterCommand == StarterCommand.ShowVer)
                    {
                        try
                        {
                            DLicense.ShowText(Config.Default.GetShowVesion());
                        }
                        catch { }
                    }
                    return;
                }

                // log is avilable after this point only
                try
                {
                    RawLog.Default.Init();
                    DownThread.Default.Monitor.OnLog += RawLog.Default.Log;
                }
                catch (Exception xx) { Utils.OnError(xx); }

                RawLog.Default.Log("Cmd " + starterCommand.ToString());
                string tempLogPath = Config.Default.GetLogPath();

                switch (starterCommand)
                {
                case StarterCommand.ShowVer:
                    DLicense.ShowText(Config.Default.GetShowVesion());
                    return;

                case StarterCommand.KillApp:
                    Utils.KillApp(true, false);
                    return;

                case StarterCommand.ClearLog:
                    RawLog.Default.Dispose();
                    Utils.DeleteFile(tempLogPath);
                    return;

                case StarterCommand.ShowLog:

                    if (File.Exists(tempLogPath))
                    {
                        System.Diagnostics.Process p = System.Diagnostics.Process.Start(tempLogPath);
                        if (p != null)
                        {
                            p.Close();
                            p = null;
                        }
                    }
                    return;

                case StarterCommand.ClearCache:
                    try
                    {
                        Utils.KillApp(false, true);
                    }
                    catch (Exception xx) { Utils.OnError(xx); }
                    Thread.Sleep(1000);
                    Local.ClearCache();
                    return;

                case StarterCommand.ReplaceSelf:
                    if (SelfReplacer.DoSelfReplace(args))
                    {
                        return;
                    }
                    break;

                default:
                    // do nothing
                    break;
                }
                if (SelfReplacer.CheckReplace(args))
                {
                    return;
                }

                ServicePointManager.ServerCertificateValidationCallback
                    += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);

                bool     guiMode = false;
                DownForm df      = new DownForm();

                if (Config.Default.updateBeforeStart)
                {
                    if (starterCommand == StarterCommand.RunLocal)
                    {
                        guiMode = StartIt();
                        if (!guiMode)
                        {
                            return;
                        }
                    }
                    RawLog.Default.Log("ui");
                    Application.Run(df);
                    return;
                }

                guiMode = StartIt();

                if (!guiMode)
                {
                    if (starterCommand == StarterCommand.RunLocal)
                    {
                        return;
                    }
                    df.SetInivisibleMode();
                }
                else
                {
                    RawLog.Default.Log("ui");
                }

                Application.Run(df);
            }
            catch (Exception ex)
            {
                string m = ex.Message;
#if DEBUG
                m += " " + ex.StackTrace;
#endif
                MessageBox.Show(null, m, Str.Def.Get(Str.Error) + " - " + Config.Default.AppName);
            }
            finally
            {
                try
                {
                    RawLog.Default.Dispose();
                }
                catch { }
                try
                {
                    ExclusiveLocker.Default.Dispose();
                }
                catch (Exception xx) { Utils.OnError(xx); }
            }
        }