public DeckSlideContentMessage(DeckModel deck, ByteArray hash)
            : base(hash)
        {
            using(Synchronizer.Lock(deck.SyncRoot)) {
                Image image = deck.GetSlideContent(hash);

                if(image == null)
                    throw new ArgumentException("The specified ByteArray does not map to slide content in the specified deck.", "hash");

                this.Target = this.Content = new ImageHashtable.ImageHashTableItem(hash, image);
                this.AddLocalRef( this.Target );
            }
        }
Пример #2
0
        private void insertSlidesHelper(DeckModel deckToInsert)
        {
            if (deckToInsert == null)
                return;

            //Now insert the deck after the current location
            //Do this in from the back forward so that we use the same index to insert
            //Start locking everything
            using (Synchronizer.Lock(this.traversal.SyncRoot)) {
                using (Synchronizer.Lock(this.deck.SyncRoot)) {
                    using (Synchronizer.Lock(this.traversal.Current.SyncRoot)) {
                        using (Synchronizer.Lock(deckToInsert.SyncRoot)) {
                            int[] path = this.traversal.Current.PathFromRoot;
                            int insertIndex = 0;
                            if (this.insertBefore) {
                                insertIndex = 0;
                            } else {
                                insertIndex = 1;
                            }
                            if (path.Length == 0) {
                                //This is already at the root
                                insertIndex += this.deck.TableOfContents.Entries.IndexOf(this.traversal.Current);
                            } else {
                                insertIndex += path[0];
                            }

                            //Iterate through each slide
                            for (int i = deckToInsert.TableOfContents.Entries.Count - 1; i >= 0; i--) {
                                Model.Presentation.TableOfContentsModel.Entry currentEntry = deckToInsert.TableOfContents.Entries[i];
                                SlideModel currentSlide = currentEntry.Slide;
                                using (Synchronizer.Lock(currentSlide.SyncRoot)) {
                                    //Copy the annotation and content sheets to the new deck
                                    foreach (SheetModel sm in currentSlide.ContentSheets) {
                                        if (sm is Model.Presentation.ImageSheetModel) {
                                            //Grab the MD5 and image from HT
                                            Image temp = deckToInsert.GetSlideContent(((ImageSheetModel)sm).MD5);
                                            this.deck.AddSlideContent(((ImageSheetModel)sm).MD5, temp);
                                        }
                                    }
                                    foreach (SheetModel sm in currentSlide.AnnotationSheets) {
                                        if (sm is Model.Presentation.ImageSheetModel) {
                                            //Grab the MD5 and image from HT
                                            Image temp = deckToInsert.GetSlideContent(((ImageSheetModel)sm).MD5);
                                            this.deck.AddSlideContent(((ImageSheetModel)sm).MD5, temp);
                                        }
                                    }

                                    //Add slide to deck
                                    this.deck.InsertSlide(currentSlide);
                                    //Create a new entry
                                    Model.Presentation.TableOfContentsModel.Entry newEntry = new UW.ClassroomPresenter.Model.Presentation.TableOfContentsModel.Entry(Guid.NewGuid(), this.deck.TableOfContents, currentSlide);
                                    //Add entry to TOC
                                    this.deck.TableOfContents.Entries.Insert(insertIndex, newEntry);
                                    //If this is the last slide we add, then this is the first slide of the set
                                    //Navigate to it
                                    if (i == 0) {
                                        this.traversal.Current = newEntry;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Cursor.Current = Cursors.Default;
            this.BeginInvoke(new MethodInvoker(this.updateSlideMenu));
            this.isDirty = true;
        }