private void GameLoop()
        {
            if (Visible)
            {
                gameTime = new GameTime(timer.Elapsed, timer.Elapsed - elapsed);
                elapsed  = timer.Elapsed;

                System.Drawing.Point p = this.PointToClient(
                    new System.Drawing.Point(Cursor.Position.X, Cursor.Position.Y));

                if (ClientRectangle.Contains(p))
                {
                    _MousePosition = new Vector2(
                        MathHelper.Clamp(p.X, 0, _graphicsDeviceService.GraphicsDevice.Viewport.Width),
                        MathHelper.Clamp(p.Y, 0, _graphicsDeviceService.GraphicsDevice.Viewport.Height));
                }

                Update(gameTime);
                Invalidate();
            }
        }
示例#2
0
        protected override void OnClick(System.EventArgs e)
        {
            Focus();

            base.OnClick(e);

            if (m_bSkipClick == false)
            {
                Point pnt = MousePosition;
                pnt = PointToClient(pnt);

                if ((m_clickButton.Contains(pnt) == true) ||
                    (m_editbox.ReadOnly == true && ClientRectangle.Contains(pnt))
                    )
                {
                    DroppedDown = true;
                }
            }

            m_bSkipClick = false;
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mevent"></param>
 protected override void OnMouseMove(MouseEventArgs mevent)
 {
     base.OnMouseMove(mevent);
     if (ClientRectangle.Contains(mevent.Location))
     {
         ControlState = MouseState.Hover;
         if (ShowSpliteButton)
         {
             CurrentMousePosition = ButtonRect.Contains(mevent.Location) ? ButtonMousePosition.Button : ButtonMousePosition.Splitebutton;
         }
         else
         {
             CurrentMousePosition = ButtonMousePosition.Button;
         }
     }
     else
     {
         ControlState         = MouseState.Normal;
         CurrentMousePosition = ButtonMousePosition.None;
     }
 }
示例#4
0
 /// <summary>Handles the mouse up event.</summary>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
     {
         _mouseDown = false;
         if (!AllowChecking)
         {
             Point mousePosition = Control.MousePosition;
             if (ClientRectangle.Contains(PointToClient(mousePosition)))
             {
                 _highlighted = true;
             }
         }
         Invalidate();
         if (ClientRectangle.Contains(PointToClient(MousePosition)))
         {
             OnClick(e);
         }
     }
     base.OnMouseUp(e);
 }
示例#5
0
        private void CheckHover()
        {
            if (!ClientRectangle.Contains(PointToClient(MousePosition)))
            {
                if (IsDragging)
                {
                    if (_dropNode != null)
                    {
                        _dropNode = null;
                        Invalidate();
                    }
                }

                return;
            }

            foreach (var node in Nodes)
            {
                CheckNodeHover(node, OffsetMousePosition);
            }
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            // Update the popup only if the image selection has changed
            if (ClientRectangle.Contains(new Point(e.X, e.Y)))
            {
                if (EnableDragDrop && _bIsMouseDown)
                {
                    int nImage = _nCoordY * _nColumns + _nCoordX;
                    if (nImage <= _imageList.Images.Count - 1)
                    {
                        DataObject data = new DataObject();
                        data.SetData(DataFormats.Text, nImage.ToString());
                        data.SetData(DataFormats.Bitmap, _imageList.Images[nImage]);
                        try
                        {
                            //DragDropEffects dde =
                            DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move);
                        }
                        catch
                        {
                        }
                        _bIsMouseDown = false;
                    }
                }

                if (((e.X / _nItemWidth) != _nCoordX) || ((e.Y / _nItemHeight) != _nCoordY))
                {
                    _nCoordX = e.X / _nItemWidth;
                    _nCoordY = e.Y / _nItemHeight;
                    Invalidate();
                }
            }
            else
            {
                _nCoordX = -1;
                _nCoordY = -1;
                Invalidate();
            }
            base.OnMouseMove(e);
        }
示例#7
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg != (int)Msg.WM_PAINT)
            {
                return;
            }

            if (this.styleType != StyleType.VS2003)
            {
                return;
            }

            Win32.RECT wrec = new RECT();
            WindowsAPI.GetWindowRect(this.Handle, ref wrec);
            Rectangle rec = new Rectangle(0, 0, wrec.right - wrec.left, wrec.bottom - wrec.top);
            Pen       pen = new Pen(SystemBrushes.Window);
            IntPtr    hDc = WindowsAPI.GetWindowDC(Handle);
            Graphics  g   = Graphics.FromHdc(hDc);

            g.DrawRectangle(pen, 1, 1, rec.Width - 3, rec.Height - 3);
            pen.Dispose();

            if (!DesignMode && mblnHighlight && Enabled && (Focused || ClientRectangle.Contains(PointToClient(MousePosition))))
            {
                pen = new Pen(mclrHighlight);
            }
            else
            {
                pen = new Pen(mclrBorder);
            }



            g.DrawRectangle(pen, 0, 0, rec.Width - 1, rec.Height - 1);
            g.Dispose();

            pen.Dispose();
            WindowsAPI.ReleaseDC(Handle, hDc);
        }
示例#8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            DrawBackground(e);

            Rectangle rect = ClientRectangle.Inflate(Padding);

            if (!Buttons.IsNullOrEmpty())
            {
                rect.Width = Buttons.Min(b => b.Bounds.Left) - rect.X;
            }

            if (Icon != null && rect.Width > 16)
            {
                e.Graphics.DrawImage(Icon,
                                     new Rectangle(rect.Left, rect.Top + (rect.Height - Icon.Height) / 2, Icon.Width, Icon.Height),
                                     0, 0, Icon.Width, Icon.Height, GraphicsUnit.Pixel);
                rect.X     += Icon.Width + 4;
                rect.Width -= Icon.Width + 4;
            }

            if (!string.IsNullOrEmpty(Text) && rect.Width > 10)
            {
                StringFormat sf = PaintHelper.SFLeft;
                sf.FormatFlags |= StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rect, sf);
            }

            if (!Buttons.IsNullOrEmpty())
            {
                foreach (var btn in Buttons)
                {
                    if (!btn.Visible)
                    {
                        continue;
                    }
                    DrawButton(e, btn);
                }
            }
        }
示例#9
0
        /// <summary>
        /// We monitor all messages in order to detect when the users clicks outside the dropdown and the combo
        /// If this happens, we close the dropdown (as AutoClose is false)
        /// </summary>
        public bool PreFilterMessage(ref Message m)
        {
            if (Visible)
            {
                switch (m.Msg)
                {
                case WM_LBUTTONDOWN:
                case WM_RBUTTONDOWN:
                case WM_MBUTTONDOWN:
                case WM_NCLBUTTONDOWN:
                case WM_NCRBUTTONDOWN:
                case WM_NCMBUTTONDOWN:
                    int    i      = unchecked ((int)(long)m.LParam);
                    short  x      = (short)(i & 0xFFFF);
                    short  y      = (short)((i >> 16) & 0xffff);
                    Point  pt     = new Point(x, y);
                    IntPtr srcWnd =
                        // client area: x, y are relative to the client area of the windows
                        (m.Msg == WM_LBUTTONDOWN) || (m.Msg == WM_RBUTTONDOWN) || (m.Msg == WM_MBUTTONDOWN) ?
                        m.HWnd :
                        // non-client area: x, y are relative to the desktop
                        IntPtr.Zero;

                    MapWindowPoints(srcWnd, Handle, ref pt, 1);
                    if (!ClientRectangle.Contains(pt))
                    {
                        // the user has clicked outside the dropdown
                        pt = new Point(x, y);
                        MapWindowPoints(srcWnd, m_opener.Handle, ref pt, 1);
                        if (!m_opener.ClientRectangle.Contains(pt))
                        {
                            // the user has clicked outside the opener control
                            Close();
                        }
                    }
                    break;
                }
            }
            return(false);
        }
示例#10
0
        /// <summary>
        /// Process Windows-based messages.
        /// </summary>
        /// <param name="m">A Windows-based message.</param>
        protected override void WndProc(ref Message m)
        {
            // We need to snoop the need to show a context menu
            if (m.Msg == PI.WM_CONTEXTMENU)
            {
                // Only interested in overriding the behavior when we have a krypton context menu...
                if (KryptonContextMenu != null)
                {
                    // Extract the screen mouse position (if might not actually be provided)
                    Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam));

                    // If keyboard activated, the menu position is centered
                    if (((int)((long)m.LParam)) == -1)
                    {
                        mousePt = new Point(Width / 2, Height / 2);
                    }
                    else
                    {
                        mousePt = PointToClient(mousePt);

                        // Mouse point up and left 1 pixel so that the mouse overlaps the top left corner
                        // of the showing context menu just like it happens for a ContextMenuStrip.
                        mousePt.X -= 1;
                        mousePt.Y -= 1;
                    }

                    // If the mouse posiiton is within our client area
                    if (ClientRectangle.Contains(mousePt))
                    {
                        // Show the context menu
                        KryptonContextMenu.Show(this, PointToScreen(mousePt));

                        // We eat the message!
                        return;
                    }
                }
            }

            base.WndProc(ref m);
        }
示例#11
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_resizeRegion != ResizeRegion.None)
            {
                HandleResize();
                return;
            }

            Point     clientCursorPos = PointToClient(MousePosition);
            Rectangle resizeInnerRect = ClientRectangle;

            resizeInnerRect.Inflate(-_resizeBorderWidth, -_resizeBorderWidth);

            bool inResizableArea = ClientRectangle.Contains(clientCursorPos) && !resizeInnerRect.Contains(clientCursorPos);

            if (inResizableArea && !IsLocked)
            {
                ResizeRegion resizeRegion = GetResizeRegion(clientCursorPos);
                SetResizeCursor(resizeRegion);

                if (e.Button == MouseButtons.Left)
                {
                    _resizeRegion = resizeRegion;
                    HandleResize();
                }
            }
            else
            {
                Cursor = Cursors.Default;

                if (e.Button == MouseButtons.Left)
                {
                    Location = new Point(MousePosition.X - _offset.X, MousePosition.Y - _offset.Y);
                }
            }

            Invalidate();

            base.OnMouseMove(e);
        }
示例#12
0
 /// <summary>
 /// 绘制地图左下角的一些附加信息 如当前坐标、地图级别、logo、版权等
 /// </summary>
 /// <param name="g"></param>
 private void DrawMapInfo(Graphics g)
 {
     using (GraphicsPath gp = MapHelper.CreateRoundedRectanglePath(new Rectangle(10, Height - 100, 250, 90), 6))
     {
         using (SolidBrush sb = new SolidBrush(Color.FromArgb(180, Color.White)))
         {
             g.FillPath(sb, gp);
             g.DrawPath(Pens.Black, gp);
             using (Font f = new Font("微软雅黑", 11))
             {
                 g.DrawString(MapHelper.GetMapModeTitle(_mode) + "," + _zoom + "级," + MapHelper.GetLoadMapModeTitle(_loadmode), f, Brushes.Teal, new PointF(20, Height - 100 + 10));
                 Point p = PointToClient(Cursor.Position);
                 if (ClientRectangle.Contains(p))
                 {
                     LatLngPoint llp = MapHelper.GetLatLngByScreenLocation(p, _center, _zoom, ClientSize); //当前鼠标经纬度
                     g.DrawString(Math.Round(llp.Lat, 5) + "," + Math.Round(llp.Lng, 5), f, Brushes.Teal, new PointF(20, Height - 100 + 35));
                 }
                 g.DrawString("BMap.NET 2015 by 周见智", f, Brushes.Teal, new PointF(20, Height - 100 + 60));
             }
         }
     }
 }
示例#13
0
        protected override void OnMouseUp(MouseEventArgs args)
        {
            base.OnMouseUp(args);
            MsaglMouseEventArgs iArgs = CreateMouseEventArgs(args);

            gViewer.RaiseMouseUpEvent(iArgs);
            if (NeedToEraseRubber)
            {
                DrawXorFrame();
            }
            if (!iArgs.Handled)
            {
                if (gViewer.OriginalGraph != null && MouseDraggingMode == DraggingMode.WindowZoom)
                {
                    var    p = mouseDownPoint;
                    double f = Math.Max(Math.Abs(p.X - args.X), Math.Abs(p.Y - args.Y)) / GViewer.Dpi;
                    if (f > gViewer.ZoomWindowThreshold && zoomWindow)
                    {
                        mouseUpPoint = new Point(args.X, args.Y);
                        if (ClientRectangle.Contains(mouseUpPoint))
                        {
                            //var r = GViewer.RectFromPoints(mouseDownPoint, mouseUpPoint);
                            //r.Intersect(gViewer.DestRect);
                            if (GViewer.ModifierKeyWasPressed() == false)
                            {
                                P2     p1 = gViewer.ScreenToSource(mouseDownPoint);
                                P2     p2 = gViewer.ScreenToSource(mouseUpPoint);
                                double sc = Math.Min(Width / Math.Abs(p1.X - p2.X),
                                                     Height / Math.Abs(p1.Y - p2.Y));
                                P2 center = 0.5f * (p1 + p2);
                                gViewer.SetTransformOnScaleAndCenter(sc, center);
                                Invalidate();
                            }
                        }
                    }
                }
            }
            zoomWindow = false;
        }
示例#14
0
        void render(int x0, int y0, char dir)
        { //msg("render: "+x0+","+y0);
            x_new = x0;
            y_new = y0;
            if ((x_old > 0) && (x_new > 0))
            {
#if DEBUGGING_CODE
                g.FillRectangle(Brushes.Blue, ScaleFactor * x_old, ScaleFactor * y_old, ScaleFactor / 2, ScaleFactor / 2);
                g.DrawLine(Pens.Blue, ScaleFactor * x_old + ScaleFactor / 4, ScaleFactor * y_old + ScaleFactor / 4,
                           ScaleFactor * x_new + ScaleFactor / 4, ScaleFactor * y_new + ScaleFactor / 4);
#endif

                byte b;
                if (!rdr.MoveNext())
                {
                    b = 0xFF;
                }
                else
                {
                    b = rdr.Current;
                }

                if (ClientRectangle.Contains(x_old, y_old))
                {
                    int o = (y_old * Width + x_old) * 4;

                    this.data[o + 0] = b;
                    this.data[o + 1] = b;
                    this.data[o + 2] = b;
                    this.data[o + 3] = 0;
                }
            }
            else
            {
                //  g.FillRectangle(Brushes.Red, ScaleFactor * x_new, ScaleFactor * y_new, 3 * ScaleFactor / 2, 3 * ScaleFactor / 2);
            }
            x_old = x_new;
            y_old = y_new;
        }
示例#15
0
        private void ApplicationOnUpdateEvent()
        {
            var mclient = PointToClient(MousePosition);

            if (splitterMoving)
            {
                if (Orientation == Orientation.Vertical)
                {
                    splitterDistance = mclient.X - splitterMovingOffset;
                }
                else
                {
                    splitterDistance = mclient.Y - splitterMovingOffset;
                }

                UpdateSplitter();
            }
            else if (ClientRectangle.Contains(mclient))
            {
                Cursor.Current = null;

                if (Orientation == Orientation.Vertical)
                {
                    if (mclient.X >= splitterDistance &&
                        mclient.X <= splitterDistance + splitterWidth)
                    {
                        Cursor.Current = Cursors.VSplit;
                    }
                }
                else
                {
                    if (mclient.Y >= splitterDistance &&
                        mclient.Y <= splitterDistance + splitterWidth)
                    {
                        Cursor.Current = Cursors.HSplit;
                    }
                }
            }
        }
示例#16
0
 void RemoveCharges()
 {
     for (int i = 0; i < charges.Length; i++)
     {
         if (ClientRectangle.Contains(Point.Round(charges[i].Bounds.Location)) == false && charges[i].Active == true)
         {
             PCharge[] tempCharges = new PCharge[numOfCharges];
             tempCharges = charges;
             numOfCharges--;
             charges = new PCharge[numOfCharges];
             for (int j = 0; j < i; j++)
             {
                 charges[j] = tempCharges[j];
             }
             for (int j = i; j < charges.Length; j++)
             {
                 charges[j] = tempCharges[j + 1];
             }
             gui.RemoveChargeInfoWidget(i);
         }
     }
 }
示例#17
0
文件: TrackBar.cs 项目: ForNeVeR/pnet
        protected override void OnMouseMove(MouseEventArgs e)
        {
            mouseCoords = new Point(e.X, e.Y);

            if (barDown)
            {
                if (ClientRectangle.Contains(new Point(e.X, e.Y)))
                {
                    if (ValueFromPosition != this.value)
                    {
                        this.value = ValueFromPosition;
                        OnValueChanged(new EventArgs());
                    }
                    this.Invalidate();
                }
            }
            else if (trackDown)
            {
            }

            base.OnMouseMove(e);
        }
示例#18
0
        void DrawMinimapPixel(SpriteBatch spriteBatch, Colour colour, Point2D screenLocation)
        {
            if (!ClientRectangle.Contains(screenLocation))
            {
                return;
            }

            int alpha = alphaMask[screenLocation.X - Location.X, screenLocation.Y - Location.Y];

            if (alpha == 0)
            {
                return;
            }

            pixel.Tint     = colour;
            pixel.Location = screenLocation;

            // TODO: Opacity changing doesn't work properly
            //pixel.Opacity = alphaMask[screenLocation.X - Location.X, screenLocation.Y - Location.Y];

            pixel.Draw(spriteBatch);
        }
示例#19
0
        /**
         * When a link label is clicked, displays the respective resource.
         * When it is right-clicked, shows the resource popup menu.
         */

        private void OnLinkMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            _dragStartPoint = new Point(-1, -1);
            if (e.Button == MouseButtons.Left && _clickableLink && ClientRectangle.Contains(e.X, e.Y))
            {
                CancelEventArgs args = new CancelEventArgs(false);
                if (ResourceLinkClicked != null)
                {
                    ResourceLinkClicked(this, args);
                }
                if (!args.Cancel)
                {
                    ActionContext context = GetActionContext(ActionContextKind.Other);
                    if (!Core.ActionManager.ExecuteLinkClickAction(context))
                    {
                        if (!_resource.IsDeleted)
                        {
                            // the link label may get reused, and _resource may be replaced
                            IResource resourceToDisplay = _resource;
                            IResource linkOwner         = _linkOwnerResource;
                            Core.UIManager.DisplayResourceInContext(_resource);
                            if (linkOwner != null && Core.ResourceBrowser.OwnerResource != null &&
                                !Core.ResourceBrowser.VisibleResources.Contains(resourceToDisplay))
                            {
                                Core.ResourceBrowser.SelectResource(linkOwner);
                            }
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (LinkContextMenu != null)
                {
                    LinkContextMenu(this, new ResourceLinkLabelEventArgs(new Point(e.X, e.Y),
                                                                         _resource));
                }
            }
        }
示例#20
0
        public void Initialize(Document document)
        {
            Document = document;

            PrepareCSS();
            Render();

            Events.Add("onclick", new Action(() =>
            {
                if (ClientRectangle.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)) && !IsPressed)
                {
                    Global.JSExecutor.CallGlobalFunction(HtmlTag.Attributes.Find(p => p.AttributeName.Equals("onclick")).Value.Replace("(", "").Replace(")", ""));
                    IsPressed = true;
                }
            }));
            Events.Add("onrelease", new Action(() =>
            {
                IsPressed = false;
            }));

            Document.AddUpdateLogic(this);
        }
示例#21
0
        /// <summary>
        /// Overrides the OnMouseMove event in order to track mouse movement.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!Enabled)
            {
                return;
            }

            Point mousePosition = new Point(e.X, e.Y);

            // Invalidation causes an OnMouseMove event - filter it out so it doesn't
            // interfere with keyboard control
            if (ClientRectangle.Contains(mousePosition) && (lastMousePosition != mousePosition))
            {
                lastMousePosition = mousePosition;

                ColorWellInfo newColor = ColorWellFromPoint(e.X, e.Y);

                ChangeColor(newColor);
            }
        }
示例#22
0
        /// <summary>
        /// 绘制鼠标效果
        /// </summary>
        /// <param name="g"></param>
        private void DrawCursor(Graphics g)
        {
            Point p = PointToClient(Cursor.Position);

            if (ClientRectangle.Contains(p))
            {
                if (_cursor_located)  //鼠标定位效果
                {
                    using (Pen pen = new Pen(Color.FromArgb(200, _mode == MapMode.Normal ? Color.Blue : Color.White), 2))
                    {
                        pen.DashStyle = DashStyle.Dash;
                        g.DrawLine(pen, new Point(0, p.Y), new Point(ClientSize.Width, p.Y));
                        g.DrawLine(pen, new Point(p.X, 0), new Point(p.X, ClientSize.Height));
                    }
                }
                if (_mouse_type == MouseType.DrawMarker)  //鼠标绘制标记效果
                {
                    Bitmap b = Properties.BMap.ico_marker;
                    g.DrawImage(b, new Rectangle(p.X - b.Width / 2, p.Y - b.Height, b.Width, b.Height));
                }
            }
        }
示例#23
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            base.OnKeyUp(e);

            if (e.KeyCode != Keys.Space)
            {
                return;
            }

            _spacePressed = false;

            var location = Cursor.Position;

            if (!ClientRectangle.Contains(location))
            {
                SetButtonState(DarkControlState.Normal);
            }
            else
            {
                SetButtonState(DarkControlState.Hover);
            }
        }
示例#24
0
        private void checkCursorPosition_Tick(object sender, EventArgs e)
        {
            if (Cursor.Position.X - Location.X > this.Width - 50 && ClientRectangle.Contains(PointToClient(Control.MousePosition)) && PopupBackground.Visible == false)
            {
                Timeout.Stop();
                Timeout.Start();
                Turn.Stop();

                TurnEarth(false);
            }

            if (Cursor.Position.X - Location.X < 50 && ClientRectangle.Contains(PointToClient(Control.MousePosition)) && PopupBackground.Visible == false)
            {
                Timeout.Stop();
                Timeout.Start();
                Turn.Stop();

                TurnEarth(true);
            }

            //TempTextbox.Text = (Cursor.Position.X - this.Location.X).ToString() + "   " + (Cursor.Position.Y - this.Location.Y).ToString() + "   " + currentFrame.ToString();
        }
示例#25
0
 /// <summary>
 /// Raises the <see cref="M:System.Windows.Forms.Control.OnMouseMove(System.Windows.Forms.MouseEventArgs)" /> event.
 /// </summary>
 /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (e.Button != MouseButtons.None)
     {
         if (!ClientRectangle.Contains(e.X, e.Y))
         {
             if (_isHovered)
             {
                 _isHovered = false;
                 Fade();
                 Invalidate();
             }
         }
         else if (!_isHovered)
         {
             _isHovered = true;
             Fade();
             Invalidate();
         }
     }
 }
示例#26
0
 ///<summary></summary>
 protected override void OnMouseMove(MouseEventArgs mea)
 {
     base.OnMouseMove(mea);
     if (ClientRectangle.Contains(mea.X, mea.Y))
     {
         if (_buttonState == ODButtonState.Hover && this.Capture && !_bCanClick)
         {
             _bCanClick   = true;
             _buttonState = ODButtonState.Pressed;
             this.Invalidate();
         }
     }
     else
     {
         if (_buttonState == ODButtonState.Pressed)
         {
             _bCanClick   = false;
             _buttonState = ODButtonState.Hover;
             this.Invalidate();
         }
     }
 }
示例#27
0
 private void ProcessPan(MouseEventArgs args)
 {
     if (ClientRectangle.Contains(args.X, args.Y))
     {
         if (args.Button == System.Windows.Forms.MouseButtons.Left)
         {
             double dx = (double)(args.X - mouseDownPoint.X);
             double dy = (double)(args.Y - mouseDownPoint.Y);
             dx /= gViewer.LocalScale;
             dy /= gViewer.LocalScale; //map it to real coord
             int dh = gViewer.ScaleFromSrcXToScroll(dx);
             int dv = gViewer.ScaleFromSrcYToScroll(dy);
             gViewer.HVal = mouseDownHVal - dh;
             gViewer.VVal = mouseDownVVal + dv;
             gViewer.Invalidate();
         }
         else
         {
             GViewer.Hit(args);
         }
     }
 }
 private void CheckMouse(object sender, EventArgs e)     // best way of knowing your inside the client.. using mouseleave/enter with transparency does not work..
 {
     if (!ProgClose)
     {
         if (ClientRectangle.Contains(this.PointToClient(MousePosition)))
         {
             panelshowcounter++;
             if (panelshowcounter == 3)
             {
                 TransparencyKey = Color.Empty;
             }
         }
         else
         {
             if (panelshowcounter >= 3 && Theme.Current != null)
             {
                 TransparencyKey = Theme.Current.Form;
             }
             panelshowcounter = 0;
         }
     }
 }
示例#29
0
        /// ------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var br = new SolidBrush(BackColor))
                e.Graphics.FillRectangle(br, ClientRectangle);

            var textRect = GetTextRectangle(e.Graphics);

            // I was having some trouble getting the DrawCheckBox to honor the ForeColor property
            // under curtain circumstances and I never could sort out why. Therefore, I draw the
            // text as a separate operations in which I can specify the text color. It may
            // actually be better since if I were to set the ForeColor property here, I would get
            // a recursive call to OnPaint.

            CheckBoxRenderer.DrawCheckBox(e.Graphics, GetCheckBoxLocation(e.Graphics),
                                          textRect, string.Empty, Font, Focused, GetCheckState());

            var clr = (ClientRectangle.Contains(PointToClient(MousePosition)) || _completeType != StageCompleteType.Auto ?
                       SystemColors.ControlText : Color.DimGray);

            TextRenderer.DrawText(e.Graphics, Text, Font, textRect, clr,
                                  TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
        }
示例#30
0
        public void CenterMouse()
        {
            if (closing)
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new CenterDelegate(CenterMouse));
            }
            else
            {
                // center point only if inside window
                Point pt = PointToClient(Cursor.Position);
                if (ClientRectangle.Contains(pt))
                {
                    pt = new Point(ClientSize.Width / 2, ClientSize.Height / 2);
                    Cursor.Position = PointToScreen(pt);
                }
            }
        }