private bool NewFileInternal() { // Clear the filename ClearFilename(); // Create a new SlideCollection _slideCollection = new Model.SlideCollection(CodeFlowViewModel.Instance.HistoryController); // Create a new slide for the collection. var newSlide = new Slide { Name = "New Slide" }; // Add the new slide to the slide collection. _slideCollection.AddChild(newSlide); // Hopefully the UI has subscribed to the SlideSelected event. CodeFlowViewModel.Instance.SetCurrentSlide(newSlide.GetView <SlideView>()); return(true); }
public void tSerializer_DefaultNode() { var hc = new HistoryController(); var filename = @"c:\temp\tSerializer_DefaultNode.xml"; var slideCollection = new SlideCollection(); var slide1 = new Slide { Name = "Slide1" }; var child1 = new DefaultNode { Name = "child1", Description = "child1_description", Comment = "child1_comment", Background = new System.Windows.Media.Color { A = 1, B = 150, G = 160, R = 170 }, BorderType = BorderType.normal, Foreground = new System.Windows.Media.Color { A = 1, R = 2, G = 3, B = 4 }, Location = new System.Windows.Point { X = 1, Y = 2 }, ShapeType = ShapeType.rectangle, Size = new System.Windows.Size { Height = 1, Width = 2 }, Parent = null }; slideCollection.AddChild(slide1); slide1.AddChild(child1); Serializer.Serialize(slideCollection, filename); var result = Serializer.DeSerialize(filename, hc); Assert.AreEqual(typeof(SlideCollection), result.GetType()); var r = (SlideCollection)result; var Slide = r.Children[0]; Assert.AreEqual(r.Guid, Slide.Parent.Guid); var tNode = (DefaultNode)Slide.Children[0]; Assert.AreEqual(Slide.Guid, tNode.Parent.Guid); Assert.AreEqual("child1", tNode.Name); Assert.AreEqual("child1_description", tNode.Description); Assert.AreEqual("child1_comment", tNode.Comment); Assert.AreEqual(new System.Windows.Media.Color { A = 1, B = 150, G = 160, R = 170 }, tNode.Background); Assert.AreEqual(BorderType.normal, tNode.BorderType); Assert.AreEqual(new System.Windows.Media.Color { A = 1, R = 2, G = 3, B = 4 }, tNode.Foreground); Assert.AreEqual(new System.Windows.Point { X = 1, Y = 2 }, tNode.Location); Assert.AreEqual(ShapeType.rectangle, tNode.ShapeType); Assert.AreEqual(new System.Windows.Size { Height = 1, Width = 2 }, tNode.Size); }
public void tSerializer_Slides() { var filename = @"c:\temp\tSerializer_Slides.xml"; var slideCollection = new SlideCollection(); var slide1 = new Slide { Name = "Slide1" }; var slide2 = new Slide { Name = "Slide2" }; var child1 = new VisualNode { Name = "child1", Description = "child1_description", Comment = "child1_comment", Parent = null }; var child2 = new VisualNode { Name = "child2", Description = "child2_description", Comment = "child2_comment", Parent = null }; var child3 = new VisualNode { Name = "child3", Description = "child3_description", Comment = "child3_comment", Parent = null }; var child4 = new VisualNode { Name = "child4", Description = "child4_description", Comment = "child4_comment", Parent = null }; slideCollection.AddChild(slide1); slideCollection.AddChild(slide2); slide1.AddChild(child1); slide1.AddChild(child2); slide2.AddChild(child3); slide2.AddChild(child4); Serializer.Serialize(slideCollection, filename); var result = Serializer.DeSerialize(filename); Assert.AreEqual(typeof(SlideCollection), result.GetType()); var r = (SlideCollection)result; // The Parent properties of both slides in the slide collection should reference the // slide collection. var firstSlide = r.Children[0]; var secondSlide = r.Children[1]; Assert.AreEqual(r.Guid, firstSlide.Parent.Guid); Assert.AreEqual(r.Guid, secondSlide.Parent.Guid); // The Parent properties of both children of the first slide should reference the // first slide. var firstChild = firstSlide.Children[0]; var secondChild = firstSlide.Children[1]; Assert.AreEqual(firstSlide.Guid, firstChild.Parent.Guid); Assert.AreEqual(firstSlide.Guid, secondChild.Parent.Guid); // The Parent properties of both children of the secode slide should reference the // second slide. firstChild = secondSlide.Children[0]; secondChild = secondSlide.Children[1]; Assert.AreEqual(secondSlide.Guid, firstChild.Parent.Guid); Assert.AreEqual(secondSlide.Guid, secondChild.Parent.Guid); }
public void tFileStoreContoller() { var hc = new HistoryController(); var filename = @"c:\temp\tFileStoreContoller_HistoryController.xml"; var slideCollection = new SlideCollection(); var slide1 = new Slide { Name = "Slide1" }; var slide2 = new Slide { Name = "Slide2" }; var child1 = new DefaultNode { Name = "child1", Description = "child1_description", Comment = "child1_comment", Parent = null }; var child2 = new VisualNode { Name = "child2", Description = "child2_description", Comment = "child2_comment", Parent = null }; var child3 = new VisualNode { Name = "child3", Description = "child3_description", Comment = "child3_comment", Parent = null }; var child4 = new VisualNode { Name = "child4", Description = "child4_description", Comment = "child4_comment", Parent = null }; slideCollection.AddChild(slide1); slideCollection.AddChild(slide2); slide1.AddChild(child1); slide1.AddChild(child2); slide2.AddChild(child3); slide2.AddChild(child4); var fileStoreController = new FileStoreController(); fileStoreController.PersistSlideCollection(filename, slideCollection); var result = fileStoreController.RestoreSlideCollection(filename, hc); Assert.AreEqual(typeof(SlideCollection), result.GetType()); var r = (SlideCollection)result; // The Parent properties of both slides in the slide collection should reference the // slide collection. var firstSlide = r.Children[0]; var secondSlide = r.Children[1]; Assert.AreEqual(r.Guid, firstSlide.Parent.Guid); Assert.AreEqual(r.Guid, secondSlide.Parent.Guid); // The Parent properties of both children of the first slide should reference the // first slide. var firstChild = firstSlide.Children[0]; var secondChild = firstSlide.Children[1]; Assert.AreEqual(firstSlide.Guid, firstChild.Parent.Guid); Assert.AreEqual(firstSlide.Guid, secondChild.Parent.Guid); // The Parent properties of both children of the second slide should reference the // second slide. firstChild = secondSlide.Children[0]; secondChild = secondSlide.Children[1]; Assert.AreEqual(secondSlide.Guid, firstChild.Parent.Guid); Assert.AreEqual(secondSlide.Guid, secondChild.Parent.Guid); firstChild.Name = "testA"; Assert.AreEqual("testA", firstChild.Name); firstChild.Name = "testB"; Assert.AreEqual("testB", firstChild.Name); hc.Undo(); Assert.AreEqual("testA", firstChild.Name); hc.Redo(); Assert.AreEqual("testB", firstChild.Name); }