コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public QuickPollMessage( QuickPollModel poll )
     : base((poll != null) ? poll.Id : Guid.Empty)
 {
     if( poll != null ) {
         this.AddLocalRef( poll );
     }
     this.m_Model = poll;
 }
コード例 #2
0
        private bool m_ForcingStudentNavigationLock; // bool

        #endregion Fields

        #region Constructors

        public InstructorModel(Guid id)
            : base(id)
        {
            this.m_CurrentPresentation = null;
            this.m_CurrentDeckTraversal = null;
            this.m_CurrentQuickPoll = null;
            this.m_AcceptingStudentSubmissions = true;
            this.m_AcceptingQuickPollSubmissions = false;
            this.m_ForcingStudentNavigationLock = false;
        }
コード例 #3
0
        /// <summary>
        /// Constructs a new QuickPollResultNetworkService
        /// </summary>
        /// <param name="sender">The message queue to use</param>
        /// <param name="presentation">The PresentationModel to associate this service with</param>
        /// <param name="poll">The QuickPollModel to associate this service with</param>
        /// <param name="result">The QuickPollResultModel to associate this service with</param>
        public QuickPollResultNetworkService( SendingQueue sender, PresentationModel presentation, QuickPollModel poll, QuickPollResultModel result )
        {
            this.m_Sender = sender;
            this.m_Presentation = presentation;
            this.m_QuickPoll = poll;
            this.m_Result = result;

            // Listen to changes tot he ResultString
            this.m_ResultChangedDispatcher = new EventQueue.PropertyEventDispatcher( this.m_Sender, new PropertyEventHandler( this.HandleResultChanged ) );
            this.m_Result.Changed["ResultString"].Add( this.m_ResultChangedDispatcher.Dispatcher );
        }
コード例 #4
0
 public PresentationModel(Guid id, ParticipantModel owner, string humanName, bool isUntitledPresentation)
 {
     this.m_Id = id;
     this.m_DeckTraversals = new DeckTraversalCollection(this, "DeckTraversals");
     this.m_Participants = new ParticipantCollection(this, "Participants");
     this.m_Owner = owner;
     this.m_HumanName = humanName;
     this.m_QuickPoll = null;
     this.m_IsUntitledPresentation = isUntitledPresentation;
     CurrentPresentation = this;
 }
コード例 #5
0
        /// <summary>
        /// Constructs a new StudentQuickPollNetworkService
        /// </summary>
        /// <param name="sender">The message queue to post messages to</param>
        /// <param name="presentation">The PresentationModel to create this class from</param>
        /// <param name="poll">The QuickPollModel to create this class from</param>
        public StudentQuickPollNetworkService( SendingQueue sender, PresentationModel presentation )
        {
            this.m_Sender = sender;
            this.m_Presentation = presentation;
            using( Synchronizer.Lock( this.m_Presentation.SyncRoot ) ) {
                this.m_QuickPoll = this.m_Presentation.QuickPoll;
            }

            if( this.m_QuickPoll != null ) {
                this.m_QuickPollResultCollectionHelper = new QuickPollResultCollectionHelper( this );
            }
        }
コード例 #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public QuickPollModel( Guid id, QuickPollModel m )
        {
            using( Synchronizer.Lock( m.SyncRoot ) ) {
                this.m_Id = id;
                this.m_OriginalSlideId = m.OriginalSlideId;
                this.m_QuickPollStyle = m.PollStyle;
                this.m_QuickPollResults = new QuickPollResultCollection( this, "QuickPollResults" );
                this.m_Changed = false;
                this.m_Choices = (string[])m.m_Choices.Clone();

                // Update the results
                foreach( QuickPollResultModel res in m.QuickPollResults ) {
                    this.AddResult( res );
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        public QuickPollModel(Guid id, QuickPollModel m)
        {
            using (Synchronizer.Lock(m.SyncRoot)) {
                this.m_Id = id;
                this.m_OriginalSlideId  = m.OriginalSlideId;
                this.m_QuickPollStyle   = m.PollStyle;
                this.m_QuickPollResults = new QuickPollResultCollection(this, "QuickPollResults");
                this.m_Changed          = false;
                this.m_Choices          = (string[])m.m_Choices.Clone();

                // Update the results
                foreach (QuickPollResultModel res in m.QuickPollResults)
                {
                    this.AddResult(res);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets the vote count
        /// </summary>
        /// <returns></returns>
        public Hashtable GetVoteCount()
        {
            // Get the possible strings
            ArrayList strings = QuickPollModel.GetVoteStringsFromStyle(this.m_QuickPollStyle);
            Hashtable counts  = new Hashtable();

            foreach (string s in strings)
            {
                counts.Add(s, 0);
            }

            // Count up the votes
            foreach (QuickPollResultModel m in this.m_QuickPollResults)
            {
                using (Synchronizer.Lock(m.SyncRoot)) {
                    System.Diagnostics.Debug.Assert(counts.ContainsKey(m.ResultString));
                    counts[m.ResultString] = ((int)counts[m.ResultString]) + 1;
                }
            }

            return(counts);
        }
コード例 #9
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 );
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: ToolsMenu.cs プロジェクト: ClassroomPresenter/CP3
            /// <summary>
            /// Constructs this menu item
            /// </summary>
            /// <param name="model">The PresenterModel to operate over</param>
            public PollTypeOptionMenuItem( PresenterModel model, string text, QuickPollModel.QuickPollStyle style )
            {
                localModel = model;
                this.m_Style = style;
                this.Text = text;

                using( Synchronizer.Lock( this.localModel.ViewerState.SyncRoot ) ) {
                    this.localModel.ViewerState.Changed["PollStyle"].Add( new PropertyEventHandler( this.HandleStyleChanged ) );
                }

                // Initialize the state of the menu items.
                this.HandleStyleChanged( this, null );
            }
コード例 #11
0
        /// <summary>
        /// Handle the receipt of this message
        /// </summary>
        /// <param name="context">The context of the receiver from which the message was sent</param>
        protected override bool UpdateTarget( ReceiveContext context )
        {
            QuickPollModel poll = this.Target as QuickPollModel;

            // Update Target and poll
            if( poll == null ) {
                if( this.m_Model == null ) {
                    this.Target = poll = null;
                    return false;
                } else {
                    // Create a new model
                    using( Synchronizer.Lock( this.m_Model.SyncRoot ) ) {
                        this.Target = poll = new QuickPollModel( ((Guid)this.TargetId), this.m_Model );
                    }

                    // Find a parent PresentationModel message
                    PresentationModel presentation = null;
                    Message parent = this.Parent;
                    while( parent != null && presentation == null ) {
                        if( parent.Target is PresentationModel ) {
                            presentation = parent.Target as PresentationModel;
                        } else {
                            parent = parent.Parent;
                        }
                    }
                    if( presentation == null )
                        return false;

                    using( Synchronizer.Lock( presentation.SyncRoot ) ) {
                        if( presentation.QuickPoll == null || !presentation.QuickPoll.Equals( poll ) )
                            presentation.QuickPoll = poll;
                    }
                }
            } else {
                // No properties can get updated
            }

            return true;
        }
コード例 #12
0
 public QuickPollInformationMessage( QuickPollModel poll )
     : base(poll)
 {
 }
コード例 #13
0
 public QuickPollMessage( Message parent, SerializedPacket p )
     : base(parent, p)
 {
     this.m_Model = (!SerializedPacket.IsNullPacket( p.PeekNextPart() )) ?
         new QuickPollModel( p.PeekNextPart() ) : null; p.GetNextPart();
 }
コード例 #14
0
 /// <summary>
 /// Constructs a default quickpollsheetmodel which has been scaled to fit the current transform
 /// </summary>
 /// <param name="id"></param>
 /// <param name="model"></param>
 public QuickPollSheetModel( Guid id, QuickPollModel model )
     : base(id, 0)
 {
     this.m_QuickPoll = model;
 }
コード例 #15
0
 /// <summary>
 /// Constructs a default quickpollsheetmodel which has been scaled to fit the current transform
 /// </summary>
 /// <param name="id"></param>
 /// <param name="model"></param>
 public QuickPollSheetModel(Guid id, QuickPollModel model) : base(id, 0)
 {
     this.m_QuickPoll = model;
 }