private void ProcessQueuedInstanceMessages() { if (this.splashForm != null) { this.splashForm.Close(); this.splashForm.Dispose(); this.splashForm = null; } if (IsHandleCreated && !PdnInfo.IsExpired && this.singleInstanceManager != null) { string[] messages1 = this.singleInstanceManager.GetPendingInstanceMessages(); string[] messages2 = this.queuedInstanceMessages.ToArray(); this.queuedInstanceMessages.Clear(); string[] messages = new string[messages1.Length + messages2.Length]; for (int i = 0; i < messages1.Length; ++i) { messages[i] = messages1[i]; } for (int i = 0; i < messages2.Length; ++i) { messages[i + messages1.Length] = messages2[i]; } foreach (string message in messages) { bool result = ProcessMessage(message); if (!result) { break; } } } }
public MainForm(string[] args) { bool canSetCurrentDir = true; this.StartPosition = FormStartPosition.WindowsDefaultLocation; bool splash = false; List <string> fileNames = new List <string>(); // Parse command line arguments foreach (string argument in args) { if (0 == string.Compare(argument, "/dontForceGC")) { Utility.AllowGCFullCollect = false; } else if (0 == string.Compare(argument, "/splash", true)) { splash = true; } else if (0 == string.Compare(argument, "/test", true)) { // This lets us use an alternate update manifest on the web server so that // we can test manifests on a small scale before "deploying" them to everybody PdnInfo.IsTestMode = true; } else if (0 == string.Compare(argument, "/profileStartupTimed", true)) { // profileStartupTimed and profileStartupWorkingSet compete, which // ever is last in the args list wins. PdnInfo.StartupTest = StartupTestType.Timed; } else if (0 == string.Compare(argument, "/profileStartupWorkingSet", true)) { // profileStartupTimed and profileStartupWorkingSet compete, which // ever is last in the args list wins. PdnInfo.StartupTest = StartupTestType.WorkingSet; } else if (argument.Length > 0 && argument[0] != '/') { try { string fullPath = Path.GetFullPath(argument); fileNames.Add(fullPath); } catch (Exception) { fileNames.Add(argument); canSetCurrentDir = false; } splash = true; } } if (canSetCurrentDir) { try { Environment.CurrentDirectory = PdnInfo.GetApplicationDir(); } catch (Exception ex) { Tracing.Ping("Exception while trying to set Environment.CurrentDirectory: " + ex.ToString()); } } // make splash, if warranted if (splash) { this.splashForm = new SplashForm(); this.splashForm.TopMost = true; this.splashForm.Show(); this.splashForm.Update(); } InitializeComponent(); this.Icon = PdnInfo.AppIcon; // Does not load window location/state LoadSettings(); foreach (string fileName in fileNames) { this.queuedInstanceMessages.Add(fileName); } // no file specified? create a blank image if (fileNames.Count == 0) { MeasurementUnit units = Document.DefaultDpuUnit; double dpu = Document.GetDefaultDpu(units); Size newSize = this.appWorkspace.GetNewDocumentSize(); this.appWorkspace.CreateBlankDocumentInNewWorkspace(newSize, units, dpu, true); this.appWorkspace.ActiveDocumentWorkspace.IncrementJustPaintWhite(); this.appWorkspace.ActiveDocumentWorkspace.Document.Dirty = false; } LoadWindowState(); deferredInitializationTimer.Enabled = true; Application.Idle += new EventHandler(Application_Idle); }