/// <summary> /// Clone this model. /// </summary> /// <returns>The cloned model.</returns> public object Clone() { SimpleWebSlide slide = new SimpleWebSlide(); foreach (SimpleWebInk ink in this.Inks) { slide.Inks.Add(ink.Clone()); } slide.Id = this.Id; slide.Index = this.Index; slide.Name = (string)this.Name.Clone(); return(slide); }
/// <summary> /// Build the values for the slide strokes. /// </summary> /// <param name="first">The first slide.</param> /// <param name="second">The second slide.</param> /// <returns>The data structure for the strokes array.</returns> protected List <object> BuildStrokesData(SimpleWebSlide first, SimpleWebSlide second) { bool nonNull = false; List <object> strokes = new List <object>(); // We need an entry for every stroke in the second model. for (int i = 0; i < second.Inks.Count; i++) { // Optionally, get the first stroke if this stroke existed in the first model. SimpleWebInk firstInk = null; if (first != null && i < first.Inks.Count) { firstInk = (SimpleWebInk)first.Inks[i]; } // Get the difference between the two strokes, if the strokes are the same add null. List <KeyValuePair <string, object> > strokeData = BuildStrokeData(firstInk, (SimpleWebInk)second.Inks[i]); if (strokeData != null) { strokes.Add(strokeData); nonNull = true; } else { strokes.Add(null); } } // Return the result only if some stroke was updated. if (nonNull == true && strokes.Count > 0) { return(strokes); } else { return(null); } }
/// <summary> /// Build the values for a single deck slide. /// </summary> /// <param name="first">The first slide.</param> /// <param name="second">The second slide.</param> /// <param name="index">The slide index.</param> /// <param name="deckName">The deck name, needed to construct the background image path.</param> /// <returns>The data structure for the slide difference.</returns> protected List <KeyValuePair <string, object> > BuildSlideData(SimpleWebSlide first, SimpleWebSlide second, int index, string deckName) { List <KeyValuePair <string, object> > slide = new List <KeyValuePair <string, object> >(); // Optionally, add the slide index. if (first == null || first.Index != second.Index) { slide.Add(new KeyValuePair <string, object>(SlideIndex, second.Index)); } // Optionally, add the slide name. if (first == null || first.Name != second.Name) { slide.Add(new KeyValuePair <string, object>(SlideName, second.Name)); } // Optionally, add the slide background image path. if (first == null || first.Id != second.Id) { slide.Add(new KeyValuePair <string, object>(SlideImagePath, "./images/decks/" + deckName + "/" + deckName + "/" + deckName + "_" + String.Format("{0:000}", index + 1) + ".png")); } // Optionally, add the slide strokes. List <object> strokes = BuildStrokesData(first, second); if (strokes != null) { slide.Add(new KeyValuePair <string, object>(SlideStrokes, strokes)); } // Return the result only if we added/updated data. if (slide.Count > 0) { return(slide); } else { return(null); } }
/// <summary> /// Clone this model. /// </summary> /// <returns>The cloned model.</returns> public object Clone() { SimpleWebSlide slide = new SimpleWebSlide(); foreach (SimpleWebInk ink in this.Inks) { slide.Inks.Add(ink.Clone()); } slide.Id = this.Id; slide.Index = this.Index; slide.Name = (string)this.Name.Clone(); return slide; }
/// <summary> /// Build the values for the slide strokes. /// </summary> /// <param name="first">The first slide.</param> /// <param name="second">The second slide.</param> /// <returns>The data structure for the strokes array.</returns> protected List<object> BuildStrokesData(SimpleWebSlide first, SimpleWebSlide second) { bool nonNull = false; List<object> strokes = new List<object>(); // We need an entry for every stroke in the second model. for (int i = 0; i < second.Inks.Count; i++) { // Optionally, get the first stroke if this stroke existed in the first model. SimpleWebInk firstInk = null; if (first != null && i < first.Inks.Count) { firstInk = (SimpleWebInk)first.Inks[i]; } // Get the difference between the two strokes, if the strokes are the same add null. List<KeyValuePair<string, object>> strokeData = BuildStrokeData(firstInk, (SimpleWebInk)second.Inks[i]); if (strokeData != null) { strokes.Add(strokeData); nonNull = true; } else { strokes.Add(null); } } // Return the result only if some stroke was updated. if (nonNull == true && strokes.Count > 0) return strokes; else return null; }
/// <summary> /// Build the values for a single deck slide. /// </summary> /// <param name="first">The first slide.</param> /// <param name="second">The second slide.</param> /// <param name="index">The slide index.</param> /// <param name="deckName">The deck name, needed to construct the background image path.</param> /// <returns>The data structure for the slide difference.</returns> protected List<KeyValuePair<string, object>> BuildSlideData(SimpleWebSlide first, SimpleWebSlide second, int index, string deckName) { List<KeyValuePair<string, object>> slide = new List<KeyValuePair<string, object>>(); // Optionally, add the slide index. if (first == null || first.Index != second.Index) { slide.Add(new KeyValuePair<string, object>(SlideIndex, second.Index)); } // Optionally, add the slide name. if (first == null || first.Name != second.Name) { slide.Add(new KeyValuePair<string, object>(SlideName, second.Name)); } // Optionally, add the slide background image path. if (first == null || first.Id != second.Id) { slide.Add(new KeyValuePair<string, object>(SlideImagePath, "./images/decks/" + deckName + "/" + deckName + "/" + deckName + "_" + String.Format("{0:000}", index + 1) + ".png")); } // Optionally, add the slide strokes. List<object> strokes = BuildStrokesData(first, second); if (strokes != null) { slide.Add(new KeyValuePair<string, object>(SlideStrokes, strokes)); } // Return the result only if we added/updated data. if (slide.Count > 0) return slide; else return null; }
protected void UpdateAllSlidesAndContent() { int deckIndex = GetDeckIndex(); using (Synchronizer.Lock(this.m_Deck.SyncRoot)) { using( Synchronizer.Lock( this.m_Deck.TableOfContents.SyncRoot ) ) { foreach (TableOfContentsModel.Entry e in this.m_Deck.TableOfContents.Entries) { // Get the index of this entry int index = this.m_Deck.TableOfContents.Entries.IndexOf( e ); using (Synchronizer.Lock(e.SyncRoot)) { using( Synchronizer.Lock( e.Slide.SyncRoot ) ) { if (!this.m_SlideWebServices.ContainsKey(e.Slide.Id)) { SlideWebService service = new SlideWebService(this.m_Sender, this.m_Presentation, this.m_Deck, e.Slide); this.m_SlideWebServices.Add(e.Slide.Id, service); } // Check if the slide exists yet lock (WebService.Instance.GlobalModel) { SimpleWebSlide s = GetExistingWebSlide((SimpleWebDeck)WebService.Instance.GlobalModel.Decks[deckIndex], e.Slide.Id); if (s == null) { // Add the new slide s = new SimpleWebSlide(); s.Id = e.Slide.Id; s.Index = index; s.Name = e.Slide.Title; ((SimpleWebDeck)WebService.Instance.GlobalModel.Decks[deckIndex]).Slides.Add(s); } else { // Update the slide values s.Index = index; s.Name = e.Slide.Title; } } WebService.Instance.UpdateModel(); } } } } } }
protected static string BuildSlideString(string prefix, string deckName, int index, SimpleWebSlide slide) { string newPrefix = prefix + "_" + index; string result = ""; result += "\t\t\t\t<div id=\"" + newPrefix + "\">\n"; result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Index\">" + index + "</div>\n"; result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Name\">" + slide.Name + "</div>\n"; result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Image\">" + "./images/" + deckName + "/" + deckName + "/" + deckName + "_" + String.Format( "{0:000}", index+1 ) + ".png" + "</div>\n"; result += "\t\t\t\t</div>\n"; return result; }