示例#1
0
 public CP77Mod(EditorProject project)
 {
     Author  = project.Author;
     Email   = project.Email;
     Name    = project.Name;
     Version = project.Version;
 }
示例#2
0
        public static string GetRelativeName(string FullName, EditorProject project)
        {
            if (project == null)
            {
                return(FullName);
            }

            var filedir      = project.FileDirectory;
            var moddir       = project.ModDirectory;
            var rawDirectory = project.RawDirectory;
            var packedDir    = project.PackedRootDirectory;

            if (FullName.Equals(filedir, StringComparison.Ordinal))
            {
                return("");
            }
            // hack so that we get proper hashes
            if (FullName.Equals(moddir, StringComparison.Ordinal))
            {
                return(s_moddir);
            }
            if (FullName.Equals(rawDirectory, StringComparison.Ordinal))
            {
                return(s_rawdir);
            }
            if (FullName.Equals(packedDir, StringComparison.Ordinal))
            {
                return("wkitpackeddir");
            }

            if (FullName.StartsWith(moddir, StringComparison.Ordinal))
            {
                return(FullName[(moddir.Length + 1)..]);
示例#3
0
        public FileModel(string path, EditorProject project)
        {
            FullName = path;
            var parentfullname = "";

            if (Directory.Exists(path))
            {
                IsDirectory = true;
                var di = new DirectoryInfo(path);
                parentfullname = di.Parent.FullName;
                Name           = di.Name;
                _extension     = ECustomImageKeys.OpenDirImageKey.ToString();
            }
            else if (File.Exists(path))
            {
                IsDirectory = false;
                var fi = new FileInfo(path);
                parentfullname = fi.Directory.FullName;
                Name           = fi.Name;
                _extension     = fi.Extension;
            }
            else
            {
                throw new FileNotFoundException();
            }

            Hash       = GenerateKey(FullName, project);
            ParentHash = GenerateKey(parentfullname, project);
        }
        protected virtual string GetPromptText(EditorProject project, SaveChangesReason reason)
        {
            Argument.IsNotNull(() => project);

            var location = project.Location;

            string message;

            switch (reason)
            {
            case SaveChangesReason.Closing:
                message = $"The file '{location}' has to be closed, but is was changed\n\nDo you want to save changes?";
                break;

            case SaveChangesReason.Refreshing:
                message = $"The file '{location}' has to be refreshed, but is was changed\n\nDo you want to save changes?";
                break;

            default:
                message = $"The file '{location}' has been changed\n\nDo you want to save changes?";
                break;
            }

            return(message);
        }
示例#5
0
        public async Task <bool> LoadAsync(string location)
        {
            IsProjectLoaded = false;
            await ReadFromLocationAsync(location).ContinueWith(_ =>
            {
                if (_.IsCompletedSuccessfully)
                {
                    if (_.Result == null)
                    {
                    }
                    else
                    {
                        ActiveProject   = _.Result;
                        IsProjectLoaded = true;

                        if (_recentlyUsedItemsService.Items.All(item => item.Name != location))
                        {
                            _recentlyUsedItemsService.AddItem(new RecentlyUsedItem(location, DateTime.Now));
                        }
                    }
                }
                else
                {
                }
            });


            return(true);
        }
        public void PlaybackSession(string filename)
        {
            CloseActiveProject();

            string absFilename = filename;

            if (!FileHelper.IsAbsolute(absFilename))
            {
                absFilename = Path.Combine(TestDataDir, filename);
            }

            string        projDir = EditorProject.FindProjectFor(absFilename);
            EditorProject proj    = new EditorProject();

            if (projDir == null || !proj.Load(projDir))
            {
                throw new FileNotFoundException("Project file not found for " + absFilename);
            }

            EditorManager.Project = proj;

            RecordSession session = RecordSession.LoadFromFile(proj.MakeRelative(absFilename));

            if (session == null)
            {
                throw new FileNotFoundException("Session file not found", absFilename);
            }

            TestRecordReport report = new TestRecordReport();

            if (!session.Playback(report, true))
            {
                throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
            }
        }
        private async Task <bool> EnsureChangesSavedAsync(EditorProject project, string message)
        {
            Argument.IsNotNull(() => project);
            Argument.IsNotNullOrEmpty(() => message);

            if (project == null || !project.IsDirty)
            {
                return(true);
            }

            var caption = AssemblyHelper.GetEntryAssembly().Title();

            MessageResult messageBoxResult;

            using (_pleaseWaitService.HideTemporarily())
            {
                messageBoxResult = await _messageService.ShowAsync(message, caption, MessageButton.YesNoCancel).ConfigureAwait(false);
            }

            switch (messageBoxResult)
            {
            case MessageResult.Cancel:
                return(false);

            case MessageResult.No:
                return(true);

            case MessageResult.Yes:
                return(await _projectManager.SaveAsync(project.Location).ConfigureAwait(false));
            }

            return(false);
        }
        public Task <bool> EnsureChangesSavedAsync(EditorProject project, SaveChangesReason reason)
        {
            Argument.IsNotNull(() => project);

            var message = GetPromptText(project, reason);

            return(EnsureChangesSavedAsync(project, message));
        }
        public void TestShapeSerialization()
        {
            const string TEST_SCENENAME = "TestShapeSerialization.scene";

            // setup new test project/scene
            TestManager.Helpers.CreateTestScene(TEST_SCENENAME);
            EditorProject project = EditorApp.Project;

            try
            {
                // create all registered shapes
                foreach (IShapeCreatorPlugin plugin in EditorManager.ShapeCreatorPlugins)
                {
                    plugin.ExecutePlugin();
                }
                string projectFile      = project.PathName;
                int    numCreatedShapes = CountShapeInstances(project.Scene);

                // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash)
                TestManager.Helpers.ProcessEvents();

                // close map
                project.Save();

                ShapeCollection c1 = project.Scene.ActiveLayer.Root.ChildCollection;

                EditorManager.Scene.Close();
                project.Close();

                // reload map
                project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject;
                Assert.IsNotNull(project);

                project.Load(projectFile);
                EditorManager.Project = project;
                bool bResult = project.OpenScene(TEST_SCENENAME);
                Assert.IsTrue(bResult);

                // verify that shape instances exist
                int             numLoadedShapes = CountShapeInstances(project.Scene);
                ShapeCollection c2 = project.Scene.ActiveLayer.Root.ChildCollection;

                for (int i = 0; i < c1.Count; i++)
                {
                    ShapeBase s1 = c1[i];
                    ShapeBase s2 = c2[i];
                    Assert.AreEqual(s1.GetType(), s2.GetType());
                }

                Assert.AreEqual(numCreatedShapes, numLoadedShapes);

                TestManager.Helpers.CloseTestProject();
            }
            catch (Exception ex)
            {
                EditorManager.DumpException(ex, true);
            }
        }
示例#10
0
        protected virtual async Task ProjectActivated(EditorProject oldEditorProject, EditorProject newEditorProject)
        {
            if (newEditorProject == null)
            {
                return;
            }

            await Task.Run(() => newEditorProject.Initialize());
        }
示例#11
0
        private void projectToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string newProjectPath = null;

            using (var fbd = new FolderBrowserDialog())
            {
                fbd.SelectedPath = Application.StartupPath;
                fbd.Description  = "Select a folder for your project.";
                DialogResult result = fbd.ShowDialog();


                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    if (Directory.EnumerateFileSystemEntries(fbd.SelectedPath).Any())
                    {
                        MessageBox.Show("The folder must be empty!");
                        return;
                    }

                    newProjectPath = fbd.SelectedPath;

                    string modName   = Prompt.ShowDialog("Project Name", "Create New Project");
                    string modAuthor = Prompt.ShowDialog("Mod Author", "Create New Project");
                    MessageBox.Show("Please note that the only currently supported game is The Walking Dead: The Telltale Definitive Series (TTDS).");

                    EditorProject toCreate = new EditorProject
                    {
                        formatVersion = "1",
                        mod           = new ModJSON()
                        {
                            name     = modName,
                            version  = "1.0",
                            author   = modAuthor,
                            priority = 950
                        },
                        tool = new ToolJSON()
                        {
                            game = "TTDS"
                        }
                    };

                    string modFileName      = Regex.Replace(modName, @"[^A-Za-z0-9]+", "");
                    string modFileDirectory = $"{newProjectPath}\\{modFileName}.tseproj";

                    File.WriteAllText(modFileDirectory, JsonConvert.SerializeObject(toCreate, Formatting.Indented));

                    WorkingDirectory = Path.GetDirectoryName(modFileDirectory);
                    fileManager      = new FileManagement(operationProgressBar, projectFileTree, WorkingDirectory, this);
                    fileManager.LoadProject(modFileDirectory);
                    fileManager.PopulateFileGUI();
                }
            }
        }
        public void TestEntityPropertySerialization()
        {
            try
            {
                const string TEST_SCENENAME = "TestEntityPropertySerialization";

                // setup new test project/scene
                TestManager.Helpers.CreateTestScene(TEST_SCENENAME);
                EditorProject project = EditorApp.Project;

                // create an entity shape
                EditorManager.GetShapeCreatorPluginByName("Entity").ExecutePlugin();
                ShapeBase entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0];

                string projectFile      = project.PathName;
                int    numCreatedShapes = CountShapeInstances(project.Scene);

                // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash)
                TestManager.Helpers.ProcessEvents();

                // close map
                project.Save();
                project.Close();

                // reload map
                project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject;
                Assert.IsNotNull(project);
                project.Load(projectFile);
                EditorManager.Project = project;
                bool bResult = project.OpenScene(TEST_SCENENAME);
                Assert.IsTrue(bResult);

                // verify that EntityProperty type is part of the active EntityClassManager assembly
                entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0];
                DynamicPropertyCollection entityProperties = (DynamicPropertyCollection)entityShape.GetType().InvokeMember("EntityProperties", BindingFlags.GetProperty, null, entityShape, new object[] {});
                Assert.IsTrue(EditorManager.EngineManager.EntityClassManager.Exists(entityProperties.CollectionType.UniqueName));

                TestManager.Helpers.CloseTestProject();
            }
            catch (Exception ex)
            {
                EditorManager.DumpException(ex, true);
                throw ex;
            }
        }
        /// <summary>
        /// Load a project file
        /// </summary>
        /// <param name="x">The location of the project file</param>
        public bool LoadProject(string x)
        {
            try
            {
                CurrentProject = JsonConvert.DeserializeObject <EditorProject>(File.ReadAllText(x));

                if (CurrentProject.mod.priority <= 0)
                {
                    EditorProject toCreate = new EditorProject
                    {
                        formatVersion = "1",
                        mod           = new ModJSON()
                        {
                            name     = CurrentProject.mod.name,
                            version  = CurrentProject.mod.version,
                            author   = CurrentProject.mod.author,
                            priority = 950
                        },
                        tool = new ToolJSON()
                        {
                            game = CurrentProject.mod.name
                        }
                    };

                    string modFileName      = Regex.Replace(CurrentProject.mod.name, @"[^A-Za-z0-9]+", "");
                    string modFileDirectory = $"{WorkingDirectory}\\{modFileName}.tseproj";

                    File.WriteAllText(modFileDirectory, JsonConvert.SerializeObject(toCreate, Formatting.Indented));

                    CurrentProject.mod.priority = 650;
                    MessageBox.Show("Your mod's priority was invalid (must be at least 1) or wasn't set, so I've set it to the default value.", "Just a heads up...");
                }
                Console.WriteLine($"Loaded \"{CurrentProject.mod.name}\" by {CurrentProject.mod.author}");
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show("This is not a valid project file! See console for more info.", "Error");
                Console.WriteLine(e.Message);
                return(false);
            }
        }
示例#14
0
        protected override async Task <IProject> ReadFromLocationAsync(string location)
        {
            try
            {
                var fi = new FileInfo(location);
                if (!fi.Exists)
                {
                    return(null);
                }

                EditorProject project = null;
                switch (fi.Extension)
                {
                case ".w3modproj":
                {
                    project = new Tw3Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    await MainController.SetGame(new Tw3Controller()).ContinueWith(t => _notificationService.Success("Project " + Path.GetFileNameWithoutExtension(location) +
                                                                                                                     " loaded!"), TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;
                }

                case ".cpmodproj":
                {
                    project = new Cp77Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    await MainController.SetGame(new Cp77Controller()).ContinueWith(t => _notificationService.Success("Project " + Path.GetFileNameWithoutExtension(location) + " loaded!"), TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;
                }
                }

                return(await Task.FromResult <IProject>(project));
            }
            catch (IOException ex)
            {
                _notificationService.Error(ex.Message);
            }

            return(null);
        }
        public void PlaybackSessionsInProject(string projectDir, string subdir)
        {
            CloseActiveProject();

            string absFilename = projectDir;

            if (!FileHelper.IsAbsolute(absFilename))
            {
                absFilename = Path.Combine(TestDataDir, projectDir);
            }

            string        projDir = EditorProject.FindProjectFor(Path.Combine(absFilename, "dummy.xyz"));
            EditorProject proj    = new EditorProject();

            if (projDir == null)
            {
                throw new FileNotFoundException("Project file not found for " + absFilename);
            }

            proj.Load(projDir);

            EditorManager.Project = proj;

            DirectoryInfo folder = new DirectoryInfo(proj.MakeAbsolute(subdir));

            FileInfo[] files = folder.GetFiles("*.record");
            foreach (FileInfo file in files)
            {
                RecordSession session = RecordSession.LoadFromFile(Path.Combine(subdir, file.Name));
                if (session == null)
                {
                    throw new FileNotFoundException("Session file not found", absFilename);
                }

                TestRecordReport report = new TestRecordReport();
                if (!session.Playback(report, true))
                {
                    throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
                }
            }
        }
示例#16
0
        protected override Task <IProject> ReadFromLocationAsync(string location)
        {
            try
            {
                var fi = new FileInfo(location);
                if (!fi.Exists)
                {
                    return(null);
                }

                EditorProject project = null;
                switch (fi.Extension)
                {
                case ".w3modproj":
                {
                    project = new Tw3Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    MainController.Get().SetGame(new Tw3Controller());
                    break;
                }

                case ".cpmodproj":
                {
                    project = new Cp77Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    MainController.Get().SetGame(new Cp77Controller());
                    break;
                }
                }
                _notificationService.ShowNotification("Success", "Project " + Path.GetFileNameWithoutExtension(location) +
                                                      " loaded!");
                return(Task.FromResult <IProject>(project));
            } catch (IOException ex)
            {
                _notificationService.ShowNotification("Could not open file", ex.Message);
            }

            return(null);
        }
        /// <summary>
        /// see ITestHelpers.CreateTestScene
        /// </summary>
        /// <param name="sceneName"></param>
        public void CreateTestScene(string sceneName)
        {
            // create project
            const string  projectName = "TestProject";
            EditorProject project     = EditorProject.CreateProject(TestDirectory, projectName);

            EditorManager.Project = project;

            // Step 1: copy default files (what customers also get)
            FileHelper.CopyFiles(
                new DirectoryInfo(Path.Combine(EditorManager.AppDataDir, @"NewProjectData")), "*.*",
                new DirectoryInfo(project.ProjectDir), true, false, FileAttributes.Hidden, false);

            // Step 2: copy generic test data for automated tests
            FileHelper.CopyFiles(
                new DirectoryInfo(Path.Combine(EditorManager.AppDataDir, @"..\..\..\..\Test\Vision\Editor\vForge\Data\AutomatedTests")), "*.*",
                new DirectoryInfo(project.ProjectDir), true, false, FileAttributes.Hidden, false);

            // open scene
            bool bResult = project.NewScene(sceneName);

            Debug.Assert(bResult == true);
        }
 /// <summary>
 /// Load a project file
 /// </summary>
 /// <param name="x">The location of the project file</param>
 public void LoadProject(string x)
 {
     CurrentProject = JsonConvert.DeserializeObject <EditorProject>(File.ReadAllText(x));
     Console.WriteLine($"Loaded \"{CurrentProject.mod.name}\" by {CurrentProject.mod.author}");
 }
        public void TestLayerLocking()
        {
            try
            {
                const string TEST_SCENENAME  = "TestSceneLocking";
                const string TEST_SCENENAME2 = "TestSceneLocking_SaveAsTest";

                // Create a new project and scene
                TestManager.Helpers.CreateTestScene(TEST_SCENENAME);
                EditorProject project    = EditorApp.Project;
                IScene        scene      = project.Scene;
                Layer         firstLayer = scene.Layers[0];

                // First layer must be writeable
                Assert.IsTrue(firstLayer.OwnsLock);
                Assert.IsTrue(firstLayer.SaveToFile());

                // close scene
                string layerFilePath = firstLayer.AbsoluteLayerFilename;
                firstLayer = null;
                scene.Close();
                Assert.IsNull(project.Scene);

                // Get external lock on layer file
                IFileLock extFileLock = EditorManager.FileLockFactory.GetFileLock(layerFilePath);
                Assert.IsTrue(extFileLock.TryLock());

                // Reopen scene: must fail on saving layer (locked externally)
                Assert.IsTrue(project.OpenScene(TEST_SCENENAME));
                scene      = project.Scene;
                firstLayer = scene.Layers[0];
                Assert.IsFalse(firstLayer.OwnsLock);

                // Release lock: OwnsWriteLock state must get updated
                extFileLock.Unlock();
                // Give windows time to inform the file watcher
                System.Threading.Thread.Sleep(1000); TestManager.Helpers.ProcessEvents();
                // And then give the file watcher time to send his queued/delayed notification
                System.Threading.Thread.Sleep(1000); TestManager.Helpers.ProcessEvents();
                Assert.IsTrue(firstLayer.LockStatus == Layer.LayerLockStatus_e.NotLocked);

                // Let the scene lock the layer again: saving file must be successful
                firstLayer.TryLock(null, false);
                Assert.IsTrue(firstLayer.OwnsLock);
                Assert.IsTrue(firstLayer.SaveToFile());

                // Getting external lock must fail (since file is locked by scene)
                Assert.IsFalse(extFileLock.TryLock());

                // Rename the scene file
                Assert.IsTrue(scene.SaveAs(TEST_SCENENAME2));
                string renamedLayerFilePath = firstLayer.AbsoluteLayerFilename;
                Assert.IsTrue(renamedLayerFilePath != layerFilePath);

                // Getting external lock must work after scene-save-as
                Assert.IsTrue(firstLayer.OwnsLock);
                Assert.IsTrue(extFileLock.TryLock());
                extFileLock.Unlock();

                // Getting external lock on renamed file must fail
                IFileLock extFileLockRenamed = EditorManager.FileLockFactory.GetFileLock(renamedLayerFilePath);
                Assert.IsFalse(extFileLockRenamed.TryLock());

                // Verify that a scene can't be opened without closing it at first
                // (important, since we otherwise still have the lock on the old scene)
                Assert.IsFalse(project.OpenScene(TEST_SCENENAME));

                // Close scene
                scene.Close();
                Assert.IsNull(project.Scene);

                // Test correct behaviour for readonly layer files
                {
                    // Set the layer as readonly (as done by some version control systems
                    // when using exclusive locking)
                    File.SetAttributes(layerFilePath, File.GetAttributes(layerFilePath) | FileAttributes.ReadOnly);

                    // Reopen scene
                    Assert.IsTrue(project.OpenScene(TEST_SCENENAME));
                    scene      = project.Scene;
                    firstLayer = scene.Layers[0];

                    // Layer must not be locked due to being readonly.
                    Assert.IsFalse(firstLayer.OwnsLock);
                    Assert.AreEqual(Layer.LayerLockStatus_e.ReadOnly, firstLayer.LockStatus);

                    // Close scene
                    scene.Close();
                    Assert.IsNull(project.Scene);

                    // Set the layer as readonly (as done by some version control systems
                    // when using exclusive locking)
                    File.SetAttributes(layerFilePath, File.GetAttributes(layerFilePath) & (~FileAttributes.ReadOnly));
                }

                TestManager.Helpers.CloseTestProject();
            }
            catch (Exception ex)
            {
                EditorManager.DumpException(ex);
                throw ex;
            }
        }
示例#20
0
        public FileModel(string path, EditorProject project)
        {
            FullName = path;
            Project  = project;
            string parentfullname;

            if (Directory.Exists(path))
            {
                IsDirectory = true;
                var di = new DirectoryInfo(path);
                parentfullname = di.Parent.FullName;
                Name           = di.Name;
                _extension     = ECustomImageKeys.OpenDirImageKey.ToString();
                if (project is Cp77Project cpp)
                {
                    if (FullName.StartsWith(cpp.ModDirectory))
                    {
                        _extension = "ModDirectoryTop";
                    }
                    else if (FullName.ToLower().StartsWith(cpp.RawDirectory.ToLower()))
                    {
                        _extension = "RawDirectoryTop";
                    }
                    else if (FullName.StartsWith(cpp.ScriptDirectory))
                    {
                        _extension = "ScriptDirectoryTop";
                    }
                    else if (FullName.StartsWith(cpp.TweakDirectory))
                    {
                        _extension = "TweakDirectoryTop";
                    }
                }
            }
            else if (File.Exists(path))
            {
                IsDirectory = false;
                var fi = new FileInfo(path);
                parentfullname = fi.Directory.FullName;
                Name           = fi.Name;
                _extension     = fi.Extension;
                if (project is Cp77Project cpp)
                {
                    if (FullName.StartsWith(cpp.TweakDirectory) && _extension == "bin")
                    {
                        _extension = "tweak";
                    }
                }

                /*if (_extension == "")
                 * {
                 *  var guessedExtensions = FileTypeHelper.GetFileExtensions(FullName);
                 *  if (guessedExtensions.Length == 1)
                 *  {
                 *      _extension = guessedExtensions[0];
                 *  }
                 * }*/
            }
            else
            {
                throw new FileNotFoundException();
            }

            Hash              = GenerateKey(FullName, project);
            ParentHash        = GenerateKey(parentfullname, project);
            RelativePath      = GetRelativeName(FullName, project);
            OpenFileCommand   = new RelayCommand(ExecuteOpenFile, CanOpenFile);
            DeleteFileCommand = new RelayCommand(ExecuteDeleteFile, CanDeleteFile);
            RenameFileCommand = new RelayCommand(ExecuteRenameFile, CanRenameFile);
        }
示例#21
0
 public ulong GetRedHash(EditorProject project) => FNV1A64HashAlgorithm.HashString(GetRelativeName(project));
示例#22
0
        public void PlaybackSession(string filename)
        {
            CloseActiveProject();

              string absFilename = filename;
              if (!FileHelper.IsAbsolute(absFilename))
            absFilename = Path.Combine(TestDataDir, filename);

              string projDir = EditorProject.FindProjectFor(absFilename);
              EditorProject proj = new EditorProject();
              if (projDir == null || !proj.Load(projDir))
            throw new FileNotFoundException("Project file not found for " + absFilename);

              EditorManager.Project = proj;

              RecordSession session = RecordSession.LoadFromFile(proj.MakeRelative(absFilename));
              if (session == null)
            throw new FileNotFoundException("Session file not found", absFilename);

              TestRecordReport report = new TestRecordReport();
              if (!session.Playback(report, true))
            throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
        }
示例#23
0
        public void PlaybackSessionsInProject(string projectDir, string subdir)
        {
            CloseActiveProject();

              string absFilename = projectDir;
              if (!FileHelper.IsAbsolute(absFilename))
            absFilename = Path.Combine(TestDataDir, projectDir);

              string projDir = EditorProject.FindProjectFor(Path.Combine(absFilename, "dummy.xyz"));
              EditorProject proj = new EditorProject();
              if (projDir == null || !proj.Load(projDir))
            throw new FileNotFoundException("Project file not found for " + absFilename);

              EditorManager.Project = proj;

              DirectoryInfo folder = new DirectoryInfo(proj.MakeAbsolute(subdir));
              FileInfo[] files = folder.GetFiles("*.record");
              foreach (FileInfo file in files)
              {
            RecordSession session = RecordSession.LoadFromFile(Path.Combine(subdir, file.Name));
            if (session == null)
              throw new FileNotFoundException("Session file not found", absFilename);

            TestRecordReport report = new TestRecordReport();
            if (!session.Playback(report, true))
              throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
              }
        }
示例#24
0
 /// <summary>
 /// This constructor should be used
 /// </summary>
 /// <param name="project"></param>
 public ReportForm(EditorProject project) : this()
 {
     this.project = project;
 }