public void StartQuestBuilder() { Quests.QuestGenerator.QuestBuilder tool = new Quests.QuestGenerator.QuestBuilder(); System.Windows.Forms.ApplicationContext appContext = new System.Windows.Forms.ApplicationContext(); appContext.MainForm = tool; System.Windows.Forms.Application.Run(appContext); }
static void Main(string[] args) { Outlook.Application outlookApp = new Outlook.Application(); Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "My Subject"; mailItem.To = ""; mailItem.Attachments.Add(@"C:\test.pdf"); mailItem.Body = "This is my Body-Text"; mailItem.Importance = Outlook.OlImportance.olImportanceNormal; ((Outlook.ItemEvents_10_Event)mailItem).Close += MailItem_onClose; ((Outlook.ItemEvents_10_Event)mailItem).Send += MailItem_onSend; //mailItem.Display(true); // This call will make mailItem MODAL - // This way, you are not allowed to create another new mail, ob browse Outlook-Folders while mailItem is visible // Using ApplicationContext will wait until your email is sent or closed without blocking other Outlook actions. using (_context = new System.Windows.Forms.ApplicationContext()) { mailItem.Display(); System.Windows.Forms.Application.Run(_context); } if (mailWasSent) { System.Windows.Forms.MessageBox.Show("Email was sent"); } else { System.Windows.Forms.MessageBox.Show("Email was NOT sent"); } }
static int Main(string[] args) { app_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/pn_document_opener"; if (System.IO.Directory.Exists(app_path)) { RemoveDirectory(app_path); } if (System.IO.Directory.Exists(app_path)) { return(1); } for (int i = 0; i < 10 && !System.IO.Directory.Exists(app_path); ++i) { try { System.IO.Directory.CreateDirectory(app_path); } catch (Exception) { } } if (!System.IO.Directory.Exists(app_path)) { System.Windows.Forms.MessageBox.Show("Unable to create directory " + app_path, "PN Document Opener - Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly); return(1); } op_mutex = new System.Threading.Mutex(); server = new WebServer(); op_win = new OperationWindow(); op_win.Size = new System.Drawing.Size(0, 0); op_win.Shown += startWin; app_ctx = new System.Windows.Forms.ApplicationContext(op_win); System.Windows.Forms.Application.Run(app_ctx); return(0); }
static void Main(string[] args) { for (var i = 0; i < args.Length; i++) { if (args[i] == "--debug") { IsDebug = true; } if (args[i] == "--default") { ForceDefaultMapping = true; } if (args[i] == "--skip-ui") { ShouldOpenUI = false; } if (args[i] == "--mapping") { InitialMappingName = args[i + 1]; i++; } if (args[i] == "--start-disabled") { ShouldStartDisabled = true; } } RestServerInstance = new RestServer(); KeyboardMapperInstance = new KeyboardMapper(); ControllerManagerInstance = new ControllerManager(); KeyboardMapperInstance.OnParse += (s, e) => { if (ControllerManagerInstance.IsRunning) { ControllerManagerInstance.Stop(); ControllerManagerInstance.Start(); } }; RestServerInstance.Start(); if (!ShouldStartDisabled) { KeyboardMapperInstance.Start(); ControllerManagerInstance.Start(); } // See https://github.com/gmamaladze/globalmousekeyhook/issues/3#issuecomment-230909645 System.Windows.Forms.ApplicationContext msgLoop = new System.Windows.Forms.ApplicationContext(); ConsoleCtrlHandlerRef += new ConsoleCtrlHandler(HandleConsoleExit); SetConsoleCtrlHandler(ConsoleCtrlHandlerRef, true); System.Windows.Forms.Application.Run(msgLoop); }
/// <summary> /// Spustí main formulář aplikace /// </summary> /// <param name="formType"></param> private void _RunMainForm(Type formType) { System.Threading.Thread.CurrentThread.Name = "GUI"; System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); try { using (System.Windows.Forms.ApplicationContext context = new System.Windows.Forms.ApplicationContext()) { this._AppContext = context; this._AppMainForm = System.Activator.CreateInstance(formType) as System.Windows.Forms.Form; context.MainForm = this._AppMainForm; System.Windows.Forms.Application.Run(context); } } catch (Exception exc) { Trace.Exception(exc); Exception e = exc; while (e.InnerException != null) { e = e.InnerException; } string message = e.Message + Environment.NewLine + e.StackTrace; ShowError(message); if (System.Diagnostics.Debugger.IsAttached) { throw; } } finally { this._AppMainForm = null; this._AppContext = null; } Application.App.End(); }
static void Main(string[] args) { for (var i = 0; i < args.Length; i++) { if (args[i] == "--debug") { IsDebug = true; } if (args[i] == "--default") { ForceDefaultMapping = true; } if (args[i] == "--skip-ui") { ShouldOpenUI = false; } } RestServerInstance = new RestServer(); KeyboardMapperInstance = new KeyboardMapper(); ControllerManagerInstance = new ControllerManager(); KeyboardMapperInstance.OnParse += (s, e) => { if (ControllerManagerInstance.IsRunning) { ControllerManagerInstance.Stop(); ControllerManagerInstance.Start(); } }; RestServerInstance.Start(); KeyboardMapperInstance.Start(); ControllerManagerInstance.Start(); // See https://github.com/gmamaladze/globalmousekeyhook/issues/3#issuecomment-230909645 System.Windows.Forms.ApplicationContext msgLoop = new System.Windows.Forms.ApplicationContext(); System.Windows.Forms.Application.Run(msgLoop); }
static int Main(string[] args) { app_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+"/pn_document_opener"; if (System.IO.Directory.Exists(app_path)) RemoveDirectory(app_path); if (System.IO.Directory.Exists(app_path)) return 1; for (int i = 0; i < 10 && !System.IO.Directory.Exists(app_path); ++i) { try { System.IO.Directory.CreateDirectory(app_path); } catch (Exception) { } } if (!System.IO.Directory.Exists(app_path)) { System.Windows.Forms.MessageBox.Show("Unable to create directory " + app_path, "PN Document Opener - Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly); return 1; } op_mutex = new System.Threading.Mutex(); server = new WebServer(); op_win = new OperationWindow(); op_win.Size = new System.Drawing.Size(0,0); op_win.Shown += startWin; app_ctx = new System.Windows.Forms.ApplicationContext(op_win); System.Windows.Forms.Application.Run(app_ctx); return 0; }
public void StartQuestBuilder() { Quests.QuestGenerator.QuestBuilder tool = new Quests.QuestGenerator.QuestBuilder(); System.Windows.Forms.ApplicationContext appContext = new System.Windows.Forms.ApplicationContext(); appContext.MainForm = tool; System.Windows.Forms.Application.Run(appContext); }
/// <summary> /// Initializes a new instance of the <see cref="InteractiveWindow"/> class. /// </summary> /// <param name="context">The context that is use to terminate the application.</param> /// <param name="communicator">The object that forwards communication commands onto the real communicator.</param> public InteractiveWindow(System.Windows.Forms.ApplicationContext context, IHandleCommunication communicator) : this() { m_Context = context; m_Communicator = communicator; }
private void RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) { if ((reason == 4) && !SystemInformation.UserInteractive) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("CantShowModalOnNonInteractive")); } if (reason == -1) { this.SetState(8, false); } if (totalMessageLoopCount++ == 0) { baseLoopReason = reason; } this.messageLoopCount++; if (reason == -1) { if (this.messageLoopCount != 1) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("CantNestMessageLoops")); } this.applicationContext = context; this.applicationContext.ThreadExit += new EventHandler(this.OnAppThreadExit); if (this.applicationContext.MainForm != null) { this.applicationContext.MainForm.Visible = true; } } Form currentForm = this.currentForm; if (context != null) { this.currentForm = context.MainForm; } bool flag = false; bool flag2 = false; HandleRef hWnd = new HandleRef(null, IntPtr.Zero); if (reason == -2) { flag2 = true; } if ((reason == 4) || (reason == 5)) { flag = true; bool enable = (this.currentForm != null) && this.currentForm.Enabled; this.BeginModalMessageLoop(context); hWnd = new HandleRef(null, System.Windows.Forms.UnsafeNativeMethods.GetWindowLong(new HandleRef(this.currentForm, this.currentForm.Handle), -8)); if (hWnd.Handle != IntPtr.Zero) { if (System.Windows.Forms.SafeNativeMethods.IsWindowEnabled(hWnd)) { System.Windows.Forms.SafeNativeMethods.EnableWindow(hWnd, false); } else { hWnd = new HandleRef(null, IntPtr.Zero); } } if (((this.currentForm != null) && this.currentForm.IsHandleCreated) && (System.Windows.Forms.SafeNativeMethods.IsWindowEnabled(new HandleRef(this.currentForm, this.currentForm.Handle)) != enable)) { System.Windows.Forms.SafeNativeMethods.EnableWindow(new HandleRef(this.currentForm, this.currentForm.Handle), enable); } } try { if (this.messageLoopCount == 1) { WindowsFormsSynchronizationContext.InstallIfNeeded(); } if (flag && (this.currentForm != null)) { this.currentForm.Visible = true; } if ((!flag && !flag2) || (this.ComponentManager is System.Windows.Forms.Application.ComponentManager)) { this.ComponentManager.FPushMessageLoop((IntPtr) this.componentID, reason, 0); } else if ((reason == 2) || (reason == -2)) { this.LocalModalMessageLoop(null); } else { this.LocalModalMessageLoop(this.currentForm); } } finally { if (flag) { this.EndModalMessageLoop(context); if (hWnd.Handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.EnableWindow(hWnd, true); } } this.currentForm = currentForm; totalMessageLoopCount--; this.messageLoopCount--; if (this.messageLoopCount == 0) { WindowsFormsSynchronizationContext.Uninstall(false); } if (reason == -1) { this.Dispose(true); } else if ((this.messageLoopCount == 0) && (this.componentManager != null)) { this.RevokeComponent(); } } }
internal void DisposeThreadWindows() { try { if (this.applicationContext != null) { this.applicationContext.Dispose(); this.applicationContext = null; } new Application.ThreadWindows(true).Dispose(); this.DisposeParkingWindow(); } catch { } }