public override void InvalidateView() { if (control == null) { return; } if (isWindow) { parentView.Invalidate(); return; } Rectangle clip; // Repaint della vecchia posizione/dimensione del controllo (non necessariamente il solito controllo attualmente selezionato) clip = getMetaControlsOuterRectangle(selectedControlOldRect.abslocation, selectedControlOldRect.size).RoundUp(); parentView.Invalidate(clip); // Repaint della nuova posizione/dimensione del controllo var absloc = control.GetAbsoluteLocation(); clip = getMetaControlsOuterRectangle(absloc, control.Size).RoundUp(); parentView.Invalidate(clip); selectedControlOldRect.abslocation = absloc; selectedControlOldRect.size = control.Size; }
private void drawResizingMeasure(Graphics g) { if (control != null) { bool drawUp = (MeasureDirection & Direction.Up) == Direction.Up; bool drawLeft = (MeasureDirection & Direction.Left) == Direction.Left; bool drawDown = (MeasureDirection & Direction.Down) == Direction.Down; bool drawRight = (MeasureDirection & Direction.Right) == Direction.Right; var loc = control.GetAbsoluteLocation(); if (drawUp) { drawSingleResizingMeasure(g, loc, control.Size, Direction.Up); } if (drawLeft) { drawSingleResizingMeasure(g, loc, control.Size, Direction.Left); } if (drawDown) { drawSingleResizingMeasure(g, loc, control.Size, Direction.Down); } if (drawRight) { drawSingleResizingMeasure(g, loc, control.Size, Direction.Right); } } }
/// <summary> /// Dato un punto, determina quale resize handle è disponibile su quel punto. /// </summary> /// <param name="p">Punto in coordinate relative alla View</param> /// <returns></returns> public Direction WhatResizeHandle(PointF p) { SkinnableControls.SkinnableControl c = this.control; if (c == null) { return(Direction.None); } Direction dir = Direction.None; var loc = c.GetAbsoluteLocation(); if (loc.X + c.Size.Width - 5 <= p.X && p.X <= loc.X + c.Size.Width + 5 && loc.Y + c.Size.Height - 5 <= p.Y && p.Y <= loc.Y + c.Size.Height + 5) { dir = Direction.Right | Direction.Down; } else if (loc.X - 6 <= p.X && p.X <= loc.X + 5 && loc.Y - 6 <= p.Y && p.Y <= loc.Y + 5) { dir = Direction.Left | Direction.Up; } else if (loc.X + c.Size.Width - 5 <= p.X && p.X <= loc.X + c.Size.Width + 5 && loc.Y - 6 <= p.Y && p.Y <= loc.Y + 5) { dir = Direction.Right | Direction.Up; } else if (loc.X - 6 <= p.X && p.X <= loc.X + 5 && loc.Y + c.Size.Height - 5 <= p.Y && p.Y <= loc.Y + c.Size.Height + 5) { dir = Direction.Left | Direction.Down; } else if (loc.X + c.Size.Width - 2 <= p.X && p.X <= loc.X + c.Size.Width + 5 && loc.Y <= p.Y && p.Y <= loc.Y + c.Size.Height) { dir = Direction.Right; } else if (loc.Y + c.Size.Height - 2 <= p.Y && p.Y <= loc.Y + c.Size.Height + 5 && loc.X <= p.X && p.X <= loc.X + c.Size.Width) { dir = Direction.Down; } else if (loc.Y - 6 <= p.Y && p.Y <= loc.Y + 2 && loc.X <= p.X && p.X <= loc.X + c.Size.Width) { dir = Direction.Up; } else if (loc.X - 6 <= p.X && p.X <= loc.X + 2 && loc.Y <= p.Y && p.Y <= loc.Y + c.Size.Height) { dir = Direction.Left; } return(dir); }
public RectangleF GetHandleRectangle() { var loc = control.GetAbsoluteLocation(); return(new RectangleF(loc.X + 12, loc.Y - 8, 16, 16)); }