/// <summary> /// Called to initialize the various application views on startup. /// </summary> private void InitViews() { m_mainWindow = new Citadel.UI.Windows.MainWindow(); m_mainWindow.WindowRestoreRequested += (() => { BringAppToFocus(); }); m_mainWindow.Closing += ((object sender, CancelEventArgs e) => { // Don't actually let the window close, just hide it. e.Cancel = true; if (m_mainWindow.CurrentView.Content == m_viewLogin) { Application.Current.Shutdown(ExitCodes.ShutdownWithoutSafeguards); return; } // When the main window closes, go to tray and show notification. MinimizeToTray(true); }); m_viewLogin = new LoginView(); if (m_viewLogin.DataContext != null && m_viewLogin.DataContext is BaseCitadelViewModel) { ((BaseCitadelViewModel)(m_viewLogin.DataContext)).ViewChangeRequest = OnViewChangeRequest; } m_viewProgressWait = new ProgressWait(); m_viewDashboard = new DashboardView(); if (m_viewDashboard.DataContext != null && m_viewDashboard.DataContext is BaseCitadelViewModel) { ((BaseCitadelViewModel)(m_viewDashboard.DataContext)).ViewChangeRequest = OnViewChangeRequest; ((BaseCitadelViewModel)(m_viewDashboard.DataContext)).UserNotificationRequest = OnNotifyUserRequest; } m_sslExemptionsView = new SslExemptionsView(); if (m_sslExemptionsView.DataContext != null && m_sslExemptionsView.DataContext is BaseCitadelViewModel) { ((BaseCitadelViewModel)(m_sslExemptionsView.DataContext)).ViewChangeRequest = OnViewChangeRequest; ((BaseCitadelViewModel)(m_sslExemptionsView.DataContext)).UserNotificationRequest = OnNotifyUserRequest; } // Set the current view to ProgressWait because we're gonna do background init next. this.MainWindow = m_mainWindow; m_mainWindow.Show(); OnViewChangeRequest(typeof(ProgressWait)); }
protected override bool Run(string folderPath) { ProgressWait wait = new ProgressWait("区位可达性"); Hashtable para = new Hashtable() { { "wait", wait }, { "folderPath", folderPath }, { "ret", false } }; Thread t = new Thread(new ParameterizedThreadStart(Run)); t.Start(para); wait.ShowDialog(); t.Abort(); return((bool)para["ret"]); }
private bool WriteCityRaster(string folderPath) { ProgressWait wait = new ProgressWait("计算(未开通)空间可达性"); Hashtable para = new Hashtable() { { "wait", wait }, { "folderPath", folderPath }, { "ret", false } }; Thread t = new Thread(new ParameterizedThreadStart(Run)); t.Start(para); wait.ShowDialog(); t.Abort(); return((bool)para["ret"]); }
private bool SetTimeCost(string shapeFilePath, string typeField, string targetField) { if (!FieldsCheck(shapeFilePath, typeField, targetField)) { Messenger.Default.Send(new GenericMessage <string>(string.Format("{0}shape文件缺少{1}和{2}", shapeFilePath, typeField, targetField)) , "ArgumentError"); return(false); } var wait = new ProgressWait("计算时间成本"); Hashtable para = new Hashtable() { { "shapeFilePath", shapeFilePath }, { "typeField", typeField }, { "targetField", targetField } , { "wait", wait }, { "ret", false } }; Thread t = new Thread(new ParameterizedThreadStart(TimeCostRun)); t.Start(para); wait.ShowDialog(); t.Abort(); return((bool)para["ret"]); }
/// <summary> /// Inits all the various views for the application, which will be pushed and popped on the /// primary window as requested or required. /// </summary> private void InitViews() { if (m_filteringEngine == null) { throw new Exception("Engine must be initialized prior to initializing views, as views require references to allow user control."); } // We null check, because if the save state load worked, these conditions will be // false and we won't overwrite our restored state. // This collection is initialized here because it has a direct connection to the UI. if (m_filteredApplicationsTable == null) { m_filteredApplicationsTable = new ConcurrentDictionary <string, FilteredAppModel>(); } if (m_modelDashboard == null) { m_modelDashboard = new DashboardModel(m_filteringEngine); } if (m_viewModelDashboard == null) { m_viewModelDashboard = new DashboardViewModel(m_modelDashboard); } if (m_modelStatistics == null) { m_modelStatistics = new StatisticsModel(); } if (m_viewModelStatistics == null) { m_viewModelStatistics = new StatisticsViewModel(m_modelStatistics); } if (m_modelSettings == null) { m_modelSettings = new SettingsModel(); } if (m_viewModelSettings == null) { m_viewModelSettings = new SettingsViewModel(m_modelSettings); } if (m_viewModelWaste == null) { m_viewModelWaste = new WasteViewModel(m_viewModelSettings, m_viewModelDashboard); } // Necessary because we use a background worker. This thread != UI thread. Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { m_modelStatistics.FilterCategories = m_filteringCategoriesObservable; m_modelSettings.FilterCategories = m_filteringCategoriesObservable; m_primaryWindow = new MainWindow(); m_viewProgressWait = new ProgressWait(); m_viewStatistics = new Statistics(m_viewModelStatistics); m_viewDashboard = new Dashboard(m_viewModelDashboard); m_viewSettings = new Settings(m_viewModelSettings, new AddCategoryControl(m_filteringEngine)); m_viewWaste = new Waste(m_viewModelWaste); m_primaryWindow.ViewChangeRequest += OnViewChangeRequest; m_viewDashboard.ViewChangeRequest += OnViewChangeRequest; m_viewStatistics.ViewChangeRequest += OnViewChangeRequest; m_viewSettings.ViewChangeRequest += OnViewChangeRequest; m_viewWaste.ViewChangeRequest += OnViewChangeRequest; // Listen for the statistics view requests for app-wide stats deletion. m_viewStatistics.ClearStatisticsRequested += OnClearAllStatsRequest; MainWindow = m_primaryWindow; } ); }