private void OpenTestProjectMenuItem_Click(object sender, RoutedEventArgs e) { //TestProjectsViewModel tmp = this.testProjectView.DataContext as TestProjectsViewModel; //if (tmp != null) //{ // tmp.LoadTestProjectsCommand.Execute(null); //} TestProjectsViewModel tmp = this.testProjectView.DataContext as TestProjectsViewModel; if (tmp == null) { return; } List <KeyValuePair <string, string> > filters = new List <KeyValuePair <string, string> >(); filters.Add(new KeyValuePair <string, string>("测试工程", Constants.TestProjectFileTypePattern)); filters.Add(new KeyValuePair <string, string>("所有文件", "*")); IConfigurationManager configurationManager = (App.Current as App).Container.GetService <IConfigurationManager>(); FileDialogSettings fileDialogSettings = new FileDialogSettings() { Title = "选择测试工程", Multiselect = false, Filters = filters, InitialDirectory = Path.GetFullPath(configurationManager.GetConfigValue(Constants.LastTestProjectsPath)) }; IDialogService <object> dialogService = (App.Current as App).Container.GetService <IDialogService <object> >(); if (dialogService.ShowOpenFileDialog(this, fileDialogSettings, false)) { tmp.LoadTestProjectsCommand.Execute(fileDialogSettings.FileName); } }
private void NewTestProjectMenuItem_Click(object sender, RoutedEventArgs e) { TestProjectsViewModel tmp = this.testProjectView.DataContext as TestProjectsViewModel; if (tmp != null) { tmp.AddTestProjectCommand.Execute(null); } }
private void Doc_Closing(object sender, System.ComponentModel.CancelEventArgs e) { LayoutContent doc = sender as LayoutContent; TestMethodListView listView = doc.Content as TestMethodListView; TestProjectInfo projectInfo = (listView.DataContext as TestMethodListViewModel).CurrentTestProject; TestProjectsViewModel testProjectsView = this.testProjectView.DataContext as TestProjectsViewModel; testProjectsView.CloseTestProjectCommand.Execute(projectInfo); }
public TestProjectView() { InitializeComponent(); if (!DesignerProperties.GetIsInDesignMode(this)) { this.testProjectsViewModel = (App.Current as App).Container.GetService <TestProjectsViewModel>(); this.DataContext = testProjectsViewModel; this.testProjectsViewModel.OpenTestProject += this.TestProjectsViewModel_OpenTestProject; } }
private void SaveChanges() { TestMethodListViewModel testMethodsListView = this.testMethodRespositoryView.DataContext as TestMethodListViewModel; if (testMethodsListView != null) { testMethodsListView.SaveTestMethodsCommand.Execute(null); } TestProjectsViewModel testProjectsView = this.testProjectView.DataContext as TestProjectsViewModel; if (testProjectsView != null) { testProjectsView.SaveTestProjectsCommand.Execute(null); } }
private void OpenTestAssemblyMenuItem_Click(object sender, RoutedEventArgs e) { List <KeyValuePair <string, string> > filters = new List <KeyValuePair <string, string> >(); filters.Add(new KeyValuePair <string, string>("测试程序集", Constants.TestAssemblyFileTypeExtension)); filters.Add(new KeyValuePair <string, string>("所有文件", "*")); FileDialogSettings fileDialogSettings = new FileDialogSettings() { Title = "选择测试程序集", Multiselect = true, Filters = filters }; IDialogService <object> dialogService = (App.Current as App).Container.GetService <IDialogService <object> >(); if (dialogService.ShowOpenFileDialog(this, fileDialogSettings, false)) { List <string> testAssemblies = new List <string>(); testAssemblies.AddRange(fileDialogSettings.FileNames); if (!string.IsNullOrEmpty(fileDialogSettings.FileName) && !testAssemblies.Contains(fileDialogSettings.FileName)) { testAssemblies.Add(fileDialogSettings.FileName); } TestProjectsViewModel tmp = this.testProjectView.DataContext as TestProjectsViewModel; TestProjectInfo testProjectInfo = sender as TestProjectInfo; if (testProjectInfo == null) { testProjectInfo = tmp.CurrentTestProject?.TestProjectInfo; } TestMethodsSelector testMethodsSelectorDialog = new TestMethodsSelector(testAssemblies, testProjectInfo); if (testMethodsSelectorDialog.ShowDialog() == true) { if (testMethodsSelectorDialog.TestProject.Name == "测试用例仓库") { this.RefreshTestMesthodsList(); } else { this.OpenTestProject(tmp.CurrentTestProject?.TestProjectInfo); } } } }
private void TestProjectView_CloseTestProjectEvent(object sender, System.EventArgs e) { TestProjectsViewModel testProjectsView = this.testProjectView.DataContext as TestProjectsViewModel; if (testProjectsView != null) { TestProjectShip testProject = sender as TestProjectShip; testProjectsView.CloseTestProjectCommand.Execute(testProject.TestProjectInfo); LayoutDocumentPane firstDocumentPane = dockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); LayoutContent temp = firstDocumentPane.Children.FirstOrDefault(o => o.Title == testProject.Name && o.ToolTip.ToString() == testProject.TestProjectInfo?.Location); if (temp != null && temp is LayoutDocument) { LayoutDocument doc = temp as LayoutDocument; if (doc.CanClose) { doc.Close(); } } } }