コード例 #1
0
        private bool ProcessTrackMessage(TrackMousePositionMessage trackMessage)
        {
            this.Location = trackMessage.Location;

            if (HasMoved(this.Location))
            {
                _contextMenuEnabled = false;
            }

            if (this.CaptureHandler != null)
            {
                if (ConstrainToTile(this.CaptureHandler) && !this.TileClientRectangle.Contains(this.Location))
                {
                    SetCursorToken(null);
                    return(true);
                }

                if (this.CaptureHandler.Track(this))
                {
                    SetCursorToken();
                    return(true);
                }
            }

            if (!_tile.Enabled)
            {
                return(true);
            }

            IMouseButtonHandler handler = FindHandlingGraphic(TrackHandler);

            SetCursorToken(handler);
            return(handler != null);
        }
コード例 #2
0
            public bool Track(IMouseInformation mouseInformation)
            {
                bool result = false;

                if (_capturedHandler != null)
                {
                    return(_capturedHandler.Track(mouseInformation));
                }

                foreach (IGraphic graphic in EnumerateChildGraphics(true))
                {
                    if (!graphic.Visible)
                    {
                        continue;
                    }

                    IMouseButtonHandler handler = graphic as IMouseButtonHandler;
                    if (handler != null)
                    {
                        result = handler.Track(mouseInformation);
                        if (result)
                        {
                            break;
                        }
                    }
                }

                return(result);
            }
コード例 #3
0
        /// <summary>
        /// Called by the framework when the mouse button is released.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Stop"/> on
        /// the current handler, <see cref="Stop"/>, or any child graphics implementing <see cref="IMouseButtonHandler"/>,
        /// in decreasing order of priority.
        /// </para>
        /// </remarks>
        /// <param name="mouseInformation">The mouse input information.</param>
        /// <returns>True if the framework should <b>not</b> release capture; False otherwise.</returns>
        bool IMouseButtonHandler.Stop(IMouseInformation mouseInformation)
        {
            bool result;

            if (_capturedHandler != null)
            {
                result = _capturedHandler.Stop(mouseInformation);
                if (!result)
                {
                    _capturedHandler = null;
                    return(result);
                }
            }

            try
            {
                result = this.Stop(mouseInformation);
            }
            finally
            {
                _isTracking          = false;
                _lastTrackedPosition = PointF.Empty;
            }

            return(result);
        }
コード例 #4
0
 public void Cancel()
 {
     if (_capturedHandler != null)
     {
         _capturedHandler.Cancel();
         _capturedHandler = null;
     }
 }
コード例 #5
0
        /// <summary>
        /// Called by the framework each time a mouse button is pressed.
        /// </summary>
        /// <remarks>
        /// <para>
        /// As a general rule, if the <see cref="IMouseButtonHandler"/> object did anything as a result of this call, it must
        /// return true.  If false is returned, <see cref="IMouseButtonHandler.Start"/> is called on other <see cref="IMouseButtonHandler"/>s
        /// until one returns true.
        /// </para>
        /// <para>
        /// The <see cref="ControlGraphic"/> implementation finds a handler by trying <see cref="Start"/>,
        /// and any child graphics implementing <see cref="IMouseButtonHandler"/>, in decreasing order of priority.
        /// </para>
        /// </remarks>
        /// <param name="mouseInformation">The mouse input information.</param>
        /// <returns>True if the <see cref="ControlGraphic"/> did something as a result of the call and hence would like to receive capture; False otherwise.</returns>
        bool IMouseButtonHandler.Start(IMouseInformation mouseInformation)
        {
            bool result = false;

            if (_capturedHandler != null)
            {
                result = _capturedHandler.Start(mouseInformation);
                if (result)
                {
                    return(true);
                }
            }

            if (Enabled)
            {
                CoordinateSystem = CoordinateSystem.Destination;
                try
                {
                    if (HitTest(mouseInformation.Location))
                    {
                        _lastTrackedPosition = mouseInformation.Location;
                        _isTracking          = true;
                    }
                    result      = Start(mouseInformation);
                    _isTracking = _isTracking && result;
                }
                finally
                {
                    ResetCoordinateSystem();
                }
            }

            _capturedHandler = null;
            if (!result)
            {
                foreach (IGraphic graphic in EnumerateChildGraphics(true))
                {
                    if (!graphic.Visible)
                    {
                        continue;
                    }

                    IMouseButtonHandler handler = graphic as IMouseButtonHandler;
                    if (handler != null)
                    {
                        result = handler.Start(mouseInformation);
                        if (result)
                        {
                            _capturedHandler = handler;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #6
0
        private void OnCaptureChanging(object sender, ItemEventArgs <IMouseButtonHandler> e)
        {
            if (_currentMouseButtonHandler == e.Item)
            {
                return;
            }

            _currentMouseButtonHandler = e.Item;
            this.Capture = (_currentMouseButtonHandler != null);
        }
コード例 #7
0
        private bool StopHandler(IMouseButtonHandler handler)
        {
            bool handled = handler.Stop(this);

            if (!handled)
            {
                _startCount = 0;
            }

            return(handled);
        }
コード例 #8
0
 private void SetCursorToken(IMouseButtonHandler handler, Point location)
 {
     if (handler is ICursorTokenProvider)
     {
         this.CursorToken = (handler as ICursorTokenProvider).GetCursorToken(location);
     }
     else
     {
         this.CursorToken = null;
     }
 }
コード例 #9
0
        private bool TrackHandler(IMouseButtonHandler handler)
        {
            if (!_tile.Selected && SuppressOnTileActivate(handler))
            {
                return(false);
            }

            if (ConstrainToTile(handler) && !this.TileClientRectangle.Contains(this.Location))
            {
                return(false);
            }

            return(handler.Track(this));
        }
コード例 #10
0
 private bool CanStartNewHandler(IMouseButtonHandler handler)
 {
     if (_clickCount < 2)
     {
         return(true);
     }
     else if (CanStartOnDoubleClick(handler))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #11
0
            public bool Stop(IMouseInformation mouseInformation)
            {
                bool result = false;

                if (_capturedHandler != null)
                {
                    result = _capturedHandler.Stop(mouseInformation);
                    if (!result)
                    {
                        _capturedHandler = null;
                        return(false);
                    }
                }

                return(result);
            }
コード例 #12
0
        /// <summary>
        /// Called by the framework when the mouse has moved.
        /// </summary>
        /// <remarks>
        /// <para>
        /// A button does not necessarily have to be down for this message to be called.  The framework can
        /// call it any time the mouse moves.
        /// </para>
        /// <para>
        /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Track"/> on
        /// the current handler, <see cref="Track"/>, or any child graphics implementing <see cref="IMouseButtonHandler"/>,
        /// in decreasing order of priority.
        /// </para>
        /// </remarks>
        /// <param name="mouseInformation">The mouse input information.</param>
        /// <returns>True if the message was handled; False otherwise.</returns>
        bool IMouseButtonHandler.Track(IMouseInformation mouseInformation)
        {
            bool result = false;

            if (_capturedHandler != null)
            {
                return(_capturedHandler.Track(mouseInformation));
            }

            if (Enabled)
            {
                try
                {
                    result = Track(mouseInformation);
                }
                finally
                {
                    if (_isTracking)
                    {
                        _lastTrackedPosition = mouseInformation.Location;
                    }
                }
            }

            if (!result)
            {
                foreach (IGraphic graphic in EnumerateChildGraphics(true))
                {
                    if (!graphic.Visible)
                    {
                        continue;
                    }

                    IMouseButtonHandler handler = graphic as IMouseButtonHandler;
                    if (handler != null)
                    {
                        result = handler.Track(mouseInformation);
                        if (result)
                        {
                            break;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #13
0
        private void SetCapture(IMouseButtonHandler handler)
        {
            Trace.WriteLine(String.Format("Setting capture: {0}", handler.GetType().FullName));

            this.CaptureHandler = handler;

            if (SuppressContextMenu(this.CaptureHandler))
            {
                _contextMenuEnabled = false;
            }

            SetCursorToken();
            //tools can't have context menus
            if (handler is IGraphic)
            {
                this.ContextMenuProvider = handler as IContextMenuProvider;
            }
        }
コード例 #14
0
        /// <summary>
        /// Called by the framework to let <see cref="IMouseButtonHandler"/> perform any necessary cleanup
        /// when capture is going to be forcibly released.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Cancel"/> on
        /// the current handler or <see cref="Cancel"/> in decreasing order of priority.
        /// </para>
        /// </remarks>
        void IMouseButtonHandler.Cancel()
        {
            if (_capturedHandler != null)
            {
                _capturedHandler.Cancel();
                _capturedHandler = null;
            }

            try
            {
                this.Cancel();
            }
            finally
            {
                _isTracking          = false;
                _lastTrackedPosition = PointF.Empty;
            }
        }
コード例 #15
0
        private bool StartHandler(IMouseButtonHandler handler)
        {
            if (_selectedOnThisClick && SuppressOnTileActivate(handler))
            {
                return(false);
            }

            if (_clickCount > 1 && IgnoreDoubleClicks(handler))
            {
                return(false);
            }

            bool start = handler.Start(this);

            if (start)
            {
                ++_startCount;
            }

            return(start);
        }
コード例 #16
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool ConstrainToTile(IMouseButtonHandler handler)
		{
			return (handler.Behaviour & MouseButtonHandlerBehaviour.ConstrainToTile) == MouseButtonHandlerBehaviour.ConstrainToTile;
		}
コード例 #17
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool CancelStartOnDoubleClick(IMouseButtonHandler handler)
		{
			return (handler.Behaviour & MouseButtonHandlerBehaviour.CancelStartOnDoubleClick) == MouseButtonHandlerBehaviour.CancelStartOnDoubleClick;
		}
コード例 #18
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool SuppressContextMenu(IMouseButtonHandler handler)
		{
			return (handler.Behaviour & MouseButtonHandlerBehaviour.SuppressContextMenu) == MouseButtonHandlerBehaviour.SuppressContextMenu;
		}
コード例 #19
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private bool TrackHandler(IMouseButtonHandler handler)
		{
			if (!_tile.Selected && SuppressOnTileActivate(handler))
				return false;

			if (ConstrainToTile(handler) && !this.TileClientRectangle.Contains(this.Location))
				return false;

			return handler.Track(this);
		}
コード例 #20
0
 private static bool SuppressOnTileActivate(IMouseButtonHandler handler)
 {
     return((handler.Behaviour & MouseButtonHandlerBehaviour.SuppressOnTileActivate) == MouseButtonHandlerBehaviour.SuppressOnTileActivate);
 }
コード例 #21
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private void SetCursorToken(IMouseButtonHandler handler)
		{
			SetCursorToken(handler, Location);
		}
コード例 #22
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private bool CanStartNewHandler(IMouseButtonHandler handler)
		{
			if (_clickCount < 2)
				return true;
			else if (CanStartOnDoubleClick(handler))
				return true;
			else
				return false;
		}
コード例 #23
0
ファイル: TileControl.cs プロジェクト: nhannd/Xian
		private void OnCaptureChanging(object sender, ItemEventArgs<IMouseButtonHandler> e)
		{
			if (_currentMouseButtonHandler == e.Item)
				return;

			_currentMouseButtonHandler = e.Item;
			this.Capture = (_currentMouseButtonHandler != null);
		}
コード例 #24
0
			public bool Start(IMouseInformation mouseInformation)
			{
				bool result = false;

				if (_capturedHandler != null)
				{
					result = _capturedHandler.Start(mouseInformation);
					if (result) return true;
				}

				_capturedHandler = null;
				foreach (IGraphic graphic in EnumerateChildGraphics(true))
				{
					if (!graphic.Visible)
						continue;

					IMouseButtonHandler handler = graphic as IMouseButtonHandler;
					if (handler != null)
					{
						result = handler.Start(mouseInformation);
						if (result)
						{
							_capturedHandler = handler;
							break;
						}
					}
				}

				return result;
			}
コード例 #25
0
 private static bool IgnoreDoubleClicks(IMouseButtonHandler handler)
 {
     return((handler.Behaviour & MouseButtonHandlerBehaviour.IgnoreDoubleClicks) == MouseButtonHandlerBehaviour.IgnoreDoubleClicks);
 }
コード例 #26
0
 private static bool CanStartOnDoubleClick(IMouseButtonHandler handler)
 {
     return(false == CancelStartOnDoubleClick(handler));
 }
コード例 #27
0
 private static bool CancelStartOnDoubleClick(IMouseButtonHandler handler)
 {
     return((handler.Behaviour & MouseButtonHandlerBehaviour.CancelStartOnDoubleClick) == MouseButtonHandlerBehaviour.CancelStartOnDoubleClick);
 }
コード例 #28
0
 private static bool SuppressContextMenu(IMouseButtonHandler handler)
 {
     return((handler.Behaviour & MouseButtonHandlerBehaviour.SuppressContextMenu) == MouseButtonHandlerBehaviour.SuppressContextMenu);
 }
コード例 #29
0
 private static bool ConstrainToTile(IMouseButtonHandler handler)
 {
     return((handler.Behaviour & MouseButtonHandlerBehaviour.ConstrainToTile) == MouseButtonHandlerBehaviour.ConstrainToTile);
 }
コード例 #30
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool SuppressOnTileActivate(IMouseButtonHandler handler)
		{
			return (handler.Behaviour & MouseButtonHandlerBehaviour.SuppressOnTileActivate) == MouseButtonHandlerBehaviour.SuppressOnTileActivate;
		}
コード例 #31
0
			public bool Stop(IMouseInformation mouseInformation)
			{
				bool result = false;

				if (_capturedHandler != null)
				{
					result = _capturedHandler.Stop(mouseInformation);
					if (!result)
					{
						_capturedHandler = null;
						return false;
					}
				}

				return result;
			}
コード例 #32
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private void SetCursorToken(IMouseButtonHandler handler, Point location)
		{
			if (handler is ICursorTokenProvider)
			{
				this.CursorToken = (handler as ICursorTokenProvider).GetCursorToken(location);
			}
			else
			{
				this.CursorToken = null;
			}
		}
コード例 #33
0
			public void Cancel()
			{
				if (_capturedHandler != null)
				{
					_capturedHandler.Cancel();
					_capturedHandler = null;
				}
			}
コード例 #34
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private void SetCapture(IMouseButtonHandler handler)
		{
			Trace.WriteLine(String.Format("Setting capture: {0}", handler.GetType().FullName));

			this.CaptureHandler = handler;

			if (SuppressContextMenu(this.CaptureHandler))
				_contextMenuEnabled = false;

			SetCursorToken();
			//tools can't have context menus
			if (handler is IGraphic)
				this.ContextMenuProvider = handler as IContextMenuProvider;
		}
コード例 #35
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool CanStartOnDoubleClick(IMouseButtonHandler handler)
		{
			return false == CancelStartOnDoubleClick(handler);
		}
コード例 #36
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private bool StartHandler(IMouseButtonHandler handler)
		{
			if (_selectedOnThisClick && SuppressOnTileActivate(handler))
				return false;

			if (_clickCount > 1 && IgnoreDoubleClicks(handler))
				return false;

			bool start = handler.Start(this);
			if (start)
				++_startCount;

			return start;
		}
コード例 #37
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private static bool IgnoreDoubleClicks(IMouseButtonHandler handler)
		{
			return (handler.Behaviour & MouseButtonHandlerBehaviour.IgnoreDoubleClicks) == MouseButtonHandlerBehaviour.IgnoreDoubleClicks;
		}
コード例 #38
0
ファイル: TileController.cs プロジェクト: nhannd/Xian
		private bool StopHandler(IMouseButtonHandler handler)
		{
			bool handled = handler.Stop(this);
			if (!handled)
				_startCount = 0;

			return handled;
		}
コード例 #39
0
 private void SetCursorToken(IMouseButtonHandler handler)
 {
     SetCursorToken(handler, Location);
 }