Example #1
0
    private SlideCollection LoadSlide()
    {
        Data            objdata = new Data(Global.ConnectionSql);
        SlideCollection col     = new SlideCollection();

        try
        {
            Slide obj = new Slide();
            obj.DataObject = objdata;
            col            = obj.GetAll();
            if (col != null)
            {
                rptslide.DataSource = col;
                rptslide.DataBind();
            }
        }
        catch (Exception ex)
        {
            Global.WriteLogError("LoadProduct()" + ex);
        }
        finally
        {
            objdata.DeConnect();
        }
        return(col);
    }
Example #2
0
        private EditAbleCollection <Slide> InitSlides()
        {
            var preSettings     = new PreSettings(_sdkPre.PresentationPart.Presentation);
            var slideCollection = SlideCollection.Create(_sdkPre, preSettings);

            return(slideCollection);
        }
Example #3
0
 /// <summary>
 /// Returns the entire hierarchy for default slide in the collection.
 /// </summary>
 /// <returns>
 /// ATM there is no meta data or anything that determines which view in the slide collection
 /// is the 'default' slide. For now just return the first slide in the collection.
 /// </returns>
 private SlideView GetDefaultSlideView(SlideCollection slideCollection)
 {
     // TODO:
     // Implement some way of determining a 'default' slide in a slide collection.
     Verify.NotNull(slideCollection?.Children[0], "The slide collection in the file does not contain any slides!");
     return((SlideView)ViewFactory.Instance.GetHierarchy(slideCollection.Children[0]));
 }
Example #4
0
        private EditAbleCollection <Slide> GetSlides()
        {
            var sdkPrePart = _sdkPre.PresentationPart;

            _preSettings = new PreSettings(sdkPrePart.Presentation, _slideSize);
            var slideCollection = SlideCollection.Create(sdkPrePart, _preSettings);

            return(slideCollection);
        }
Example #5
0
 private bool CloseFileInternal()
 {
     Verify.NotNull(_slideCollection, "_slideCollection is null.");
     CodeFlowViewModel.Instance.DetachCurrentSlide();
     _slideCollection.Dispose();
     _slideCollection = null;
     CodeFlowViewModel.Instance.ClearDirtyFlag();
     ClearFilename();
     return(true);
 }
Example #6
0
 private void BindingData()
 {
     try
     {
         SlideCollection col = null;
         col = this.LoadSlide();
         rptData.DataSource = col;
         rptData.DataBind();
     }
     catch (Exception ex)
     {
         Global.WriteLogError("BindingData()" + ex);
     }
 }
        // Used for v0.1
        void CommitHold(SlideCollection col)
        {
            Hold        tempHold  = new Hold(0, 0, 0, Side.NotSet);
            List <Note> tempNotes = new List <Note>();

            for (int i = 0; i < col.Notes.Count; i++)
            {
                var    parsed  = col.Notes[i].Item1;
                double noteSub = 1.0 / parsed.Notes.Count;
                var    j       = col.Notes[i].Item2;
                Side   side    = parsed.NoteClass == 2 ? Side.Left : Side.Right;

                if (i == 0)
                {
                    tempHold = new Hold(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side);
                }
                else
                {
                    switch (parsed.Notes[j].Item1)
                    {
                    case 1:     // Shouldn't happen because it was already added above
                        throw new Exception("Unexpected start note.");

                    case 2:     // End a hold note with no shuffle
                    case 4:     // Add a midpoint with no shuffle
                        tempNotes.Add(new Note(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side)
                        {
                            Type = NoteType.Hold
                        });
                        break;

                    case 3:     // End a hold note with a shuffle
                    case 5:     // Add a midpoint with a shuffle
                        tempNotes.Add(new Note(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side)
                        {
                            Type = NoteType.Shuffle
                        });
                        break;
                    }
                }
            }
            tempNotes.Sort((x, y) => x.BeatLocation.CompareTo(y.BeatLocation));
            foreach (var note in tempNotes)
            {
                tempHold.AddNote(note);
            }

            Holds.Add(tempHold);
        }
Example #8
0
        private bool OpenFileInternal(string path, string filename, string ext)
        {
            if (_slideCollection != null)
            {
                CloseFileInternal();
            }
            SetFilename(path, filename, ext);
            _slideCollection =
                _storeController.RestoreSlideCollection(
                    CreateFullFilename(),
                    CodeFlowViewModel.Instance.HistoryController
                    );
            var slide = _slideCollection.GetFirstOrNew();

            CodeFlowViewModel.Instance.SetCurrentSlide((SlideView)ViewFactory.Instance.GetHierarchy(slide));
            return(true);
        }
Example #9
0
        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);
        }
        // string connStr, string dbOwner, string objQualifier)
        public bool LoadFromDB(string RotatorId)
        {
            DataProvider.Instance().Init(Configuration);
            bool hasValues = false;
            using (IDataReader dr = DataProvider.Instance().GetSettings(RotatorId)) {

                while (dr.Read()) {

                    hasValues = true;

                    string val = "";
                    try { val = dr["SettingValue"].ToString(); } catch { }

                    switch (dr["SettingName"].ToString()) {
                        case "Width":
                            try {
                                Width = Convert.ToInt32(val);
                            } catch { }
                            break;
                        case "Height":
                            try {
                                Height = Convert.ToInt32(val);
                            } catch { }
                            break;
                        //case "RenderEngine":
                        //    try {
                        //        RenderEngine = (eRenderEngine)Enum.Parse(typeof(eRenderEngine), val, true);
                        //    } catch { RenderEngine = eRenderEngine.Flash; }
                        //    break;
                        case "FallbackImage":
                            FallbackImage = val;
                            break;
                        case "AutoStartSlideShow":
                            AutoStartSlideShow = val == "true";
                            break;
                        case "ShowBottomButtons":
                            ShowBottomButtons = val == "true";
                            break;
                        case "ShowPlayPauseControls":
                            ShowPlayPauseControls = val == "true";
                            break;
                        case "BackgroundColor":
                            try {
                                BackgroundColor = System.Drawing.Color.FromArgb(Convert.ToInt32(val.Replace("#", "0x"), 16));
                            } catch { }
                            break;
                        case "ShowTopTitle":
                            ShowTopTitle = val == "true";
                            break;
                        case "TopTitleBackground":
                            try {
                                TopTitleBackground = System.Drawing.Color.FromArgb(Convert.ToInt32(val.Replace("#", "0x"), 16));
                            } catch { }
                            break;
                        case "TopTitleBgTransparency":
                            try {
                                TopTitleBgTransparency = Convert.ToInt32(val);
                            } catch { }
                            break;
                        case "TopTitleTextColor":
                            try {
                                TopTitleTextColor = System.Drawing.Color.FromArgb(Convert.ToInt32(val.Replace("#", "0x"), 16));
                            } catch { }
                            break;
                        case "ShowTimerBar":
                            ShowTimerBar = val == "true";
                            break;
                        case "RandomOrder":
                            RandomOrder = val == "true";
                            break;
                        case "SlideButtonsColor":
                            try {
                                SlideButtonsColor = System.Drawing.Color.FromArgb(Convert.ToInt32(val.Replace("#", "0x"), 16));
                            } catch { }
                            break;
                        case "SlideButtonsNumberColor":
                            try {
                                SlideButtonsNumberColor = System.Drawing.Color.FromArgb(Convert.ToInt32(val.Replace("#", "0x"), 16));
                            } catch { }
                            break;
                        case "SlideButtonsType":
                            try {
                                SlideButtonsType = (eSlideButtonsType)Enum.Parse(typeof(eSlideButtonsType), val, true);
                            } catch { }
                            break;
                        case "SlideButtonsXoffset":
                            try {
                                SlideButtonsXoffset = Convert.ToInt32(val);
                            } catch { }
                            break;
                        case "SlideButtonsYoffset":
                            try {
                                SlideButtonsYoffset = Convert.ToInt32(val);
                            } catch { }
                            break;
                        //case "TransparentBackground":
                        //    TransparentBackground = val == "true";
                        //    break;
                        //case "_DebugMode":
                        //    _DebugMode = val == "true";
                        //    break;
                        case "LastUpdate":
                            try {
                                LastUpdate = DateTime.Parse(val, new CultureInfo("en-US").DateTimeFormat);
                            } catch { LastUpdate = DateTime.Now; }
                            break;
                    }
                }
                dr.Close();
            }

            // load slides
            _Slides = new SlideCollection();
            using (IDataReader dr = DataProvider.Instance().GetSlides(RotatorId)) {
                while (dr.Read()) {
                    SlideInfo slide = new SlideInfo();
                    slide.Load(dr);
                    slide.Settings = this;
                    Slides.Add(slide);
                }
                dr.Close();
            }

            return hasValues;
        }
 public void PersistSlideCollection(string filename, SlideCollection slideCollection)
 {
     PersistTriggered = true;
 }
Example #12
0
        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);
        }
Example #13
0
        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);
        }
 /// <summary>
 /// Stores 'slideCollection' in a file called 'filename'.
 /// </summary>
 /// <param name="filename">
 /// The name of the file which the slideCollection will be serialized to.</param>
 /// <param name="slideCollection">
 /// The slideCollection that will be serialized.
 /// </param>
 /// <remarks>
 /// The FileStoreController does not perform any existence checks before saving files. If the
 /// PersistSlideCollection would destroy an existing file, it is expected that the caller has
 /// already determined that the operation has been confirmed by the user.
 /// </remarks>
 public void PersistSlideCollection(string filename, SlideCollection slideCollection)
 {
     Serializer.Serialize(slideCollection, filename);
 }
        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);
        }