예제 #1
0
        public System.Drawing.Point AbsTransformPoint(int x, int y)
        {
            SimpleRectangleTransform pre  = null;
            SimpleRectangleTransform next = null;
            SimpleRectangleTransform cur  = null;

            foreach (SimpleRectangleTransform item in this)
            {
                if (item.Enable == false)
                {
                    continue;
                }
                if (item.SourceRect.Contains(x, y))
                {
                    return(item.TransformPoint(x, y));
                }

                if (y >= item.SourceRectF.Top && y <= item.SourceRectF.Bottom)
                {
                    cur = item;
                    break;
                }
                if (y < item.SourceRectF.Top)
                {
                    if (next == null || item.SourceRectF.Top < next.SourceRectF.Top)
                    {
                        next = item;
                    }
                }
                if (y > item.SourceRectF.Bottom)
                {
                    if (pre == null || item.SourceRectF.Bottom > pre.SourceRectF.Bottom)
                    {
                        pre = item;
                    }
                }
            }
            if (cur == null)
            {
                if (pre != null)
                {
                    cur = pre;
                }
                else
                {
                    cur = next;
                }
            }
            if (cur == null)
            {
                return(System.Drawing.Point.Empty);
            }
            System.Drawing.Point p = new System.Drawing.Point(x, y);
            p = Common.RectangleCommon.MoveInto(p, cur.SourceRect);
            return(cur.TransformPoint(p));
        }
예제 #2
0
        private void cap_Draw(object sender, CaptureMouseMoveEventArgs e)
        {
            DragPointStyle hit = (DragPointStyle)e.Sender.Tag;

            System.Drawing.Rectangle rect  = Rectangle.Ceiling(this.AbsBounds);
            System.Drawing.Point     p1    = e.StartPosition;
            System.Drawing.Point     p2    = e.CurrentPosition;
            SimpleRectangleTransform trans = this.OwnerDocument.EditorControl.GetTransformItemByDescPoint(rect.Left, rect.Top);

            if (trans != null)
            {
                p1   = trans.TransformPoint(p1);
                p2   = trans.TransformPoint(p2);
                rect = DragRectangle.CalcuteDragRectangle(
                    (int)(p2.X - p1.X),
                    (int)(p2.Y - p1.Y),
                    hit,
                    Rectangle.Ceiling(this.AbsBounds));
                if (rect.Width > (int)this.OwnerDocument.Width)
                {
                    rect.Width = (int)this.OwnerDocument.Width;
                }
                if (this.WidthHeightRate > 0.1)
                {
                    rect.Height = (int)(rect.Width / this.WidthHeightRate);
                }
                LastDragBounds = rect;
                rect           = trans.UnTransformRectangle(rect);
                using (ReversibleDrawer drawer =
                           ReversibleDrawer.FromHwnd(this.OwnerDocument.EditorControl.Handle))
                {
                    drawer.PenStyle = PenStyle.PS_DOT;
                    drawer.PenColor = System.Drawing.Color.Red;
                    drawer.DrawRectangle(rect);
                }
            }
        }