示例#1
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MouseButtonMessage(Point location, XMouseButtons mouseButton, ButtonActions buttonAction, uint clickCount, bool control, bool alt, bool shift)
		{
			_location = location;
			_buttonAction = buttonAction;
			_clickCount = clickCount;
			_mouseButtonShortcut = new MouseButtonShortcut(mouseButton, control, alt, shift);
		}
示例#2
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MouseButtonMessage(Point location, XMouseButtons mouseButton, ButtonActions buttonAction, uint clickCount, ModifierFlags modifierFlags)
			: this(location, mouseButton, buttonAction, clickCount, 
						(modifierFlags & ModifierFlags.Control) == ModifierFlags.Control,
						(modifierFlags & ModifierFlags.Alt) == ModifierFlags.Alt,
						(modifierFlags & ModifierFlags.Shift) == ModifierFlags.Shift)
		{
		}
示例#3
0
		private static void UpdateMouseButtonIconSet(IActionSet actions, XMouseButtons mouseButton)
		{
			foreach (IAction action in actions)
			{
				if (action is Action && action.IconSet is MouseButtonIconSet)
					((Action) action).IconSet = new MouseButtonIconSet(action.IconSet, mouseButton);
			}
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		public DefaultMouseToolButtonAttribute(XMouseButtons mouseButton)
		{
			_shortcut = new MouseButtonShortcut(mouseButton);
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		public DefaultMouseToolButtonAttribute(XMouseButtons mouseButton, ModifierFlags modifierFlags)
		{
			_shortcut = new MouseButtonShortcut(mouseButton, modifierFlags);
		}
		private void AssertStringParse(string sButtons, XMouseButtons eButtons, CultureInfo culture, string message)
		{
			XMouseButtons actualEnum = (XMouseButtons) _converter.ConvertFromString(null, culture, sButtons);
			//System.Diagnostics.Trace.WriteLine(actualEnum);
			Assert.AreEqual((int) eButtons, (int) actualEnum, message + ": converting " + sButtons + " which is " + actualEnum.ToString());
		}
示例#7
0
		/// <summary>
		/// Formats a <see cref="XMouseButtons"/> value as a string using the <see cref="CultureInfo.InvariantCulture"/>.
		/// </summary>
		/// <param name="value">The <see cref="XMouseButtons"/> value to be formatted.</param>
		/// <returns>The string representation of the given <paramref name="value"/>.</returns>
		public static string FormatInvariant(XMouseButtons value)
		{
			return Format(value, CultureInfo.InvariantCulture);
		}
示例#8
0
		private void ProcessDelayedContextMenuRequest(object sender, EventArgs e)
		{
            var eventArgs = e as ItemEventArgs<Point>;
			if (eventArgs == null)
				return;

		    if (HasMoved(eventArgs.Item, _currentMousePoint))
                return;
		    
            if (CaptureHandler != null)
		        ReleaseCapture(true);

		    //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
		    _startCount = 0;

		    _contextMenuEnabled = true;
		    EventsHelper.Fire(_contextMenuRequested, this, eventArgs);
		}
		private void AssertEquivalency(string sButtons, XMouseButtons eButtons, CultureInfo culture, string message)
		{
			AssertStringFormat(sButtons, eButtons, culture, message);
			AssertStringParse(sButtons, eButtons, culture, message);
		}
 private IEnumerable<TestTool> GetMouseButtonHandlers(XMouseButtons button)
 {
     return GetMouseButtonHandlers(new MouseButtonShortcut(button)).Cast<TestTool>();
 }
示例#11
0
		private bool ProcessMouseButtonDownMessage(MouseButtonMessage buttonMessage)
		{
			this.CaptureMouseWheelHandler = null;

			//don't allow multiple buttons, it's just cleaner and easier to manage behaviour.
			if (_activeButton != 0)
			{
				_contextMenuEnabled = false;
				return true;
			}

			_activeButton = buttonMessage.Shortcut.MouseButton;
			_clickCount = buttonMessage.ClickCount;

			if (StartCaptureHandler(buttonMessage))
				return true;

			_tile.Select();
			_contextMenuEnabled = (buttonMessage.Shortcut.MouseButton == XMouseButtons.Right);

			_startMousePoint = buttonMessage.Location;

			if (_tile.PresentationImage == null || !_tile.Enabled)
				return true;

			//give unfocused graphics a chance to focus (in the case of going straight from context menu to a graphic).
			FindHandlingGraphic(TrackHandler);

			return StartNewHandler(buttonMessage);
		}
示例#12
0
		/// <summary>
		/// Parses a string as an <see cref="XMouseButtons"/> value using the <see cref="CultureInfo.CurrentUICulture">current thread's UI CultureInfo</see>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="result">The <see cref="XMouseButtons"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="XMouseButtons.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParse(string s, out XMouseButtons result)
		{
			return TryParse(s, CultureInfo.CurrentUICulture, out result);
		}
 private TestTool GetActiveTool(XMouseButtons button)
 {
     return GetActiveTools(button).FirstOrDefault();
 }
示例#14
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="tooltipPrefix">The tooltip prefix, which usually describes the tool's function.</param>
		protected MouseImageViewerTool(string tooltipPrefix)
			: base()
		{
			_tooltipPrefix = tooltipPrefix;
			_mousebuttonBehaviour = MouseButtonHandlerBehaviour.Default;
			_mouseButton = XMouseButtons.None;
			_defaultMouseButtonShortcut = null;
			_mouseWheelShortcut = null;
			_active = false;
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		public ModifiedMouseToolButtonAttribute(XMouseButtons mouseButton, ModifierFlags modifierFlags)
			: base(mouseButton, modifierFlags)
		{
		}
示例#16
0
		private static string GetName(XMouseButtons value, IDictionary<XMouseButtons, string> map)
		{
			if (map.ContainsKey(value))
				return map[value];
			else if (Enum.IsDefined(typeof (XMouseButtons), (int) value))
				return Enum.GetName(typeof (XMouseButtons), (int) value);
			return string.Empty;
		}
示例#17
0
		/// <summary>
		/// Parses a string as an <see cref="XMouseButtons"/> value using the <see cref="CultureInfo.InvariantCulture"/>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="result">The <see cref="XMouseButtons"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="XMouseButtons.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParseInvariant(string s, out XMouseButtons result)
		{
			return TryParse(s, CultureInfo.InvariantCulture, out result);
		}
示例#18
0
		/// <summary>
		/// Parses a string as an <see cref="XMouseButtons"/> value using the specified <see cref="CultureInfo"/>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="culture">The <see cref="CultureInfo"/> for which the string should be parsed.</param>
		/// <param name="result">The <see cref="XMouseButtons"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="XMouseButtons.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParse(string s, CultureInfo culture, out XMouseButtons result)
		{
			try
			{
				result = Parse(s, culture);
				return true;
			}
			catch (FormatException)
			{
				result = XMouseButtons.None;
				return false;
			}
		}
 private IEnumerable<TestTool> GetActiveTools(XMouseButtons button)
 {
     return from tool in GetTools() where tool.Active && tool.MouseButton == button select tool;
 }
示例#20
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MouseButtonMessage(Point location, XMouseButtons mouseButton, ButtonActions buttonAction, uint clickCount)
			: this(location, mouseButton, buttonAction, clickCount, false, false, false)
		{
		}
 private IEnumerable<TestTool> GetMouseButtonHandlers(XMouseButtons button, bool ctrl, bool alt, bool shift)
 {
     return GetMouseButtonHandlers(new MouseButtonShortcut(button, ctrl, alt, shift)).Cast<TestTool>();
 }
示例#22
0
			/// <summary>
			/// Initializes a new instance of <see cref="MouseButtonIconSet"/>.
			/// </summary>
			/// <param name="baseIconSet">A template <see cref="IconSet"/> from which to copy resource names.</param>
			/// <param name="assignedButton">The mouse button that is assigned to the associated tool.</param>
			public MouseButtonIconSet(IconSet baseIconSet, XMouseButtons assignedButton)
				: base(baseIconSet.SmallIcon, baseIconSet.MediumIcon, baseIconSet.LargeIcon)
			{
				_assignedButton = assignedButton;
			}
示例#23
0
		private bool ProcessMouseButtonUpMessage(MouseButtonMessage buttonMessage)
		{
			if (_activeButton != buttonMessage.Shortcut.MouseButton)
				return true;

			_activeButton = 0;
			_clickCount = 0;

			if (this.CaptureHandler != null)
			{
				if (StopHandler(this.CaptureHandler))
				{
					if (_capturedOnThisClick && !HasMoved(buttonMessage.Location) && buttonMessage.Shortcut.MouseButton == XMouseButtons.Right)
						_delayedContextMenuRequestPublisher.Publish(this, new ItemEventArgs<Point>(buttonMessage.Location));

					return true;
				}

                //Trace.WriteLine(String.Format("Release capture {0}", this.CaptureHandler.GetType()));

				ReleaseCapture(false);
				return true;
			}

			return false;
		}
示例#24
0
			public MouseButtonIconSet(IconScheme scheme, string smallIcon, string mediumIcon, string largeIcon, XMouseButtons assignedButton)
				: base(scheme, smallIcon, mediumIcon, largeIcon) {}
示例#25
0
	    private void ProcessExplicitContextMenuRequest(Point? location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
                ReleaseCapture(true);

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
                location = _currentMousePoint;

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType<IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs<Point>(location.Value));

            ContextMenuProvider = null;
        }
示例#26
0
			/// <summary>
			/// Initializes a new instance of <see cref="MouseButtonIconSet"/>.
			/// </summary>
			/// <param name="smallIcon">The resource name of the icon to be used at small resolutions (around 24 x 24).</param>
			/// <param name="mediumIcon">The resource name of the icon to be used at medium resolutions (around 48 x 48).</param>
			/// <param name="largeIcon">The resource name of the icon to be used at large resolutions (around 64 x 64).</param>
			/// <param name="assignedButton">The mouse button that is assigned to the associated tool.</param>
			public MouseButtonIconSet(string smallIcon, string mediumIcon, string largeIcon, XMouseButtons assignedButton)
				: base(smallIcon, mediumIcon, largeIcon)
			{
				_assignedButton = assignedButton;
			}
		private void AssertStringFormat(string sButtons, XMouseButtons eButtons, CultureInfo culture, string message)
		{
			string actualString = _converter.ConvertToString(null, culture, eButtons);
			//System.Diagnostics.Trace.WriteLine(actualString);
			Assert.AreEqual(sButtons, actualString, message + ": converting " + (int) eButtons + " which is " + eButtons.ToString());
		}
示例#28
0
			/// <summary>
			/// Initializes a new instance of <see cref="MouseButtonIconSet"/>.
			/// </summary>
			/// <param name="icon">The resource name of the icon to be used at all resolutions.</param>
			/// <param name="assignedButton">The mouse button that is assigned to the associated tool.</param>
			public MouseButtonIconSet(string icon, XMouseButtons assignedButton)
				: base(icon)
			{
				_assignedButton = assignedButton;
			}
        private MouseImageViewerTool GetActiveMouseTool(XMouseButtons mouseButton)
		{
            return GetMouseTools().FirstOrDefault(t => t.Active && t.MouseButton == mouseButton);
		}
示例#30
0
		/// <summary>
		/// Formats a <see cref="XMouseButtons"/> value as a string using the specified <see cref="CultureInfo"/>.
		/// </summary>
		/// <param name="value">The <see cref="XMouseButtons"/> value to be formatted.</param>
		/// <param name="culture">The <see cref="CultureInfo"/> for which the value should be formatted.</param>
		/// <returns>The string representation of the given <paramref name="value"/>.</returns>
		public static string Format(XMouseButtons value, CultureInfo culture)
		{
			return Default.ConvertToString(null, culture, value);
		}