コード例 #1
0
        private void UpdateFormPositionOnUIThread()
        {
            try
            {
                var posX   = _configManager.GetProperty <long>("behaviour.frame.chat.position.x");
                var posY   = _configManager.GetProperty <long>("behaviour.frame.chat.position.y");
                var width  = _configManager.GetProperty <long>("behaviour.frame.chat.size.width");
                var height = _configManager.GetProperty <long>("behaviour.frame.chat.size.height");

                var location = new System.Drawing.Point((int)posX, (int)posY);
                var size     = new System.Drawing.Size((int)width, (int)height);

                if (!IsFrameOnScreens(new System.Drawing.Rectangle(location, size)))
                { // location and size invalid, fallback to default location
                    logger.Info("Overlay off screen, reseting position and size");
                    ResetFrameToDefaultLocation();
                    return;
                }

                if (!location.Equals(_overlay.Location))
                {
                    _overlay.Location = location;
                }

                if (!size.Equals(_overlay.Size))
                {
                    _overlay.Size = size;
                }
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
            }
        }
コード例 #2
0
ファイル: VectorPoint.cs プロジェクト: LikoIlya/AOP-Ruller
        public override bool Equals(object obj)
        {
            bool result = false;

            if (obj is VectorPoint)
            {
                VectorPoint temp = (VectorPoint)obj;
                result = (firstPoint.Equals(temp.FirstPoint) && secondPoint.Equals(temp.SecondPoint));
            }
            return(result);
        }
コード例 #3
0
        private async void MouseUp(object sender, MouseEventArgs e)
        {
            if (_isMouseDown && !_mouseSecondPoint.Equals(_mouseFirstPoint))
            {
                _mouseSecondPoint = e.Location;
                if (_cancellationTokenSource.Token.IsCancellationRequested)
                {
                    return;
                }

                await SendCopyCommandAsync();

                _isMouseDown = false;
            }
        }
コード例 #4
0
 private void EndMoveShapes(DragCompletedEventArgs e)
 {
     System.Drawing.Point NewMousePos = System.Windows.Forms.Cursor.Position;
     if (NewMousePos.Equals(OldMousePos))
     {
         IShape shape          = getShapeFromElement(e.Source);
         bool   clearSelection = !Keyboard.IsKeyDown(Key.LeftShift);
         SelectShape(shape, clearSelection);
     }
     else
     {
         double offsetX = NewMousePos.X - OldMousePos.X;
         double offsetY = NewMousePos.Y - OldMousePos.Y;
         new ShapeMoveCommand(Selected, offsetX, offsetY).Add();
     }
 }
コード例 #5
0
        private async void MouseUp(object sender, MouseEventArgs e)
        {
            await Task.Run(async() =>
            {
                if (isMouseDown && !mouseSecondPoint.Equals(mouseFirstPoint))
                {
                    mouseSecondPoint = e.Location;
                    if (cancellationTokenSource.Token.IsCancellationRequested)
                    {
                        return;
                    }

                    await SendCopyCommandAsync();
                    isMouseDown = false;
                }
            });
        }
コード例 #6
0
ファイル: MathCommon.cs プロジェクト: xuanximoming/key
        /// <summary>
        /// 对若干条线段进行矩形区域剪切处理
        /// </summary>
        /// <remarks>本函数修改点数组,使之包含在矩形区域中,若线段不在矩形区域中,
        /// 则设置起点和终点坐标为( int.MinValue , int.MinValue )</remarks>
        /// <param name="ClipRectangle">剪切矩形</param>
        /// <param name="Lines">线段起点和终点的坐标</param>
        public static void RectangleClipLines(
            System.Drawing.Rectangle ClipRectangle,
            System.Drawing.Point[] LinesPoints)
        {
            if (ClipRectangle.IsEmpty)
            {
                throw new System.ArgumentException("ClipRectangle is Empty", "ClipRectangle");
            }
            if (LinesPoints == null)
            {
                throw new System.ArgumentNullException("LinesPoints");
            }
            if (LinesPoints.Length == 0)
            {
                throw new System.ArgumentException("LinesPoints is empty", "LinesPoints");
            }
            // 点数组必须是二的倍数
            if ((LinesPoints.Length % 2) != 0)
            {
                throw new System.ArgumentException("LinesPoints is error", "LinesPoints");
            }

            System.Drawing.Point BlankPoint = new System.Drawing.Point(int.MinValue, int.MinValue);

            int left   = ClipRectangle.Left;
            int top    = ClipRectangle.Top;
            int right  = ClipRectangle.Right;
            int bottom = ClipRectangle.Bottom;

            for (int iCount = 0; iCount < LinesPoints.Length; iCount += 2)
            {
                System.Drawing.Point p1 = LinesPoints[iCount];
                System.Drawing.Point p2 = LinesPoints[iCount + 1];

                bool c1 = ClipRectangle.Contains(p1);

                // 若两点重合
                if (p1.Equals(p2))
                {
                    if (c1 == false)
                    {
                        LinesPoints[iCount]     = BlankPoint;
                        LinesPoints[iCount + 1] = BlankPoint;
                    }
                    continue;
                }
                bool c2 = ClipRectangle.Contains(p2);
                // 两个端点都在矩形内部则不需要处理
                if (c1 && c2)
                {
                    continue;
                }

                if (p1.X == p2.X)
                {
                    // 垂直线
                    if (p1.X >= left && p1.X <= right)
                    {
                        LinesPoints[iCount].Y     = FixToRange(p1.Y, top, bottom);
                        LinesPoints[iCount + 1].Y = FixToRange(p2.Y, top, bottom);
                    }
                    else
                    {
                        LinesPoints[iCount]     = BlankPoint;
                        LinesPoints[iCount + 1] = BlankPoint;
                    }
                }
                else if (p1.Y == p2.Y)
                {
                    // 水平线
                    if (p1.Y >= top && p1.Y <= bottom)
                    {
                        LinesPoints[iCount].X     = FixToRange(p1.X, left, right);
                        LinesPoints[iCount + 1].X = FixToRange(p2.X, left, right);
                    }
                    else
                    {
                        LinesPoints[iCount]     = BlankPoint;
                        LinesPoints[iCount + 1] = BlankPoint;
                    }
                }
                else
                {
                    // 斜线
                    double[] ps = GetLineEquationParameter(p1.X, p1.Y, p2.X, p2.Y);
                    //int index = 0 ;
                    double a = ps[0];
                    double b = ps[1];

                    if (p1.X < left)
                    {
                        p1.X = left;
                        p1.Y = (int)(a * p1.X + b);
                    }
                    else if (p1.X > right)
                    {
                        p1.X = right;
                        p1.Y = (int)(a * p1.X + b);
                    }
                    if (p1.Y < top)
                    {
                        p1.Y = top;
                        p1.X = (int)((p1.Y - b) / a);
                    }
                    else if (p1.Y > bottom)
                    {
                        p1.Y = bottom;
                        p1.X = (int)((p1.Y - b) / a);
                    }

                    if (p2.X < left)
                    {
                        p2.X = left;
                        p2.Y = (int)(a * p2.X + b);
                    }
                    else if (p2.X > right)
                    {
                        p2.X = right;
                        p2.Y = (int)(a * p2.X + b);
                    }
                    if (p2.Y < top)
                    {
                        p2.Y = top;
                        p2.X = (int)((p2.Y - b) / a);
                    }
                    else if (p2.Y > bottom)
                    {
                        p2.Y = bottom;
                        p2.X = (int)((p2.Y - b) / a);
                    }

                    bool flag = false;
                    if (p1.X >= left && p1.X <= right)
                    {
                        if (p1.Y >= top && p1.Y <= bottom)
                        {
                            if (p2.X >= left && p2.X <= right)
                            {
                                if (p2.Y >= top && p2.Y <= bottom)
                                {
                                    flag = true;
                                }
                            }
                        }
                    }
                    if (flag)
                    {
                        LinesPoints[iCount]     = p1;
                        LinesPoints[iCount + 1] = p2;
                    }
                    else
                    {
                        LinesPoints[iCount]     = BlankPoint;
                        LinesPoints[iCount + 1] = BlankPoint;
                    }
                }
            }//for( int iCount = 0 ; iCount < LinesPoints.Length ; iCount += 2 )
        }