Example #1
0
        public static Message RemoteForSheet(SheetModel sheet, SheetCollection collection)
        {
            SheetModel newModel = null;

            if (sheet is ImageSheetModel)
            {
                newModel = sheet;
            }
            else if (sheet is RealTimeInkSheetModel)
            {
                using (Synchronizer.Lock(sheet.SyncRoot)) {
                    newModel = new RealTimeInkSheetModel(sheet.Id, sheet.Disposition | SheetDisposition.Remote, sheet.Bounds);
                    using (Synchronizer.Lock(newModel.SyncRoot))
                        ((RealTimeInkSheetModel)newModel).CurrentDrawingAttributes = ((RealTimeInkSheetModel)sheet).CurrentDrawingAttributes;
                }
            }
            else if (sheet is InkSheetModel)
            {
                newModel = sheet;
            }
            else if (sheet is TextSheetModel)
            {
                newModel = sheet;
            }
            else if (sheet is QuickPollSheetModel)
            {
                newModel = sheet;
            }
            else if (sheet is XPSPageSheetModel)
            {
                newModel = sheet;
            }
            return(SheetMessage.ForSheet(newModel, collection));
        }
        protected Guid SendStudentSubmission()
        {
            Guid newSlideGuid = Guid.Empty;

            UW.ClassroomPresenter.Network.Messages.Message pres, deck, slide, sheet;
            // Add the presentation
            if (this.Presentation == null)
            {
                return(Guid.Empty);
            }
            pres       = new PresentationInformationMessage(this.Presentation);
            pres.Group = Groups.Group.Submissions;

            //Add the current deck model that corresponds to this slide deck at the remote location
            deck       = new DeckInformationMessage(this.Deck);
            deck.Group = Groups.Group.Submissions;
            pres.InsertChild(deck);

            // Add the Slide Message
            newSlideGuid = Guid.NewGuid();
            slide        = new StudentSubmissionSlideInformationMessage(this.Slide, newSlideGuid, Guid.NewGuid());
            slide.Group  = Groups.Group.Submissions;
            deck.InsertChild(slide);

            // Find the correct user ink layer to send
            RealTimeInkSheetModel m_Sheet = null;

            using (Synchronizer.Lock(this.Slide.SyncRoot)) {
                foreach (SheetModel s in this.Slide.AnnotationSheets)
                {
                    if (s is RealTimeInkSheetModel && (s.Disposition & SheetDisposition.Remote) == 0)
                    {
                        m_Sheet = (RealTimeInkSheetModel)s;
                        break;
                    }
                }
            }

            // Find the existing ink on the slide
            Microsoft.Ink.Ink extracted;
            using (Synchronizer.Lock(m_Sheet.Ink.Strokes.SyncRoot)) {
                // Ensure that each stroke has a Guid which will uniquely identify it on the remote side
                foreach (Microsoft.Ink.Stroke stroke in m_Sheet.Ink.Strokes)
                {
                    if (!stroke.ExtendedProperties.DoesPropertyExist(InkSheetMessage.StrokeIdExtendedProperty))
                    {
                        stroke.ExtendedProperties.Add(InkSheetMessage.StrokeIdExtendedProperty, Guid.NewGuid().ToString());
                    }
                }
                // Extract all of the strokes
                extracted = m_Sheet.Ink.ExtractStrokes(m_Sheet.Ink.Strokes, Microsoft.Ink.ExtractFlags.CopyFromOriginal);
            }

            // Find the Realtime ink on the slide
            RealTimeInkSheetModel newSheet = null;

            using (Synchronizer.Lock(m_Sheet.SyncRoot)) {
                newSheet = new RealTimeInkSheetModel(Guid.NewGuid(), m_Sheet.Disposition | SheetDisposition.Remote, m_Sheet.Bounds);
                using (Synchronizer.Lock(newSheet.SyncRoot)) {
                    newSheet.CurrentDrawingAttributes = m_Sheet.CurrentDrawingAttributes;
                }
            }

            // Add the Sheet Message for the existing
            sheet       = new InkSheetStrokesAddedMessage(newSheet, (Guid)slide.TargetId, SheetMessage.SheetCollection.AnnotationSheets, extracted);
            sheet.Group = Groups.Group.Submissions;
            slide.InsertChild(sheet);

            // Add the Sheet Message for the real-time ink
            sheet       = SheetMessage.ForSheet(newSheet, SheetMessage.SheetCollection.AnnotationSheets);
            sheet.Group = Groups.Group.Submissions;
            slide.AddOldestPredecessor(sheet);

            // Send the message
            this.m_Sender.Send(pres);

            return(newSlideGuid);
        }