private static void Main() { bool exists = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1; if (exists) { MessageBox.Show("Программа уже запущена!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } AppDomain.CurrentDomain.AssemblyResolve += (o, ev) => { string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string assemblyPath = Path.Combine(folderPath, "lib", new AssemblyName(ev.Name).Name); if (File.Exists(assemblyPath + ".dll")) { return(Assembly.LoadFrom(assemblyPath + ".dll")); } if (File.Exists(assemblyPath + ".exe")) { return(Assembly.LoadFrom(assemblyPath + ".exe")); } return(null); }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Program program = new Program(); MainWindow window = new MainWindow(program); window.FormClosing += program.onFormMainClosing; Application.Run(window); }
/// <summary> /// Initializes a new instance of the <see cref="Application"/> class. /// </summary> protected Application(ApplicationContext settings) : base(settings) { Settings = settings; var uiSynchronizationContextCreated = new AutoResetEvent(false); UiThread = new Thread(() => { FormsApplication.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); FormsApplication.ThreadException += new ThreadExceptionEventHandler(Forms_UiUnhandledException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Forms_UnhandledException); FormsApplication.EnableVisualStyles(); FormsApplication.SetCompatibleTextRenderingDefault(false); SynchronizationContext.SetSynchronizationContext(UiSynchronizationContext = new WindowsFormsSynchronizationContext()); uiSynchronizationContextCreated.Set(); FormsApplication.Run(); }); UiThread.SetApartmentState(ApartmentState.STA); UiThread.Start(); uiSynchronizationContextCreated.WaitOne(); }
static void Main() { string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string productDataDir = Directory.CreateDirectory(MainApplication.ProductName).Name; string dataDir = Path.Combine(appdata, productDataDir); Directory.CreateDirectory(dataDir); AppDomain.CurrentDomain.SetData("DataDirectory", dataDir); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var success = true; try { AppDomain.CurrentDomain.SetData("ConnectionString", ConfigurationManager.ConnectionStrings["SettingsDatabase"].ConnectionString); } catch (Exception ex) { MessageBox.Show("There was a problem while loading the config file: " + ex.Message); success = false; } if (success) { MainApplication.EnableVisualStyles(); MainApplication.SetCompatibleTextRenderingDefault(false); MainApplication.Run(new ChurchTimer.Presentation.ControlPanel()); } }
private static void Main() { if (!IsAdministrator()) { var info = new ProcessStartInfo(Assembly.GetExecutingAssembly().GetName().Name); info.Verb = "runas"; Process.Start(info); Application.Exit(); } else { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Application.Run(new MainForm()); } catch (Exception ex) { TraceHelper.Tracer.WriteTrace(ex.ToString()); MessageBox.Show(ex.ToString()); } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; Application.Run(new Form1()); }
public void Run() { var app = new MockApplication(); var sut = new UI(app); Application.Run(sut); }
static void Main(string[] args) { try { HighlightingManager.Manager.AddSyntaxModeFileProvider( new SyntaxEditor()); if (ConfigHelper.IsStandalone) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new PringManagerForm()); } else { app = Nampula.UI.Application.GetInstance(); app.OnStartCreateMenu += App_OnStartCreateMenu; app.OnStartConnection += App_OnStartConnection; app.OnShutDown += App_OnShutDown; if (app.StartApplication("LP", Nampula.UI.eAppType.SAPForms)) { var mainForm = app.MainForm(); Application.Run(mainForm); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main() { client.SetSecurity(); client.LoginAsync().Wait(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.AddMessageFilter(new MouseMessageFilter()); MouseMessageFilter.Click += MouseClick; _parentForm = new ParentForm(); Application.Run(_parentForm); }
//[TestMethod] public void CasearTemplateTest() { var form = new TestForm(); var uiThread = new Thread(() => Application.Run(form)); uiThread.SetApartmentState(ApartmentState.STA); uiThread.Start(); //This test doesn't work yet! uiThread.Join(); }
private static void Startup(string[] args) { bool startMinimized = args.Any(a => a.Equals("/background", StringComparison.OrdinalIgnoreCase)); var ctx = MuteAppContext.Create(startMinimized); if (ctx != null) { WinFormsApplication.Run(ctx); } else { WinFormsApplication.Exit(); } }
static void Main() { var w = (int)SystemParameters.PrimaryScreenWidth; var h = (int)SystemParameters.PrimaryScreenHeight; IntPtr ptr = GetConsoleWindow(); int width = 640; MoveWindow(ptr, w - width, 0, width, h / 2, true); Console.BufferHeight = Int16.MaxValue - 1; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); StartUpdate(); Application.Run(new Form_Main()); }
/// <summary> /// UI thread start. /// </summary> private void UiThreadStart() { FormsApplication.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); FormsApplication.ThreadException += new ThreadExceptionEventHandler(Forms_UiUnhandledException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Forms_UnhandledException); FormsApplication.EnableVisualStyles(); FormsApplication.SetCompatibleTextRenderingDefault(false); SynchronizationContext.SetSynchronizationContext(UiSynchronizationContext = new WindowsFormsSynchronizationContext()); UiSynchronizationContextCreated.Set(); FormsApplication.Run(); }
private static void Main() { WinFormsApplication.EnableVisualStyles(); WinFormsApplication.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.UnhandledException += (sender, e) => TearDown(e.IsTerminating, e.ExceptionObject as Exception); WinFormsApplication.ApplicationExit += (sender, e) => TearDown(isTerminating: false, ex: null); // Initialize AppSettings file AppSettings.Instance.Save(); ConfigureCompositionRoot(); SplashScreenForm.Splash(() => _compositionRoot.Resolver.Resolve <SplashScreenForm>(), ExecuteBootstrapActions); WinFormsApplication.Run(_compositionRoot.Resolver.Resolve <MainForm>()); }
async void samplesListbox_SelectedIndexChanged(object sender, EventArgs e) { currentApplication?.Engine.Exit(); currentApplication = null; await semaphoreSlim.WaitAsync(); var type = (Type) samplesListbox.SelectedItem; if (type == null) return; urhoSurfacePlaceholder.Controls.Clear(); //urho will destroy previous control so we have to create a new one var urhoSurface = new Panel { Dock = DockStyle.Fill }; urhoSurfacePlaceholder.Controls.Add(urhoSurface); await Task.Delay(100);//give some time for GC to cleanup everything currentApplication = Application.CreateInstance(type, new ApplicationOptions("Data") { ExternalWindow = urhoSurface.Handle }); urhoSurface.Focus(); currentApplication.Run(); semaphoreSlim.Release(); }
public void LoadGUI() { try { Application.SetCompatibleTextRenderingDefault(false); if (Gui == null) { Gui = new MaidFiddlerGUI(this); } Application.Run(Gui); } catch (Exception e) { FiddlerUtils.ThrowErrorMessage(e, "Generic error", this); } }
public static void InitiateCommand() { var t = new Thread(() => { Mutex mutex = new System.Threading.Mutex(false, "lspdbg_instance"); try { if (mutex.WaitOne(0, false) || MessageBox.Show("An instance of Lisp Debugging Assistant is already running.\nMake sure to check on the tray icons.\nWould you still like to open a new instance?", "Instance Already Exists", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { SystemSounds.Asterisk.Play(); Application.Run(Main.MainForm = new MainForm()); } } finally { mutex?.Close(); } }); t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Start(); }
/// <summary> /// Run. /// </summary> /// <param name="name">Name.</param> /// <param name="iconPath">Icon file path.</param> /// <param name="exitCaption">Caption for the tasktray item to exit.</param> public static void Run(string name = "Wendigo", string iconPath = null, string exitCaption = "Exit") { tasktrayIcon.Text = name; tasktrayIcon.Icon = iconPath is null ? Resources.app : new Icon(iconPath); // Disable Ctrl+C not to raise exception in the caller process (e.g. KeyboardInterrupt). Console.TreatControlCAsInput = true; // Dispose the tasktray icon if whatever happens. FormApplication.ApplicationExit += Dispose; FormApplication.ThreadException += Dispose; Thread.GetDomain().UnhandledException += Dispose; // Add a tasktray item to exit. tasktrayIcon.AddMenuItem(exitCaption, Exit); Notify("Wendigo", "Activated Wendigo."); FormApplication.Run(new MainForm()); }
static void Main() { //AppDomain.CurrentDomain.AssemblyResolve+=CurrentDomain_AssemblyResolve; //绑定程序中的异常处理 #if Publish BindExceptionHandler(); #endif MessageBoxEx.EnableGlass = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Splasher.Show(typeof(frmSplash)); try { Application.Run(new frmMain()); } catch (Exception e) { LogHelper.WriteLog("用户取消了注册"); } }
public void WinFormsMethods_AreDispatchedCorrectly() { this.form = null; ManualResetEventSlim ready = new ManualResetEventSlim(false); Thread windowThread = new Thread(() => { this.form = new DispatchWinFormsObject(ready); FormsApplication.Run(this.form); }); windowThread.SetApartmentState(ApartmentState.STA); windowThread.Start(); ready.Wait(); this.form.AddControl(); this.form.Invoke(new Action(this.form.Close)); windowThread.Join(); }
private static void Main() { bool exists = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1; if (exists) { MessageBox.Show("Программа уже запущена!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Распаковка DLL, которая не находится при упаковке через LibZ File.WriteAllBytes("Microsoft.WindowsAPICodePack.dll", Resources.Microsoft_WindowsAPICodePack); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Program program = new Program(); MainWindow window = new MainWindow(program); window.FormClosing += program.onFormMainClosing; Application.Run(window); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); #if DEBUG // for manually testing different cultures //SetupCulture("de-DE"); #endif Core.Application.SetPaths( Application.StartupPath, System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HFM")); using (var container = new ServiceContainer()) { var bootStrapper = new BootStrapper(args, container); try { container.RegisterAssembly(Assembly.GetExecutingAssembly()); // wires up IServiceProvider and IServiceScopeFactory _ = container.CreateServiceProvider(new EmptyServiceCollection()); Forms.TypeDescriptionProviderSetup.Execute(); bootStrapper.Execute(); } catch (Exception ex) { bootStrapper.ShowStartupException(ex); return; } if (bootStrapper.MainForm != null) { Application.Run(bootStrapper.MainForm); } } }
private static void Main(string[] args) { initTrayIcon(); Handle.load(); if (Handle.data.isFirstStart) { //show window for first startup openUI(); Handle.data.isFirstStart = false; } //load all different managers Handle.init(); Handle.data.IsAutostartChanged += RegChanger.ChangeAutostart; Handle.data.SaveLocationChanged += updateSaveLocation; Handle.data.WallpaperTypeChanged += wallpaperTypeChanged; WinFormApplication.ApplicationExit += Application_ApplicationExit; WinFormApplication.Run(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new LayoutStylesForm()); }
public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Program()); }
public static void ShowForm() { innerForm = new WelcomeDialog(); Application.Run(innerForm); }
private static void Main() { Application.EnableVisualStyles(); Application.Run(new IsometricDrawingDemo()); }
public void Start() { // init user folder FileHelper.EnsureUserWorkspacerPathExists(); // init logging Logger.Initialize(FileHelper.GetUserWorkspacerPath()); Logger.Debug("starting workspacer"); // init plugin assembly resolver AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly; // init context and managers _context = new ConfigContext(); // connect to watcher _context.ConnectToWatcher(); // attach console output target Logger.AttachConsoleLogger((str) => { Console.WriteLine(str); _context.SendLogToConsole(str); }); // init system tray _context.SystemTray.AddToContextMenu("enable/disable workspacer", () => _context.Enabled = !_context.Enabled); _context.SystemTray.AddToContextMenu("quit workspacer", () => _context.Quit()); _context.SystemTray.AddToContextMenu("restart workspacer", () => _context.Restart()); _context.SystemTray.AddToContextMenu("show/hide keybind help", () => _context.Keybinds.ShowKeybindDialog()); if (ConfigHelper.CanCreateExampleConfig()) { _context.SystemTray.AddToContextMenu("create example workspacer.config.csx", CreateExampleConfig); } // init config ConfigHelper.DoConfig(_context); // init windows _context.Windows.Initialize(); // verify config var allWorkspaces = _context.WorkspaceContainer.GetAllWorkspaces().ToList(); // check to make sure there are enough workspaces for the monitors if (_context.MonitorContainer.NumMonitors > allWorkspaces.Count) { throw new Exception("you must specify at least enough workspaces to cover all monitors"); } // init workspaces var state = _context.LoadState(); if (state != null) { _context.Workspaces.InitializeWithState(state.WorkspaceState, _context.Windows.Windows); Enabled = true; } else { _context.Workspaces.Initialize(_context.Windows.Windows); Enabled = true; _context.Workspaces.SwitchToWorkspace(0); } // force first layout foreach (var workspace in _context.WorkspaceContainer.GetAllWorkspaces()) { workspace.DoLayout(); } // notify plugins that config is done _context.Plugins.AfterConfig(_context); // start message pump on main thread Application.Run(); }
public ProgramContextMenu(Program program) { AutoAccept = new MenuItem("Auto accept", CheckAndSave) { Checked = Settings.Default.AutoAccept }; AutoLock = new MenuItem("Auto lock", CheckAndSave) { Checked = Settings.Default.AutoLock }; AutoPick = new MenuItem("Auto pick", (sender, args) => { var window = program.autoPickFormWPF; void OpenNewAutoPick(System.Windows.Application application) => application.Dispatcher.Invoke(() => { window = new AutoPickWPF(); window.Closed += (o, eventArgs) => program.autoPickFormWPF = null; program.autoPickFormWPF = window; window.Show(); }); if (window == null) { var app = System.Windows.Application.Current; if (app == null) { var thread = new Thread(() => { app = new System.Windows.Application { ShutdownMode = ShutdownMode.OnExplicitShutdown }; OpenNewAutoPick(app); app.Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else { OpenNewAutoPick(app); } } else { program.autoPickFormWPF.Dispatcher.Invoke(() => { if (!window.IsVisible) { window.Show(); } if (window.WindowState == WindowState.Minimized) { window.WindowState = WindowState.Normal; } window.Activate(); window.Topmost = true; // important window.Topmost = false; // important window.Focus(); // important }); } //if (program.autoPickForm == null) //{ // program.autoPickForm = new AutoPickForm(); // program.autoPickForm.FormClosed += (o, eventArgs) => program.autoPickForm = null; // var thread = new Thread(() => Application.Run(program.autoPickForm)); // thread.SetApartmentState(ApartmentState.STA); // thread.Start(); //} //else //{ // program.autoPickForm.BringToFront(); //} }); #if DEBUG AutoPick.PerformClick(); #endif var rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); string currentRegValue = (string)rkApp?.GetValue(nameof(LolAutoAccept)); if (currentRegValue != null && currentRegValue != Application.ExecutablePath) { rkApp.SetValue(nameof(LolAutoAccept), Application.ExecutablePath); } AutoLoad = new MenuItem("Autoload on startup", (sender, args) => { ((MenuItem)sender).Checked = !((MenuItem)sender).Checked; if (((MenuItem)sender).Checked) { //string src = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //string dest = "C:\\temp\\" + System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName; //System.IO.File.Copy(src, dest); // Add the value in the registry so that the application runs at startup rkApp?.SetValue(nameof(LolAutoAccept), Application.ExecutablePath); } else { // Remove the value from the registry so that the application doesn't start rkApp?.DeleteValue(nameof(LolAutoAccept), false); } }) { Checked = currentRegValue != null }; CapturePattern = new MenuItem("CapturePattern (for dev only)", (sender, args) => { program.patternCaptureForm = new PatterCaptureForm(); program.patternCaptureForm.FormClosed += (o, eventArgs) => program.patternCaptureForm = null; var thread = new Thread(() => Application.Run(program.patternCaptureForm)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }); SearchMatchingPatternSize = new MenuItem("SearchMatchingPatternSize (for dev only)", (sender, args) => { var thread = new Thread(() => Application.Run(new SearchMatchingSizeForm())); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }); MenuItems.AddRange(new[] { AutoAccept, AutoLock, Divider1, AutoPick, Divider2, AutoLoad, Divider3, CapturePattern, SearchMatchingPatternSize, Divider4, Exit }); }
private void StartThreads() { size = Device.Info.ScaledScreenSize; size = Device.Info.PixelScreenSize; size = new Forms.Size(1280, 720); scale = new Forms.Size((Device.Info.PixelScreenSize.Width / size.Width), (Device.Info.PixelScreenSize.Height / size.Height)); XplatUIMine.GetInstance()._virtualScreen = new Rectangle(0, 0, (int)size.Width, (int)size.Height); XplatUIMine.GetInstance()._workingArea = new Rectangle(0, 0, (int)size.Width, (int)size.Height); new Thread(() => { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; MissionPlanner.Program.Main(new string[0]); MessageBox.Show("Application Exit"); return; var frm = new Form() { Width = (int)Forms.Application.Current.MainPage.Width, Height = (int)Forms.Application.Current.MainPage.Height, Location = new System.Drawing.Point(0, 0) }; frm.Controls.Add(new Label() { Text = "this is a test", Location = new System.Drawing.Point(frm.Width / 2, frm.Height / 2) }); /* * frm.Controls.Add(new RadioButton()); * frm.Controls.Add(new CheckBox()); * frm.Controls.Add(new ComboBox()); * frm.Controls.Add(new DomainUpDown()); * frm.Controls.Add(new DataGridView()); * frm.Controls.Add(new TextBox()); */ var param = new ConfigRawParams() { Location = new System.Drawing.Point(0, 0), Size = new System.Drawing.Size(frm.Width, frm.Height) }; frm.Controls.Add(param); frm.Shown += (sender, args) => { param.Activate(); }; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.Run(frm); }).Start(); Forms.Device.StartTimer(TimeSpan.FromMilliseconds(100), () => { this.SkCanvasView.InvalidateSurface(); return(true); }); this.SkCanvasView.PaintSurface += SkCanvasView_PaintSurface; this.SkCanvasView.EnableTouchEvents = true; this.SkCanvasView.Touch += SkCanvasView_Touch; }
public static void Main(string[] sargs) { Thread.CurrentThread.CurrentUICulture = Culture; CommandArgs args = new CommandArgs(sargs); if (args.styles) { Application.EnableVisualStyles(); } // Damn .NET text rendering Application.SetCompatibleTextRenderingDefault(false); Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(Application.ExecutablePath)); Localizations = new LocalizationInterface(); try { string[] langfiles = Directory.GetFiles("MGE3", "*.lng"); foreach (string langfile in langfiles) { Localizations.Add(langfile); } } catch { } string language = "English (default)"; bool autoLanguage = true; try { INIFile MGEini = new INIFile(fn_inifile, new INIFile.INIVariableDef [] { INIFile.iniDefEmpty, MainForm.iniLanguage, MainForm.iniAutoLang }); language = MGEini.getKeyString("Language"); autoLanguage = (MGEini.getKeyValue("AutoLang") == 1); } catch { } Localizations.Current = language; Localizations.ApplyStrings("", strings); if (args.mutex && !MutexCheck.PerformCheck()) { MessageBox.Show(strings["MGEguiRunning"], strings["Error"]); return; } Process[] morrowind = Process.GetProcessesByName("Morrowind"); foreach (Process p in morrowind) { MessageBox.Show(strings["MWRunning"], strings["Error"]); return; } if (!File.Exists("./morrowind.exe") || !File.Exists("./morrowind.ini") || !Directory.Exists("data files")) { MessageBox.Show(strings["NotMWDir"], strings["Error"]); return; } if (!Directory.Exists("MGE3") || !File.Exists("./MGE3/MGEfuncs.dll") || !File.Exists("./d3d8.dll") || !File.Exists("./dinput8.dll")) { MessageBox.Show(strings["MGEMissing"], strings["Error"]); return; } // Morrowind version info try { FileVersionInfo MorrowVersion = FileVersionInfo.GetVersionInfo("Morrowind.exe"); if (MorrowVersion.FileMajorPart != 1 || MorrowVersion.FileMinorPart < 6) { MessageBox.Show(strings["MWIncompat"], strings["Error"]); return; } } catch { MessageBox.Show(strings["MWCorrupt"], strings["Error"]); return; } runDir = System.Windows.Forms.Application.StartupPath; // Create some structures for (int i = 0; i < MACROS; i++) { Macros[i] = new Macro(); } for (int i = 0; i < TRIGGERS; i++) { Triggers[i] = new Trigger(); } DXMain.GetDeviceCaps(); mf = new MainForm(autoLanguage); Application.Run(mf); }