public static IEnumerable <IDelta> ComputeDelta(CanvasDocument parent, CanvasDocument child)
        {
            var delta = new List <IDelta>();

            foreach (var originalScreen in parent._screens)
            {
                if (child._screens.TryGetValue(originalScreen.Key, out var childScreen))
                {
                    delta.AddRange(ControlDiffVisitor.GetControlDelta(childScreen, originalScreen.Value, parent._editorStateStore));
                }
                else
                {
                    delta.Add(new RemoveControl()
                    {
                        ControlName = originalScreen.Key, ParentControlPath = ControlPath.Empty
                    });
                }
            }
            foreach (var newScreen in child._screens.Where(kvp => !parent._screens.ContainsKey(kvp.Key)))
            {
                delta.Add(new AddControl()
                {
                    Control = newScreen.Value, ControlStates = child._editorStateStore.GetControlsWithTopParent(newScreen.Key).ToDictionary(state => state.Name), ParentControlPath = ControlPath.Empty
                });
            }

            return(delta);
        }
        public void DefaultPropertyEditTest()
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", "MyWeather.msapp");

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            Assert.IsFalse(errors.HasErrors);

            MergeTester(
                msapp,
                (branchADoc) =>
            {
                // Nothing
            },
                (branchBDoc) =>
            {
                branchBDoc._screens.TryGetValue("Screen1", out var control);
                var label = control.Children.First(child => child.Name.Identifier == "Label1");
                label.Properties.Add(new PropertyNode()
                {
                    Identifier = "Fill", Expression = new ExpressionNode()
                    {
                        Expression = "Color.Blue"
                    }
                });
            },
                (resultDoc) =>
            {
                resultDoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var fillProp = label.Properties.First(prop => prop.Identifier == "Fill");

                Assert.AreEqual("Color.Blue", fillProp.Expression.Expression);
            });
        }
        public void TestTopParentSerialization(string appName, string topParentName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Go find the source file for the editor state
                string filename     = $"{topParentName}{EditorStateFileExtension}";
                string fullFilePath = Path.Combine(outSrcDir, "Src", "EditorState", filename);
                if (File.Exists(fullFilePath))
                {
                    // Get the file for the specific control we're looking for
                    DirectoryReader.Entry file        = new DirectoryReader.Entry(fullFilePath);
                    ControlTreeState      editorState = file.ToObject <ControlTreeState>();

                    // Check that the IsTopParent was set correctly
                    Assert.AreEqual(topParentName, editorState.TopParentName);
                }
                else
                {
                    Assert.Fail($"Could not find expected file {fullFilePath}.");
                }
            }
        }
示例#4
0
        /// <summary>
        /// 添加新的Document
        /// </summary>
        /// <param name="document"></param>
        public static void AddCanvasDocument(CanvasDocument document)
        {
            bool isAdd = true;

            if (canvasDocuments != null)
            {
                //清除canvasDocuments中没有删除的document,和winodw的保持一致

                if (canvasDocuments.Contains(document))
                {
                    canvasDocuments.Remove(document);
                }

                foreach (CanvasDocument doc in canvasDocuments)
                {
                    if (doc.Equals(document))
                    {
                        isAdd = false;
                        break;
                    }
                }
            }
            else
            {
                canvasDocuments = new List <CanvasDocument>();
            }
            if (isAdd)
            {
                //canvasDocuments.Add(document);
                Window1 mainWindow = GetMainWindow();
                mainWindow.DockingManager.Items.Add(document);
            }
            SetDocumentSelected(document);
        }
        public void Apply(CanvasDocument document)
        {
            var resources = document._resourcesJson.Resources.ToDictionary(res => res.Name);

            resources.Remove(Name);
            document._resourcesJson.Resources = resources.Values.ToArray();
        }
        public void PropertyRemoveDefaultTest()
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", "MyWeather.msapp");

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            Assert.IsFalse(errors.HasErrors);

            MergeTester(msapp,
                        (branchADoc) =>
            {
                // Nothing
            },
                        (branchBDoc) =>
            {
                branchBDoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var textProp = label.Properties.First(prop => prop.Identifier == "Text");
                label.Properties.Remove(textProp);
            },
                        (resultDoc) =>
            {
                resultDoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var textProp = label.Properties.FirstOrDefault(prop => prop.Identifier == "Text");

                Assert.AreEqual(default, textProp);
        public void PropertyEditCollisonTest()
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", "MyWeather.msapp");

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            Assert.IsFalse(errors.HasErrors);

            MergeTester(msapp,
                        (branchADoc) =>
            {
                branchADoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var textProp = label.Properties.First(prop => prop.Identifier == "Text");
                textProp.Expression.Expression = "UpdatedBranchA";
            },
                        (branchBDoc) =>
            {
                branchBDoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var textProp = label.Properties.First(prop => prop.Identifier == "Text");
                textProp.Expression.Expression = "UpdatedBranchB";
            },
                        (resultDoc) =>
            {
                resultDoc._screens.TryGetValue("Screen1", out var control);
                var label    = control.Children.First(child => child.Name.Identifier == "Label1");
                var textProp = label.Properties.First(prop => prop.Identifier == "Text");

                Assert.AreEqual("UpdatedBranchA", textProp.Expression.Expression);
            });
        }
示例#8
0
 public void Apply(CanvasDocument document)
 {
     if (document._templateStore.AddTemplate(Name, Template) && JsonTemplate != null)
     {
         document._templates.UsedTemplates = document._templates.UsedTemplates.Concat(new[] { JsonTemplate }).ToArray();
     }
 }
示例#9
0
        /// <summary>
        /// 添加新的Document
        /// </summary>
        /// <param name="document"></param>
        public static void AddCanvasDocument(CanvasDocument document)
        {
            bool isAdd = true;
            if (canvasDocuments != null)
            {
                //清除canvasDocuments中没有删除的document,和winodw的保持一致

                if (canvasDocuments.Contains(document))
                {
                    canvasDocuments.Remove(document);
                }

                foreach (CanvasDocument doc in canvasDocuments)
                {
                    if (doc.Equals(document))
                    {
                        isAdd = false;
                        break;
                    }
                }
            }
            else
            {
                canvasDocuments = new List<CanvasDocument>();
            }
            if (isAdd)
            {
                //canvasDocuments.Add(document);
                Window1 mainWindow = GetMainWindow();
                mainWindow.DockingManager.Items.Add(document);
            }
            SetDocumentSelected(document);
        }
示例#10
0
        public void TestPackWhenEditorStateIsDeleted(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Delete Entropy directory
                var editorStatePath = Path.Combine(outSrcDir, "Src", "EditorState");
                if (Directory.Exists(editorStatePath))
                {
                    Directory.Delete(editorStatePath, true);
                }

                // Load app from the sources after deleting the entropy
                var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                using (var tempFile = new TempFile())
                {
                    // Repack the app
                    MsAppSerializer.SaveAsMsApp(app, tempFile.FullPath, new ErrorContainer());
                }
            }
        }
示例#11
0
        private static void AddDataSourceDeltas(CanvasDocument parent, CanvasDocument child, List <IDelta> deltas)
        {
            foreach (var ds in child._dataSources)
            {
                if (!parent._dataSources.ContainsKey(ds.Key))
                {
                    deltas.Add(new AddDataSource()
                    {
                        Name = ds.Key, Contents = ds.Value
                    });
                }
            }


            foreach (var ds in parent._dataSources)
            {
                if (!child._dataSources.ContainsKey(ds.Key))
                {
                    deltas.Add(new RemoveDataSource()
                    {
                        Name = ds.Key
                    });
                }
            }
        }
示例#12
0
        private static void AddConnectionDeltas(CanvasDocument parent, CanvasDocument child, List <IDelta> deltas)
        {
            foreach (var connection in (child._connections ?? Enumerable.Empty <KeyValuePair <string, ConnectionJson> >()))
            {
                if (!parent._connections.ContainsKey(connection.Key))
                {
                    deltas.Add(new AddConnection()
                    {
                        Name = connection.Key, Contents = connection.Value
                    });
                }
            }


            foreach (var connection in (parent._connections ?? Enumerable.Empty <KeyValuePair <string, ConnectionJson> >()))
            {
                if (!child._connections.ContainsKey(connection.Key))
                {
                    deltas.Add(new RemoveConnection()
                    {
                        Name = connection.Key
                    });
                }
            }
        }
示例#13
0
        /// <summary>
        /// 删除Document
        /// </summary>
        /// <param name="document"></param>
        public static void RemoveDocument(CanvasDocument document)
        {
            canvasDocuments.Remove(document);
            Window1 mainWindow = GetMainWindow();

            mainWindow.DockingManager.Items.Remove(document);
        }
        public void TestTableDefinitionsAreLastEntriesWhenEntropyDeleted(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Delete Entropy directory
                var entropyPath = Path.Combine(outSrcDir, "Entropy");
                if (Directory.Exists(entropyPath))
                {
                    Directory.Delete(entropyPath, true);
                }

                // Load app from the sources after deleting the entropy
                var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                using (var tempFile = new TempFile())
                {
                    // Repack the app
                    MsAppSerializer.SaveAsMsApp(app, tempFile.FullPath, new ErrorContainer());

                    using (var stream = new FileStream(tempFile.FullPath, FileMode.Open))
                    {
                        // Read the msapp file
                        ZipArchive zipOpen = new ZipArchive(stream, ZipArchiveMode.Read);

                        foreach (var entry in zipOpen.Entries)
                        {
                            var kind = FileEntry.TriageKind(FilePath.FromMsAppPath(entry.FullName));

                            switch (kind)
                            {
                            // Validate that the last entry in the DataSources.json is TableDefinition entry.
                            case FileKind.DataSources:
                            {
                                var dataSourcesFromMsapp = ToObject <DataSourcesJson>(entry);
                                var last = dataSourcesFromMsapp.DataSources.LastOrDefault();
                                Assert.AreEqual(last.TableDefinition != null, true);
                                return;
                            }

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#15
0
 /// <summary>
 /// 构造函数,打开工程时使用
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="guid"></param>
 public AbstractProject(string fileName, string guid)
 {
     this.fileName = fileName;
     this.guidID = new Guid(guid);
     this.canvasDocument = new CanvasDocument();
     this.CanvasDocument.Name = this.Name;
     this.canvasDocument.Title = this.Name;
 }
示例#16
0
 private static void AddScreenOrderDelta(CanvasDocument parent, CanvasDocument child, List <IDelta> deltas)
 {
     if (parent._screenOrder.SequenceEqual(child._screenOrder))
     {
         return;
     }
     deltas.Add(new ScreenOrderChange(child._screenOrder));
 }
示例#17
0
 protected ProjectItem(IProject project, ItemType type)
 {
     this.project = project;
     this.itemType = type;
     this.canvasDocument = new CanvasDocument();
     this.canvasDocument.Name = this.Name;
     this.canvasDocument.Title = this.Name;
 }
示例#18
0
        public void Test()
        {
            // Empty stream is invalid document, should generate a Read error.
            MemoryStream ms = new MemoryStream();

            (var doc, var errors) = CanvasDocument.LoadFromMsapp(ms);
            Assert.IsTrue(errors.HasErrors);
            Assert.IsNull(doc);
        }
示例#19
0
        public void OpenBadSources()
        {
            // Common error can be mixing up arguments. Ensure that we detect passing a valid msapp as a source param.
            Assert.IsTrue(File.Exists(PathToValidMsapp));

            (var doc, var errors) = CanvasDocument.LoadFromSources(PathToValidMsapp);
            Assert.IsTrue(errors.HasErrors);
            Assert.IsNull(doc);
        }
示例#20
0
        public CanvasDocument Deserialize()
        {
            var            compositionDto = (ModelDto)serializer.Deserialize(stream);
            var            objectDtos     = compositionDto.Objects;
            var            items          = Mapper.Map <List <CanvasItem> >(objectDtos);
            CanvasDocument document       = new CanvasDocument(items);

            return(document);
        }
示例#21
0
        public void Apply(CanvasDocument document)
        {
            if (!(document._connections?.ContainsKey(Name) ?? false))
            {
                return;
            }

            document._connections.Remove(Name);
        }
示例#22
0
        public void Apply(CanvasDocument document)
        {
            if (!document._dataSources.ContainsKey(Name))
            {
                return;
            }

            document._dataSources.Remove(Name);
        }
示例#23
0
        public void Apply(CanvasDocument document)
        {
            if (document._dataSources.ContainsKey(Name))
            {
                return;
            }

            document._dataSources.Add(Name, Contents);
        }
示例#24
0
        public void Serialize(CanvasDocument document)
        {
            var objects = Mapper.Map <List <ObjectDto> >(document.Children);

            var compositionDto = new ModelDto
            {
                Objects = objects
            };

            serializer.Serialize(stream, compositionDto);
        }
示例#25
0
 protected ProjectItem(IProject project)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     this.project = project;
     this.canvasDocument = new CanvasDocument();
     this.canvasDocument.Name = this.Name;
     this.canvasDocument.Title = this.Name;
 }
示例#26
0
        public void Apply(CanvasDocument document)
        {
            // Screen addition
            if (ParentControlPath == ControlPath.Empty)
            {
                if (!IsControlTreeCollisionFree(this.Control, document._editorStateStore))
                {
                    return;
                }

                AddControlStates(this.Control, document._editorStateStore);

                document._screens.Add(this.Control.Name.Identifier, this.Control);
                return;
            }

            // screen was removed?
            if (!document._screens.TryGetValue(ParentControlPath.Current, out var control))
            {
                return;
            }

            var path = ParentControlPath.Next();

            while (path.Current != null)
            {
                var found = false;
                foreach (var child in control.Children)
                {
                    if (child.Name.Identifier == path.Current)
                    {
                        control = child;
                        path    = path.Next();
                        found   = true;
                        break;
                    }
                }
                // tree was deleted
                if (!found)
                {
                    return;
                }
            }

            if (!IsControlTreeCollisionFree(this.Control, document._editorStateStore))
            {
                return;
            }

            AddControlStates(this.Control, document._editorStateStore);

            control.Children.Add(this.Control);
        }
        public void Apply(CanvasDocument document)
        {
            var resources = document._resourcesJson.Resources.ToDictionary(res => res.Name);

            resources.Remove(_name);
            document._resourcesJson.Resources = resources.Values.ToArray();

            if (_assetKey != null)
            {
                document._assetFiles.Remove(_assetKey);
            }
        }
        private void MergeTester(CanvasDocument baseDoc, BranchChange branchAChange, BranchChange branchBChange, ResultValidator resultValidator)
        {
            var branchADoc = new CanvasDocument(baseDoc);
            var branchBDoc = new CanvasDocument(baseDoc);

            branchAChange(branchADoc);
            branchBChange(branchBDoc);

            var mergeResult = CanvasMerger.Merge(branchADoc, branchBDoc, baseDoc);

            resultValidator(mergeResult);
        }
        public void TestTopParentNameFallback(string appName, string topParentName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Go find the source file for the editor state
                string filename     = $"{topParentName}.editorstate.json";
                string fullFilePath = Path.Combine(outSrcDir, "Src", "EditorState", filename);
                if (File.Exists(fullFilePath))
                {
                    // Get the file for the specific control we're looking for
                    DirectoryReader.Entry file        = new DirectoryReader.Entry(fullFilePath);
                    ControlTreeState      editorState = file.ToObject <ControlTreeState>();

                    // Rename the file so we know that the file name itself is used.
                    string newFileName = Guid.NewGuid().ToString();
                    string newFilePath = Path.Combine(outSrcDir, "Src", "EditorState");

                    // Write out only the dictionary to the file, which is the older format.
                    DirectoryWriter dir = new DirectoryWriter(newFilePath);
                    dir.WriteAllJson(newFilePath, $"{newFileName}{EditorStateFileExtension}", editorState.ControlStates);

                    // Remove the old file, we only want the re-written and re-named file
                    File.Delete(fullFilePath);

                    // Load app from the source folder
                    var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                    // Find the relevant controls and check their top parent name
                    foreach (var control in editorState.ControlStates)
                    {
                        app._editorStateStore.TryGetControlState(control.Value.Name, out ControlState state);
                        Assert.AreEqual(newFileName, state.TopParentName);
                    }
                }
                else
                {
                    Assert.Fail($"Could not find expected file {fullFilePath}.");
                }
            }
        }
示例#30
0
        public void TestEditorStateRename(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Create a list of expected controles with an EditorState file
                List <string> expectedControlsWithEditorState = new List <string>();
                expectedControlsWithEditorState.AddRange(msapp._screens.Keys);
                expectedControlsWithEditorState.AddRange(msapp._components.Keys);

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Look for the expected controls in the EditorState files
                string srcPath = Path.Combine(outSrcDir, "Src", "EditorState");
                foreach (string editorStateFile in Directory.GetFiles(srcPath, "*.editorstate.json", SearchOption.TopDirectoryOnly))
                {
                    string fileName = Path.GetFileName(editorStateFile).Replace(".editorstate.json", string.Empty);

                    // Check for an exact match between the control and the file.
                    if (expectedControlsWithEditorState.Contains(fileName))
                    {
                        expectedControlsWithEditorState.Remove(fileName);
                        continue;
                    }

                    // Replace any appended suffixes on Windows to see if there was a file collision.
                    fileName = Regex.Replace(fileName, "(?:_\\d+)?$", string.Empty);

                    // Check if the new file name without a suffix matches, otherwise fail the test
                    if (expectedControlsWithEditorState.Contains(fileName))
                    {
                        expectedControlsWithEditorState.Remove(fileName);
                    }
                    else
                    {
                        Assert.Fail($"Unexpected file {editorStateFile} in EditorState folder.");
                    }
                }

                // There should be no expected files that were not found
                Assert.AreEqual <int>(expectedControlsWithEditorState.Count, 0, $"{expectedControlsWithEditorState.Count} editor state files not found in EditorState directory.");
            }
        }
示例#31
0
        public void TestAssetFileRename()
        {
            var doc       = new CanvasDocument();
            var resource1 = new ResourceJson()
            {
                Name         = "Image", // Capital
                Path         = "Assets\\Images\\Image.png",
                FileName     = "Image.png",
                ResourceKind = ResourceKind.LocalFile,
                Content      = ContentKind.Image,
            };

            doc._assetFiles.Add(new FilePath("Images", "Image.png"), new FileEntry());

            var resource2 = new ResourceJson()
            {
                Name         = "image", // Lowercase
                Path         = "Assets\\Images\\image.png",
                FileName     = "image.png",
                ResourceKind = ResourceKind.LocalFile,
                Content      = ContentKind.Image,
            };

            doc._assetFiles.Add(new FilePath("Images", "image.png"), new FileEntry());

            var resource3 = new ResourceJson()
            {
                Name         = "image_1",
                Path         = "Assets\\Images\\image_1.png",
                FileName     = "image_1.png",
                ResourceKind = ResourceKind.LocalFile,
                Content      = ContentKind.Image,
            };

            doc._assetFiles.Add(new FilePath("Images", "image_1.png"), new FileEntry());

            doc._resourcesJson = new ResourcesJson()
            {
                Resources = new ResourceJson[] { resource1, resource2, resource3 }
            };

            var errorContainer = new ErrorContainer();

            doc.StabilizeAssetFilePaths(errorContainer);

            var newFileNames = doc._resourcesJson.Resources.Select(resource => resource.Name);

            Assert.IsTrue(newFileNames.Contains("Image"));
            Assert.IsTrue(newFileNames.Contains("image_1"));
            Assert.IsTrue(newFileNames.Contains("image_2"));
        }
示例#32
0
        public void Apply(CanvasDocument document)
        {
            if (document._connections == null)
            {
                document._connections = new Dictionary <string, ConnectionJson>(StringComparer.Ordinal);
            }

            if (document._connections.ContainsKey(Name))
            {
                return;
            }

            document._connections.Add(Name, Contents);
        }
 public void Apply(CanvasDocument document)
 {
     if (document._templateStore.AddTemplate(_name, _template))
     {
         if (_isPcf && _pcfTemplate != null)
         {
             document._pcfControls.Add(_name, _pcfTemplate);
         }
         else if (_jsonTemplate != null)
         {
             document._templates.UsedTemplates = document._templates.UsedTemplates.Concat(new[] { _jsonTemplate }).ToArray();
         }
     }
 }
示例#34
0
        public void TestScreenRename(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Create a list of screens expected to be seen in the output
                List <string> expectedScreens = msapp._screens.Keys.ToList();

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Look for the expected screens in the YAML files
                string srcPath = Path.Combine(outSrcDir, "Src");
                foreach (string yamlFile in Directory.GetFiles(srcPath, "*.fx.yaml", SearchOption.TopDirectoryOnly))
                {
                    string fileName = Path.GetFileName(yamlFile).Replace(".fx.yaml", string.Empty);

                    // Check for an exact match between the screen name and the file.
                    if (expectedScreens.Contains(fileName))
                    {
                        expectedScreens.Remove(fileName);
                        continue;
                    }

                    // Replace any appended suffixes on Windows to see if there was a file collision.
                    fileName = Regex.Replace(fileName, "(?:_\\d+)?$", string.Empty);

                    // Check if the new file name without a suffix matches, otherwise fail the test
                    if (expectedScreens.Contains(fileName))
                    {
                        expectedScreens.Remove(fileName);
                    }
                    else
                    {
                        Assert.Fail($"Unexpected file {yamlFile} in Src folder.");
                    }
                }

                // There should be no expected files that were not found
                Assert.AreEqual <int>(expectedScreens.Count, 0, $"{expectedScreens.Count} screens not found in Src directory.");
            }
        }
        public void Serialize(CanvasDocument document)
        {
            var objects = Mapper.Map<List<ObjectDto>>(document.Children);

            var compositionDto = new ModelDto
                                 {
                                     Objects = objects
                                 };

            serializer.Serialize(stream, compositionDto);
        }
示例#36
0
 /// <summary>
 /// 设置此Document处于选中状态
 /// </summary>
 /// <param name="document"></param>
 public static void SetDocumentSelected(CanvasDocument document)
 {
     Window1 mainWindow = GetMainWindow();
     foreach (CanvasDocument doc in mainWindow.DockingManager.Items)
     {
         if (doc.Equals(document))
         {
             mainWindow.DockingManager.SelectedItem = doc;
             currentCanvas = doc.Canvas;
             //显示鼠标坐标
             mainWindow.statusBar.DataContext = currentCanvas;
             break;
         }
     }
 }
示例#37
0
 /// <summary>
 /// 删除Document
 /// </summary>
 /// <param name="document"></param>
 public static void RemoveDocument(CanvasDocument document)
 {
     canvasDocuments.Remove(document);
     Window1 mainWindow = GetMainWindow();
     mainWindow.DockingManager.Items.Remove(document);
 }
        public CanvasDocument Deserialize()
        {
            var compositionDto = (ModelDto)serializer.Deserialize(stream);
            var objectDtos = compositionDto.Objects;
            var items = Mapper.Map<List<CanvasItem>>(objectDtos);
            CanvasDocument document = new CanvasDocument(items);

            return  document;
        }