private void btnActivate_Click(object sender, EventArgs e)
 {
     this.btnCancel.Enabled   = false;
     this.txtCode.Enabled     = false;
     this.btnActivate.Enabled = false;
     base.Update();
     LicenseManager.Licensee = null;
     WSAgent.RegisterOffline(this.txtCode.Text, this._forAll);
     if (!string.IsNullOrEmpty(LicenseManager.Licensee))
     {
         MessageBox.Show("Activation Successful");
         base.Close();
     }
     else
     {
         MessageBox.Show("Invalid Activation Code");
     }
     this.btnCancel.Enabled   = true;
     this.txtCode.Enabled     = true;
     this.btnActivate.Enabled = true;
 }
示例#2
0
 private void _worker_DoWork(object sender, DoWorkEventArgs e)
 {
     WSAgent.Register(this.ActivationCode, this.rbAll.Checked, e);
 }
示例#3
0
 private static void Run(string queryToLoad, bool runQuery, string activationCode, bool deactivate, bool noForward, bool noUpdate, string caller)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (Environment.OSVersion.Version.Major >= 6)
     {
         try
         {
             SetProcessDPIAware();
         }
         catch
         {
         }
     }
     AutoSaver.Start();
     Wheeler.Register();
     if (Environment.OSVersion.Version.Major < 6)
     {
         ToolStripManager.RenderMode = ToolStripManagerRenderMode.System;
     }
     if (!((activationCode != null) || deactivate))
     {
         Splash = new LINQPad.UI.Splash();
         Splash.Show();
         Splash.Update();
     }
     Log.add_StringWriter(new Action <string>(Log.Write));
     Log.add_ExceptionWriter(new Action <Exception>(Log.Write));
     TypeResolver.ManyToOne  = Resources.ManyToOne;
     TypeResolver.OneToMany  = Resources.OneToMany;
     TypeResolver.OneToOne   = Resources.OneToOne;
     TypeResolver.ManyToMany = Resources.ManyToMany;
     TypeResolver.Results    = Resources.Results;
     TypeResolver.Column     = Resources.Column;
     TypeResolver.Key        = Resources.Key;
     TypeResolver.Database   = Resources.Database;
     TypeResolver.GetSameFolderReferences        = new Func <string, string[]>(AssemblyProber.GetSameFolderReferences);
     WSAgent.WebClientFactory                    = new Func <WebClient>(WebHelper.GetWebClient);
     WSAgent.FastWebClientFactory                = new Func <WebClient>(WebHelper.GetFastWebClient);
     WSAgent.BackupWebClientFactory              = new Func <WebClient>(WebHelper.GetBackupWebClient);
     WSAgent.CurrentVersionString                = VersionString;
     AutocompletionManager.PassiveAutocompletion = UserOptions.Instance.PassiveAutocompletion;
     AutocompletionManager.DisableLambdaSnippets = UserOptions.Instance.DisableLambdaSnippets;
     SnippetManager.set_LINQPadSnippetsFolder(UserOptions.Instance.GetCustomSnippetsFolder(false));
     WSAgent.DiagnosticMode = DiagnosticMode;
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);
     if (deactivate)
     {
         WSAgent.Remove(true);
     }
     else
     {
         if (activationCode != null)
         {
             using (RegisterForm form = new RegisterForm(activationCode))
             {
                 form.ShowDialog();
                 return;
             }
         }
         if (!noUpdate)
         {
             Thread thread = new Thread(new ParameterizedThreadStart(UpdateAgent.RunServerComms))
             {
                 Name         = "Update Agent",
                 IsBackground = true
             };
             _updateThread = thread;
             _updateThread.Start(caller);
         }
         if (!string.IsNullOrEmpty(caller))
         {
             new Thread(delegate {
                 try
                 {
                     Thread.Sleep(0xbb8);
                     if (File.Exists(caller))
                     {
                         FileInfo info = new FileInfo(caller);
                         if (((info.Directory == null) || (info.Directory.Parent == null)) || (info.Directory.Parent.Name.ToLowerInvariant() != "updates"))
                         {
                             if (info.IsReadOnly)
                             {
                                 info.IsReadOnly = false;
                             }
                             if (!File.Exists(caller + ".config"))
                             {
                                 try
                                 {
                                     File.WriteAllText(caller + ".config", "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             string path = Assembly.GetExecutingAssembly().Location + ".config";
                             if (!File.Exists(path))
                             {
                                 try
                                 {
                                     File.WriteAllText(path, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             try
                             {
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                             catch
                             {
                                 Thread.Sleep(0x1388);
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                         }
                     }
                 }
                 catch
                 {
                 }
             })
             {
                 Name = "Update patcher"
             }.Start();
         }
         UnpackDb();
         QueryOneToOne();
         QueryStudioKeys(noForward);
         StartSemanticParsingService();
         new Thread(delegate {
             try
             {
                 Thread.Sleep(0x3e8);
                 if (GacResolver.IsLINQPadGaced())
                 {
                     MessageBox.Show("Warning: A different revision of LINQPad has been installed to the Global Assembly Cache. This will prevent correct operation.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             catch
             {
             }
         })
         {
             IsBackground = true
         }.Start();
         Application.Run(new MainForm(queryToLoad, runQuery));
         TempFileRef.DeleteAll();
     }
 }