Exemplo n.º 1
0
        /// <summary>
        /// Determine is mouse on the element or not.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        internal override bool IsMouseOnTheElement(PointF point)
        {
            PointF[] tmpPoints           = convertDataPointToPointFArrayWithTranslate(points, YAxis.HeightRate, XAxis.WidthRate, YAxis.Center, XAxis.Center);
            float    tmpYAxesCenterWidth = XAxis.Center;

            if (tmpPoints.Length > 1)
            {
                if (AutoShift)
                {
                    if (points.GetLast().XValue > XAxis.Maximum)
                    {
                        tmpYAxesCenterWidth = -((float)points.GetLast().XValue - XAxis.Maximum) * XAxis.WidthRate + YAxis.Center;
                    }
                    else
                    {
                        tmpYAxesCenterWidth = -tmpPoints[0].X + YAxis.Center;
                    }
                }
            }

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            if (tmpPoints.Length > 2)
            {
                gp.AddLines(tmpPoints);
            }
            //if (XAxis.Labels.Count > 0)
            // point = new PointF(point.X - XAxis.WidthRate / 2, point.Y);
            point = new PointF(point.X - transLate.X, point.Y);
            return(gp.IsOutlineVisible(point, new Pen(Color.Red, mouseHitRay)));
        }
Exemplo n.º 2
0
        public override bool HitTest(System.Drawing.Point pt)
        {
            System.Drawing.Drawing2D.GraphicsPath gp       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.Matrix       myMatrix = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Pen myPen = new System.Drawing.Pen(this.m_lineColor, (float)this.m_lineWidth + 2);
            float X = (float)this.X;
            float Y = (float)this.Y;

            if (this.m_BondType == ChemInfo.BondType.Single)
            {
                gp.AddLine(X, Y, X + m_Size.Width, Y + m_Size.Height);
            }
            if (this.m_BondType == ChemInfo.BondType.Double)
            {
                gp.AddLine(X + m_OffsetX, Y + m_OffsetY, X + m_Size.Width + m_OffsetX, Y + m_Size.Height + m_OffsetY);
                gp.AddLine(X - m_OffsetX, Y - m_OffsetY, X + m_Size.Width - m_OffsetX, Y + m_Size.Height - m_OffsetY);
            }
            if (this.m_BondType == ChemInfo.BondType.Triple)
            {
                gp.AddLine(X + m_OffsetX, Y + m_OffsetY, X + m_Size.Width + m_OffsetX, Y + m_Size.Height + m_OffsetY);
                gp.AddLine(X, Y, X + m_Size.Width, Y + m_Size.Height);
                gp.AddLine(X - m_OffsetX, Y - m_OffsetY, X + m_Size.Width - m_OffsetX, Y + m_Size.Height - m_OffsetY);
            }
            myMatrix.RotateAt((float)this.m_Rotation, new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
            gp.Transform(myMatrix);
            return(gp.IsOutlineVisible(pt, myPen));
        }
Exemplo n.º 3
0
        public override bool HitTest(System.Drawing.PointF point, float precisionDelta)
        {
            bool result = false;

            if (_pen != null || _brush != null)
            {
                using (System.Drawing.Drawing2D.GraphicsPath actualPath = (System.Drawing.Drawing2D.GraphicsPath) this.Path.Clone())
                {
                    actualPath.Transform(_matrix);

                    if (_pen != null)
                    {
                        using (System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, _pen.Width + precisionDelta))
                            result = actualPath.IsOutlineVisible(point, pen);
                    }

                    if (!result && _brush != null)
                    {
                        result = actualPath.IsVisible(point);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public override bool HitTest(System.Drawing.Point point, ICoordinateMapper coordinateMapper)
        {
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            bool result = false;

            if (base.Enabled && _path != null)
            {
                System.Drawing.Point convertedPoint = coordinateMapper.WorkspaceToControl(base.Location, Aurigma.GraphicsMill.Unit.Point);

                point.X -= convertedPoint.X;
                point.Y -= convertedPoint.Y;

                result = _path.IsVisible(point);
                if (!result && this.Pen != null)
                {
                    result = _path.IsOutlineVisible(point, this.Pen);
                }
            }

            return(result);
        }
        // Graphics methods
        //chuck's new code 2/20/04
        //this method indicates whether point is along outline of graphic
        //and if so, what type of cursor should show
        public virtual void BoundaryTest(System.Drawing.Point pt, SizeDirection dir)
        {
            System.Drawing.Drawing2D.GraphicsPath gp       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.Matrix       myMatrix = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 3);

            gp.AddRectangle(new System.Drawing.Rectangle(this.m_Position.X - 3, this.m_Position.Y - 3, this.m_Size.Width + 6, this.m_Size.Height + 6));
            if (this.m_Rotation != 0)
            {
                myMatrix.RotateAt((float)this.m_Rotation, new System.Drawing.PointF((float)this.X, (float)this.Y), System.Drawing.Drawing2D.MatrixOrder.Append);
            }

            gp.Transform(myMatrix);
            dir = SizeDirection.NA;
            if (gp.IsOutlineVisible(pt, pen))
            {
                //user has placed the mouse along the outline of the selected
                //object - change the mouse to allow for resizing
                System.Drawing.RectangleF rect = gp.GetBounds();
                if (Math.Abs((int)rect.Left - pt.X) <= 2)
                {
                    if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Northwest;
                    }
                    else if (Math.Abs((int)rect.Bottom - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Southwest;
                    }
                    else
                    {
                        dir = SizeDirection.West;
                    }
                }
                else if (Math.Abs((int)rect.Right - pt.X) <= 2)
                {
                    if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Northeast;
                    }
                    else if (Math.Abs((int)rect.Bottom - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Southeast;
                    }
                    else
                    {
                        dir = SizeDirection.East;
                    }
                }
                else if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                {
                    dir = SizeDirection.North;
                }
                else
                {
                    dir = SizeDirection.South;
                }
            }
        }
Exemplo n.º 6
0
        public override bool HitTest(System.Drawing.Point pt)
        {
            System.Drawing.Drawing2D.GraphicsPath gp       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.Matrix       myMatrix = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Pen myPen = new System.Drawing.Pen(this.m_lineColor, (float)this.m_lineWidth + 2);
            float X = (float)this.X;
            float Y = (float)this.Y;

            gp.AddLine(X, Y, X + m_Size.Width, Y + m_Size.Height);
            myMatrix.RotateAt((float)this.m_Rotation, new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
            gp.Transform(myMatrix);
            return(gp.IsOutlineVisible(pt, myPen));
        }
Exemplo n.º 7
0
        private void FrmPolygonShape2_Paint(object sender, PaintEventArgs e)
        {
            /// zoom and shift the output
            Form   f = (Form)sender;
            double d = f.ClientSize.Width / (double)f.ClientSize.Height;

            _shiftX = pt.Min(a => a.X);
            _shiftY = pt.Min(a => a.Y);
            float  distX  = Math.Abs(pt.Max(a => a.X) - _shiftX);
            float  distY  = Math.Abs(pt.Max(a => a.Y) - _shiftY);
            double factor = distX / distY;

            _zoom = 1.0f;
            _zoom = factor >= d ? (float)(f.ClientSize.Width / distX) : (float)(f.ClientSize.Height / distY);

            e.Graphics.ScaleTransform(_zoom, _zoom);
            e.Graphics.TranslateTransform(-_shiftX * _zoom, -_shiftY * _zoom, System.Drawing.Drawing2D.MatrixOrder.Append);

            /// make nicer look
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            /// setup the path and test for being inside
            using (System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                myPath.AddLines(pt);
                myPath.CloseFigure();

                using (Pen pen = new Pen(Color.Blue, 4))
                    e.Graphics.DrawPath(pen, myPath);

                using (Pen pen = new Pen(Color.Blue))
                {
                    /// IsoutlineVisible is not needed normally
                    if (myPath.IsVisible(ptCheck) || myPath.IsOutlineVisible(ptCheck, pen))
                    {
                        this.Text = "inside - Origin at " + new PointF(_shiftX, _shiftY).ToString() + "; ZoomFacotr: ";// + _zoom.ToString();
                    }
                    else
                    {
                        this.Text = "outside - Origin at " + new PointF(_shiftX, _shiftY).ToString() + "; ZoomFacotr: ";// + _zoom.ToString();
                    }
                }
            }

            /// draw the testpoint as a small cross
            using (Pen pen = new Pen(Color.Red, 4))
            {
                e.Graphics.DrawLine(pen, ptCheck.X - 5 / _zoom, ptCheck.Y, ptCheck.X + 5 / _zoom, ptCheck.Y);
                e.Graphics.DrawLine(pen, ptCheck.X, ptCheck.Y - 5 / _zoom, ptCheck.X, ptCheck.Y + 5 / _zoom);
            }
        }