public override void ResizeCheck(ref Point offset, MouseTool.ResizingTypes dir) { Size textOffset = new Size(0, 0); Size textSize = new Size(10, TextRenderer.MeasureText(Description, font).Height); //TextRenderer.MeasureText(Description, font); if ((dir & MouseTool.ResizingTypes.Left) != 0) { if (rect.Width - offset.X < textSize.Width + textOffset.Width) { offset.X = rect.Width - textSize.Width - textOffset.Width; } } if ((dir & MouseTool.ResizingTypes.Right) != 0) { if (rect.Width + offset.X < textSize.Width + textOffset.Width) { offset.X = -rect.Width + textSize.Width + textOffset.Width; } } if ((dir & MouseTool.ResizingTypes.Top) != 0) { if (rect.Height - offset.Y < textSize.Height + textOffset.Height) { offset.Y = rect.Height - textSize.Height - textOffset.Height; } } if ((dir & MouseTool.ResizingTypes.Bottom) != 0) { if (rect.Height + offset.Y < textSize.Height + textOffset.Height) { offset.Y = -rect.Height + textSize.Height + textOffset.Height; } } }
public override void Resize(Point offset, MouseTool.ResizingTypes dir) { if ((dir & MouseTool.ResizingTypes.Left) != 0) { if (rect.Width - offset.X >= 0) { rect.X += offset.X; rect.Width -= offset.X; } } if ((dir & MouseTool.ResizingTypes.Right) != 0) { if (rect.Width + offset.X >= 0) { rect.Width += offset.X; } } if ((dir & MouseTool.ResizingTypes.Top) != 0) { if (rect.Height - offset.Y >= 0) { rect.Y += offset.Y; rect.Height -= offset.Y; } } if ((dir & MouseTool.ResizingTypes.Bottom) != 0) { if (rect.Height + offset.Y >= 0) { rect.Height += offset.Y; } } }
public override void ResizeCheck(ref Point offset, MouseTool.ResizingTypes dir) { Size textOffset = new Size(15, 15 * (Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Length)); Size textSize = TextRenderer.MeasureText(Text, font); if ((dir & MouseTool.ResizingTypes.Left) != 0) { if (rect.Width - offset.X < textSize.Width + textOffset.Width) { offset.X = rect.Width - textSize.Width - textOffset.Width; } } if ((dir & MouseTool.ResizingTypes.Right) != 0) { if (rect.Width + offset.X < textSize.Width + textOffset.Width) { offset.X = -rect.Width + textSize.Width + textOffset.Width; } } if ((dir & MouseTool.ResizingTypes.Top) != 0) { if (rect.Height - offset.Y < textSize.Height + textOffset.Height) { offset.Y = rect.Height - textSize.Height - textOffset.Height; } } if ((dir & MouseTool.ResizingTypes.Bottom) != 0) { if (rect.Height + offset.Y < textSize.Height + textOffset.Height) { offset.Y = -rect.Height + textSize.Height + textOffset.Height; } } }
public override Point OutDir(Point position, out double angle) { double dec = 0d; MouseTool.ResizingTypes resizing = MouseTool.ResizingTypes.None; if (position.X <= rect.Left) { resizing |= MouseTool.ResizingTypes.Left; dec = Math.Abs((double)(position.Y - rect.Y) / rect.Height); } else if (position.X == rect.Right) { resizing |= MouseTool.ResizingTypes.Right; dec = Math.Abs((double)(position.Y - rect.Y) / rect.Height); } if (position.Y == rect.Top) { resizing |= MouseTool.ResizingTypes.Top; dec = Math.Abs((double)(position.X - rect.X) / rect.Width); } else if (position.Y == rect.Bottom) { resizing |= MouseTool.ResizingTypes.Bottom; dec = Math.Abs((double)(position.X - rect.X) / rect.Width); } angle = (double)resizing + dec; Point center = Util.Center(rect); return(Util.GetPoint(center, Util.Distance(center, position) + transitionVector, Util.GetAngle(center, position))); }
public override void Resize(Point offset, MouseTool.ResizingTypes dir) { int idx = (int)Math.Log((double)dir, 2d) - 4; if (idx == 0 || idx == 3) { Point newPoint = points[idx]; newPoint.Offset(offset); DrawInDir(newPoint, idx); } else { int idx2 = idx == 2 ? 3 : 0; points[idx].Offset(offset); maxDist[idx - 1] = Math.Sqrt(Math.Pow(points[idx].X - points[idx2].X, 2) + Math.Pow(points[idx].Y - points[idx2].Y, 2)); } }
public Point PointFromOffset(MouseTool.ResizingTypes resizingType, Point location, double angle) { MouseTool.ResizingTypes pointSide = (MouseTool.ResizingTypes)Math.Floor(angle); double dec; if (pointSide.HasFlag(MouseTool.ResizingTypes.Left) && pointSide.HasFlag(MouseTool.ResizingTypes.Right) || pointSide.HasFlag(MouseTool.ResizingTypes.Top) && pointSide.HasFlag(MouseTool.ResizingTypes.Bottom)) { pointSide--; dec = 1d; } else { dec = angle - (double)pointSide; } Point res = location; if (pointSide.HasFlag(MouseTool.ResizingTypes.Left)) { if (resizingType.HasFlag(MouseTool.ResizingTypes.Left)) { res.X = rect.Left; } if ((resizingType.HasFlag(MouseTool.ResizingTypes.Top) || resizingType.HasFlag(MouseTool.ResizingTypes.Bottom)) && !pointSide.HasFlag(MouseTool.ResizingTypes.Bottom)) { res.Y = rect.Y + (int)(dec * rect.Height); } } else if (pointSide.HasFlag(MouseTool.ResizingTypes.Right)) { if (resizingType.HasFlag(MouseTool.ResizingTypes.Right)) { res.X = rect.Right; } if ((resizingType.HasFlag(MouseTool.ResizingTypes.Top) || resizingType.HasFlag(MouseTool.ResizingTypes.Bottom)) && !pointSide.HasFlag(MouseTool.ResizingTypes.Top)) { res.Y = rect.Y + (int)(dec * rect.Height); } } if (pointSide.HasFlag(MouseTool.ResizingTypes.Top)) { if (resizingType.HasFlag(MouseTool.ResizingTypes.Top)) { res.Y = rect.Top; } if ((resizingType.HasFlag(MouseTool.ResizingTypes.Left) || resizingType.HasFlag(MouseTool.ResizingTypes.Right)) && !pointSide.HasFlag(MouseTool.ResizingTypes.Right)) { res.X = rect.X + (int)(dec * rect.Width); } } else if (pointSide.HasFlag(MouseTool.ResizingTypes.Bottom)) { if (resizingType.HasFlag(MouseTool.ResizingTypes.Bottom)) { res.Y = rect.Bottom; } if ((resizingType.HasFlag(MouseTool.ResizingTypes.Left) || resizingType.HasFlag(MouseTool.ResizingTypes.Right)) && !pointSide.HasFlag(MouseTool.ResizingTypes.Left)) { res.X = rect.X + (int)(dec * rect.Width); } } return(res); }
public override void ResizeCheck(ref Point offset, MouseTool.ResizingTypes dir) { }