public StylusEntry(DrawingAttributes atts, StylusModel stylus, string toolTipText, PenType pt)
        {
            if (atts == null)
                throw new ArgumentNullException("atts");
            if (stylus == null)
                throw new ArgumentNullException("stylus");

            this.DrawingAttributes = atts;
            this.Stylus = stylus;
            this.ToolTipText = toolTipText;
            this.PenType = pt;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dispatcher">The event queue</param>
        /// <param name="stylus">The stylus model</param>
        /// <param name="model">The presenter model</param>
        public StylusToolBarButton(ControlEventQueue dispatcher, StylusModel stylus, PresenterModel model)
        {
            this.m_EventQueue = dispatcher;
            this.m_Stylus = stylus;
            this.m_Model = model;

            this.m_StylusChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.m_EventQueue, new PropertyEventHandler(this.HandleStylusChanged));
            this.m_Model.Changed["Stylus"].Add(this.m_StylusChangedDispatcher.Dispatcher);

            // Initialize the Pushed state.
            this.m_StylusChangedDispatcher.Dispatcher(null, null);
        }
Esempio n. 3
0
 public PresenterModel()
 {
     this.m_Stylus = null;
     this.m_CurrentResult = null;
     this.m_Network = new NetworkModel();
     this.m_VersionExchange = new VersionExchangeModel();
     /// Note: We currently assume that the ParticipantModel Guid will be different for each application invocation.
     /// (In particular TCP reconnection relies on this assumption.)  If we need an identifer that persists across
     /// sessions, we'd need to create a new identifier for this.
     ParticipantId = Guid.NewGuid();
     this.m_Participant = new ParticipantModel(ParticipantId, System.Windows.Forms.SystemInformation.UserName);
     this.m_Workspace = new WorkspaceModel();
     this.m_Undo = new UndoModel();
     this.m_ViewerState = new ViewerStateModel();
     this.m_PenState = new PenStateModel();
     TheInstance = this;
 }
        /// <summary>
        /// Handle the stylus changing
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="args">The event arguments</param>
        private void HandleStylusChanged(object sender, PropertyEventArgs args)
        {
            bool enable;
            Color color;

            using(Synchronizer.Lock(this.m_Model.SyncRoot)) {
                if(this.m_Model.Stylus != null && this.m_Table.ContainsKey(this.m_Model.Stylus)) {
                    using( Synchronizer.Lock( this.m_Model.Stylus.SyncRoot ) ) {
                        color = this.m_Model.Stylus.DrawingAttributes.Color;
                    }

                    using (Synchronizer.Lock(this.m_Model.ViewerState.SyncRoot)) {
                        if (this.m_Model.ViewerState.UseLightColorSet) {
                            if (color == Color.Black) {
                                color = Color.White;
                            } else if (color == Color.Red) {
                                color = Color.Pink;
                            } else if (color == Color.Green) {
                                color = Color.LightGreen;
                            } else if (color == Color.Blue) {
                                color = Color.LightBlue;
                            }
                        } else {
                            if (color == Color.White) {
                                color = Color.Black;
                            } else if (color == Color.LightBlue) {
                                color = Color.Blue;
                            } else if (color == Color.Pink) {
                                color = Color.Red;
                            } else if (color == Color.LightGreen) {
                                color = Color.Green;
                            }
                        }
                    }

                    using( Synchronizer.Lock( this.m_Model.Stylus.SyncRoot ) ) {
                        if (color != this.m_Model.Stylus.DrawingAttributes.Color)
                            this.m_Model.Stylus.DrawingAttributes.Color = color;
                    }
                    // In addition to enabling the button, update the current stylus
                    // and DrawingAttributes (possibly causing redrawing the bitmap).
                    this.m_CurrentStylus = this.m_Model.Stylus;
                    this.HandleDrawingAttributesChanged(this.m_Model.Stylus, null);
                    enable = true;
                } else {
                    enable = false;
                }
            }

            this.Enabled = enable;
        }
        /// <summary>
        /// Handle the stylus changing
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="args">The event args</param>
        private void HandleStylusChanged( object sender, PropertyEventArgs args )
        {
            bool enable;

            using( Synchronizer.Lock( this.m_Model.SyncRoot ) ) {
                if( this.m_Model.Stylus != null && this.m_Table.ContainsKey( this.m_Model.Stylus ) ) {
                    // In addition to enabling the button, update the current stylus
                    // and DrawingAttributes (possibly causing redrawing the bitmap).
                    if (m_Model.Stylus is PenStylusModel) {
                        this.m_CurrentStylus = (PenStylusModel)this.m_Model.Stylus;
                    } else {
                        this.m_CurrentStylus = (TextStylusModel)this.m_Model.Stylus;
                    }
                    this.HandleDrawingAttributesChanged( this.m_Model.Stylus, null );
                    enable = true;
                } else {
                    enable = false;
                }
            }

            this.Enabled = enable;
        }
Esempio n. 6
0
        /// <summary>
        /// Updates the current stylus, registers and unregisters event listeners, and 
        /// creates the edit textboxes when the current stylus is a TextStylusModel.
        /// </summary>
        private void SetCurrentStylus(StylusModel stylus)
        {
            // Unregister any existing event listeners.
            if (current_stylus_ != null)
                current_stylus_.Changed["DrawingAttributes"].Remove(stylus_color_listener_.Dispatcher);
            current_stylus_ = stylus;
            if( current_stylus_ != null && stylus_color_listener_ != null )
                current_stylus_.Changed["DrawingAttributes"].Add( stylus_color_listener_.Dispatcher );

            ///only change text settings if our page can be edited.
            ///and if we actually have a slide :P
            ///
            if (!editable_page_ || this.Slide == null) {
                return;
            }
            if (current_text_helper_ != null) {
                current_text_helper_.Dispose();
            }
            if (current_image_helper_ != null) {
                current_image_helper_.Dispose();
            }

            // Change UI if we are dealing with Images (change cursor, add collection helper
            if (stylus is ImageStylusModel) {
                this.Cursor = Cursors.Default;
                current_image_helper_ = new ImageItCollectionHelper(this, this.Slide);
            } else if (stylus is EraserStylusModel) {
                // Use an eraser cursor when the eraser is selected.
                this.Cursor = Cursors.Cross;
            } else {
                this.Cursor = Cursors.Default;
            }

            // Change UI if we are going to be adding text.
            if (stylus is TextStylusModel) {
                ///we are in text editing mode, so we need to change the stylus and editing mode
                editing_text_ = true;
                this.Cursor = Cursors.IBeam;

                //Remove the sheets that just represent empty text boxes.
                for (int i = Slide.AnnotationSheets.Count - 1; i >= 0; i--) {
                    bool remove = false;
                    SheetModel s = Slide.AnnotationSheets[i];
                    using (Synchronizer.Lock(s.SyncRoot)) {
                        if (s is TextSheetModel) {
                            using (Synchronizer.Lock(((TextSheetModel)(s)).Text)) {
                                if (((TextSheetModel)(s)).Text == "") {
                                    remove = true;
                                }
                            }
                        }
                    }

                    if (remove) {
                        using (Synchronizer.Lock(Slide.SyncRoot)) {
                            using (Synchronizer.Lock(Slide.AnnotationSheets)) {
                                Slide.AnnotationSheets.Remove(s);
                            }
                        }
                    }
                }
                current_text_helper_ = new TextItBoxCollectionHelper(this, this.Slide);
                TextStylusModel.GetInstance().Changed["Font"].Add(this.HandleStylusFontChanged);
            } else {
                editing_text_ = false;
            }
        }
 internal StylusData(StylusModel stylus, DrawingAttributes atts)
 {
     this.m_Stylus = stylus;
     this.m_DrawingAttributes = atts;
 }
 private void HandleStylusChanged(object sender, PropertyEventArgs args)
 {
     using(Synchronizer.Lock(this.m_Model.SyncRoot)) {
         this.Stylus = this.m_Model.Stylus;
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if(this.m_Disposed) return;
     if(disposing) {
         this.m_Model.Changed["Stylus"].Remove(new PropertyEventHandler(this.HandleStylusChanged));
         // Unregister the stylus event listeners via the Stylus setter.
         this.Stylus = null;
     }
     this.m_Disposed = true;
 }