public TableOfContentsModel.Entry MarshalDestEntry( TableOfContentsModel.Entry entry ) { foreach( TableOfContentsEntryMatch match in this.m_TableOfContentsEntryMatches ) if( entry.Id == match.DestEntry.Id ) return match.SourceEntry; return null; }
public Entry(Guid id, TableOfContentsModel toc, SlideModel slide) : base(toc) { this.m_Id = id; this.m_Children = new EntryCollection(this, "Entries"); this.m_TOC = toc; this.m_Slide = slide; }
private void addToSlideLookup(Entry newEntry) { TableOfContentsModel toc = getRootTOC(); if (toc != null) { toc.addToSlideLookup(newEntry); } }
private void removeFromSlideLookup(Entry removeEntry) { TableOfContentsModel toc = getRootTOC(); if (toc != null) { toc.removeFromSlideLookup(removeEntry); } }
public TableOfContentsEntryMessage(TableOfContentsModel.Entry entry) : base(entry.Id) { this.AddLocalRef( entry ); using(Synchronizer.Lock(entry.SyncRoot)) { int[] path = entry.PathFromRoot; if(path.Length < 1) throw new ArgumentException("The entry's path is invalid; it must contain at least one index.", "path"); this.PathFromRoot = ((int[]) path.Clone()); } }
/// <summary> /// Constructor for this object /// </summary> /// <param name="id">The globally unique identifier for this deck</param> /// <param name="disposition"></param> /// <param name="humanName"></param> public DeckModel(Guid id, DeckDisposition disposition, string humanName, TableOfContentsModel toc, Hashtable slides, ImageHashtable sc, Hashtable ctsl) { this.m_Id = id; this.m_Disposition = disposition; this.m_HumanName = humanName; this.m_DeckBackgroundColor = Color.White; this.Filename = ""; this.Group = Group.AllParticipant; if (this.Disposition == DeckDisposition.StudentSubmission || this.Disposition == DeckDisposition.QuickPoll) { this.m_Dirty = true; } else { this.m_Dirty = false; } if (toc == null) { this.m_TableOfContents = new TableOfContentsModel(); } else { this.m_TableOfContents = toc; } if (slides == null) { this.m_Slides = new Hashtable(); } else { this.m_Slides = slides; } if (sc == null) { this.m_SlideContent = new ImageHashtable(); } else { this.m_SlideContent = sc; } if (ctsl != null) { this.m_ContentToSlideLookup = ctsl; } }
private TableOfContentsModel getRootTOC() { TableOfContentsModel toc = m_Parent as TableOfContentsModel; if (m_Parent == null) { Entry entry = m_Parent as Entry; if (entry != null) { toc = entry.TableOfContents; } else { Debug.Fail("Unexpected TOC Entry parent type"); } } return(toc); }
/// <summary> /// If the entry's <see cref="Entry.PathFromRoot"><c>PathFromRoot</c></see> differs from that of /// the <see cref="EntryInformation"/> record, this method removes and re-adds the entry into /// the correct location in its <see cref="TableOfContentsModel"/>. /// </summary> /// <remarks> /// This method is invoked by <see cref="UpdateEntry"/>, but <em>not</em> by <see cref="CreateEntry"/>. /// The reasoning is that <see cref="CreateEntry"/> does nothing other than instantiating the /// <see cref="TableOfContentsModel.Entry"/> object, allowing for other processing between /// the time that the entry is instantiated and when it is inserted into the <see cref="TableOfContentsModel"/>. /// </remarks> /// <param name="entry">The entry to update.</param> public void UpdatePathFromRoot(TableOfContentsModel.Entry entry) { using(Synchronizer.Lock(entry.SyncRoot)) { int[] old = entry.PathFromRoot; int[] path = this.PathFromRoot; bool changed = (old.Length != path.Length); for(int i = 0; !changed && i < path.Length; i++) changed = (old[i] != path[i]); if(changed) { // Remove the entry from its current parent, if any. if(entry.Parent == null) { if(entry.TableOfContents.Entries.Contains(entry)) { entry.TableOfContents.Entries.Remove(entry); } } else { entry.Parent.Children.Remove(entry); } // Insert the entry as a child of its new parent, // whether that be as a root entry of the TableOfContents // or as a child of some other entry. Debug.Assert(path.Length >= 1); if(path.Length == 1) { int index = Math.Min(entry.TableOfContents.Entries.Count, Math.Max(0, path[0])); //Natalie // entry.TableOfContents.Entries.Insert(index, entry); //entry.index = path[0]; entry.TableOfContents.Entries.BroadcastInsert(path[0], entry); } else { int[] parentPath = new int[path.Length - 1]; Array.Copy(path, 0, parentPath, 0, parentPath.Length); TableOfContentsModel.Entry parent = entry.TableOfContents[parentPath]; // FIXME: Handle the case when no parent at the specified index exists. int index = Math.Min(parent.Children.Count, Math.Max(0, path[path.Length - 1])); //Natalie - what is this? parent.Children.Insert(index, entry); } } } }
public FilmStripSlideViewer(MultiColumnFilmStrip parent, PresenterModel model, DeckTraversalModel traversal, DeckTraversalModel previewTraversal, TableOfContentsModel.Entry entry) { this.m_Model = model; this.m_Parent = parent; this.m_DeckTraversal = traversal; this.m_Entry = entry; this.m_PreviewDeckTraversal = previewTraversal; this.BorderStyle = BorderStyle.FixedSingle; this.m_CurrentEntryChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.SlideDisplay.EventQueue, new PropertyEventHandler(this.HandleCurrentEntryChanged)); this.m_EntriesChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.SlideDisplay.EventQueue, new PropertyEventHandler(this.HandleEntriesChanged)); this.m_DeckBackgroundColorChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.SlideDisplay.EventQueue, new PropertyEventHandler(this.HandleDeckBackgroundColorChanged)); this.m_DeckBackgroundTemplateChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.SlideDisplay.EventQueue, new PropertyEventHandler(this.HandleDeckBackgroundTemplateChanged)); this.m_DeckTraversal.Changed["Current"].Add(this.m_CurrentEntryChangedDispatcher.Dispatcher); this.m_Entry.TableOfContents.Changed["Entries"].Add(this.m_EntriesChangedDispatcher.Dispatcher); using (Synchronizer.Lock(this.m_DeckTraversal.Deck.SyncRoot)) { this.m_DeckTraversal.Deck.Changed["DeckBackgroundColor"].Add(this.m_DeckBackgroundColorChangedDispatcher.Dispatcher); this.m_DeckTraversal.Deck.Changed["DeckBackgroundTemplate"].Add(this.m_DeckBackgroundTemplateChangedDispatcher.Dispatcher); this.DefaultDeckBGColor = this.m_DeckTraversal.Deck.DeckBackgroundColor; this.DefaultDeckBGTemplate = this.m_DeckTraversal.Deck.DeckBackgroundTemplate; } this.m_EntriesChangedDispatcher.Dispatcher(this.m_Entry, null); this.m_CurrentEntryChangedDispatcher.Dispatcher(this.m_DeckTraversal, null); this.m_CurrentDeckTraversalChangedDispatcher = this.m_Model.Workspace.CurrentDeckTraversal.ListenAndInitialize(this.SlideDisplay.EventQueue, delegate(Property<DeckTraversalModel>.EventArgs args) { bool old = this.m_IsCurrentDeckTraversal; using (this.m_Model.Workspace.Lock()) { this.m_IsCurrentDeckTraversal = (~this.m_Model.Workspace.CurrentDeckTraversal == this.m_DeckTraversal); } if (old != this.m_IsCurrentDeckTraversal) { // Invalidate the display to draw the new selection border. this.UpdateSelection(); } }); }
private static bool TestEntry(TableOfContentsModel.Entry entry) { return entry.Slide != null; }
protected void SetNext(TableOfContentsModel.Entry value) { this.SetPublishedProperty("Next", ref this.m_Next, value); }
protected void SetPrevious(TableOfContentsModel.Entry value) { this.SetPublishedProperty("Previous", ref this.m_Previous, value); }
/// <summary> /// Finds the next entry, in pre-order relative to the specified entry, which is accepted by the entry filter. /// </summary> /// <remarks> /// The caller is required to hold a reader lock on the entry's <see cref="TableOfContentsModel"/>. /// </remarks> public TableOfContentsModel.Entry FindNext(TableOfContentsModel.Entry entry) { if (entry == null) return null; using (Synchronizer.Lock(entry.SyncRoot)) { // Pre-order traversal: we've already visited the "current" entry, so visit it's children next. if (entry.Children.Count > 0) { TableOfContentsModel.Entry child = entry.Children[0]; if (this.m_Filter(child)) { return child; } else { return this.FindNext(child); } } // If there are no children, look for a next sibling, parent's sibling, etc. else { TableOfContentsModel.Entry parent = entry.Parent; TableOfContentsModel.EntryCollection siblings = (parent == null) ? entry.TableOfContents.Entries : parent.Children; while (siblings != null) { int index = siblings.IndexOf(entry); // Use the entry's sibling within the parent, if possible. if (index >= 0 && index < siblings.Count - 1) { TableOfContentsModel.Entry sibling = siblings[index + 1]; if (this.m_Filter(sibling)) { return sibling; } else { return this.FindNext(sibling); } } // If there is no sibling in the parent, go up another level. // Do not consider parent nodes in the pre-order traversal. else { entry = parent; parent = (entry == null) ? null : entry.Parent; siblings = (parent == null) ? null : parent.Children; } } // If we get here, then we've run out of parents and there is no next entry! return null; } } }
/// <summary> /// Finds the next entry, relative to the specified entry, which is accepted by the entry filter. /// </summary> /// <remarks> /// The caller is required to hold a reader lock on the entry's <see cref="TableOfContentsModel"/>. /// </remarks> public TableOfContentsModel.Entry FindPrevious(TableOfContentsModel.Entry entry) { if (entry == null) return null; // Pre-order traversal: we start with the last descendent of the entry's previous sibling. using (Synchronizer.Lock(entry.SyncRoot)) { TableOfContentsModel.Entry parent = entry.Parent; TableOfContentsModel.EntryCollection siblings = (parent == null) ? entry.TableOfContents.Entries : parent.Children; int index = siblings.IndexOf(entry); // If there exists a previous sibling, we're in good shape. // (This also handles the case when the given entry is not a child of its parent, // which can happen when entries are received over the network in a strange order.) if (index > 0) { entry = siblings[index - 1]; // Find the *last* descendent of the sibling by going down as far as possible. siblings = entry.Children; while (siblings.Count > 0) { entry = siblings[siblings.Count - 1]; siblings = entry.Children; } // Now, we've either got the original sibling or the last descendent of it. // Use this as the previous entry, or start here if it's not accepted by the filter. if (this.m_Filter(entry)) { return entry; } else { return this.FindPrevious(entry); } } // If there's no previous sibling and no parent, we're screwed. else if (parent == null) { return null; } // Otherwise, if there's no previous sibling, use the parent. else { if (this.m_Filter(parent)) { return parent; } else { return this.FindPrevious(parent); } } } }
/// <summary> /// Construct the matching between two entries /// </summary> /// <param name="srcEntry">The source entry</param> /// <param name="dstEntry">The destination entry</param> public TableOfContentsEntryMatch( TableOfContentsModel.Entry srcEntry, TableOfContentsModel.Entry dstEntry ) { this.m_SourceEntry = srcEntry; this.m_DestEntry = dstEntry; }
private void SendEntryAdded(TableOfContentsModel.Entry entry, Group receivers) { Message message, deck, slide; message = new PresentationInformationMessage(this.m_Service.m_Presentation); message.Group = receivers; message.InsertChild(deck = new DeckInformationMessage(this.m_Service.m_Deck)); deck.InsertChild(slide = new SlideInformationMessage(entry.Slide)); slide.InsertChild(new TableOfContentsEntryMessage(entry)); this.m_Service.m_Sender.Send(message); }
// NOTE: Eventually this code should be converted to use SlideRenderer instead of each SheetRenderer. There were some issues with doing // this initially so for the time being we will keep it like this. public static Bitmap DrawSlide(TableOfContentsModel.Entry currentEntry, BackgroundTemplate template, System.Drawing.Color background, SheetDisposition dispositions, int width, int height, float scale ) { // Save the old state System.Drawing.Drawing2D.GraphicsState oldState; using (Synchronizer.Lock(currentEntry.Slide.SyncRoot)) { Rectangle rect; int boundsWidth = currentEntry.Slide.Bounds.Width; int boundsHeight = currentEntry.Slide.Bounds.Height; int exportWidth = width; int exportHeight = height; if (width > 0 && height > 0) { // Do Nothing } else if (width > 0) { exportHeight = (int)Math.Round( ( (float)width / (float)boundsWidth ) * (float)boundsHeight ); } else if (height > 0) { exportWidth = (int)Math.Round( ( (float)height / (float)boundsHeight ) * (float)boundsWidth ); } else { exportWidth = boundsWidth; exportHeight = boundsHeight; } // Scale the size exportWidth = (int)Math.Round( exportWidth * scale ); exportHeight = (int)Math.Round( exportHeight * scale ); rect = new Rectangle(0, 0, exportWidth, exportHeight); //Note: Uses DibGraphicsBuffer from TPC SDK to do antialiasing //See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dntablet/html/tbconprintingink.asp /// create the bitmap we're exporting to Bitmap toExport = new Bitmap(rect.Width, rect.Height); /// create what we will be drawing on to the export Graphics toSave = Graphics.FromImage(toExport); /// draw the slide data on a temporary graphics object in a temporary form System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form(); Graphics screenGraphics = tempForm.CreateGraphics(); DibGraphicsBuffer dib = new DibGraphicsBuffer(); Graphics tempGraphics = dib.RequestBuffer(screenGraphics, rect.Width, rect.Height); //Add the background color //First see if there is a Slide BG, if not, try the Deck. Otherwise, use transparent. tempGraphics.Clear(background); //Add the background template if (template != null) { using (BackgroundTemplateRenderer bkgRender = new BackgroundTemplateRenderer(template)) { bkgRender.DrawAll(tempGraphics, rect); } } //Get the Slide content and draw it oldState = tempGraphics.Save(); Model.Presentation.SlideModel.SheetCollection sheets = currentEntry.Slide.ContentSheets; for (int i = 0; i < sheets.Count; i++) { Model.Viewer.SlideDisplayModel display = new Model.Viewer.SlideDisplayModel(tempGraphics, null); Rectangle slide = rect; float zoom = 1f; if (currentEntry.Slide != null) { slide = currentEntry.Slide.Bounds; zoom = currentEntry.Slide.Zoom; } System.Drawing.Drawing2D.Matrix pixel, ink; display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink); using (Synchronizer.Lock(display.SyncRoot)) { display.SheetDisposition = dispositions; display.Bounds = slide; display.PixelTransform = pixel; display.InkTransform = ink; } Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet(display, sheets[i]); if ((r.Sheet.Disposition & dispositions) != 0) r.Paint(new System.Windows.Forms.PaintEventArgs(tempGraphics, rect)); r.Dispose(); } //Restore the Old State tempGraphics.Restore(oldState); oldState = tempGraphics.Save(); //Get the Annotation content and draw it sheets = currentEntry.Slide.AnnotationSheets; for (int i = 0; i < sheets.Count; i++) { Model.Viewer.SlideDisplayModel display = new Model.Viewer.SlideDisplayModel(tempGraphics, null); Rectangle slide = rect; float zoom = 1f; if (currentEntry.Slide != null) { slide = currentEntry.Slide.Bounds; zoom = currentEntry.Slide.Zoom; } System.Drawing.Drawing2D.Matrix pixel, ink; display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink); using (Synchronizer.Lock(display.SyncRoot)) { display.SheetDisposition = dispositions; display.Bounds = slide; display.PixelTransform = pixel; display.InkTransform = ink; } Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet(display, sheets[i]); if ((r.Sheet.Disposition & dispositions) != 0) r.Paint(new System.Windows.Forms.PaintEventArgs(tempGraphics, rect)); r.Dispose(); } //Restore the Old State tempGraphics.Restore(oldState); //Export the image //Merge the graphics dib.PaintBuffer(toSave, 0, 0); //Dispose all the graphics toSave.Dispose(); screenGraphics.Dispose(); tempGraphics.Dispose(); return toExport; } }
// NOTE: Eventually this code should be converted to use SlideRenderer instead of each SheetRenderer. There were some issues with doing // this initially so for the time being we will keep it like this. public static Bitmap DrawSlide(TableOfContentsModel.Entry currentEntry, BackgroundTemplate template, System.Drawing.Color background, SheetDisposition dispositions) { return PPTDeckIO.DrawSlide(currentEntry, template, background, dispositions, 0, 0, 1.0f); }
public TableOfContentsEntryRemovedMessage(TableOfContentsModel.Entry entry) : base(entry.Id) { }
public SlideMenuItem(TableOfContentsModel.Entry entry, DeckTraversalModel traversal, int slideCount) { this.Entry = entry; this.Traversal = traversal; using (Synchronizer.Lock(this.Entry.Slide.SyncRoot)) { //Set a 50 char limit on the title string toDisplay = this.Entry.Slide.Title; if (toDisplay.Length > 50) { toDisplay = toDisplay.Substring(0, 50) + "..."; } this.Text = "" + slideCount + ". " + toDisplay; } using (Synchronizer.Lock(this.Traversal)) { this.Traversal.Changed["Current"].Add(new Model.PropertyEventHandler(this.OnUpdate)); } this.OnUpdate(this, null); }
/// <summary> /// Constructor /// </summary> /// <param name="i">The index of this entry</param> /// <param name="e">The entry this control represents</param> /// <param name="deckColor">The background color for the deck /// containing this entry</param> /// <param name="location">The location for this control</param> /// <param name="size">The size of this control</param> public SSOrganizerEntry(int i, TableOfContentsModel.Entry e, Color deckColor, PointF location, SizeF size) { this.entry = e; this.location = location; this.size = size; this.SuspendLayout(); // Create the background image this.cachedImage = this.CacheSlideImage(deckColor); this.BackgroundImage = this.cachedImage; this.BackgroundImageLayout = ImageLayout.Stretch; this.BackColor = Color.White; this.BorderStyle = BorderStyle.FixedSingle; this.ClientSize = new Size(200, 150); this.Location = new Point(i * this.Size.Width, 0); this.Anchor = AnchorStyles.Left | AnchorStyles.Top; this.ResumeLayout(); }
public PublicSlideMenuItem(DeckModel deck, TableOfContentsModel.EntryCollection bucket, DeckTraversalModel traversal, PresenterModel model) : base(Strings.CopyToPublic) { this.m_Deck = deck; this.m_WhereTheEntriesGo = bucket; this.traversal_ = traversal; this.m_Model = model; if ((deck.Disposition & DeckDisposition.StudentSubmission) == 0) // Only enable for student submissions this.Enabled = false; }
public InsertSlideMenuItem(DeckModel deck, TableOfContentsModel.EntryCollection bucket, DeckTraversalModel traversal, PresenterModel model) : base(Strings.NewSlide) { this.m_Deck = deck; this.m_WhereTheEntriesGo = bucket; this.traversal_ = traversal; this.m_Model = model; // TODO: Disable this menu item if the deck is immutable (requires defining what sorts of decks are mutable or not). }