public OptionsForm(int startTabPage)
 {
     this._fontPath = Path.Combine(Program.UserDataFolder, "queryfont.txt");
     this._queriesPath = Path.Combine(Program.UserDataFolder, "querypath.txt");
     this._userOptions = UserOptions.Instance;
     this._advancedOptions = new AdvancedOptions();
     this._oldEditorBackColor = UserOptions.Instance.ActualEditorBackColor;
     this.components = null;
     this.InitializeComponent();
     this.cboFont.DropDownHeight = this.Font.Height * 20;
     this._fonts = new Font[] { new Font(Control.DefaultFont, FontStyle.Regular) };
     this.cboFont.Items.Add("Populating...");
     this.cboFont.SelectedIndex = 0;
     this.fontWorker.RunWorkerAsync();
     this.rbCustomColor.Checked = !string.IsNullOrEmpty(UserOptions.Instance.EditorBackColor);
     this.panColorSample.BackColor = UserOptions.Instance.ActualEditorBackColor;
     if (File.Exists(this._queriesPath))
     {
         try
         {
             this.myQueries.FolderText = File.ReadAllText(this._queriesPath);
         }
         catch
         {
         }
     }
     if (!string.IsNullOrEmpty(this._userOptions.CustomSnippetsFolder))
     {
         this.mySnippets.FolderText = this._userOptions.CustomSnippetsFolder;
     }
     if (!string.IsNullOrEmpty(this._userOptions.PluginsFolder))
     {
         this.myPlugins.FolderText = this._userOptions.PluginsFolder;
     }
     if (File.Exists(Options.CustomStyleSheetLocation))
     {
         this.rbCustomStyleSheet.Checked = true;
     }
     try
     {
         int? maxQueryRows = this._userOptions.MaxQueryRows;
         this.udMaxQueryResults.Value = maxQueryRows.HasValue ? ((decimal) maxQueryRows.GetValueOrDefault()) : 0x3e8;
     }
     catch
     {
     }
     try
     {
         QueryLanguage? defaultQueryLanguage = this._userOptions.DefaultQueryLanguage;
         this.cboLanguage.SelectedIndex = defaultQueryLanguage.HasValue ? ((int) defaultQueryLanguage.GetValueOrDefault()) : 0;
     }
     catch
     {
     }
     this.chkDisable1To1.Checked = File.Exists(Program.OneToOneAckFile) && string.Equals(File.ReadAllText(Program.OneToOneAckFile).Trim(), "False", StringComparison.OrdinalIgnoreCase);
     this.chkLineNumbers.Checked = this._userOptions.ShowLineNumbersInEditor;
     if (this._userOptions.ResultsInGrids)
     {
         this.rbGrids.Checked = true;
     }
     this.rbOptimize.Checked = MainForm.Instance.OptimizeQueries;
     this.rbNoOptimize.Checked = !MainForm.Instance.OptimizeQueries;
     this._advancedOptions.Read();
     this.EnableControls();
     this.lblAdvancedRestart.Font = new Font(this.lblAdvancedRestart.Font, FontStyle.Bold);
     this.tabControl.SelectedIndex = startTabPage;
     this.tabControl_SelectedIndexChanged(this, EventArgs.Empty);
     this.myQueries.MRU = MRU.QueryLocations;
     this.mySnippets.MRU = MRU.SnippetLocations;
     this.myPlugins.MRU = MRU.PluginLocations;
 }
Exemple #2
0
 private static void Go(string[] args)
 {
     if (Path.GetFileName(Assembly.GetExecutingAssembly().Location).ToLowerInvariant() != "linqpad.exe")
     {
         MessageBox.Show("The application must be named LINQPad.exe in order to run.", "LINQPad");
     }
     else
     {
         if ((args.Length > 0) && !args[0].StartsWith("-", StringComparison.Ordinal))
         {
         }
         string queryToLoad = (CS$ < > 9__CachedAnonymousMethodDelegatef != null) ? null : string.Join(" ", args.TakeWhile <string>(CS$ < > 9__CachedAnonymousMethodDelegatef).ToArray <string>());
         if (queryToLoad != null)
         {
             queryToLoad = queryToLoad.Trim();
             if (queryToLoad.StartsWith("\"") && queryToLoad.EndsWith("\""))
             {
                 queryToLoad = queryToLoad.Substring(1, queryToLoad.Length - 2);
             }
         }
         if ((queryToLoad == null) || !CheckForExistingProcess(queryToLoad))
         {
             UserOptions instance  = UserOptions.Instance;
             bool        noForward = args.Any <string>(a => a.ToLowerInvariant() == "-noforward");
             bool        noUpdate  = args.Any <string>(a => a.ToLowerInvariant() == "-noupdate");
             BetaMode            = args.Any <string>(a => a.ToLowerInvariant() == "-beta");
             _mtaMode            = args.Any <string>(a => a.ToLowerInvariant() == "-mta");
             _presentationMode   = args.Any <string>(a => a.ToLowerInvariant() == "-presenter");
             _preserveAppDomains = args.Any <string>(a => a.ToLowerInvariant() == "-preserveappdomains");
             _freshAppDomains    = args.Any <string>(a => a.ToLowerInvariant() == "-freshappdomains");
             _enableMars         = args.Any <string>(a => a.ToLowerInvariant() == "-mars");
             DiagnosticMode      = args.Any <string>(a => a.ToLowerInvariant() == "-diagnosticmode");
             bool   runQuery = args.Any <string>(a => a.ToLowerInvariant() == "-run");
             string caller   = args.FirstOrDefault <string>(a => a.StartsWith("-caller=", StringComparison.OrdinalIgnoreCase));
             if (caller != null)
             {
                 Caller = caller = caller.Substring(8);
             }
             string activationCode = args.FirstOrDefault <string>(a => a.StartsWith("-activate=", StringComparison.OrdinalIgnoreCase));
             if (activationCode != null)
             {
                 activationCode = activationCode.Substring(10);
                 noUpdate       = noForward = true;
             }
             bool deactivate = args.Any <string>(a => a.ToLowerInvariant() == "-deactivate");
             if (!noForward)
             {
                 string laterExe = UpdateAgent.GetLaterExe();
                 if (laterExe != null)
                 {
                     string arguments = string.Join(" ", args) + " -noforward";
                     if (caller == null)
                     {
                         arguments = arguments + " -caller=\"" + Assembly.GetExecutingAssembly().Location + "\"";
                     }
                     try
                     {
                         PropagateConfig(laterExe);
                     }
                     catch
                     {
                     }
                     Process.Start(laterExe, arguments);
                     UpdateAgent.UpdateRetractions();
                     return;
                 }
             }
             AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Program.FindAssem);
             try
             {
                 CreateAppDataFolder();
                 string str7 = "LINQPad4Path.txt";
                 string path = Path.Combine(AppDataFolder, str7);
                 if (!(File.Exists(path) && !(File.ReadAllText(path) != Assembly.GetExecutingAssembly().Location)))
                 {
                     File.WriteAllText(path, Assembly.GetExecutingAssembly().Location);
                 }
             }
             catch
             {
             }
             try
             {
                 if (Caller != null)
                 {
                     QueryConfigFile = Path.Combine(Path.GetDirectoryName(Caller), "LINQPad.config");
                 }
                 else
                 {
                     QueryConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LINQPad.config");
                 }
             }
             catch
             {
             }
             new Thread(new ThreadStart(Program.Listen))
             {
                 IsBackground = true, Name = "OpenQuery Monitor"
             }.Start();
             Run(queryToLoad, runQuery, activationCode, deactivate, noForward, noUpdate, caller);
         }
     }
 }