void Update() { for (int i = m_Requests.Count - 1; i >= 0; i--) { var t_Request = m_Requests[i]; if (t_Request.Request.isDone) { foreach (HTTPCallback t_Callback in t_Request.Callbacks) { t_Callback.Invoke(t_Request.Request); } m_Requests.Remove(t_Request); } } if (HasImportantTask()) { LoadingWindow.Show(); } else { LoadingWindow.Hide(); } }
async void InitLogin() { if (settings.loginDatas != null && settings.loginDatas.Count > 0) { ld = new LoadingWindow(); ld.Show(); ld.SetTitle("登陆中"); ld.SetTip("正在登陆"); ld.SetPgr(0, settings.loginDatas.Count); for (int i = 0; i < settings.loginDatas.Count; i++) { var t = settings.loginDatas[i]; ld.SetPgr(i, settings.loginDatas.Count); ld.SetTip("正在登陆账号:" + t.phone); await UserLogin(t); } chk_autoRefresh.IsChecked = settings.autoRefresh; LoadAccounts(); await RefreshStatus(); ld.Close(); ld = null; StatusTimer.Start(); } }
//CONSTRUCTOR public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) { _regionManager = regionManager; _regionManager.RegisterViewWithRegion(Regions.ContentRegion, typeof(SegmentSummaryPage)); //Sets default user control as SegmentSummaryPage _regionManager.RegisterViewWithRegion(Regions.TitleMenuRegion, typeof(TitleMenu)); _regionManager.RegisterViewWithRegion(Regions.ButtonsMenuRegion, typeof(ButtonsMenu)); _eventAggregator = eventAggregator; countSubscription = 0; //Start a new thread that runs the loading window independently(in order to allow the progress ring to appear) loadingWindowThread = new Thread(new ThreadStart(() => { // Create and show the Window LoadingWindow tempWindow = new LoadingWindow(); tempWindow.Show(); tempWindow.Activate(); // Start the Dispatcher Processing try { System.Windows.Threading.Dispatcher.Run(); } catch (Exception) { } })); loadingWindowThread.SetApartmentState(ApartmentState.STA); loadingWindowThread.IsBackground = true; loadingWindowThread.Start(); eventAggregator.GetEvent <IsSubscriptionCompleted>().Subscribe(CountSubscription); eventAggregator.GetEvent <UpdatedSourceEvent>().Subscribe(WriteOPCValue); }
protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); base.OnStartup(e); LoadingWindow loadingWindow = new LoadingWindow(); loadingWindow.Show(); ModelLoader loader = new ModelLoader(loadingWindow); Task.Factory.StartNew(() => { loader.LoadUserSettings(); loader.TryToConnect(); modelContainer = loader.GetModelConatiner(); this.Dispatcher.Invoke(() => { MainWindow window = new MainWindow(); MainViewModel MainViewModel = new MainViewModel(modelContainer); window.DataContext = MainViewModel; this.MainWindow = window; loadingWindow.Close(); window.Show(); //modelContainer.jetsonClient.StartTelemetry(2); }); }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var wnd = new LoadingWindow(); wnd.Show(); this.OnServiceLoaded += (s, _e) => { Dispatcher.BeginInvoke((Action)(() => { wnd.Hide(); new MainWindow().Show(); wnd.Close(); })); }; this.AsyncDispatch(() => { var languageInstance = Lib.Languages.Languages.Instance(); languageInstance.Initialize(); App.ServiceProvider.ScanCurrent(); var settingsProvider = App.ServiceProvider.GetProvider <SettingsProviderService>(); Debug.WriteLine("Currently active Language: " + settingsProvider?.GetConfig <ApplicationSettings>()?.SelectedLanguage.DisplayName); this.OnServiceLoaded?.Invoke(this, new EventArgs()); }).Execute(); Application.Current.Exit += (s, _e) => { App.ServiceProvider.GetProvider <AnimeService>()?.onExit(); }; }
private async void Application_Startup(object sender, StartupEventArgs e) { this.Dispatcher.UnhandledException += DispatcherOnUnhandledException; var loadingWindow = new LoadingWindow(); loadingWindow.Show(null, MiscStrings.CheckingConfiguration, MiscStrings.Initialising); var initResult = await BootStrap.CheckConfigurationAndInit(); _container = initResult.container; if (!initResult.ConfigResult.Success) { MessageBox.Show(string.Join(Environment.NewLine, initResult.ConfigResult.Errors), MiscStrings.LoadErrorCaption); Shutdown(); return; } loadingWindow.SetStatus(MiscStrings.CheckingForNewVersion); var release = await _container.GetInstance <IVersionChecker>().GetLatestVersion(); if (release.NewVersion) { MessageBox.Show(release.Release.ChangeLog, "New version " + release.Release.TagName + " is available!"); } loadingWindow.Hide(); _container.Configure(c => c.For <ILoadingWindow>().Use(loadingWindow).Singleton()); var windowProvider = _container.GetInstance <IWindowProvider>(); windowProvider.CreateWindow <IDeployment>().Show(); }
private void SignIn_Click(object sender, RoutedEventArgs e) { string Login = textBoxLogin.Text; string Password = passwordUserPassword.Password; Connection.Connect(Login, Password); IsEnabled = false; LoadingWindow LoadingWindow = new LoadingWindow { Owner = this, Width = Width - 40, Height = Height - 40 }; LoadingWindow.Show(); Thread ConnectThread = new Thread(() => { if (Configuration.Connect(Login, Password)) { Dispatcher.BeginInvoke(new Action(delegate() { this.Hide(); MainWindow MWindow = new MainWindow(Login, Password); MWindow.Show(); })); } }); ConnectThread.Start(); LoadingWindow.Hide(); IsEnabled = true; }
private void LoadLibrary(Library library) { _currentLibrary = library; ViewModelLocator.Cleanup(); Hub.Instance.Init(library); InitLog4Net(); SetAppTheme(); Hub.Instance.Settings.PropertyChanged += SettingsPropertyChanged; _activityTimer = new DispatcherTimer { Interval = TimeSpan.FromMinutes(Hub.Instance.Settings.AutoLockMainWindowAfter), IsEnabled = true }; _activityTimer.Tick += OnInactivity; var loading = new LoadingWindow(); SetTheme(loading); loading.Loaded += LoadingLoaded; loading.SetMessage("Initializing core"); loading.Show(); }
// For some reason reiniting is flaky :( public IEnumerator <object> InitGateways() { DestroyEndpoints(); Endpoints.Clear(); EndpointSettings[] endpoints = null; using (var q = Database.BuildQuery("SELECT * FROM jabber.endpoints")) yield return(q.ExecuteArray <EndpointSettings>().Bind(() => endpoints)); foreach (var settings in endpoints) { Endpoints[settings.Name] = null; } if (endpoints.Length == 0) { yield break; } using (var lw = new LoadingWindow()) { lw.SetStatus("Connecting", null); lw.Text = "Jabber Gateway"; lw.Show(); float?current = null; float stepSize = (1.0f / endpoints.Length); var sleep = new Sleep(0.25f); foreach (var settings in endpoints) { lw.SetStatus(String.Format("Connecting endpoint {0}", settings.Name), current); Console.Write("Initializing endpoint '{0}'... ", settings.Name); var f = Endpoint.Connect( this, settings, (s) => lw.SetProgress(current + (s * stepSize)) ); yield return(f); if (f.Error != null) { Console.WriteLine("failed: {0}", f.Error); Scheduler.OnTaskError(f.Error); } else { Console.WriteLine("initialized."); } current = current.GetValueOrDefault(0.0f) + stepSize; lw.SetProgress(current); yield return(sleep); } lw.SetStatus("Ready", 1.0f); lw.Close(); } }
/// <summary> /// Shows the loading message window after a short delay, to let the user know we are in fact working on it /// </summary> /// <param name="cancellationToken">token that will cancel when the loading is complete or timed out</param> /// <returns>The loading message window, so it may be closed.</returns> private static async Task <Window> ShowLoadingWindow(CancellationToken cancellationToken) { await Task.Delay(LoadingWindowDelayMilliseconds, cancellationToken); var window = new LoadingWindow(); window.Show(); return(window); }
public void DownloadData() { _loadingWindow = new LoadingWindow("Loading information"); _loadingWindow.Owner = _parent; _loadingWindow.Show(); _webClient = new WebClient(); _webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged; _webClient.DownloadStringCompleted += WebClient_DownloadStringCompleted; _webClient.DownloadStringAsync(new Uri("http://steamcommunity.com/sharedfiles/filedetails/?id=" + _id.ToString())); }
/// <summary> /// Initializes a new Instance of ExtenedMetroWindow. /// Begins the startup behaviour: /// 1. [MTA] Call App.InitializeSession /// Once done: /// 2. [MTA] Initialize ViewModel /// 3. [MTA] Assign dispatcher to ViewModel /// 4. [SYNC] Call OnInitializeSession /// Once done: /// 5. [SYNC] Call OnInitializedViewModel /// </summary> public ExtenedMetroWindow() { loadingWindow = new LoadingWindow { IsIndeterminate = true, Title = "Loading" }; CallbackTask.Run(App.InitializeSession, StartUpInitializeSession); loadingWindow.Show(); }
public (CancellationToken cancellation, Action close) ShowLoading() { var parent_window = App.ActiveWindow; var _LoadingWindow = new LoadingWindow() { Owner = parent_window, }; App.ActiveWindow.IsEnabled = false; _LoadingWindow.Show(); return(_LoadingWindow.Cancel, () => { _LoadingWindow.Close(); parent_window.IsEnabled = true; }); }
/// <summary> /// Shows the loading window either in normal or dialog mode. /// </summary> /// <param name="dialog">True if the window should be shown in dialog mode.</param> public void ShowLoadingWindow(bool asDialog) { Window window = new LoadingWindow(); if (asDialog) { window.ShowDialog(); } else { window.Show(); } }
private async void Btu_refreshStatus_Click(object sender, RoutedEventArgs e) { StatusTimer.Stop(); ld = new LoadingWindow(); ld.Show(); await RefreshStatus(); ld.Close(); ld = null; if (chk_autoRefresh.IsChecked == true) { StatusTimer.Start(); } }
public void ShowWindow() { if (window != null) { return; } window = BaseWindow.LoadWindow("LoadingWindow") as LoadingWindow; if (window != null) { window.OnWindowHide += OnWindowHide; window.Show(); } }
private void SiteSettingForm_OKButtonSelected(object sender, EventArgs e) { SiteSetting siteSetting = (SiteSetting)this.Tag; LoadingWindow loadingWindow = new LoadingWindow(); loadingWindow.Show(Languages.Translate("Checking connection...")); if (ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType).CheckConnection(siteSetting) == false) { this.IsValid = false; loadingWindow.Close(); MessageBox.Show(Languages.Translate("Checking connection failed. Please correct the entries.")); return; } loadingWindow.Close(); }
private async Task ShowLoadingWindowAfterDelayAsync(CancellationToken cancellationToken) { try { // Show LoadingWindow after a small delay // Goal is to avoid flicker for fast loading sites but to show progress for sites that take longer await Task.Delay(LoadingWindowDelayMilliseconds, cancellationToken); MainWindow = new LoadingWindow(); MainWindow.Show(); } catch (TaskCanceledException) { } }
private void ButtonFinish_Click(object sender, EventArgs e) { LoadingWindow loadingWindow = new LoadingWindow(); try { loadingWindow.Show(); Hide(); RequestClosed?.Invoke(this, EventArgs.Empty); Close(); loadingWindow.Close(); } catch (Exception ex) { MessageBox.Show("Exception EXPORT: " + ex.Message); } }
/// <summary> /// Keeps the loading window updated while the game is loading. /// </summary> protected void LoadingWindowThread() { // Create a loading window. LoadingWindow loadingWindow = new LoadingWindow(); loadingWindow.Text = "Loading " + _gameTitle; loadingWindow.SetStatus("Loading " + _gameTitle + "..."); loadingWindow.Show(); while (_loading == true) { Application.DoEvents(); Thread.Sleep(50); } loadingWindow.Close(); }
private void AnalyzeTextButton(object sender, RoutedEventArgs e) { if (true == StartBackgroundWork()) { var DC = this.DataContext as MainShellViewModel; ConnectionManager.saveData(DC.NgramSize, DC.PathToMainInputFile, DC.SegmentSize, DC.ChoosenRun); enginePipe.close(); LoadingWindow LW = new LoadingWindow(this); this.Hide(); LW.Show(); } //else //{ // //pop up error message // MessageBox.Show("Please Fill all fields", "Invalid input", MessageBoxButton.OK); //} }
public CollectedStatisticsWindow() { if (Settings.Current.StartupMaximized) { WindowState = WindowState.Maximized; } loadingWindow = new LoadingWindow { IsIndeterminate = true, Title = App.GetSharedResource("Loading"), Header = App.GetWindowResource("Stat_LoadingHeader"), Message = App.GetWindowResource("Stat_LoadingMessage"), ShowActivated = true }; loadingWindow.Show(); IsEnabled = false; CallbackTask.Run(App.InitializeSession, InitializedSession); logger.TraceResource("WinInit"); InitializeComponent(); logger.TraceResource("WinInitD"); }
private void OKButton_Click(object sender, RoutedEventArgs e) { var selectedItem = tabControl.SelectedItem as TabItem; if (null == selectedItem) { return; } if (selectedItem == tabItem1) { if (buffer == null || buffer.Length <= 0 || file == null || this.comboBox1.SelectedIndex == -1) { MessageBox.Show("请选择模板文件,或者选择导入的类别。", "提示", MessageBoxButton.OK); return; } //调用服务上传 try { loadingWindow.Show(); WSDesignerSoapClient da = Glo.GetDesignerServiceInstance(); da.UploadfileCCFormAsync(buffer, file.Name, this.comboBox1.SelectedValue.ToString()); da.UploadfileCCFormCompleted += new EventHandler <UploadfileCCFormCompletedEventArgs>(da_UploadfileCCFormCompleted); } catch (Exception ex) { this.DialogResult = false; MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK); } } if (selectedItem == tabItem2) { MessageBox.Show("此功能在施工中,敬请期待。或者访问http://templete.ccflow.org 流程与表单模板网下载到本机在导入。", "Sorry", MessageBoxButton.OK); } this.DialogResult = false; }
public void ShowModalLoadingAnimation() { lock (_loadingSyncLock) { _loadingCount++; if (_loadingCount == 1) { Window.Dispatcher.InvokeAsync(() => { if (_loadingWindow == null) { _loadingWindow = new LoadingWindow(); } if (!_loadingWindow.IsActive) { _loadingWindow.Show(Window); } }); } } }
private async void btu_tibi_Click(object sender, RoutedEventArgs e) { //MessageBox.Show("请等待接下来的开发和更新", "提示"); LoadingWindow wkld = new LoadingWindow(); wkld.SetTitle("正在提取玩客币"); wkld.Show(); string result = ""; for (int i = 0; i < settings.loginDatas.Count; i++) { var t = settings.loginDatas[i]; wkld.SetTip($"正在提取账号{t.phone}的玩客币"); wkld.SetPgr(i, settings.loginDatas.Count); string tresult = ""; var r = await DrawWkb(t.phone); if (r != null) { tresult = $"{t.phone}:({r.iRet}){r.sMsg}"; } else { tresult = $"{t.phone}:网络通讯失败"; } if (i != settings.loginDatas.Count - 1) { result += tresult + Environment.NewLine; } else { result += tresult; } } wkld.Close(); MessageBox.Show(result, "提币结果"); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var uid = TextBoxUid.Text; if (uid.IsEmptyOrNull()) { return; } if (!uid.IsNumber()) { return; } //开始加载 var loading = new LoadingWindow { Owner = this }; loading.Show(); OpacityMask = new SolidColorBrush { Opacity = 0.4, Color = Colors.Black }; IsEnabled = false; //查询函数 var stats = await QueryCore.QueryStats(uid); var avatars = (await QueryCore.QueryAvatars(uid)).ToList(); //赋值查询的状态 ActiveDays.Status = stats.ActiveDays; AchievementCount.Status = stats.AchievementCount; WinRate.Status = stats.WinRate; AnemoculusCount.Status = stats.AnemoculusCount; GeoculusCount.Status = stats.GeoculusCount; AvatarCount.Status = stats.AvatarCount; WayPointCount.Status = stats.WayPointCount; DomainCount.Status = stats.DomainCount; SpiralAbyss.Status = stats.SpiralAbyss; PreciousChests.Status = stats.PreciousChests; LuxuriousChests.Status = stats.LuxuriousChests; ExquisiteChests.Status = stats.ExquisiteChests; CommonChests.Status = stats.CommonChests; //赋值人物信息 //var roles = new ObservableCollection<RolesEntity>(); var count = 1; foreach (var a in avatars) { ListViewRoles.Items.Add(new RolesEntity { Avatar = a.Image, Element = a.Element.ToElement(), Fetter = a.Fetter + "级", Index = count++.ToString(), Level = a.Level + "级", Name = a.Name, Rarity = a.Rarity + "星" }); } //结束加载 OpacityMask = null; IsEnabled = true; loading.Close(); }
private void TemplatesGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DocumentTemplate documentTemplate = (DocumentTemplate)TemplatesGrid.SelectedItem; List <DocumentTemplateMapping> mappings = ConfigurationManager.GetInstance().GetDocumentTemplateMappings(documentTemplate.ID); DocumentTemplateMapping selectedDocumentTemplateMapping = null; Folder selectedTargetFolder = null; SiteSetting siteSetting = null; ContentType contentType = null; IServiceManager serviceManager = null; if (mappings.Count == 0) { MessageBox.Show(Languages.Translate("This template does not have any mapping for location")); return; } else if (mappings.Count == 1) { selectedDocumentTemplateMapping = mappings[0]; siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(selectedDocumentTemplateMapping.Folder.SiteSettingID); serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType); selectedTargetFolder = serviceManager.GetFolder(siteSetting, selectedDocumentTemplateMapping.Folder); contentType = serviceManager.GetContentType(siteSetting, selectedTargetFolder, selectedDocumentTemplateMapping.ContentTypeID, false); } else { DocumentTemplateLocationSelectionForm documentTemplateLocationSelectionForm = new DocumentTemplateLocationSelectionForm(); documentTemplateLocationSelectionForm.Initialize(mappings); if (documentTemplateLocationSelectionForm.ShowDialog(null, Languages.Translate("Select a location")) == true) { selectedDocumentTemplateMapping = documentTemplateLocationSelectionForm.SelectedDocumentTemplateMapping; selectedTargetFolder = documentTemplateLocationSelectionForm.SelectedFolder; siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(selectedDocumentTemplateMapping.Folder.SiteSettingID); serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType); contentType = serviceManager.GetContentType(siteSetting, selectedTargetFolder, selectedDocumentTemplateMapping.ContentTypeID, false); } else { return; } } List <ContentType> contentTypes = new List <ContentType>(); contentTypes.Add(contentType); FolderSettings folderSettings = ConfigurationManager.GetInstance().GetFolderSettings(ApplicationContext.Current.GetApplicationType()).GetRelatedFolderSettings(selectedTargetFolder.GetUrl()); FolderSetting defaultFolderSetting = ConfigurationManager.GetInstance().GetFolderSettings(ApplicationContext.Current.GetApplicationType()).GetDefaultFolderSetting(); EditItemPropertiesControl editItemPropertiesControl = new EditItemPropertiesControl(selectedTargetFolder.GetWebUrl(), null, contentTypes, folderSettings, defaultFolderSetting, siteSetting, selectedTargetFolder.GetUrl(), null, true); bool?dialogResult = editItemPropertiesControl.ShowDialog(null, Languages.Translate("Meta Data")); if (dialogResult == true) { LoadingWindow lw = new LoadingWindow(); lw.WindowStartupLocation = WindowStartupLocation.CenterScreen; lw.Show(); ContentType selectedContentType; Dictionary <object, object> values = editItemPropertiesControl.GetValues(out selectedContentType); string templateFilePath = documentTemplate.TemplatePath; FileInfo fi = new FileInfo(templateFilePath); string fileName = string.Empty; foreach (object key in values.Keys) { Field f = key as Field; if (f.Name.Equals("Title", StringComparison.InvariantCultureIgnoreCase) == true) { fileName = values[key] + fi.Extension; break; } } //string fileName = string.Format("w_{0}{1}", Guid.NewGuid().ToString().Replace("-", ""), fi.Extension); string actualFilePath = ConfigurationManager.GetInstance().GetTempFolder() + "\\" + fileName; ApplicationContext.Current.CreateNewFile(templateFilePath, actualFilePath); bool isListItemAndAttachment = ConfigurationManager.GetInstance().GetListItemAndAttachmentOption(); UploadItem uploadItem = new UploadItem(); uploadItem.FilePath = actualFilePath; uploadItem.Folder = selectedTargetFolder; uploadItem.ContentType = contentType; uploadItem.FieldInformations = values; Sobiens.Connectors.Common.ApplicationContext.Current.UploadFile(siteSetting, uploadItem, null, false, isListItemAndAttachment, Upload_Success, Upload_Failed); string documentURL = selectedTargetFolder.GetUrl() + "/" + fileName; object document = ApplicationContext.Current.OpenFile(siteSetting, documentURL); ApplicationContext.Current.RefreshControlsFromConfiguration(); lw.Close(); ApplicationContext.Current.ActivateDocument(document); } }
public void ShowModalWindow(WindowType windowType, object vm) { if (openWindows.Contains(windowType)) { return; } ; openWindows.Add(windowType); Messenger.Default.Send <DialogOpenedMessage>(new DialogOpenedMessage { Sender = this }); if (windowType == WindowType.AddFieldWindow) { addFieldWindow = new AddFieldWindow(); addFieldWindow.DataContext = vm; addFieldWindow.Show(); } else if (windowType == WindowType.PickupWindow) { pickupWindow = new PickupWindow(); pickupWindow.DataContext = vm; pickupWindow.Show(); } else if (windowType == WindowType.LoadingWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { loadingWindow = new LoadingWindow(); loadingWindow.DataContext = vm; loadingWindow.Show(); })); } else if (windowType == WindowType.LoadingAtGin) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { loadingAtGinWindow = new LoadingAtGin(); loadingAtGinWindow.DataContext = vm; loadingAtGinWindow.Show(); })); } else if (windowType == WindowType.UnloadingAtGin) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { unloadingAtGinWindow = new UnloadingWindow(); unloadingAtGinWindow.DataContext = vm; unloadingAtGinWindow.Show(); })); } else if (windowType == WindowType.LoadingIncorrectModuleWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { loadingIncorrectModuleWindow = new LoadingIncorrectModuleWindow(); loadingIncorrectModuleWindow.DataContext = vm; loadingIncorrectModuleWindow.Show(); })); } else if (windowType == WindowType.WaitingForUnloadWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { waitingForUnloadWindow = new WaitingForUnloadWindow(); waitingForUnloadWindow.DataContext = vm; waitingForUnloadWindow.Show(); })); } else if (windowType == WindowType.UnloadCorrectionWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { unloadCorrectionWindow = new UnloadingCorrectionWindow(); unloadCorrectionWindow.DataContext = vm; unloadCorrectionWindow.Show(); })); } else if (windowType == WindowType.ChangeListWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { loadingIncorrectModuleWindow.StopBeep(); changeFieldWindow = new ChangeFieldWindow(); changeFieldWindow.DataContext = vm; changeFieldWindow.Show(); })); } else if (windowType == WindowType.TruckSetupWindow) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { firstRunWindow = new FirstRunWindow(); firstRunWindow.DataContext = vm; firstRunWindow.Show(); })); } }
/// <summary> /// Keeps the loading window updated while the game is loading. /// </summary> protected void LoadingWindowThread() { // Create a loading window. LoadingWindow loadingWindow = new LoadingWindow(); loadingWindow.Text = "Loading " + _gameTitle; loadingWindow.SetStatus("Loading "+_gameTitle+"..."); loadingWindow.Show(); while (_loading == true) { Application.DoEvents(); Thread.Sleep(50); } loadingWindow.Close(); }
//MARK: Evaluation Methods private void EvalNetwork(string elapsedTime) //evaluate the newly trained network using DeepLabCut's evaluate_network function { BarInteraction(); string filePath = EnvDirectory + "\\vdlc_eval_network.py"; FileSystemUtils.MurderPython(); FileSystemUtils.RenewScript(filePath, AllScripts.EvalNetwork); FileSystemUtils.ReplaceStringInFile(filePath, "config_path_identifier", CurrentProject.ConfigPath); Process p = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.RedirectStandardInput = true; info.UseShellExecute = false; info.Verb = "runas"; info.CreateNoWindow = !ReadShowDebugConsole(); //if show debug console = true, then create no window has to be false this.Dispatcher.Invoke(() => { LoadingWindow = new LoadingWindow(); LoadingWindow.Title = "Evaluating"; LoadingWindow.Show(); LoadingWindow.Closed += LoadingClosed; LoadingWindow.ProgressBar.Maximum = 100; LoadingWindow.ProgressBar.Value = 100; LoadingWindow.ProgressLabel.Content = "Just a sec..."; }); p.EnableRaisingEvents = true; p.Exited += (sender1, e1) => { CurrentProject.TrainTime = elapsedTime; GetEvalResultsSaveTime(ref CurrentProject); this.Dispatcher.Invoke(() => { LoadingWindow.Close(); EvalWindow evalWindow = new EvalWindow(CurrentProject.TrainTime, CurrentProject.TrainError, CurrentProject.TestError, CurrentProject.PCutoff); //once done evaluating, show a window with evaluation stats evalWindow.Show(); }); SyncUI(); EnableInteraction(); }; p.StartInfo = info; p.Start(); globalStopWatch = new Stopwatch(); globalStopWatch.Start(); using ( StreamWriter sw = p.StandardInput) { //run the evaluation script if (sw.BaseStream.CanWrite) { sw.WriteLine(Drive); sw.WriteLine("cd " + EnvDirectory); sw.WriteLine(FileSystemUtils.CONDA_ACTIVATE_PATH); sw.WriteLine("conda activate " + EnvName); sw.WriteLine("ipython vdlc_eval_network.py"); if (info.CreateNoWindow == false) //for debug purposes { sw.WriteLine("ECHO WHEN YOU'RE DONE, CLOSE THIS WINDOW"); p.WaitForExit(); sw.WriteLine("Done, exiting."); } } } }
// Analyze videos for the corresponding analysis videos using DLC's built in analyze_videos function // If not in Debug mode, it redirects the output to the loading window accordingly private void AnalyzeVideos(Dictionary <int, AnalysisVideo> videos) { Console.WriteLine("Analyzing video..."); // Prepare script string filePath = EnvDirectory + "\\vdlc_analyze_video.py"; FileSystemUtils.MurderPython(); FileSystemUtils.RenewScript(filePath, AllScripts.AnalyzeVideo); FileSystemUtils.ReplaceStringInFile(filePath, "config_path_identifier", CurrentProject.ConfigPath); // Prepare cmd process Process p = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.RedirectStandardInput = true; info.RedirectStandardOutput = true; //!ReadShowDebugConsole(); info.UseShellExecute = false; info.Verb = "runas"; info.CreateNoWindow = !ReadShowDebugConsole(); //if show debug console = true, then create no window has to be false Dispatcher.Invoke(() => //once done close the loading window { LoadingWindow = new LoadingWindow(); LoadingWindow.Title = "Analyzing"; LoadingWindow.Show(); LoadingWindow.Closed += LoadingClosed; }); bool errorDuringAnalysis = false; string errorMessage = "No Error"; string progressValue = "0"; string progressMax = "0"; int videoProgValue = 0; //NONDEBUG ----------------------------------------------------------------------------------------------- if (info.CreateNoWindow) { //redirect output if debug mode disabled p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => //feed cmd output to the loading window so the user knows the progress of the analysis { if (!string.IsNullOrEmpty(e.Data)) { string line = e.Data; Console.WriteLine(line); if (line.Contains("OOM")) { errorMessage = "Analysis failed due to insufficient GPU memory. Try importing the video again and reducing its resolution, and/or cropping it."; errorDuringAnalysis = true; FileSystemUtils.MurderPython(); } if (line.Contains("progress_maximum")) { progressMax = line.Substring(line.IndexOf(":") + 1, line.IndexOf("#") - line.IndexOf(":") - 1); Dispatcher.Invoke(() => { LoadingWindow.ProgressBar.Maximum = int.Parse(progressMax); }); } if (line.Contains("progress_value")) { progressValue = line.Substring(line.IndexOf(":") + 1, line.IndexOf("#") - line.IndexOf(":") - 1); Dispatcher.Invoke(() => { LoadingWindow.ProgressLabel2.Content = progressValue + " / " + progressMax + " frames"; LoadingWindow.ProgressBar.Value = int.Parse(progressValue); }); } if (line.Contains("Starting to analyze")) { videoProgValue++; string videoName = line.Split('\\').Last(); Dispatcher.Invoke(() => { LoadingWindow.ProgressLabel.Content = "Analyzing " + videoName + " (" + videoProgValue + "/" + videos.Count + ")"; LoadingWindow.ProgressBar.Value = int.Parse(progressValue); }); } } }); } //NONDEBUG ----------------------------------------------------------------------------------------------- p.EnableRaisingEvents = true; p.Exited += (sender1, e1) => { if (errorDuringAnalysis) { this.Dispatcher.Invoke(() => { LoadingWindow.Close(); EnableInteraction(); }); UpdateVGLConfig(); //update VGLS's config file MessageBox.Show(errorMessage, "Error Occurred", MessageBoxButton.OK, MessageBoxImage.Error); } // If done analyzing, start creating labelled videos this.Dispatcher.Invoke(() => { LoadingWindow.ProgressLabel.Content = "Creating labeled videos (will take a while)..."; LoadingWindow.ProgressLabel2.Content = ""; }); CreateLabeledVideos(videos); }; p.StartInfo = info; p.Start(); using (StreamWriter sw = p.StandardInput) { if (sw.BaseStream.CanWrite) { sw.WriteLine(Drive); sw.WriteLine("cd " + EnvDirectory); sw.WriteLine(FileSystemUtils.CONDA_ACTIVATE_PATH); sw.WriteLine("conda activate " + EnvName); sw.Write("ipython vdlc_analyze_video.py"); // Arguments foreach (var video in videos.Values) { sw.Write(" \"" + video.Path + "\""); } sw.WriteLine(""); if (info.CreateNoWindow == false) { //for debug purposes sw.WriteLine("\n\n\nECHO WHEN YOU'RE DONE, CLOSE THIS WINDOW"); p.WaitForExit(); sw.WriteLine("Done, exiting."); } } } if (info.CreateNoWindow) { p.BeginOutputReadLine(); //only redirect output if debug enabled } }
private void submit() { this.Hide(); loadingWindow = new LoadingWindow() { Message = "Submitting your work." }; loadingWindow.Show(); submitWorker.RunWorkerAsync(); }
private void preview() { this.Hide(); loadingWindow = new LoadingWindow() { Message = "Previewing your work." }; loadingWindow.Show(); previewWorker.RunWorkerAsync(); }