/// <summary> /// Constructs a listener for changes to the deck traversal /// </summary> /// <param name="sender">The event queue for handling updates</param> /// <param name="presentation">The presentation</param> /// <param name="traversal">The deck traversal we care about </param> public DeckTraversalWebService(SendingQueue sender, PresentationModel presentation, DeckTraversalModel traversal) { this.m_Sender = sender; this.m_Presentation = presentation; this.m_DeckTraversal = traversal; // Create the deck object string deckName = "Untitled Deck"; using (Synchronizer.Lock(this.m_DeckTraversal.SyncRoot)) { using (Synchronizer.Lock(this.m_DeckTraversal.Deck)) { deckName = this.m_DeckTraversal.Deck.HumanName; } } SimpleWebDeck deck = new SimpleWebDeck(); deck.Name = deckName; lock (WebService.Instance.GlobalModel) { WebService.Instance.GlobalModel.Decks.Add(deck); } WebService.Instance.UpdateModel(); this.m_DeckWebService = new DeckWebService(this.m_Sender, this.m_Presentation, this.m_DeckTraversal.Deck); this.m_CurrentChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.m_Sender, new PropertyEventHandler(this.HandleCurrentChanged)); this.m_DeckTraversal.Changed["Current"].Add(this.m_CurrentChangedDispatcher.Dispatcher); }
/// <summary> /// Build the values for a single model deck. /// </summary> /// <param name="first">The first deck.</param> /// <param name="second">The second deck.</param> /// <returns>The data structure for the deck difference.</returns> protected List <KeyValuePair <string, object> > BuildDeckData(SimpleWebDeck first, SimpleWebDeck second) { List <KeyValuePair <string, object> > deck = new List <KeyValuePair <string, object> >(); // Optionally, add the deck name. if (first == null || first.Name != second.Name) { deck.Add(new KeyValuePair <string, object>(DeckName, second.Name)); } // Optionally, add the deck slides. List <object> slides = BuildSlidesData(first, second); if (slides != null) { deck.Add(new KeyValuePair <string, object>(DeckSlides, slides)); } // Return the result only if we added/updated data. if (deck.Count > 0) { return(deck); } else { return(null); } }
/// <summary> /// Clone this model. /// </summary> /// <returns>The cloned model.</returns> public object Clone() { SimpleWebDeck deck = new SimpleWebDeck(); foreach (SimpleWebSlide slide in this.Slides) { deck.Slides.Add(slide.Clone()); } deck.Name = (string)this.Name.Clone(); return deck; }
/// <summary> /// Clone this model. /// </summary> /// <returns>The cloned model.</returns> public object Clone() { SimpleWebDeck deck = new SimpleWebDeck(); foreach (SimpleWebSlide slide in this.Slides) { deck.Slides.Add(slide.Clone()); } deck.Name = (string)this.Name.Clone(); return(deck); }
/// <summary> /// Build the values for the model slides. /// </summary> /// <param name="first">The first deck.</param> /// <param name="second">The second deck.</param> /// <returns>The data structure for the slides array.</returns> protected List <object> BuildSlidesData(SimpleWebDeck first, SimpleWebDeck second) { bool nonNull = false; List <object> slides = new List <object>(); // We need an entry for every slide in the second model. for (int i = 0; i < second.Slides.Count; i++) { // Optionally, get the first slide if this slide existed in the first model. SimpleWebSlide firstSlide = null; if (first != null && i < first.Slides.Count) { firstSlide = (SimpleWebSlide)first.Slides[i]; } // Get the difference between the two slides, if the slides are the same add null. List <KeyValuePair <string, object> > slideData = BuildSlideData(firstSlide, (SimpleWebSlide)second.Slides[i], i, second.Name); if (slideData != null) { slides.Add(slideData); nonNull = true; } else { slides.Add(null); } } // Return the result only if some slide was updated. if (nonNull == true && slides.Count > 0) { return(slides); } else { return(null); } }
/// <summary> /// Build the values for the model decks. /// </summary> /// <param name="first">The first model.</param> /// <param name="second">The second model.</param> /// <returns>The data structure for the decks array.</returns> protected List <object> BuildDecksData(SimpleWebModel first, SimpleWebModel second) { bool nonNull = false; List <object> decks = new List <object>(); // We need an entry for every deck in the second model. for (int i = 0; i < second.Decks.Count; i++) { // Optionally, get the first deck if this deck existed in the first model. SimpleWebDeck firstDeck = null; if (first != null && i < first.Decks.Count) { firstDeck = (SimpleWebDeck)first.Decks[i]; } // Get the difference between the two decks, if the decks are the same add null. List <KeyValuePair <string, object> > deckData = BuildDeckData(firstDeck, (SimpleWebDeck)second.Decks[i]); if (deckData != null) { decks.Add(deckData); nonNull = true; } else { decks.Add(null); } } // Return the result only if some deck was updated. if (nonNull == true && decks.Count > 0) { return(decks); } else { return(null); } }
/// <summary> /// Build the values for the model slides. /// </summary> /// <param name="first">The first deck.</param> /// <param name="second">The second deck.</param> /// <returns>The data structure for the slides array.</returns> protected List<object> BuildSlidesData(SimpleWebDeck first, SimpleWebDeck second) { bool nonNull = false; List<object> slides = new List<object>(); // We need an entry for every slide in the second model. for (int i = 0; i < second.Slides.Count; i++) { // Optionally, get the first slide if this slide existed in the first model. SimpleWebSlide firstSlide = null; if (first != null && i < first.Slides.Count) { firstSlide = (SimpleWebSlide)first.Slides[i]; } // Get the difference between the two slides, if the slides are the same add null. List<KeyValuePair<string, object>> slideData = BuildSlideData(firstSlide, (SimpleWebSlide)second.Slides[i], i, second.Name); if (slideData != null) { slides.Add(slideData); nonNull = true; } else { slides.Add(null); } } // Return the result only if some slide was updated. if (nonNull == true && slides.Count > 0) return slides; else return null; }
/// <summary> /// Build the values for a single model deck. /// </summary> /// <param name="first">The first deck.</param> /// <param name="second">The second deck.</param> /// <returns>The data structure for the deck difference.</returns> protected List<KeyValuePair<string, object>> BuildDeckData(SimpleWebDeck first, SimpleWebDeck second) { List<KeyValuePair<string, object>> deck = new List<KeyValuePair<string, object>>(); // Optionally, add the deck name. if (first == null || first.Name != second.Name) { deck.Add(new KeyValuePair<string, object>(DeckName, second.Name)); } // Optionally, add the deck slides. List<object> slides = BuildSlidesData(first, second); if (slides != null) { deck.Add(new KeyValuePair<string, object>(DeckSlides, slides)); } // Return the result only if we added/updated data. if (deck.Count > 0) return deck; else return null; }
protected SimpleWebSlide GetExistingWebSlide( SimpleWebDeck d, Guid id) { foreach( SimpleWebSlide s in d.Slides ) { if (s.Id == id) return s; } return null; }
protected static string BuildDeckString(string prefix, int index, SimpleWebDeck deck) { string newPrefix = prefix + "_" + index; string result = ""; result += "\t\t<div id=\"" + newPrefix + "\">\n"; result += "\t\t\t<div id=\"" + newPrefix + "_Index\">" + index + "</div>\n"; result += "\t\t\t<div id=\"" + newPrefix + "_Name\">" + deck.Name + "</div>\n"; result += "\t\t\t<div id=\"" + newPrefix + "_Slides\">\n"; for (int i = 0; i < deck.Slides.Count; i++) { result += BuildSlideString(newPrefix, deck.Name, i, (SimpleWebSlide)deck.Slides[i]); } result += "\t\t\t</div>\n"; result += "\t\t</div>\n"; return result; }