示例#1
0
 public GameButton(MouseButtons mouseCode)
 {
     this.keyCode = Keys.None;
     this.mouseCode = mouseCode;
     this.buttonCode = Buttons.None;
     this.inputType = InputType.MouseButton;
 }
 public override void MouseUp(IPosition p, MouseButtons b)
 {
     if (b == MouseButtons.Left)
     {
         RectFinish();
     }
 }
示例#3
0
 protected internal override void OnMouseUp(int X, int Y, MouseButtons mb)
 {
     if (mb == MouseButtons.Right)
     {
         Gumps.Destroy(this);
     }
 }
示例#4
0
 public GameButton(Buttons buttonCode)
 {
     this.keyCode = Keys.None;
     this.mouseCode = MouseButtons.None;
     this.buttonCode = buttonCode;
     this.inputType = InputType.Button;
 }
 public override void MouseMove(IPosition p, MouseButtons b)
 {
     if (b == MouseButtons.Left)
     {
         RectUpdate(p);
     }
 }
示例#6
0
		public AbsoluteMouseEventArgs(MouseButtons button, PointF location, float zoom)
		{
			this.button = button;
			this.x = location.X;
			this.y = location.Y;
			this.zoom = zoom;
		}
示例#7
0
		public AbsoluteMouseEventArgs(MouseEventArgs e, Point offset, float zoom)
		{
			this.button = e.Button;
			this.x = (e.X + offset.X) / zoom;
			this.y = (e.Y + offset.Y) / zoom;
			this.zoom = zoom;
		}
示例#8
0
        public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {

            GraphicsPath gpSeekPosition = new GraphicsPath();
            gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
            gpSeekPosition.Widen(this.m_pOneWidth);
            this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));

            if (this.m_isMouseDown == true) {

                if (pntMouseLocation.X < pntDrawOffset.X) {
                    this.SeekerPosition = 0.0F;
                }
                else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
                    this.SeekerPosition = 1.0F;
                }
                else {
                    this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
                }
            }

            float xBeginningOffset = pntDrawOffset.X;

            pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);

            this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            gpSeekPosition.Dispose();
        }
示例#9
0
		public AbsoluteMouseEventArgs(MouseButtons button, float x, float y, float zoom)
		{
			this.button = button;
			this.x = x;
			this.y = y;
			this.zoom = zoom;
		}
示例#10
0
 public void ButtonClick(MouseButtons Button)
 {
     //Check if it is a html link
     if(m_oAppDir[0] == (char)0x7F)
     {
         System.Diagnostics.Process.Start(m_oAppDir.Remove(0, 1));
     }
     else
     {
         try
         {
             if(Button == System.Windows.Forms.MouseButtons.Left)
             {
                 //This needs to be in a try catch in case the user cancels the process starting
                 System.Diagnostics.Process.Start(m_oAppDir + m_oAppName);
             }
             else if(Button == System.Windows.Forms.MouseButtons.Right)
             {
                 System.Diagnostics.Process.Start("explorer.exe", "/select, \"" + m_oAppDir + m_oAppName + "\"");
             }
         }
         catch
         {
         }
     }
 }
示例#11
0
		public override void HandleMouseDown(Point mousePos, MouseButtons mouseButtons)
		{
			int clickedVisibleLine = (mousePos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight;
			int lineNumber = textArea.Document.GetFirstLogicalLine(clickedVisibleLine);
			
			if ((mouseButtons & MouseButtons.Right) == MouseButtons.Right) {
				if (textArea.Caret.Line != lineNumber) {
					textArea.Caret.Line = lineNumber;
				}
			}
			
			IList<Bookmark> marks = textArea.Document.BookmarkManager.Marks;
			List<Bookmark> marksInLine = new List<Bookmark>();
			int oldCount = marks.Count;
			foreach (Bookmark mark in marks) {
				if (mark.LineNumber == lineNumber) {
					marksInLine.Add(mark);
				}
			}
			for (int i = marksInLine.Count - 1; i >= 0; i--) {
				Bookmark mark = marksInLine[i];
				if (mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0))) {
					if (oldCount != marks.Count) {
						textArea.UpdateLine(lineNumber);
					}
					return;
				}
			}
			base.HandleMouseDown(mousePos, mouseButtons);
		}
示例#12
0
 /// <summary>Called when a mouse button has been pressed down</summary>
 /// <param name="button">Index of the button that has been pressed</param>
 protected override void OnMousePressed(MouseButtons button) {
   if(this.Enabled) {
     if(button == MouseButtons.Left) {
       this.pressedDownByMouse = true;
     }
   }
 }
示例#13
0
        // TODO:
        //public void SimulateScroll(int x, int y, int screenWidth, int screenHeight, scrollAmount)
        //public void SimulateScroll(scrollAmount)
        // TODO: Simulation which strips the ABSOLUTE factor from the mouse events, making the mouse NOT MOVE, for the click click.
        //public static void SimulateClick(MouseButtons mouseButton, int holdClickTime = 10)
        /// <summary>Simulates a mouse click at the specified location.</summary>
        /// <param name="x">The horizontal pixel coordinate to place the mouse cursor at.</param>
        /// <param name="y">The vertical pixel coordinate to place the mouse cursor at.</param>
        /// <param name="screenWidth">The current screen width (needed to scale the mouse cursor into position).</param>
        /// <param name="screenHeight">The current screen height (needed to scale the mouse cursor into position).</param>
        /// <param name="mouseButton">Which mouse button to simulate a click for.</param>
        /// <param name="holdClickTime">How long to simulate holding the mouse button down, in milliseconds.</param>
        /// <remarks>Basically this is just a pair of simulated mouse "down" and mouse "up" simulations in sequence.</remarks>
        public static void SimulateClick(int x, int y, int screenWidth, int screenHeight, MouseButtons mouseButton, int holdClickTime = 10)
        {
            VirtualMouseAction mouseDownOption, mouseUpOption;
            switch (mouseButton)
            {
                case MouseButtons.Left:
                    mouseDownOption = VirtualMouseAction.LeftButtonDown;
                    mouseUpOption = VirtualMouseAction.LeftButtonUp;
                    break;
                case MouseButtons.Middle:
                    mouseDownOption = VirtualMouseAction.MiddleButtonDown;
                    mouseUpOption = VirtualMouseAction.MiddleButtonUp;
                    break;
                case MouseButtons.Right:
                    mouseDownOption = VirtualMouseAction.RightButtonDown;
                    mouseUpOption = VirtualMouseAction.RightButtonUp;
                    break;
                default:
                    // TODO: Implement and test XButton1 and XButton2 with a fancy mouse.
                    throw new NotSupportedException("The selected mouse button is not yet supported: " + mouseButton.ToString());
            }

            Simulate(x, y, screenWidth, screenHeight, mouseDownOption);
            Thread.Sleep(holdClickTime);
            Simulate(x, y, screenWidth, screenHeight, mouseUpOption);
        }
示例#14
0
文件: BPMMeter.cs 项目: HaKDMoDz/geff
 void mouseLeftButton_MouseFirstPressed(MouseButtons mouseButton, MouseState mouseState, GameTime gameTime)
 {
     if (Rec.Contains(UI.GameEngine.Controller.mousePositionPoint))
     {
         _prevSpeedFactor = Context.Map.SpeedFactor;
     }
 }
		public LinkLabelLinkClickedEventArgs (LinkLabel.Link link)
		{
#if NET_2_0
			this.button = MouseButtons.Left;
#endif
			this.link = link;
		}
示例#16
0
		public override void MouseMove(MouseButtons button, Point location, Keys modifierKeys)
		{
			if (button != MouseButtons.Left)
				return;

			location = Editor.Level.GetVirtualXY(location);

			//Snap
			PointF le_location = location;
			if (Settings.ShowGrid & Settings.SnapToGrid) {
				le_location = new PointF(Editor.SnapToGrid((float)location.X), Editor.SnapToGrid((float)location.Y));
			}

			RectangleF lookRange = new RectangleF(le_location.X - (mWidth / 2), le_location.Y - (mHeight / 2), mWidth, mHeight);

			if ((!Editor.Level.IsObjectIn(lookRange)) || (!mAvoidOverlapping)) {
				Editor.CreateUndoPoint();

				LevelEntry entry = (LevelEntry)mEntry.Clone();
				entry.Level = Editor.Level;
				entry.X = le_location.X;
				entry.Y = le_location.Y;

				Editor.Level.Entries.Add(entry);

				Editor.UpdateRedraw();

				//Have we finished
				if (!mDraw) {
					if ((modifierKeys & Keys.Control) == 0) {
						Finish();
					}
				}
			}
		}
示例#17
0
        public DigitalButton Assign(MouseButtons button)
        {
            // Should it replace the assignment?
            this.mappingButtons.Add(button);

            return this;
        }
示例#18
0
 protected internal override void OnMouseEnter(int x, int y, MouseButtons mb)
 {
     if (this.m_Title != null)
     {
         this.m_Title.Visible = true;
     }
 }
 public override bool OnMouseUp(Glyph g, MouseButtons button)
 {
     if ((button != MouseButtons.Left) || (this.ParentUI == null))
     {
         return true;
     }
     bool flag = true;
     if (this.ParentUI.IsDesignerActionPanelVisible)
     {
         this.HideUI();
     }
     else if (!this.ignoreNextMouseUp)
     {
         if (this.serviceProvider != null)
         {
             ISelectionService service = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService));
             if ((service != null) && (service.PrimarySelection != this.RelatedComponent))
             {
                 List<IComponent> components = new List<IComponent> {
                     this.RelatedComponent
                 };
                 service.SetSelectedComponents(components, SelectionTypes.Click);
             }
         }
         this.ShowUI(g);
     }
     else
     {
         flag = false;
     }
     this.ignoreNextMouseUp = false;
     return flag;
 }
示例#20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseEventExtArgs"/> class. 
 /// </summary>
 /// <param name="buttons">One of the MouseButtons values indicating which mouse button was pressed.</param>
 /// <param name="clicks">The number of times a mouse button was pressed.</param>
 /// <param name="point">The x and y -coordinate of a mouse click, in pixels.</param>
 /// <param name="delta">A signed count of the number of detents the wheel has rotated.</param>
 /// <param name="timestamp">The system tick count when the event occurred.</param>
 /// <param name="isMouseKeyDown">True if event signals mouse button down.</param>
 /// <param name="isMouseKeyUp">True if event signals mouse button up.</param>
 internal MouseEventExtArgs(MouseButtons buttons, int clicks, Point point, int delta, int timestamp,  bool isMouseKeyDown, bool isMouseKeyUp)
     : base(buttons, clicks, point.X, point.Y, delta)
 {
     IsMouseKeyDown = isMouseKeyDown;
     IsMouseKeyUp = isMouseKeyUp;
     Timestamp = timestamp;
 }
示例#21
0
 protected internal override void OnMouseUp(int x, int y, MouseButtons mb)
 {
     if ((mb & MouseButtons.Right) != MouseButtons.None)
     {
         Gumps.Destroy(this);
     }
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="source">The source data list for the drag and drop operation</param>
 /// <param name="start">The selection start</param>
 /// <param name="end">The selection end</param>
 /// <param name="mouseButtons">The mouse button used</param>
 public DataListBeginDragEventArgs(DataList source, int start, int end, MouseButtons mouseButtons)
 {
     this.Source = source;
     this.SelectionStart = start;
     this.SelectionEnd = end;
     this.Button = mouseButtons;
 }
        public void UpdateButtonState(MouseButtons button, ButtonState state)
        {
            if (button == MouseButtons.None || ButtonStates[button] == state && !_alwaysNotify) return;

            ButtonStates[button] = state;
            _doNotify = true;
        }
示例#24
0
        private bool OnMouseUp(MouseButtons mouseButton,int shift,int x,int y)
        {
            if (this.TETool != null)
                this.TETool.OnMouseUp((int)System.Windows.Forms.MouseButtons.Right, shift, x,y);

            return true;
        }
示例#25
0
 public ClickPacket(Point point, MouseButtons buttons, PressEvent pressEvent)
     : base(0x14)
 {
     Point = point;
     Buttons = buttons;
     PressEvent = pressEvent;
 }
	// Constructor.
	public StatusBarPanelClickEventArgs
				(StatusBarPanel statusBarPanel, MouseButtons button,
				 int clicks, int x, int y)
			: base(button, clicks, x, y, 0)
			{
				this.statusBarPanel = statusBarPanel;
			}
示例#27
0
        public override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons)
        {
            try
            {
                bool showFolding = textArea.Document.TextEditorProperties.EnableFolding;
                int physicalLine = +(int)((mousepos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight);
                int realline = textArea.Document.GetFirstLogicalLine(physicalLine);

                // focus the textarea if the user clicks on the line number view
                textArea.Focus();

                if (!showFolding || realline < 0 || realline + 1 >= textArea.Document.TotalNumberOfLines)
                {
                    return;
                }

                List<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(realline);
                foreach (FoldMarker fm in foldMarkers)
                {
                    fm.IsFolded = !fm.IsFolded;
                }
                textArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("in FoldMargin " + ex.Message);
            }
        }
		public MouseEventArgs(MouseButtons button, int clicks, int x, int y, int delta) {
			this.buttons=button;
			this.clicks=clicks;
			this.delta=delta;
			this.x=x;
			this.y=y;
		}
示例#29
0
 protected internal override void OnMouseMove(int X, int Y, MouseButtons mb)
 {
     if (Gumps.Capture == this)
     {
         Point point = ((Gump) this.m_Target).PointToScreen(new Point(0, this.m_Target.Height));
         Point point2 = base.PointToScreen(new Point(X, Y));
         int minWidth = ((point2.X - point.X) + 6) - this.m_xOffset;
         if (minWidth < this.m_Target.MinWidth)
         {
             minWidth = this.m_Target.MinWidth;
         }
         else if (minWidth > this.m_Target.MaxWidth)
         {
             minWidth = this.m_Target.MaxWidth;
         }
         bool flag = false;
         int num2 = point.Y - (point2.Y - this.m_yOffset);
         if (num2 < this.m_Target.MinHeight)
         {
             flag = true;
         }
         else if (num2 > this.m_Target.MaxHeight)
         {
             flag = true;
         }
         if (!flag)
         {
             this.m_Target.Height = num2;
             ((Gump) this.m_Target).Y = point2.Y - this.m_yOffset;
         }
         this.m_Target.Width = minWidth;
         Engine.Redraw();
     }
 }
示例#30
0
        public bool IsButtonDown(MouseButtons button)
        {
            if (button == MouseButtons.None)
                return false;

            return (_states[button] == ButtonState.Pressed);
        }
示例#31
0
 /// <summary>
 /// Hande mouse action.
 /// </summary>
 /// <param name="action">Action type</param>
 /// <param name="button">Which mouse button caused the event</param>
 /// <param name="modifierKeys">Modifier keys (Shift, Ctrl or Alt) being pressed</param>
 /// <param name="row">Row index (zero based)</param>
 /// <param name="col">Column index (zero based)</param>
 /// <returns>True if mouse action was processed.</returns>
 public virtual bool ProcessMouse(TerminalMouseAction action, MouseButtons button, Keys modifierKeys, int row, int col)
 {
     return(false);
 }
示例#32
0
 private void StopDoubleClickWaiting()
 {
     m_PreviousClicked         = MouseButtons.None;
     m_PreviousClickedTime     = 0;
     m_PreviousClickedPosition = new Point(0, 0);
 }
示例#33
0
 private void StartDoubleClickWaiting(EventArgsExtFare e)
 {
     m_PreviousClicked         = e.Button;
     m_PreviousClickedTime     = e.ZamanDamgasý;
     m_PreviousClickedPosition = e.Point;
 }
示例#34
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (mouseDown)
            {
                return;
            }

            if (BtnDownMouseLeft(e) || BtnDownMouseRight(e))
            {
                this.previewRenderer.Visible = false;

                mouseDown = true;
                Cursor    = cursorMouseDown;

                if ((!KeyDownControlOnly()) && (!KeyDownShiftOnly()))
                {
                    mouseButton = e.Button;

                    lastMouseXY.X = e.X;
                    lastMouseXY.Y = e.Y;

                    // parses and establishes the active selection area
                    if (clipRegion != null)
                    {
                        clipRegion.Dispose();
                        clipRegion = null;
                    }

                    clipRegion = Selection.CreateRegion();
                    renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace);

                    // find the replacement color and the color to replace
                    colorReplacing = AppEnvironment.PrimaryColor;
                    colorToReplace = AppEnvironment.SecondaryColor;
                    penWidth       = AppEnvironment.PenInfo.Width;

                    // get the pen width find the ceiling integer of half of the pen width
                    ceilingPenWidth = (int)Math.Max(Math.Ceiling(penWidth), 3);

                    // used only for cursor positioning
                    halfPenWidth = (int)Math.Ceiling(penWidth / 2.0f);

                    // set hasDrawn to false since nothing has been drawn
                    hasDrawn = false;

                    // render the circle via GDI+ so the AA techniques can precisely
                    // mimic GDI+.
                    this.brushRenderArgs = RenderCircleBrush();

                    // establish tolerance
                    myTolerance = (int)(AppEnvironment.Tolerance * 256);

                    // restrict tolerance so no overlap is permitted
                    RestrictTolerance();
                    OnMouseMove(e);
                }
                else
                {
                    modifierDown = ModifierKeys;
                    OnMouseMove(e);
                }
            }
        }
示例#35
0
 /// <summary>
 /// Mouse button has been released in the view.
 /// </summary>
 /// <param name="c">Reference to the source control instance.</param>
 /// <param name="pt">Mouse position relative to control.</param>
 /// <param name="button">Mouse button released.</param>
 public virtual void MouseUp(Control c, Point pt, MouseButtons button)
 {
 }
        /// <summary>
        /// A callback function which will be called every Time a mouse activity detected.
        /// </summary>
        /// <param name="nCode">
        /// [in] Specifies whether the hook procedure must process the message.
        /// If nCode is HC_ACTION, the hook procedure must process the message.
        /// If nCode is less than zero, the hook procedure must pass the message to the
        /// CallNextHookEx function without further processing and must return the
        /// value returned by CallNextHookEx.
        /// </param>
        /// <param name="wParam">
        /// [in] Specifies whether the message was sent by the current thread.
        /// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
        /// </param>
        /// <param name="lParam">
        /// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
        /// </param>
        /// <returns>
        /// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
        /// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
        /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
        /// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
        /// procedure does not call CallNextHookEx, the return value should be zero.
        /// </returns>
        private static int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                //Marshall the data from callback.
                MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

                //detect button clicked
                MouseButtons button     = MouseButtons.None;
                short        mouseDelta = 0;
                int          clickCount = 0;
                bool         mouseDown  = false;
                bool         mouseUp    = false;

                switch (wParam)
                {
                case WM_LBUTTONDOWN:
                    mouseDown  = true;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    break;

                case WM_LBUTTONUP:
                    mouseUp    = true;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    break;

                case WM_LBUTTONDBLCLK:
                    button     = MouseButtons.Left;
                    clickCount = 2;
                    break;

                case WM_RBUTTONDOWN:
                    mouseDown  = true;
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    break;

                case WM_RBUTTONUP:
                    mouseUp    = true;
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    break;

                case WM_RBUTTONDBLCLK:
                    button     = MouseButtons.Right;
                    clickCount = 2;
                    break;

                case WM_MOUSEWHEEL:
                    //If the message is WM_MOUSEWHEEL, the high-order word of MouseData member is the wheel delta.
                    //One wheel click is defined as WHEEL_DELTA, which is 120.
                    //(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value
                    mouseDelta = (short)((mouseHookStruct.MouseData >> 16) & 0xffff);

                    //TODO: X BUTTONS (I havent them so was unable to test)
                    //If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
                    //or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
                    //and the low-order word is reserved. This value can be one or more of the following values.
                    //Otherwise, MouseData is not used.
                    break;
                }

                //generate event
                MouseEventExtArgs e = new MouseEventExtArgs(
                    button,
                    clickCount,
                    mouseHookStruct.Point.X,
                    mouseHookStruct.Point.Y,
                    mouseDelta);

                //Mouse up
                if (s_MouseUp != null && mouseUp)
                {
                    s_MouseUp.Invoke(null, e);
                }

                //Mouse down
                if (s_MouseDown != null && mouseDown)
                {
                    s_MouseDown.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClick != null && clickCount > 0)
                {
                    s_MouseClick.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClickExt != null && clickCount > 0)
                {
                    s_MouseClickExt.Invoke(null, e);
                }

                //If someone listens to double click and a click is heppened
                if (s_MouseDoubleClick != null && clickCount == 2)
                {
                    s_MouseDoubleClick.Invoke(null, e);
                }

                //Wheel was moved
                if (s_MouseWheel != null && mouseDelta != 0)
                {
                    s_MouseWheel.Invoke(null, e);
                }

                //If someone listens to move and there was a change in coordinates raise move event
                if ((s_MouseMove != null || s_MouseMoveExt != null) && (m_OldX != mouseHookStruct.Point.X || m_OldY != mouseHookStruct.Point.Y))
                {
                    m_OldX = mouseHookStruct.Point.X;
                    m_OldY = mouseHookStruct.Point.Y;
                    if (s_MouseMove != null)
                    {
                        s_MouseMove.Invoke(null, e);
                    }

                    if (s_MouseMoveExt != null)
                    {
                        s_MouseMoveExt.Invoke(null, e);
                    }
                }

                if (e.Handled)
                {
                    return(-1);
                }
            }

            //call next hook
            return(CallNextHookEx(s_MouseHookHandle, nCode, wParam, lParam));
        }
示例#37
0
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary <Kill, KillDisplayDetails> dicKills, List <BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary <int, Color> teamColours)
        {
            GraphicsPath gpTimelineOutline = new GraphicsPath();

            gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) });
            //gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15));
            //gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) });
            gpTimelineOutline.Widen(this.m_pOneWidth);

            this.ObjectPath = gpTimelineOutline;
            RectangleF recBounds = gpTimelineOutline.GetBounds();

            recBounds.Height += 50.0F;
            this.HotSpot      = recBounds;

            //string strMouseOverKillList = String.Empty;
            float flMouseOffsetX = 0.0F;

            bool blRoundChanged = false;

            MapTextBlock timeList = new MapTextBlock();

            foreach (BattlemapRoundChange RoundChange in new List <BattlemapRoundChange>(lstRounds))
            {
                float      flOffsetXs        = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (flOffsetXs >= 0.0F)
                {
                    GraphicsPath gpChangeTime = new GraphicsPath();
                    gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12));
                    gpChangeTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpChangeTime.Dispose();

                    if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true)
                    {
                        //strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName);

                        timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true));

                        blRoundChanged = true;
                        flMouseOffsetX = flOffsetXs;
                        //flMouseOffsetX = flOffsetXs;
                    }
                }
            }

            foreach (KeyValuePair <Kill, KillDisplayDetails> kvpKill in new Dictionary <Kill, KillDisplayDetails>(dicKills))
            {
                float      flOffsetXs      = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true)
                {
                    GraphicsPath gpKillTime = new GraphicsPath();
                    gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12));
                    gpKillTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpKillTime.Dispose();

                    Color killerColour = Color.White;
                    Color victimColour = Color.White;

                    if (colours == KillDisplayColours.EnemyColours)
                    {
                        killerColour = ControlPaint.Light(Color.SeaGreen);
                        victimColour = ControlPaint.LightLight(Color.Black);
                    }
                    else if (colours == KillDisplayColours.TeamColours)
                    {
                        if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true)
                        {
                            killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]);
                            victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]);
                        }
                    }

                    if (kvpKill.Key.Killer.ClanTag.Length > 0)
                    {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false));
                    }

                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false));

                    timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false));

                    if (kvpKill.Key.Victim.ClanTag.Length > 0)
                    {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false));
                    }
                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true));

                    flMouseOffsetX = flOffsetXs;
                }
            }

            if (timeList.Strings.Count > 0)
            {
                RectangleF recText = timeList.GetBounds();

                PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height);

                if (timeListOffset.X + recText.Width > g.ClipBounds.Width)
                {
                    timeListOffset.X = g.ClipBounds.Width - recText.Width;
                }

                timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons);
            }

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            this.m_mtsSeek.ButtonOpacity = this.TimelineOpacity;
            this.m_mtsSeek.SeekerBounds  = recBounds;
            this.m_mtsSeek.Draw(g, new PointF(pntDrawOffset.X, pntDrawOffset.Y + 13.0F), pntMouseLocation, mbButtons);

            timeList.Dispose();
        }
示例#38
0
 public static bool IsMousePressed(MouseButtons button)
 {
     return(IsMouseDown(button) && !IsBeforeMouseDown(button));
 }
示例#39
0
 public static bool IsMouseDown(MouseButtons button)
 {
     return(mouseState.Buttons.HasFlag(button));
 }
示例#40
0
 public static bool IsMouseReleased(MouseButtons button)
 {
     return(!IsMouseDown(button) && IsBeforeMouseDown(button));
 }
示例#41
0
 public MouseDownCommand(TimeSpan delay, int x, int y, MouseButtons button) : base(delay)
 {
     this.x      = x;
     this.y      = y;
     this.button = button;
 }
示例#42
0
 public static bool IsBeforeMouseDown(MouseButtons button)
 {
     return(oldMouseState.Buttons.HasFlag(button));
 }
示例#43
0
 public InputAction SetMouseButton(MouseButtons button)
 {
     mouseButtons.Clear();
     mouseButtons.Add(button);
     return(this);
 }
示例#44
0
 protected abstract void OnMouseMove(MouseButtons button, int dx, int dy);
示例#45
0
 public bool ContainsMouseButton(MouseButtons button)
 {
     return(mouseButtons.Contains(button));
 }
示例#46
0
 public MouseControl(MouseButtons button, PressType pressType)
 {
     base.PressType = pressType;
     MouseButton    = button;
 }
示例#47
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            mMouseButtons &= ~e.Button;
        }
示例#48
0
 public InputAction AddMouseButton(MouseButtons button)
 {
     mouseButtons.Add(button);
     return(this);
 }
        /// <summary>
        /// A callback function which will be called every time a mouse activity detected.
        /// </summary>
        /// <param name="nCode">
        /// [in] Specifies whether the hook procedure must process the message.
        /// If nCode is HC_ACTION, the hook procedure must process the message.
        /// If nCode is less than zero, the hook procedure must pass the message to the
        /// CallNextHookEx function without further processing and must return the
        /// value returned by CallNextHookEx.
        /// </param>
        /// <param name="wParam">
        /// [in] Specifies whether the message was sent by the current thread.
        /// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
        /// </param>
        /// <param name="lParam">
        /// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
        /// </param>
        /// <returns>
        /// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
        /// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
        /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
        /// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
        /// procedure does not call CallNextHookEx, the return value should be zero.
        /// </returns>
        private int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            // if ok and someone listens to our events
            if ((nCode >= 0) && (OnMouseActivity != null))
            {
                //Marshall the data from callback.
                MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

                //detect button clicked
                MouseButtons button     = MouseButtons.None;
                short        mouseDelta = 0;
                switch (wParam)
                {
                case WM_LBUTTONDOWN:
                    //case WM_LBUTTONUP:
                    //case WM_LBUTTONDBLCLK:
                    button = MouseButtons.Left;
                    break;

                case WM_RBUTTONDOWN:
                    //case WM_RBUTTONUP:
                    //case WM_RBUTTONDBLCLK:
                    button = MouseButtons.Right;
                    break;

                case WM_MOUSEWHEEL:
                    //If the message is WM_MOUSEWHEEL, the high-order word of mouseData member is the wheel delta.
                    //One wheel click is defined as WHEEL_DELTA, which is 120.
                    //(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value
                    mouseDelta = (short)((mouseHookStruct.mouseData >> 16) & 0xffff);
                    //TODO: X BUTTONS (I havent them so was unable to test)
                    //If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
                    //or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
                    //and the low-order word is reserved. This value can be one or more of the following values.
                    //Otherwise, mouseData is not used.
                    break;
                }

                //double clicks
                int clickCount = 0;
                if (button != MouseButtons.None)
                {
                    if (wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDBLCLK)
                    {
                        clickCount = 2;
                    }
                    else
                    {
                        clickCount = 1;
                    }
                }

                //generate event
                MouseEventArgs e = new MouseEventArgs(
                    button,
                    clickCount,
                    mouseHookStruct.pt.x,
                    mouseHookStruct.pt.y,
                    mouseDelta);
                //raise it
                OnMouseActivity(this, e);
            }
            //call next hook
            return(CallNextHookEx(hMouseHook, nCode, wParam, lParam));
        }
示例#50
0
 public InputAction RemoveMouseButton(MouseButtons button)
 {
     mouseButtons.Remove(button);
     return(this);
 }
示例#51
0
        /// <summary>
        ///  When any MouseMove message enters the BehaviorService's AdornerWindow (mousemove, ncmousemove) it is first passed here, to the top-most Behavior in the BehaviorStack.  Returning 'true' from this function signifies that  the Message was 'handled' by the Behavior and should not continue to be processed.
        /// </summary>
        public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
        {
            bool retVal = false;
            ToolStripItemGlyph glyph     = g as ToolStripItemGlyph;
            ToolStripItem      glyphItem = glyph.Item;
            ISelectionService  selSvc    = GetSelectionService(glyphItem);

            if (selSvc is null || glyphItem.Site is null || MouseHandlerPresent(glyphItem))
            {
                return(false);
            }

            if (!selSvc.GetComponentSelected(glyphItem))
            {
                PaintInsertionMark(glyphItem);
                retVal = false;
            }

            if (button == MouseButtons.Left && glyph != null && glyph.ItemDesigner != null && !glyph.ItemDesigner.IsEditorActive)
            {
                Rectangle     dragBox      = Rectangle.Empty;
                IDesignerHost designerHost = (IDesignerHost)glyphItem.Site.GetService(typeof(IDesignerHost));
                Debug.Assert(designerHost != null, "Invalid DesignerHost");
                if (glyphItem.Placement == ToolStripItemPlacement.Overflow || (glyphItem.Placement == ToolStripItemPlacement.Main && !(glyphItem.IsOnDropDown)))
                {
                    ToolStripItemDesigner itemDesigner    = glyph.ItemDesigner;
                    ToolStrip             parentToolStrip = itemDesigner.GetMainToolStrip();
                    if (designerHost.GetDesigner(parentToolStrip) is ToolStripDesigner parentDesigner)
                    {
                        dragBox = parentDesigner.DragBoxFromMouseDown;
                    }
                }
                else if (glyphItem.IsOnDropDown)
                {
                    //Get the OwnerItem's Designer and set the value...
                    if (glyphItem.Owner is ToolStripDropDown parentDropDown)
                    {
                        ToolStripItem ownerItem = parentDropDown.OwnerItem;
                        if (designerHost.GetDesigner(ownerItem) is ToolStripItemDesigner ownerItemDesigner)
                        {
                            dragBox = ownerItemDesigner.dragBoxFromMouseDown;
                        }
                    }
                }

                // If the mouse moves outside the rectangle, start the drag.
                if (dragBox != Rectangle.Empty && !dragBox.Contains(mouseLoc.X, mouseLoc.Y))
                {
                    if (_timer != null)
                    {
                        _timer.Enabled = false;
                        _timer.Tick   -= new EventHandler(OnDoubleClickTimerTick);
                        _timer.Dispose();
                        _timer = null;
                    }

                    // Proceed with the drag and drop, passing in the list item.
                    try
                    {
                        ArrayList   dragItems = new ArrayList();
                        ICollection selComps  = selSvc.GetSelectedComponents();
                        //create our list of controls-to-drag
                        foreach (IComponent comp in selComps)
                        {
                            if (comp is ToolStripItem item)
                            {
                                dragItems.Add(item);
                            }
                        }

                        //Start Drag-Drop only if ToolStripItem is the primary Selection
                        if (selSvc.PrimarySelection is ToolStripItem selectedItem)
                        {
                            ToolStrip owner = selectedItem.Owner;
                            ToolStripItemDataObject data = new ToolStripItemDataObject(dragItems, selectedItem, owner);
                            DropSource.QueryContinueDrag += new QueryContinueDragEventHandler(QueryContinueDrag);
                            if (glyphItem is ToolStripDropDownItem ddItem)
                            {
                                if (designerHost.GetDesigner(ddItem) is ToolStripMenuItemDesigner itemDesigner)
                                {
                                    itemDesigner.InitializeBodyGlyphsForItems(false, ddItem);
                                    ddItem.HideDropDown();
                                }
                            }
                            else if (glyphItem.IsOnDropDown && !glyphItem.IsOnOverflow)
                            {
                                ToolStripDropDown     dropDown  = glyphItem.GetCurrentParent() as ToolStripDropDown;
                                ToolStripDropDownItem ownerItem = dropDown.OwnerItem as ToolStripDropDownItem;
                                selSvc.SetSelectedComponents(new IComponent[] { ownerItem }, SelectionTypes.Replace);
                            }

                            DropSource.DoDragDrop(data, DragDropEffects.All);
                        }
                    }
                    finally
                    {
                        DropSource.QueryContinueDrag -= new QueryContinueDragEventHandler(QueryContinueDrag);
                        //Reset all Drag-Variables
                        SetParentDesignerValuesForDragDrop(glyphItem, false, Point.Empty);
                        ToolStripDesigner.s_dragItem = null;
                        _dropSource = null;
                    }

                    retVal = false;
                }
            }

            return(retVal);
        }
 public override bool OnMouseUp(Glyph g, MouseButtons button)
 {
     _designer.CreateItem(_ribbon, _ribbon.QuickAccessToolbar.Items, typeof(RibbonButton));
     return(base.OnMouseUp(g, button));
 }
示例#53
0
        /// <summary>
        ///     Creates <see cref="MouseEventExtArgs" /> from relevant mouse data.
        /// </summary>
        /// <param name="wParam">First Windows Message parameter.</param>
        /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param>
        /// <returns>A new MouseEventExtArgs object.</returns>
        private static MouseEventExtArgs FromRawDataUniversal(IntPtr wParam, MouseStruct mouseInfo)
        {
            MouseButtons button     = MouseButtons.None;
            short        mouseDelta = 0;
            int          clickCount = 0;

            bool isMouseKeyDown = false;
            bool isMouseKeyUp   = false;


            switch ((long)wParam)
            {
            case Messages.WM_LBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Left;
                clickCount     = 1;
                break;

            case Messages.WM_LBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Left;
                clickCount   = 1;
                break;

            case Messages.WM_LBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Left;
                clickCount     = 2;
                break;

            case Messages.WM_RBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Right;
                clickCount     = 1;
                break;

            case Messages.WM_RBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Right;
                clickCount   = 1;
                break;

            case Messages.WM_RBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Right;
                clickCount     = 2;
                break;

            case Messages.WM_MBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Middle;
                clickCount     = 1;
                break;

            case Messages.WM_MBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Middle;
                clickCount   = 1;
                break;

            case Messages.WM_MBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Middle;
                clickCount     = 2;
                break;

            case Messages.WM_MOUSEWHEEL:
                mouseDelta = mouseInfo.MouseData;
                break;

            case Messages.WM_XBUTTONDOWN:
                button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                isMouseKeyDown = true;
                clickCount     = 1;
                break;

            case Messages.WM_XBUTTONUP:
                button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                isMouseKeyUp = true;
                clickCount   = 1;
                break;

            case Messages.WM_XBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                clickCount = 2;
                break;

            case Messages.WM_MOUSEHWHEEL:
                mouseDelta = mouseInfo.MouseData;
                break;
            }

            var e = new MouseEventExtArgs(
                button,
                clickCount,
                mouseInfo.Point,
                mouseDelta,
                mouseInfo.Timestamp,
                isMouseKeyDown,
                isMouseKeyUp);

            return(e);
        }
示例#54
0
 protected void OnCellClicked(CeldaMapa cell, MouseButtons buttons, bool abajo) => clic_celda?.Invoke(cell, buttons, abajo);
示例#55
0
 /// <summary>
 /// Create cell mouse event argument with specified parameters
 /// </summary>
 /// <param name="worksheet">worksheet instance</param>
 /// <param name="cell">cell instance</param>
 /// <param name="relativePosition">relative mouse position (position in cell)</param>
 /// <param name="absolutePosition">absolute mouse position (position in spreadsheet)</param>
 /// <param name="buttons">pressed buttons</param>
 /// <param name="clicks">number of clicks</param>
 public CellMouseEventArgs(Worksheet worksheet, Cell cell, Point relativePosition,
                           Point absolutePosition, MouseButtons buttons, int clicks)
     : this(worksheet, cell, cell == null ? CellPosition.Empty : cell.InternalPos,
            relativePosition, absolutePosition, buttons, clicks)
 {
 }
示例#56
0
        // Occurs when MouseDown on the TooLStripItem glyph
        public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc)
        {
            ToolStripItemGlyph glyph     = g as ToolStripItemGlyph;
            ToolStripItem      glyphItem = glyph.Item;
            ISelectionService  selSvc    = GetSelectionService(glyphItem);
            BehaviorService    bSvc      = GetBehaviorService(glyphItem);
            ToolStripKeyboardHandlingService keyService = GetKeyBoardHandlingService(glyphItem);

            if ((button == MouseButtons.Left) && (keyService != null) && (keyService.TemplateNodeActive))
            {
                if (keyService.ActiveTemplateNode.IsSystemContextMenuDisplayed)
                {
                    // skip behaviors when the context menu is displayed
                    return(false);
                }
            }

            IDesignerHost designerHost = (IDesignerHost)glyphItem.Site.GetService(typeof(IDesignerHost));

            Debug.Assert(designerHost != null, "Invalid DesignerHost");

            //Cache original selection
            ICollection originalSelComps = null;

            if (selSvc != null)
            {
                originalSelComps = selSvc.GetSelectedComponents();
            }

            // Add the TemplateNode to the Selection if it is currently Selected as the GetSelectedComponents won't do it for us.
            ArrayList origSel = new ArrayList(originalSelComps);

            if (origSel.Count == 0)
            {
                if (keyService != null && keyService.SelectedDesignerControl != null)
                {
                    origSel.Add(keyService.SelectedDesignerControl);
                }
            }

            if (keyService != null)
            {
                keyService.SelectedDesignerControl = null;
                if (keyService.TemplateNodeActive)
                {
                    // If templateNode Active .. commit and Select it
                    keyService.ActiveTemplateNode.CommitAndSelect();
                    // if the selected item is clicked .. then commit the node and reset the selection (refer 488002)
                    if (selSvc.PrimarySelection is ToolStripItem currentSel && currentSel == glyphItem)
                    {
                        selSvc.SetSelectedComponents(null, SelectionTypes.Replace);
                    }
                }
            }

            if (selSvc is null || MouseHandlerPresent(glyphItem))
            {
                return(false);
            }

            if (glyph != null && button == MouseButtons.Left)
            {
                ToolStripItem selectedItem = selSvc.PrimarySelection as ToolStripItem;
                // Always set the Drag-Rect for Drag-Drop...
                SetParentDesignerValuesForDragDrop(glyphItem, true, mouseLoc);
                // Check if this item is already selected ...
                if (selectedItem != null && selectedItem == glyphItem)
                {
                    // If the Selecteditem is already in editmode ... bail out
                    if (selectedItem != null)
                    {
                        ToolStripItemDesigner selectedItemDesigner = glyph.ItemDesigner;
                        if (selectedItemDesigner != null && selectedItemDesigner.IsEditorActive)
                        {
                            return(false);
                        }
                    }

                    // Check if this is CTRL + Click or SHIFT + Click, if so then just remove the selection
                    bool removeSel = (Control.ModifierKeys & (Keys.Control | Keys.Shift)) > 0;
                    if (removeSel)
                    {
                        selSvc.SetSelectedComponents(new IComponent[] { selectedItem }, SelectionTypes.Remove);
                        return(false);
                    }

                    //start Double Click Timer
                    // This is required for the second down in selection which can be the first down of a Double click on the glyph confusing... hence this comment ...
                    // Heres the scenario ....
                    // DOWN 1 - selects the ITEM
                    // DOWN 2 - ITEM goes into INSITU....
                    // DOUBLE CLICK - don't show code..
                    // Open INSITU after the double click time
                    if (selectedItem is ToolStripMenuItem)
                    {
                        _timer = new Timer
                        {
                            Interval = SystemInformation.DoubleClickTime
                        };
                        _timer.Tick   += new EventHandler(OnDoubleClickTimerTick);
                        _timer.Enabled = true;
                        _selectedGlyph = glyph;
                    }
                }
                else
                {
                    bool shiftPressed = (Control.ModifierKeys & Keys.Shift) > 0;
                    // We should process MouseDown only if we are not yet selected....
                    if (!selSvc.GetComponentSelected(glyphItem))
                    {
                        //Reset the State... On the Glyphs .. we get MouseDown - Mouse UP (for single Click) And we get MouseDown - MouseUp - DoubleClick - Up (for double Click) Hence reset the state at start....
                        _mouseUpFired     = false;
                        _doubleClickFired = false;
                        //Implementing Shift + Click....
                        // we have 2 items, namely, selectedItem (current PrimarySelection) and glyphItem (item which has received mouseDown) FIRST check if they have common parent...  IF YES then get the indices of the two and SELECT all items from LOWER index to the HIGHER index.
                        if (shiftPressed && (selectedItem != null && CommonParent(selectedItem, glyphItem)))
                        {
                            ToolStrip parent = null;
                            if (glyphItem.IsOnOverflow)
                            {
                                parent = glyphItem.Owner;
                            }
                            else
                            {
                                parent = glyphItem.GetCurrentParent();
                            }

                            int startIndexOfSelection = Math.Min(parent.Items.IndexOf(selectedItem), parent.Items.IndexOf(glyphItem));
                            int endIndexOfSelection   = Math.Max(parent.Items.IndexOf(selectedItem), parent.Items.IndexOf(glyphItem));
                            int countofItemsSelected  = (endIndexOfSelection - startIndexOfSelection) + 1;

                            // if two adjacent items are selected ...
                            if (countofItemsSelected == 2)
                            {
                                selSvc.SetSelectedComponents(new IComponent[] { glyphItem });
                            }
                            else
                            {
                                object[] totalObjects = new object[countofItemsSelected];
                                int      j            = 0;
                                for (int i = startIndexOfSelection; i <= endIndexOfSelection; i++)
                                {
                                    totalObjects[j++] = parent.Items[i];
                                }

                                selSvc.SetSelectedComponents(new IComponent[] { parent }, SelectionTypes.Replace);
                                ToolStripDesigner.s_shiftState = true;
                                selSvc.SetSelectedComponents(totalObjects, SelectionTypes.Replace);
                            }
                        }

                        //End Implementation
                        else
                        {
                            if (glyphItem.IsOnDropDown && ToolStripDesigner.s_shiftState)
                            {
                                //Invalidate glyph only if we are in ShiftState...
                                ToolStripDesigner.s_shiftState = false;
                                if (bSvc != null)
                                {
                                    bSvc.Invalidate(glyphItem.Owner.Bounds);
                                }
                            }

                            selSvc.SetSelectedComponents(new IComponent[] { glyphItem }, SelectionTypes.Auto);
                        }

                        // Set the appropriate object.
                        if (keyService != null)
                        {
                            keyService.ShiftPrimaryItem = glyphItem;
                        }
                    }

                    // we are already selected and if shiftpressed...
                    else if (shiftPressed || (Control.ModifierKeys & Keys.Control) > 0)
                    {
                        selSvc.SetSelectedComponents(new IComponent[] { glyphItem }, SelectionTypes.Remove);
                    }
                }
            }

            if (glyph != null && button == MouseButtons.Right)
            {
                if (!selSvc.GetComponentSelected(glyphItem))
                {
                    selSvc.SetSelectedComponents(new IComponent[] { glyphItem });
                }
            }

            // finally Invalidate all selections
            ToolStripDesignerUtils.InvalidateSelection(origSel, glyphItem, glyphItem.Site, false);
            return(false);
        }
示例#57
0
文件: FormMain.cs 项目: Mixi59/Stump
        private void MapControlCellClicked(MapControl.MapControl control, MapCell cell, MouseButtons buttons, bool hold)
        {
            if (buttons == MouseButtons.Left)
            {
                cell.State = (radioButtonBlue.Checked ? CellState.BluePlacement : CellState.RedPlacement);
            }
            else if (buttons == MouseButtons.Right)
            {
                cell.State = CellState.None;
            }

            UpdateComplexity();
            control.Invalidate(cell);
        }
示例#58
0
 protected internal override void OnMouseDown(int x, int y, MouseButtons mb)
 {
     base.m_Parent.BringToTop();
 }
示例#59
0
 public ButtonState GetButtonState(MouseButtons button) => _buttonStates[button];
示例#60
0
 /// <summary>
 /// Create cell mouse event argument with specified parameters
 /// </summary>
 /// <param name="worksheet">worksheet instance</param>
 /// <param name="cellPosition">cell position</param>
 /// <param name="relativePosition">relative mouse position (position in cell)</param>
 /// <param name="absolutePosition">absolute mouse position (position in spreadsheet)</param>
 /// <param name="buttons">pressed buttons</param>
 /// <param name="clicks">number of clicks</param>
 public CellMouseEventArgs(Worksheet worksheet, CellPosition cellPosition, Point relativePosition,
                           Point absolutePosition, MouseButtons buttons, int clicks)
     : this(worksheet, null, cellPosition, relativePosition, absolutePosition, buttons, clicks)
 {
 }