Exemple #1
0
        /// <summary>
        /// Performs a deep copy of the given SheetModel and resets the disposition to remote.
        /// This seems to be a little more complicated than it needs to be because the disposition is read only.
        /// If the given sheetmodel is an InkSheet or an editable sheet, it is copied, otherwise, it returns itself.
        /// </summary>
        /// <param name="s">The SheetModel to copy</param>
        /// <returns>A deep copy of an InkSheet or an Editable Sheet,  otherwise,  itself</returns>
        public static SheetModel SheetDeepRemoteCopyHelper(SheetModel s)
        {
            using (Synchronizer.Lock(s.SyncRoot)) {
                SheetModel t = null;
                // Only copy InkSheetModels
                if (s is InkSheetModel || s is EditableSheetModel)
                {
                    if (s is RealTimeInkSheetModel)
                    {
                        // Make a deep copy of the SheetModel
                        t = new RealTimeInkSheetModel(Guid.NewGuid(), s.Disposition | SheetDisposition.Remote, s.Bounds, ((RealTimeInkSheetModel)s).Ink.Clone());
                        using (Synchronizer.Lock(t.SyncRoot)) {
                            ((RealTimeInkSheetModel)t).CurrentDrawingAttributes = ((RealTimeInkSheetModel)s).CurrentDrawingAttributes;
                        }
                    }
                    else if (s is InkSheetModel)
                    {
                        // Make a deep copy of the SheetModel
                        t = new InkSheetModel(Guid.NewGuid(), s.Disposition | SheetDisposition.Remote, s.Bounds, ((InkSheetModel)s).Ink.Clone());
                    }
                    else if (s is EditableSheetModel)
                    {
                        t = (EditableSheetModel)((EditableSheetModel)s).CloneToRemote();
                    }
                    // This is a new object so add it to the local references
                    // TODO CMPRINCE: Make this a callback or something
                    UW.ClassroomPresenter.Network.Messages.Message.AddLocalRef(t.Id, t);
                    return(t);
                }
            }

            return(s);
        }
        public SSInkSheetNetworkService(SendingQueue sender, PresentationModel presentation, DeckModel deck, SlideModel slide, InkSheetModel sheet, SheetMessage.SheetCollection selector)
            : base(sender, presentation, deck, slide, sheet, selector)
        {
            this.m_Sheet = sheet;

            this.m_Sheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
            this.m_Sheet.InkDeleting += new StrokesEventHandler(this.HandleInkDeleting);

            this.SendExistingInk();
        }
        public InkSheetMatch(EventQueue sender, InkSheetModel srcSheet, InkSheetModel dstSheet)
            : base(sender, srcSheet, dstSheet)
        {
            this.m_SourceSheet = srcSheet;
            this.m_DestSheet = dstSheet;

            this.m_SourceSheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
            this.m_SourceSheet.InkDeleting += new StrokesEventHandler(this.HandleInkDeleting);

            this.SendExistingInk();
        }
        public InkSheetRenderer(SlideDisplayModel display, InkSheetModel sheet)
            : base(display, sheet)
        {
            this.m_Sheet = sheet;

            this.m_Renderer = new Renderer();

            this.m_Sheet.Changed["Selection"].Add(new PropertyEventHandler(this.HandleSelectionChanged));
            this.m_Sheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
            this.m_Sheet.InkDeleted += new StrokesEventHandler(this.HandleInkDeleted);

            this.SlideDisplay.Changed["InkTransform"].Add(new PropertyEventHandler(this.HandleInkTransformChanged));
            this.HandleInkTransformChanged(this.SlideDisplay, null);
        }
        /// <summary>
        /// Construct the InkSheetWebService, this class listens for strokes to finish 
        /// and sends them across the network
        /// </summary>
        /// <param name="sender">The queue to use</param>
        /// <param name="presentation">The presentation model</param>
        /// <param name="deck">The deck model</param>
        /// <param name="slide">The slide model</param>
        /// <param name="sheet">The sheet model</param>
        /// <param name="selector">The sheet collection we are part of</param>
        public InkSheetWebService(SendingQueue sender, PresentationModel presentation, DeckModel deck, SlideModel slide, SheetModel sheet, SheetMessage.SheetCollection selector)
            : base(sender, presentation, deck, slide, sheet, selector)
        {
            // Keep track of our sheet
            this.m_Sheet = (InkSheetModel)sheet;

            // Get the slide ID
            using (Synchronizer.Lock(slide.SyncRoot)) {
                m_SlideID = slide.Id;
            }

            // Set Events
            this.m_Sheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
            //            this.m_Sheet.InkDeleting += new StrokesEventHandler(this.HandleInkDeleting);
        }
        public InkSheetUndoService(EventQueue dispatcher, UndoModel undo, DeckModel deck, SlideModel slide, InkSheetModel sheet)
            : base(undo, deck, slide, sheet)
        {
            this.m_EventQueue = dispatcher;
            this.m_InkSheet = sheet;

            this.m_Ignore = new ArrayList();

            //Ignore any sheets with the Remote flag
            if ((this.m_InkSheet.Disposition & SheetDisposition.Remote) == 0) {
                this.m_HandleInkChangedDelegate = new HandleInkChangedDelegate(this.HandleInkChanged);
                this.m_InkSheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
                this.m_InkSheet.InkDeleting += new StrokesEventHandler(this.HandleInkDeleting);
            }
        }
        public InkSheetNetworkService(SendingQueue sender, PresentationModel presentation, DeckModel deck, SlideModel slide, InkSheetModel sheet, SheetMessage.SheetCollection selector)
            : base(sender, presentation, deck, slide, sheet, selector)
        {
            this.m_Sheet = sheet;
            using (Synchronizer.Lock(slide.SyncRoot)) {
                m_SlideID = slide.Id;
            }

            this.m_Sheet.InkAdded += new StrokesEventHandler(this.HandleInkAdded);
            this.m_Sheet.InkDeleting += new StrokesEventHandler(this.HandleInkDeleting);

            Group receivers = Group.AllParticipant;
            if( (deck.Disposition & (DeckDisposition.StudentSubmission | DeckDisposition.QuickPoll)) != 0 ) {
                receivers = Group.Submissions;
            }

            this.SendExistingInk(receivers);
        }
        /// <summary>
        /// Performs a deep copy of the given SheetModel.
        /// If the given sheetmodel is not an InkSheet, then returns itself.
        /// </summary>
        /// <param name="s">The SheetModel to copy</param>
        /// <returns>The given sheetmodel if not an InkSheetModel, otherwise a deep copy of the InkSheetModel</returns>
        protected SheetModel InkSheetDeepCopyHelper( SheetModel s )
        {
            using( Synchronizer.Lock( s.SyncRoot ) ) {
                InkSheetModel t;
                // Only copy InkSheetModels
                if( s is InkSheetModel ) {
                    if( s is RealTimeInkSheetModel ) {
                        // Make a deep copy of the SheetModel
                        t = new RealTimeInkSheetModel( Guid.NewGuid(), s.Disposition | SheetDisposition.Remote, s.Bounds, ((RealTimeInkSheetModel)s).Ink.Clone() );
                        using( Synchronizer.Lock( t.SyncRoot ) ) {
                            ((RealTimeInkSheetModel)t).CurrentDrawingAttributes = ((RealTimeInkSheetModel)s).CurrentDrawingAttributes;
                        }
                    } else {
                        // Make a deep copy of the SheetModel
                        t = new InkSheetModel( Guid.NewGuid(), s.Disposition, s.Bounds, ((InkSheetModel)s).Ink.Clone() );
                    }
                    // This is a new object so add it to the local references
                    Message.AddLocalRef(t.Id, t);
                    return t;
                }
            }

            return s;
        }
Exemple #9
0
            protected override object SetUpMember(int index, object member)
            {
                SheetModel sheet = ((SheetModel) member);

                // Add the SheetMatch to the collection of matches
                using( Synchronizer.Lock( sheet.SyncRoot ) ) {
                    using (Synchronizer.Lock( this.m_Owner.m_DestSlide.SyncRoot ) ) {
                        if( sheet is RealTimeInkSheetModel ) {
                            // Add the sheet
                            RealTimeInkSheetModel m = new RealTimeInkSheetModel( Guid.NewGuid(), sheet.Disposition, sheet.Bounds );
                            this.m_Owner.m_DestSlide.AnnotationSheets.Add( m );

                            // Add the sheet match
                            SheetMatch toAdd = SheetMatch.ForSheet(this.m_Owner.m_Sender, sheet, m );
                            this.m_Owner.m_SheetMatches.Add( toAdd );
                        }
                        else if( sheet is InkSheetModel ) {
                            // Add the sheet
                            InkSheetModel m = new InkSheetModel( Guid.NewGuid(), sheet.Disposition, sheet.Bounds );
                            this.m_Owner.m_DestSlide.AnnotationSheets.Add( m );

                            // Add the sheet match
                            SheetMatch toAdd = SheetMatch.ForSheet(this.m_Owner.m_Sender, sheet, m );
                            this.m_Owner.m_SheetMatches.Add( toAdd );
                        }
                    }
                }

                return null;
            }
 public InkSheetStrokesAddedMessage(InkSheetModel sheet, Guid slideId, SheetCollection selector, Ink ink)
     : base(sheet, selector)
 {
     this.SavedInks = new byte[][] { ink.Save() };
     SlideId = slideId;
 }
 public InkSheetMessage(InkSheetModel sheet, SheetCollection selector)
     : base(sheet, selector)
 {
 }
 public InkSheetStrokesDeletingMessage(InkSheetModel sheet, SheetCollection selector, string[] strokeIds)
     : base(sheet, selector)
 {
     this.StrokeIds = ((string[]) strokeIds.Clone());
 }
        private void LoadInkIntoTarget(InkSheetModel sheet, byte[] saved, out int[] ids)
        {
            Ink restored = new Ink();
            restored.Load(saved);

            using(Synchronizer.Lock(sheet.Ink.Strokes.SyncRoot)) {
                ids = new int[restored.Strokes.Count];

                for(int i = 0; i < ids.Length; i++) {
                    Stroke stroke = restored.Strokes[i];

                    // Remove any strokes that have the same remote Id as the new one.
                    // Unfortunately, because the InkSheetUndoService cannot preserve stroke referential identity,
                    // we must do a full search each time and cannot simply keep a table.
                    if(stroke.ExtendedProperties.DoesPropertyExist(StrokeIdExtendedProperty)) {
                        object id = stroke.ExtendedProperties[StrokeIdExtendedProperty].Data;
                        foreach(Stroke existing in sheet.Ink.Strokes) {
                            if(existing.ExtendedProperties.DoesPropertyExist(StrokeIdExtendedProperty)) {
                                if(id.Equals(existing.ExtendedProperties[StrokeIdExtendedProperty].Data)) {
                                    StrokesEventArgs args = new StrokesEventArgs(new int[] { existing.Id });
                                    sheet.OnInkDeleting(args);
                                    sheet.Ink.DeleteStroke(existing);
                                    sheet.OnInkDeleted(args);
                                }
                            }
                        }
                    }

                    // The stroke has no association with the current Ink object.
                    // Therefore, we have to recreate it by copying the raw packet data.
                    // This first requires recreating the TabletPropertyDescriptionCollection,
                    // which, for some stupid reason, must be done manually for lack of a better API.
                    TabletPropertyDescriptionCollection properties = new TabletPropertyDescriptionCollection();
                    foreach(Guid property in stroke.PacketDescription)
                        properties.Add(new TabletPropertyDescription(property, stroke.GetPacketDescriptionPropertyMetrics(property)));

                    // Create a new stroke from the raw packet data.
                    Stroke created = sheet.Ink.CreateStroke(stroke.GetPacketData(), properties);

                    // Copy the DrawingAttributes and all application data
                    // (especially the StrokesIdExtendedProperty) to the new stroke.
                    created.DrawingAttributes = stroke.DrawingAttributes;
                    foreach(ExtendedProperty prop in stroke.ExtendedProperties)
                        created.ExtendedProperties.Add(prop.Id, prop.Data);

                    ids[i] = created.Id;

                    if (ViewerStateModel.NonStandardDpi)
                        created.Transform(ViewerStateModel.DpiNormalizationReceiveMatrix);

                }
            }
        }
Exemple #14
0
        /// <summary>
        /// Performs a deep copy of the given SheetModel.
        /// If the given sheetmodel is an InkSheet or an editable sheet, it is copied, otherwise, it returns itself. 
        /// </summary>
        /// <param name="s">The SheetModel to copy</param>
        /// <returns>A deep copy of an InkSheet or an Editable Sheet,  otherwise,  itself</returns>
        public static SheetModel SheetDeepCopyHelper(SheetModel s)
        {
            using (Synchronizer.Lock(s.SyncRoot)) {
                SheetModel t = null;
                // Only copy InkSheetModels
                if (s is InkSheetModel || s is EditableSheetModel) {
                    if (s is RealTimeInkSheetModel) {
                        // Make a deep copy of the SheetModel
            //                        t = new RealTimeInkSheetModel(Guid.NewGuid(), SheetDisposition.All, s.Bounds, ((RealTimeInkSheetModel)s).Ink.Clone());
                        t = new RealTimeInkSheetModel(Guid.NewGuid(), s.Disposition, s.Bounds, ((RealTimeInkSheetModel)s).Ink.Clone());
                        using (Synchronizer.Lock(t.SyncRoot)) {
                            ((RealTimeInkSheetModel)t).CurrentDrawingAttributes = ((RealTimeInkSheetModel)s).CurrentDrawingAttributes;
                        }
                    }
                    else if (s is InkSheetModel) {
                        // Make a deep copy of the SheetModel
                        t = new InkSheetModel(Guid.NewGuid(), s.Disposition, s.Bounds, ((InkSheetModel)s).Ink.Clone());
                    }
                    else if (s is EditableSheetModel) {
                        t = (EditableSheetModel)((EditableSheetModel)s).Clone();
                    }
                    // This is a new object so add it to the local references
                    // TODO CMPRINCE: Make this a callback or something
                    UW.ClassroomPresenter.Network.Messages.Message.AddLocalRef(t.Id, t);
                    return t;
                }
            }

            return s;
        }