示例#1
0
        private void Button_Click_Speichern(object sender, RoutedEventArgs e)
        {
            if (grantTree.filteredTree == null)
            {
                Console.WriteLine("Der Baum muss vor dem Speichern gefiltert werden."); return;
            }

            // Configure save file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName         = "filteredProject_" + strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(grantTree.filteredTree)).properties.nameFiltered; // Default file name
            dlg.DefaultExt       = ".grant";                                                                                                                                          // Default file extension
            dlg.Filter           = "GRANT documents (.grant)|*.grant";                                                                                                                // Filter files by extension
            dlg.OverwritePrompt  = true;                                                                                                                                              // Hinweis wird gezeigt, wenn die Datei schon existiert
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            // Show save file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                // guiFunctions.saveFilteredTree(dlg.FileName);
                guiFunctions.saveProject(dlg.FileName);
            }
        }
示例#2
0
        public void TestSaveTree()
        {
            String        processName         = "calc";
            String        applicationPathName = @"C:\Windows\system32\calc.exe";
            HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees);

            hf.filterApplication(processName, applicationPathName);
            if (grantTrees.filteredTree == null)
            {
                Assert.Fail("Es ist kein gefilterter Baum vorhanden"); return;
            }
            Console.WriteLine("m_testContext.DeploymentDirectory: " + m_testContext.DeploymentDirectory);
            String folderPathSave = System.IO.Path.Combine(m_testContext.DeploymentDirectory, "filter_test");

            guiFuctions.saveProject(folderPathSave);
            String projectLoadedPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SavedTrees");

            projectLoadedPath = System.IO.Path.Combine(projectLoadedPath, "filteredTree_RechnerUIA");
            //  String @folderPathSaveTree = Path.GetDirectoryName(@folderPathSave) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(@folderPathSave);
            //String @projectPathTree = Path.GetDirectoryName(projectLoadedPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(projectLoadedPath);


            if (!CompareToSavedFilteredTrees(System.IO.Path.Combine(folderPathSave, Settings.getFilteredTreeSavedName()), System.IO.Path.Combine(projectLoadedPath, "filteredTree.xml")))
            {
                Assert.Fail("Der gerade gespeicherte Baum stimmt nicht mit den 'Test-Baum' überein!");
            }
        }