Exemplo n.º 1
0
 public static RoleNetworkService ForRole(SendingQueue sender, PresenterModel model, RoleModel role)
 {
     if(role is InstructorModel) {
         return new InstructorNetworkService(sender, ((InstructorModel) role));
     } else if(role is StudentModel) {
         return new StudentNetworkService( sender, model, ((StudentModel) role) );
     } else {
         // Either the role type is unsupported, or it is a PublicModel
         // which currently have no published properties which need to be broadcast.
         return null;
     }
 }
        public SubmissionStatusNetworkService(SendingQueue sender, RoleModel role)
        {
            submission_status_model_ = SubmissionStatusModel.GetInstance();

            if (role is StudentModel) {
                submission_status_model_.Role = "student";
                submission_status_model_.Changed["SubmissionStatus"].Add(new PropertyEventHandler(this.StudentSendStatus));
            } else if(role is InstructorModel){
                submission_status_model_.Role = "instructor";
                submission_status_model_.Changed["Id"].Add(new PropertyEventHandler(this.InstructorSendStatus));
            }

            sender_ = sender;
        }
Exemplo n.º 3
0
        public ParticipantModel(Guid guid, RoleModel role, string humanName)
        {
            this.m_Id = guid;
            this.m_Role = role;
            this.m_HumanName = humanName;
            this.m_Groups = new GroupCollection(this, "Groups");
            using( Synchronizer.Lock( this.SyncRoot ) ) {
                // Always add all participants to the AllParticipant group
                this.Groups.Add( Group.AllParticipant );

                // All participants also each belong to their own SingletonGroup.
                this.Groups.Add(new SingletonGroup(this));
            }
            if (PresenterModel.TheInstance != null) {
                PresenterModel.TheInstance.VersionExchange.CreateVersionExchange(this);
            }
        }
Exemplo n.º 4
0
 protected RoleMessage(RoleModel role)
     : base(role.Id)
 {
     this.Target = role;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets the <see cref="Role"/> property to the current
 /// <see cref="ParticipantModel.Role">Role</see> of
 /// the <see cref="ParticipantModel"/> of the associated <see cref="PresenterModel"/>.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method should be called from the <see cref="m_EventQueue"/> or
 /// the control's creator thread.
 /// </para>
 /// </remarks>
 protected void InitializeRole()
 {
     using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot))
     {
         this.Role = this.m_Model.Participant.Role;
         this.Visible = (this.m_Model.Participant.Role is InstructorModel);
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if(this.m_Disposed) return;
     if(disposing) {
         this.m_Participant.Changed["Role"].Remove(this.m_RoleChangedDispatcher.Dispatcher);
         // Dispose of the RoleNetworkService via the Role setter.
         this.Role = null;
     }
     this.m_Disposed = true;
 }
 private void SendRoleChangedMessage(RoleModel role, Group receivers)
 {
     Message message = RoleMessage.ForRole(role);
     message.Group = receivers;
     if(message != null) {
         this.m_Sender.Send(message);
     }
 }
 private void HandleRoleChanged(object sender, PropertyEventArgs args)
 {
     using(Synchronizer.Lock(this.m_Participant.SyncRoot)) {
         this.SendRoleChangedMessage(this.m_Participant.Role, Group.AllParticipant);
         this.Role = this.m_Participant.Role;
     }
 }
Exemplo n.º 9
0
 public InstructorMenuItem(ControlEventQueue dispatcher, PresenterModel model)
 {
     this.m_Model = model;
     this.m_EventQueue = dispatcher;
     this.m_HandleRoleChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.HandleRoleChanged));
     //Save a copy of the role
     this.m_Role = this.m_Model.Participant.Role;
     //Listen to changes in Role
     this.m_Model.Participant.Changed["Role"].Add(this.m_HandleRoleChangedDispatcher.Dispatcher);
 }
Exemplo n.º 10
0
 public RoleNetworkService(SendingQueue sender, RoleModel role)
 {
     this.Sender = sender;
     this.m_Role = role;
 }
        private void SetNetworkAssociationRole(RoleModel role)
        {
            // Remove any old event listeners.
            if (this.m_NetworkAssociationRole != null) {
                this.m_NetworkAssociationRole.Changed["ForcingStudentNavigationLock"].Remove(this.m_ForcingStudentNavigationLockChangedDispatcher.Dispatcher);
            }

            this.m_NetworkAssociationRole = role as InstructorModel;

            // If we're now associated with an instructor, we must obey its ForcingStudentNavigationLock policy.
            // So we register event listeners to watch for changes to that property.
            if (this.m_NetworkAssociationRole != null) {
                this.m_NetworkAssociationRole.Changed["ForcingStudentNavigationLock"].Add(this.m_ForcingStudentNavigationLockChangedDispatcher.Dispatcher);
                this.m_ForcingStudentNavigationLockChangedDispatcher.Dispatcher(this, null);
            }
        }
Exemplo n.º 12
0
 public ParticipantModel(Guid guid, RoleModel role)
     : this(guid, role, null)
 {
 }
 /// <summary>
 /// Release all resources
 /// </summary>
 /// <param name="disposing">True if truely disposing</param>
 protected override void Dispose( bool disposing )
 {
     if( this.m_Disposed ) return;
     try {
         if( disposing ) {
             // Unregister event listeners via the Role setter.
             this.Role = null;
             this.m_Adapter.Dispose();
         }
     } finally {
         base.Dispose( disposing );
     }
     this.m_Disposed = true;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Release all resources
 /// </summary>
 /// <param name="disposing">True if truely disposing</param>
 protected override void Dispose(bool disposing)
 {
     if (this.m_Disposed) return;
     try {
         if (disposing) {
             // Unregister event listeners
             ParticipantModel participant = null;
             using (Synchronizer.Lock(this.m_Model.Workspace.CurrentPresentation.SyncRoot)) {
                 if (this.m_Model.Workspace.CurrentPresentation.Value != null) {
                     using (Synchronizer.Lock(this.m_Model.Workspace.CurrentPresentation.Value.SyncRoot)) {
                         participant = this.m_Model.Workspace.CurrentPresentation.Value.Owner;
                     }
                 }
             }
             if (participant != null) {
                 using (Synchronizer.Lock(participant.SyncRoot)) {
                     ((InstructorModel)(participant.Role)).Changed["AcceptingStudentSubmissions"].Remove(this.m_AcceptingSSubsChangedDispatcher.Dispatcher);
                 }
             }
             this.Role = null;
         }
     }
     finally {
         base.Dispose(disposing);
     }
     this.m_Disposed = true;
 }
Exemplo n.º 15
0
 public static RoleMessage ForRole(RoleModel role)
 {
     if(role is InstructorModel) {
         return new InstructorMessage((InstructorModel) role);
     } else if(role is StudentModel) {
         return new StudentMessage((StudentModel) role);
     } else if(role is PublicModel) {
         return new PublicMessage((PublicModel) role);
     } else {
         return null;
     }
 }
Exemplo n.º 16
0
 protected override void HandleRoleChanged(object sender, PropertyEventArgs e)
 {
     using(Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) {
         if(this.m_Model.Participant.Role is PublicModel) {
             this.Checked = true;
             this.m_LastRole = this.m_Model.Participant.Role;
         } else {
             this.Checked = false;
         }
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Creates a new QuickPoll and the associated slide (and deck)
        /// </summary>
        /// <param name="model">The PresenterModel</param>
        /// <param name="role">The RoleModel</param>
        public static void CreateNewQuickPoll( PresenterModel model, RoleModel role )
        {
            // Create the quickpoll
            QuickPollModel newQuickPoll = null;
            using( Synchronizer.Lock( model.ViewerState.SyncRoot ) ) {
                newQuickPoll = new QuickPollModel( Guid.NewGuid(), Guid.NewGuid(), model.ViewerState.PollStyle );
            }

            // Add a new QuickPoll to the model
            // NOTE: This should trigger a network message about the new QuickPoll
            // NOTE: Need to do this first before adding the sheet otherwise the
            //       public display will not be able to associate the sheet with
            //       this quick poll.
            using( model.Workspace.Lock() ) {
                using( Synchronizer.Lock( (~model.Workspace.CurrentPresentation).SyncRoot ) ) {
                    (~model.Workspace.CurrentPresentation).QuickPoll = newQuickPoll;
                }
            }

            // Add the quickpoll slide to the quickpoll
            using( model.Workspace.Lock() ) {
                using( Synchronizer.Lock( model.Participant.SyncRoot ) ) {
                    DeckTraversalModel qpTraversal = null;
                    DeckModel qpDeck = null;

                    // Find the first quickpoll slidedeck.
                    foreach( DeckTraversalModel candidate in model.Workspace.DeckTraversals ) {
                        if( (candidate.Deck.Disposition & DeckDisposition.QuickPoll) != 0 ) {
                            qpTraversal = candidate;
                            using( Synchronizer.Lock( qpTraversal.SyncRoot ) ) {
                                qpDeck = qpTraversal.Deck;
                            }
                            break;
                        }
                    }

                    // If there is no existing quickpoll deck, create one.
                    if( qpTraversal == null ) {
                        // Change the name of quickpoll according to the number of it
                        string qpName = "QuickPoll";
                        // NOTE: This code is duplicated in DecksMenu.CreateBlankWhiteboardDeckMenuItem.
                        qpDeck = new DeckModel( Guid.NewGuid(), DeckDisposition.QuickPoll, qpName );
                        qpDeck.Group = Network.Groups.Group.Submissions;
                        qpTraversal = new SlideDeckTraversalModel( Guid.NewGuid(), qpDeck );

                        if( model.Workspace.CurrentPresentation.Value != null ) {
                            using( Synchronizer.Lock( (~model.Workspace.CurrentPresentation).SyncRoot ) ) {
                                (~model.Workspace.CurrentPresentation).DeckTraversals.Add( qpTraversal );
                            }
                        } else {
                            model.Workspace.DeckTraversals.Add( qpTraversal );
                        }
                    }

                    // Add the slide
                    // TODO CMPRINCE: Associate the quickpoll with this slide
                    using( Synchronizer.Lock( qpDeck.SyncRoot ) ) {

                        // Get the Current Slide
                        SlideModel oldSlide;
                        using( Synchronizer.Lock( role.SyncRoot ) ) {
                            using( Synchronizer.Lock( ((InstructorModel)role).CurrentDeckTraversal.SyncRoot ) ) {
                                using( Synchronizer.Lock( ((InstructorModel)role).CurrentDeckTraversal.Current.SyncRoot ) ) {
                                    oldSlide = ((InstructorModel)role).CurrentDeckTraversal.Current.Slide;
                                }
                            }
                        }

                        // Copy the values and sheets from the old slide to the new slide
                        using( Synchronizer.Lock( oldSlide.SyncRoot ) ) {
                            // Create the new slide to add
                            SlideModel newSlide = new SlideModel( Guid.NewGuid(), new LocalId(), SlideDisposition.Remote | SlideDisposition.StudentSubmission, DEFAULT_SLIDE_BOUNDS, oldSlide.Id );

                            // Make a list of image content sheets that need to be added to the deck.
                            List<ImageSheetModel> images = new List<ImageSheetModel>();

                            // Update the fields of the slide
                            using( Synchronizer.Lock( newSlide.SyncRoot ) ) {
                                newSlide.Title = oldSlide.Title;
                                newSlide.Bounds = oldSlide.Bounds;
                                newSlide.Zoom = oldSlide.Zoom;
                                newSlide.BackgroundColor = oldSlide.BackgroundColor;
                                newSlide.SubmissionSlideGuid = oldSlide.SubmissionSlideGuid;
                                newSlide.SubmissionStyle = oldSlide.SubmissionStyle;

                                // Copy all of the content sheets.
                                // Because ContentSheets do not change, there is no
                                // need to do a deep copy (special case for ImageSheetModels).
                                foreach( SheetModel s in oldSlide.ContentSheets ) {
                                    newSlide.ContentSheets.Add( s );

                                    // Queue up any image content to be added the deck below.
                                    ImageSheetModel ism = s as ImageSheetModel;
                                    if( ism != null )
                                        images.Add( ism );
                                }

                                // Add the QuickPollSheet
                                newSlide.ContentSheets.Add( new QuickPollSheetModel( Guid.NewGuid(), newQuickPoll ) );

                                // Make a deep copy of all the ink sheets
                                foreach( SheetModel s in oldSlide.AnnotationSheets ) {
                                    SheetModel newSheet = InkSheetModel.InkSheetDeepCopyHelper( s );
                                    newSlide.AnnotationSheets.Add( newSheet );

                                    // Queue up any image content to be added the deck below.
                                    ImageSheetModel ism = s as ImageSheetModel;
                                    if( ism != null )
                                        images.Add( ism );
                                }
                            }

                            // Add the slide content to the deck.
                            foreach( ImageSheetModel ism in images ) {
                                System.Drawing.Image image = ism.Image;
                                if( image == null )
                                    using( Synchronizer.Lock( ism.Deck.SyncRoot ) )
                                    using( Synchronizer.Lock( ism.SyncRoot ) )
                                        image = ism.Deck.GetSlideContent( ism.MD5 );
                                if( image != null )
                                    qpDeck.AddSlideContent( ism.MD5, image );
                            }

                            // Add the slide to the deck.
                            qpDeck.InsertSlide( newSlide );

                            // Add an entry to the deck traversal so that we can navigate to the slide
                            using( Synchronizer.Lock( qpDeck.TableOfContents.SyncRoot ) ) {
                                TableOfContentsModel.Entry e = new TableOfContentsModel.Entry( Guid.NewGuid(), qpDeck.TableOfContents, newSlide );
                                qpDeck.TableOfContents.Entries.Add( e );
                            }
                        }
                    }
                }
            }
        }