private async void Start() { var splash = new SplashWindow(); splash.Show(); var bootstrapper = new Bootstrapper(); var container = bootstrapper.Build(); Log.Info("Initializing reactive trader API..."); var sw = Stopwatch.StartNew(); var reactiveTraderApi = container.Resolve <IReactiveTrader>(); var username = container.Resolve <IUserProvider>().Username; reactiveTraderApi.Initialize(username, container.Resolve <IConfigurationProvider>().Servers, container.Resolve <ILoggerFactory>()); Log.InfoFormat("Reactive trader API initialized in {0}ms", sw.ElapsedMilliseconds); MainWindow = new MainWindow(); var shellViewModel = container.Resolve <IShellViewModel>(); MainWindow.Content = new ShellView(shellViewModel); await Task.Delay(TimeSpan.FromSeconds(1.5)); splash.Close(); MainWindow.Show(); Log.InfoFormat("Main UI displayed {0}ms after process start.", DateTime.Now - Process.GetCurrentProcess().StartTime); }
private void Application_Startup(object sender, StartupEventArgs e) { Thread t = new Thread(() => { SplashWindow sw = new SplashWindow(); Dic["SplashWindow"] = sw; //储存 sw.ShowDialog(); //不能用Show }); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA);//设置单线程 t.Start(); MainWindow mainWindow = new MainWindow(); Thread.Sleep(5000); if (App.Dic.ContainsKey("SplashWindow")) { SplashWindow sw = App.Dic["SplashWindow"] as SplashWindow; sw.Dispatcher.Invoke((Action)(() => sw.Close()));//在sw的线程上关闭SplashWindow } mainWindow.Focus(); mainWindow.Show(); }
public void CloseSplashScreen() { if (mSplashWindow == null) { return; } Application.Current.Dispatcher.Invoke(() => mSplashWindow.Close()); }
//Hides Progressbar private void HideProgressbar() { if (sw != null) { sw.Close(); // close window if it exists } Mouse.OverrideCursor = defaultcursor; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Initialize the splash screen and set it as the application main window. var splashScreen = new SplashWindow(); this.MainWindow = splashScreen; splashScreen.Show(); // In order to ensure the UI stays responsive, we need to do the work on a different thread. Task.Factory.StartNew(() => { // Load settings. string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Settings.SettingsPath); if (File.Exists(settingsPath)) { string settingsJson = FileManager.ReadTextFile(settingsPath, Encoding.UTF8); Settings.Instance = JsonSerializer.Deserialize <Settings>(settingsJson); } // Load history. string historyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Settings.HistoryPath); if (File.Exists(settingsPath)) { string historyJson = FileManager.ReadTextFile(historyPath, Encoding.UTF8); History.Instance = JsonSerializer.Deserialize <History>(historyJson); } // Load Workspace. Workspace.Instance = new Workspace(); // Load theme. if (Settings.Instance.ThemeStyle == ThemeStyle.Light) { UpdateSkin(SkinType.Default); Workspace.Instance.SelectedTheme = new Vs2013LightTheme(); } else { UpdateSkin(SkinType.Dark); Workspace.Instance.SelectedTheme = new Vs2013DarkTheme(); } // Since we're not on the UI thread once we're done we need to use the Dispatcher to create and show the main window. this.Dispatcher.Invoke(() => { // Initialize the main window, set it as the application main window and close the splash screen. var mainWindow = new MainWindow(); this.MainWindow = mainWindow; mainWindow.Show(); splashScreen.Close(); }); }); }
//Hides Progressbar private void HideProgressbar() { if (sw != null) { sw.Close(); // close window if it exists //sw.Visibility = Visibility.Hidden; //sw = null; } Mouse.OverrideCursor = defaultcursor; }
private void Form1_Load(object sender, EventArgs e) { Thread.Sleep(5000); this.Show(); if (Form1.Dic.ContainsKey("SplashWindow")) { SplashWindow sw = Form1.Dic["SplashWindow"] as SplashWindow; sw.Dispatcher.Invoke((Action)(() => sw.Close()));//在sw的线程上关闭SplashWindow } }
void App_Startup(object sender, StartupEventArgs e) { SplashWindow splash = new SplashWindow(); //KöTaf.WPFApplication.Views.LoginWindow newWindow = new KöTaf.WPFApplication.Views.LoginWindow(); //MainWindow newWindow = new MainWindow(null); //newWindow.Show(); splash.Show(); splash.Close(); }
private void InitData() { JazeDatabaseContext.Context.Radicals.Load(); JazeDatabaseContext.Context.Kanjis.Load(); Current.Dispatcher.BeginInvoke(new Action(() => { var mainWindow = new MainWindow(); this.MainWindow = mainWindow; mainWindow.Show(); splashWindow.Close(); splashWindow = null; })); }
private async void App_Startup(object sender, StartupEventArgs e) { var splash = new SplashWindow(); splash.Show(); await InitializeAsync(); var main = new MainWindow(); main.Show(); MainWindow = main; splash.Close(); }
private void Application_Startup(object sender, StartupEventArgs e) { SplashWindow splash = new SplashWindow(); splash.Show(); //Read the last used Workspace: string lastWorkspace = ReadWorkSpaceFromRegestry(); SwitchWorkspace(lastWorkspace, null); MainWindow main = new MainWindow(); Thread.Sleep(3000); splash.Close(); main.Show(); }
private async void App_Startup(object sender, StartupEventArgs e) { var splashVM = new SplashViewModel(); var splash = new SplashWindow { DataContext = splashVM, }; splash.Show(); await Task.Yield(); await splashVM.InitializeAsync(null); splashVM.Info = "service1 initializing..."; // await service1.InitializeAsync(); await Task.Delay(150); splashVM.Info = "service2 initializing..."; await Task.Delay(250); splashVM.Info = "service3 initializing..."; await Task.Delay(350); splashVM.Info = "service4 initializing..."; await Task.Delay(450); splashVM.Info = "service5 initializing..."; await Task.Delay(550); splashVM.Info = "finished."; var mainVM = new MainViewModel(); MainWindow = new MainWindow { DataContext = mainVM, }; MainWindow.Show(); await mainVM.InitializeAsync(null); await Task.Delay(1000); splash.Close(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { this.Loaded -= MainWindow_Loaded; SplashWindow _splash = new SplashWindow(); _splash.Show(); MessageListener.Instance.StartWork(GetStageText(0), new DispatcherOperationCallback(InitStage0)); Thread.Sleep(1); MessageListener.Instance.StartWork(GetStageText(1), new DispatcherOperationCallback(InitStage1)); Thread.Sleep(1); MessageListener.Instance.StartWork(GetStageText(2), new DispatcherOperationCallback(InitStage2)); Thread.Sleep(1); _splash.Close(); }
public static void CloseSplashWindow() { if (_dispatcher == null) { return; } _dispatcher.BeginInvoke(new Action( delegate { if (_splashWindow == null) { return; } _splashWindow.Close(); })); Application.Current.MainWindow.Activate(); _dispatcher.InvokeShutdown(); }
public App() { InitializeComponent(); log.Trace("Initializing App", null); _ = (new UpdateService()).CheckUpdates(); splash = new SplashWindow(); overlay = new OverlayWindow(Forms.Screen.PrimaryScreen); splash.Show(); Task.Run(() => { AppService.Instance.Start(); App.Current.Dispatcher.Invoke(delegate { splash.Close(); }); }); }
protected override void OnStartup(StartupEventArgs e) #endif { MainWindow mainWindow = new MainWindow(); #if !DEBUG SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); await Task.Delay(2000); #endif PrepareApp(); mainWindow.Show(); #if !DEBUG splashWindow.Close(); #endif base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { if (this.ParseCommandLine() == false) { this.Shutdown(); return; } try { var splash = new SplashWindow() { Title = AppUtility.ProductName, ThemeColor = Settings.Default.ThemeColor, Background = Settings.Default.Background, Foreground = Settings.Default.Foreground }; splash.Show(); if (this.FindResource("bootstrapper") is AppBootstrapper bootstrapper) { bootstrapper.Initialize(); } base.OnStartup(e); splash.Close(); } catch (ConfigurationErrorsException cee) { foreach (var exception in cee.Errors) { CremaLog.Error(exception); } Settings.Default.Reset(); MessageBox.Show($"설정 파일을 초기화 하였습니다.\r\n응용 프로그램을 다시 시작하십시오.\r\n\r\n{cee}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); throw; } }
protected override void OnStartup(StartupEventArgs e) { BootLog.Log("App.OnStartup start"); RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; try { appMutex = new Mutex(true, _appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { if (!NTMiner.Windows.Role.IsAdministrator) { AppHelper.RunAsAdministrator(); return; } BootLog.Log("new SplashWindow"); SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); NTMinerRoot.Inited = () => { NTMinerRoot.KernelDownloader = new KernelDownloader(); Execute.OnUIThread(() => { bool?result = true; if (string.IsNullOrEmpty(Server.LoginName) || string.IsNullOrEmpty(Server.Password)) { LoginWindow loginWindow = new LoginWindow(); splashWindow.Hide(); result = loginWindow.ShowDialog(); } if (result.HasValue && result.Value) { BootLog.Log("new MainWindow"); ControlCenterWindow window = new ControlCenterWindow(); IMainWindow mainWindow = window; this.MainWindow = window; this.MainWindow.Show(); this.MainWindow.Activate(); BootLog.Log("MainWindow showed"); notifyIcon = new ExtendedNotifyIcon("pack://application:,,,/ControlCenterApp;component/logo.ico"); notifyIcon.Init(); #region 处理显示主界面命令 Global.Access <ShowMainWindowCommand>( Guid.Parse("01f3c467-f494-42b8-bcb5-848050df59f3"), "处理显示主界面命令", LogEnum.None, action: message => { Execute.OnUIThread(() => { Dispatcher.Invoke((ThreadStart)mainWindow.ShowThisWindow); AppHelper.MainWindowShowed(); }); }); #endregion Task.Factory.StartNew(() => { AppHelper.RunPipeServer(this, _appPipName); }); } splashWindow?.Close(); BootLog.SyncToDisk(); }); }; } else { try { AppHelper.ShowMainWindow(this, _appPipName); } catch (Exception) { DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error"); Process currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); foreach (var process in processes) { if (process.Id != currentProcess.Id) { NTMiner.Windows.TaskKill.Kill(process.Id); } } } } base.OnStartup(e); BootLog.Log("App.OnStartup end"); BootLog.SyncToDisk(); }
protected override void OnStartup(StartupEventArgs e) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; // 通过群控升级挖矿端的时候升级器可能不存在所以需要下载,下载的时候需要用到下载器所以下载器需要提前注册 VirtualRoot.BuildCmdPath <ShowFileDownloaderCommand>(action: message => { UIThread.Execute(() => { FileDownloader.ShowWindow(message.DownloadFileUrl, message.FileTitle, message.DownloadComplete); }); }); VirtualRoot.BuildCmdPath <UpgradeCommand>(action: message => { AppStatic.Upgrade(message.FileName, message.Callback); }); if (!string.IsNullOrEmpty(CommandLineArgs.Upgrade)) { VirtualRoot.Execute(new UpgradeCommand(CommandLineArgs.Upgrade, () => { UIThread.Execute(() => { Environment.Exit(0); }); })); } else { try { appMutex = new Mutex(true, s_appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { Logger.InfoDebugLine($"==================NTMiner.exe {MainAssemblyInfo.CurrentVersion.ToString()}=================="); NotiCenterWindowViewModel.IsHotKeyEnabled = true; SplashWindow splashWindow = null; // 在另一个UI线程运行欢迎界面以确保欢迎界面的响应不被耗时的主界面初始化过程阻塞 // 注意:必须确保SplashWindow没有用到任何其它界面用到的依赖对象 SplashWindow.ShowWindowAsync(window => { splashWindow = window; }); //ConsoleWindow.Instance.Show(); NotiCenterWindow.ShowWindow(); if (!NTMiner.Windows.WMI.IsWmiEnabled) { DialogWindow.ShowSoftDialog(new DialogWindowViewModel( message: "开源矿工无法运行所需的组件,因为本机未开启WMI服务,开源矿工需要使用WMI服务检测windows的内存、显卡等信息,请先手动开启WMI。", title: "提醒", icon: "Icon_Error")); Shutdown(); Environment.Exit(0); } if (!NTMiner.Windows.Role.IsAdministrator) { NotiCenterWindowViewModel.Instance.Manager .CreateMessage() .Warning("请以管理员身份运行。") .WithButton("点击以管理员身份运行", button => { WpfUtil.RunAsAdministrator(); }) .Dismiss().WithButton("忽略", button => { }).Queue(); } NTMinerRoot.Instance.Init(() => { _appViewFactory.Link(); if (VirtualRoot.IsLTWin10) { VirtualRoot.ThisLocalWarn(nameof(App), AppStatic.LowWinMessage, toConsole: true); } if (NTMinerRoot.Instance.GpuSet.Count == 0) { VirtualRoot.ThisLocalError(nameof(App), "没有矿卡或矿卡未驱动。", toConsole: true); } if (NTMinerRoot.Instance.ServerContext.CoinSet.Count == 0) { VirtualRoot.ThisLocalError(nameof(App), "访问阿里云失败,请尝试更换本机dns解决此问题。", toConsole: true); } UIThread.Execute(() => { if (NTMinerRoot.Instance.MinerProfile.IsNoUi && NTMinerRoot.Instance.MinerProfile.IsAutoStart) { ConsoleWindow.Instance.Hide(); VirtualRoot.Out.ShowSuccess("已切换为无界面模式运行,可在选项页调整设置", "开源矿工"); } else { // 预热视图模型 AppContext.Instance.VmsCtor(); _appViewFactory.ShowMainWindow(isToggle: false); } StartStopMineButtonViewModel.Instance.AutoStart(); AppContext.NotifyIcon = ExtendedNotifyIcon.Create("开源矿工", isMinerStudio: false); splashWindow?.Dispatcher.Invoke((Action) delegate() { splashWindow?.Close(); }); }); Task.Factory.StartNew(() => { if (NTMinerRoot.Instance.MinerProfile.IsAutoDisableWindowsFirewall) { Firewall.DisableFirewall(); } if (!Firewall.IsMinerClientRuleExists()) { Firewall.AddMinerClientRule(); } try { HttpServer.Start($"http://localhost:{NTKeyword.MinerClientPort.ToString()}"); Daemon.DaemonUtil.RunNTMinerDaemon(); } catch (Exception ex) { Logger.ErrorDebugLine(ex); } NTMinerRoot.Instance.CpuPackage.Start(); }); }); Link(); } else { try { _appViewFactory.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerClient); } catch (Exception) { DialogWindow.ShowSoftDialog(new DialogWindowViewModel( message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "提醒", icon: "Icon_Error")); Process currentProcess = Process.GetCurrentProcess(); NTMiner.Windows.TaskKill.KillOtherProcess(currentProcess); } } } base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; if (!string.IsNullOrEmpty(CommandLineArgs.Upgrade)) { AppStatic.Upgrade(CommandLineArgs.Upgrade, () => { Environment.Exit(0); }); } else { try { appMutex = new Mutex(true, s_appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { if (!NTMiner.Windows.WMI.IsWmiEnabled) { DialogWindow.ShowDialog(message: "开源矿工无法运行所需的组件,因为本机未开机WMI服务,开源矿工需要使用WMI服务检测windows的内存、显卡等信息,请先手动开启WMI。", title: "提醒", icon: "Icon_Error"); Shutdown(); Environment.Exit(0); } NTMinerOverClockUtil.ExtractResource(); AppStatic.SetIsMinerClient(true); NotiCenterWindowViewModel.IsHotKeyEnabled = true; SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); NotiCenterWindow.Instance.Show(); NTMinerRoot.Instance.Init(() => { NTMinerRoot.KernelDownloader = new KernelDownloader(); UIThread.Execute(() => { if (!NTMinerRegistry.GetIsNoUi() || !NTMinerRegistry.GetIsAutoStart()) { Views.MainWindow.ShowMainWindow(); } else { NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("已切换为无界面模式运行", "开源矿工"); } System.Drawing.Icon icon = new System.Drawing.Icon(GetResourceStream(new Uri("pack://application:,,,/NTMiner;component/logo.ico")).Stream); AppHelper.NotifyIcon = ExtendedNotifyIcon.Create(icon, "开源矿工", isMinerStudio: false); #region 处理显示主界面命令 VirtualRoot.Window <ShowMainWindowCommand>("处理显示主界面命令", LogEnum.None, action: message => { UIThread.Execute(() => { MainWindow mainWindow = this.MainWindow as MainWindow; if (mainWindow == null) { AppContext.Enable(); Views.MainWindow.ShowMainWindow(); // 使状态栏显示显示最新状态 if (NTMinerRoot.Instance.IsMining) { var coinShare = NTMinerRoot.Instance.CoinShareSet.GetOrCreate(NTMinerRoot.Instance.CurrentMineContext.MainCoin.GetId()); VirtualRoot.Happened(new ShareChangedEvent(coinShare)); if (NTMinerRoot.Instance.CurrentMineContext is IDualMineContext dualMineContext) { coinShare = NTMinerRoot.Instance.CoinShareSet.GetOrCreate(dualMineContext.DualCoin.GetId()); VirtualRoot.Happened(new ShareChangedEvent(coinShare)); } AppContext.Instance.GpuSpeedVms.Refresh(); } } else { mainWindow.ShowThisWindow(message.IsToggle); } }); }); #endregion splashWindow?.Close(); Task.Factory.StartNew(() => { try { HttpServer.Start($"http://localhost:{WebApiConst.MinerClientPort}"); NTMinerRoot.Instance.Start(); } catch (Exception ex) { Logger.ErrorDebugLine(ex.Message, ex); } }); }); }); Link(); } else { try { AppHelper.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerClient); } catch (Exception) { DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "提醒", icon: "Icon_Error"); Process currentProcess = Process.GetCurrentProcess(); NTMiner.Windows.TaskKill.KillOtherProcess(currentProcess); } } } base.OnStartup(e); }
private void dTimer_Tick(object sender, EventArgs e) { _view.Close(); _mainTimer.Stop(); }
private void Overlay_Loaded(object sender, RoutedEventArgs e) { log.Trace("Closing splash window"); splash.Close(); }
protected override async void OnStartup(StartupEventArgs e) { _applicationInstance = new WhisperApplication(); // Initialise the application instance. using (var splash = new SplashWindow(_applicationInstance.InitialisationProgress)) { splash.Show(); var timer = System.Diagnostics.Stopwatch.StartNew(); await _applicationInstance.InitialiseApplication(); timer.Stop(); var delayDelta = (int)(1000 - timer.ElapsedMilliseconds); if (delayDelta > 0) { await Task.Delay(delayDelta); } Locator.CurrentMutable.Register(() => new CreateItemView(), typeof(IViewFor <CreateItemViewModel>)); Locator.CurrentMutable.Register(() => new HistoryListItemView(), typeof(IViewFor <HistoryListItemViewModel>)); Locator.CurrentMutable.Register(() => new HistoryListView(), typeof(IViewFor <HistoryListViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageAboutView(), typeof(IViewFor <SettingsPageAboutViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageApplicationView(), typeof(IViewFor <SettingsPageApplicationViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGeneralView(), typeof(IViewFor <SettingsPageGeneralViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGenerationView(), typeof(IViewFor <SettingsPageGenerationViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGenerationItemView(), typeof(IViewFor <SettingsPageGenerationItemViewModel>)); Func <SettingsWindow> settingsWindowFactory = () => { var settingsWindow = new SettingsWindow(); var settingsVm = new SettingsWindowViewModel(new List <SettingsPageViewModelBase> { new SettingsPageAboutViewModel(_applicationInstance.AppInfoService), new SettingsPageGeneralViewModel(_applicationInstance.ConfigService), //new SettingsPageApplicationViewModel(), new SettingsPageGenerationViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService) }); settingsWindow.ViewModel = settingsVm; return(settingsWindow); }; var settingsManager = new SettingsWindowManager(settingsWindowFactory); var shellWindowViewModel = new ShellWindowViewModel(_applicationInstance.ConfigService, new CreateItemViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService, _applicationInstance.ClipboardService), new HistoryListViewModel(_applicationInstance.GeneratorService, _applicationInstance.ClipboardService), settingsManager); // Fix this bat-shit nonsense. Locator.CurrentMutable.UnregisterAll <IPropertyBindingHook>(); Locator.CurrentMutable.Register <IPropertyBindingHook>(() => new BindingHookFixerer()); var shell = new ShellWindow { ViewModel = shellWindowViewModel }; var trayIcon = new WhisperTrayAgent(shell, settingsManager); _applicationDisposables.Add(trayIcon); splash.Hide(); splash.Close(); shell.Show(); } base.OnStartup(e); }
private static bool FinishLoading() { if (tmpSettings.FirstRun) { LoggingService.LogDebug("First run"); // Generate key if (tmpSettings.PrivateKey == null) { GenerateKeyDialog keyDialog = new GenerateKeyDialog(null); keyDialog.Run(); tmpSettings.PrivateKey = keyDialog.Key; } /* Init the core */ core = new Core(tmpSettings, getPlatform()); /* Show change password dialog */ // var dialog = new ChangeKeyPasswordDialog(splashWindow.Window); // dialog.Run(); splashWindow.Close(); PreferencesDialog preferences = new PreferencesDialog(); if (preferences.Run() != (int)ResponseType.Ok) { // Abort !! Gtk.Application.Quit(); Environment.Exit(1); return(false); } core.ReloadSettings(); } else { /* Init the core */ core = new Core(tmpSettings, getPlatform()); } tmpSettings = null; core.AvatarManager = (IAvatarManager) new AvatarManager(core); /* Set up UI actions */ builtin_actions = new BuiltinActionGroup(); ui_manager = new UIManager(); ui_manager.InsertActionGroup(builtin_actions, 0); ui_manager.AddUiFromResource("Meshwork.Client.GtkClient.MainWindow.xml"); ui_manager.AddUiFromResource("Meshwork.Client.GtkClient.TrayPopupMenu.xml"); ui_manager.AddUiFromResource("Meshwork.Client.GtkClient.SearchPopupMenu.xml"); ui_manager.AddUiFromResource("Meshwork.Client.GtkClient.MapPopupMenu.xml"); /* Create the Tray Icon */ trayIcon = new TrayIcon(); /* Load the gui */ Gui.MainWindow = new MainWindow(); Gdk.Screen screen = Gdk.Screen.Default; /* * if (Utils.OSName == "Linux") { * Gdk.Colormap colormap = screen.RgbaColormap; * if (colormap != null) { * Widget.DefaultColormap = colormap; * Gtk.Widget.PushColormap(colormap); * } * } */ splashWindow.Close(); if ((!Gui.Settings.StartInTray && options.MainWindowState != "hidden") || (Gui.Settings.StartInTray && (options.MainWindowState == "shown" | options.MainWindowState == "iconified"))) { Gui.MainWindow.Show(); if (options.MainWindowState == "iconified") { Gui.MainWindow.Iconify(); } } core.Started += (EventHandler)DispatchService.GuiDispatch(new EventHandler(Core_Started)); Thread thread = new Thread(delegate() { core.Start(); }); thread.Start(); return(false); }
protected override void OnStartup(StartupEventArgs e) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; try { appMutex = new Mutex(true, s_appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { Vms.AppStatic.IsMinerClient = false; SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); NotiCenterWindow.Instance.Show(); NTMinerRoot.AppName = "开源矿工群控客户端"; NTMinerServices.NTMinerServicesUtil.RunNTMinerServices(); NTMinerRoot.Current.Init(() => { NTMinerRoot.KernelDownloader = new KernelDownloader(); UIThread.Execute(() => { splashWindow?.Close(); bool?result = true; if (Ip.Util.IsInnerIp(NTMinerRegistry.GetControlCenterHost())) { SingleUser.LoginName = "innerip"; SingleUser.SetPasswordSha1("123"); result = true; } else if (string.IsNullOrEmpty(SingleUser.LoginName) || string.IsNullOrEmpty(SingleUser.PasswordSha1)) { LoginWindow loginWindow = new LoginWindow(); result = loginWindow.ShowDialog(); } if (result.HasValue && result.Value) { ChartsWindow.ShowWindow(); System.Drawing.Icon icon = new System.Drawing.Icon(GetResourceStream(new Uri("pack://application:,,,/MinerStudio;component/logo.ico")).Stream); AppHelper.NotifyIcon = ExtendedNotifyIcon.Create(icon, "群控客户端", isMinerStudio: true); #region 处理显示主界面命令 VirtualRoot.Window <ShowMainWindowCommand>("处理显示主界面命令", LogEnum.None, action: message => { Dispatcher.Invoke((ThreadStart)ChartsWindow.ShowWindow); }); #endregion HttpServer.Start($"http://localhost:{WebApiConst.MinerStudioPort}"); AppHelper.RemoteDesktop = MsRdpRemoteDesktop.OpenRemoteDesktop; } }); }); VirtualRoot.Window <CloseNTMinerCommand>("处理关闭群控客户端命令", LogEnum.UserConsole, action: message => { UIThread.Execute(() => { if (MainWindow != null) { MainWindow.Close(); } Shutdown(); Environment.Exit(0); }); }); } else { try { AppHelper.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerStudio); } catch (Exception) { DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error"); Process currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); foreach (var process in processes) { if (process.Id != currentProcess.Id) { NTMiner.Windows.TaskKill.Kill(process.Id); } } } } base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; if (!string.IsNullOrEmpty(CommandLineArgs.Upgrade)) { Vms.AppStatic.Upgrade(CommandLineArgs.Upgrade, () => { Environment.Exit(0); }); } else { try { appMutex = new Mutex(true, s_appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { Vms.AppStatic.IsMinerClient = true; SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); NTMinerRoot.KernelBrandId = Brand.BrandUtil.KernelBrandId; NotiCenterWindow.Instance.Show(); NTMinerRoot.AppName = "开源矿工挖矿客户端"; NTMinerRoot.Current.Init(() => { NTMinerRoot.KernelDownloader = new KernelDownloader(); UIThread.Execute(() => { MainWindow window = new MainWindow(); IMainWindow mainWindow = window; this.MainWindow = window; this.MainWindow.Show(); this.MainWindow.Activate(); System.Drawing.Icon icon = new System.Drawing.Icon(GetResourceStream(new Uri("pack://application:,,,/NTMiner;component/logo.ico")).Stream); AppHelper.NotifyIcon = ExtendedNotifyIcon.Create(icon, "挖矿端", isMinerStudio: false); #region 处理显示主界面命令 VirtualRoot.Window <ShowMainWindowCommand>("处理显示主界面命令", LogEnum.None, action: message => { Dispatcher.Invoke((ThreadStart)mainWindow.ShowThisWindow); }); #endregion splashWindow?.Close(); Task.Factory.StartNew(() => { try { HttpServer.Start($"http://localhost:{WebApiConst.MinerClientPort}"); NTMinerRoot.Current.Start(); } catch (Exception ex) { Logger.ErrorDebugLine(ex.Message, ex); } }); }); }); VirtualRoot.Window <CloseNTMinerCommand>("处理关闭NTMiner客户端命令", LogEnum.UserConsole, action: message => { UIThread.Execute(() => { if (MainWindow != null) { MainWindow.Close(); } Shutdown(); Environment.Exit(0); }); }); VirtualRoot.On <MineStartedEvent>("开始挖矿后启动1080ti小药丸", LogEnum.DevConsole, action: message => { OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start(); }); VirtualRoot.On <MineStopedEvent>("停止挖矿后停止1080ti小药丸", LogEnum.DevConsole, action: message => { OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop(); }); NTMinerOverClockUtil.ExtractResource(); } else { try { AppHelper.ShowMainWindow(this, MinerServer.NTMinerAppType.MinerClient); } catch (Exception) { DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error"); Process currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); foreach (var process in processes) { if (process.Id != currentProcess.Id) { NTMiner.Windows.TaskKill.Kill(process.Id); } } } } } base.OnStartup(e); }