/// <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;
        }
        /// <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);
        }
        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;
        }
Beispiel #4
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;
        }
 private void HandleStylusChanged(object sender, PropertyEventArgs args)
 {
     using (Synchronizer.Lock(this.m_Model.SyncRoot)) {
         this.Stylus = this.m_Model.Stylus;
     }
 }
 internal StylusData(StylusModel stylus, DrawingAttributes atts)
 {
     this.m_Stylus            = stylus;
     this.m_DrawingAttributes = atts;
 }