/// <summary> /// 恾宍偺堏摦 (捈慄) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiLine figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 恾宍傪堏摦. if (info.iGripPosition < 0) { MoveFigure(figure, current, info, key); return; } // 儅僂僗墴壓帪偺忣曬偱嵗昗寁嶼偡傞. FVIL.Data.CFviPoint axis = Math.Add(info.position, info.axis); FVIL.Data.CFviAngle angle = Math.Invert(info.angle); FVIL.Data.CFviPoint pos = FVIL.Math.Rotate(current, axis, angle); // 仸捈慄偺巒揰偲廔揰偼 GetClipRect 偐傜庢摼偱偒傑偡偑丄孹偒傪峫椂偡傞昁梫偑偁傝傑偡. FVIL.Data.CFviLineSegment ls = new FVIL.Data.CFviLineSegment(info.clip.St, info.clip.Ed); if (info.position != info.clip.St) // 巒揰偑嵍忋偱側偄. { ls.SX = info.clip.St.X; ls.SY = info.clip.Ed.Y; ls.EX = info.clip.Ed.X; ls.EY = info.clip.St.Y; } // 恾宍偺曄宍. if (info.iGripPosition == 1) // 巒揰. { ls.St = pos; figure.CopyFrom(ls.ToCFviLine()); } else if (info.iGripPosition == 2) // 廔揰. { ls.Ed = pos; figure.CopyFrom(ls.ToCFviLine()); } // --- 婡幉偺曗惓. // 仸捈慄偼 Size 偵傛偭偰巒揰偲廔揰偑曄峏偝傟傞偨傔丄婡幉偺曗惓偼偱偒傑偣傫. if (angle.Degree != 0.0) { figure.Axis = Math.Sub(axis, figure.Position); } }
/// <summary> /// 恾宍偺堏摦 (慄暘) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiLineSegment figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 恾宍傪堏摦. if (info.iGripPosition < 0) { MoveFigure(figure, current, info, key); return; } // 儅僂僗墴壓帪偺忣曬偱嵗昗寁嶼偡傞. FVIL.Data.CFviPoint axis = Math.Add(info.position, info.axis); FVIL.Data.CFviAngle angle = Math.Invert(info.angle); FVIL.Data.CFviPoint pos = FVIL.Math.Rotate(current, axis, angle); // 恾宍偺曄宍. if (info.iGripPosition == 1) // 巒揰. { figure.St = pos; } else if (info.iGripPosition == 2) // 廔揰. { figure.Ed = pos; } // --- 婡幉偺曗惓. if (angle.Degree != 0.0) { figure.Axis = Math.Sub(axis, figure.Position); } }
/// <summary> /// 恾宍偺堏摦 (斈梡) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void MoveFigure(FVIL.GDI.CFviGdiFigure figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 儃僞儞墴壓帪偐傜偺堏摦検傪寁嶼. FVIL.Data.CFviPoint move = Math.Sub(current, info.mouse); // 恾宍傪堏摦. figure.Position = Math.Add(info.position, move); }
/// <summary> /// 恾宍偺堏摦 (揰) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiPoint figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 恾宍傪堏摦. if (info.iGripPosition != 0) { MoveFigure(figure, current, info, key); return; } }
/// <summary> /// 恾宍偺夞揮 (斈梡) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void RotateFigure(FVIL.GDI.CFviGdiFigure figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } FVIL.Data.CFviAngle st = Math.Angle(info.mouse, Math.Add(figure.Position, figure.Axis)); FVIL.Data.CFviAngle ed = Math.Angle(current, Math.Add(figure.Position, figure.Axis)); // 儃僞儞墴壓帪偐傜偺堏摦検傪寁嶼. FVIL.Data.CFviAngle move = Math.Sub(ed, st); // 恾宍傪夞揮. figure.Angle = Math.Add(info.angle, move); }
/// <summary> /// 恾宍偺憖嶌 (暘婒) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void HandlingFigure(FVIL.GDI.CFviGdiFigure figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } FigureHandlingMode mode = HandlingMode; // 儌乕僪偺愗傝懼偊. if (key.IsDown && key.Control == true && key.Alt == false && key.Shift == false) { if (mode == FigureHandlingMode.Normal) { mode = FigureHandlingMode.Rotate; } else if (mode == FigureHandlingMode.Rotate) { mode = FigureHandlingMode.Normal; } } if (mode == FigureHandlingMode.Rotate) { // 恾宍偺夞揮. RotateFigure(figure, current, info, key); } else { // 恾宍偺曄宍傑偨偼堏摦. if (figure is FVIL.GDI.CFviGdiPoint) { ModifyFigure((FVIL.GDI.CFviGdiPoint)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiAnchor) { ModifyFigure((FVIL.GDI.CFviGdiAnchor)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiLine) { ModifyFigure((FVIL.GDI.CFviGdiLine)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiLineSegment) { ModifyFigure((FVIL.GDI.CFviGdiLineSegment)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiCircle) { ModifyFigure((FVIL.GDI.CFviGdiCircle)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiEllipse) { ModifyFigure((FVIL.GDI.CFviGdiEllipse)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiRectangle) { ModifyFigure((FVIL.GDI.CFviGdiRectangle)figure, current, info, key); } else if (figure is FVIL.GDI.CFviGdiPolyline) { ModifyFigure((FVIL.GDI.CFviGdiPolyline)figure, current, info, key); } else { MoveFigure(figure, current, info, key); } } }
/// <summary> /// 恾宍偺堏摦 (懡妏宍) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiPolyline figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } if (figure.Close) { if (info.iGripPosition < 0) { // 恾宍慡懱傪堏摦偡傞. MoveFigure(figure, current, info, key); } else if (0 < info.iGripPosition && info.iGripPosition <= figure.Count) { // 捀揰傪堏摦偟偰丄恾宍傪曄宍偡傞. figure.Close = false; ModifyFigure(figure, current, info, key); figure.Close = true; } } else { // 儅僂僗墴壓帪偺忣曬偱嵗昗寁嶼偡傞. FVIL.Data.CFviPoint axis = Math.Add(info.position, info.axis); FVIL.Data.CFviAngle angle = Math.Invert(info.angle); FVIL.Data.CFviPoint pos = FVIL.Math.Rotate(current, axis, angle); if (info.iGripPosition < 0) { // 恾宍慡懱傪堏摦偡傞. MoveFigure(figure, current, info, key); } else if (0 < info.iGripPosition && info.iGripPosition <= figure.Count) { // 捀揰傪堏摦偟偰丄恾宍傪曄宍偡傞. int index = info.iGripPosition - 1; figure[index] = pos; // --- 婡幉偺曗惓. if (angle.Degree != 0.0) { figure.Axis = Math.Sub(axis, figure.Position); } } } }
/// <summary> /// 恾宍偺堏摦 (嬮宍) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiRectangle figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 恾宍傪堏摦. FVIL.GDI.RectPosition rectpos = (FVIL.GDI.RectPosition)info.iGripPosition; if ((rectpos & FVIL.GDI.RectPosition.ALL) == FVIL.GDI.RectPosition.ALL) { MoveFigure(figure, current, info, key); return; } // 儅僂僗墴壓帪偺忣曬偱嵗昗寁嶼偡傞. FVIL.Data.CFviPoint axis = Math.Add(info.position, info.axis); FVIL.Data.CFviAngle angle = Math.Invert(info.angle); FVIL.Data.CFviPoint pos = FVIL.Math.Rotate(current, axis, angle); // 恾宍偺曄宍. FVIL.Data.CFviRectangle clip = figure.GetClipRect(); if ((rectpos & FVIL.GDI.RectPosition.Left) == FVIL.GDI.RectPosition.Left) { clip.Left = pos.X; } if ((rectpos & FVIL.GDI.RectPosition.Right) == FVIL.GDI.RectPosition.Right) { clip.Right = pos.X; } if ((rectpos & FVIL.GDI.RectPosition.Top) == FVIL.GDI.RectPosition.Top) { clip.Top = pos.Y; } if ((rectpos & FVIL.GDI.RectPosition.Bottom) == FVIL.GDI.RectPosition.Bottom) { clip.Bottom = pos.Y; } figure.Left = clip.Left; figure.Right = clip.Right; figure.Top = clip.Top; figure.Bottom = clip.Bottom; // --- 婡幉偺曗惓. if (angle.Degree != 0.0) { figure.Axis = Math.Sub(axis, figure.Position); } }
/// <summary> /// 恾宍偺堏摦 (恀墌) /// </summary> /// <param name="figure">恾宍</param> /// <param name="current">尰嵼偺儅僂僗埵抲</param> /// <param name="info">儃僞儞墴壓帪偺忣曬</param> /// <param name="key">儃僞儞墴壓帪偺僉乕儃乕僪忣曬</param> protected virtual void ModifyFigure(FVIL.GDI.CFviGdiCircle figure, FVIL.Data.CFviPoint current, MouseInfo info, KeyboardInfo key) { if (info.iGripPosition == 0) { return; } // 恾宍傪堏摦. FVIL.GDI.RectPosition rectpos = (FVIL.GDI.RectPosition)info.iGripPosition; if ((rectpos & FVIL.GDI.RectPosition.ALL) == FVIL.GDI.RectPosition.ALL) { MoveFigure(figure, current, info, key); return; } // 儅僂僗墴壓帪偺忣曬偱嵗昗寁嶼偡傞. FVIL.Data.CFviPoint axis = Math.Add(info.position, info.axis); FVIL.Data.CFviAngle angle = Math.Invert(info.angle); FVIL.Data.CFviPoint mouse = FVIL.Math.Rotate(info.mouse, axis, angle); FVIL.Data.CFviPoint pos = FVIL.Math.Rotate(current, axis, angle); FVIL.Data.CFviPoint move = Math.Sub(pos, mouse); // 恾宍偺曄宍. bool L = ((rectpos & FVIL.GDI.RectPosition.Left) == FVIL.GDI.RectPosition.Left); bool R = ((rectpos & FVIL.GDI.RectPosition.Right) == FVIL.GDI.RectPosition.Right); bool T = ((rectpos & FVIL.GDI.RectPosition.Top) == FVIL.GDI.RectPosition.Top); bool B = ((rectpos & FVIL.GDI.RectPosition.Bottom) == FVIL.GDI.RectPosition.Bottom); FVIL.Data.CFviRectangle clip = figure.GetClipRect(); if (L && T) { clip.Left = (mouse.X + move.X); clip.Top = (mouse.Y + move.X); } else if (L && B) { clip.Left = (mouse.X + move.X); clip.Bottom = (mouse.Y - move.X); } else if (R && T) { clip.Right = (mouse.X + move.X); clip.Top = (mouse.Y - move.X); } else if (R && B) { clip.Right = (mouse.X + move.X); clip.Bottom = (mouse.Y + move.X); } else if (L) { clip.Left = (mouse.X + move.X); clip.Top += move.X / 2; clip.Bottom -= move.X / 2; } else if (R) { clip.Right = (mouse.X + move.X); clip.Top -= move.X / 2; clip.Bottom += move.X / 2; } else if (T) { clip.Top = (mouse.Y + move.Y); clip.Left += move.Y / 2; clip.Right -= move.Y / 2; } else if (B) { clip.Bottom = (mouse.Y + move.Y); clip.Left -= move.Y / 2; clip.Right += move.Y / 2; } double radius_x = clip.Width / 2; double radius_y = clip.Height / 2; figure.X = clip.X + radius_x; figure.Y = clip.Y + radius_y; if (L || R) { figure.Radius = clip.Width / 2; } else { figure.Radius = clip.Height / 2; } // --- 婡幉偺曗惓. if (angle.Degree != 0.0) { figure.Axis = Math.Sub(axis, figure.Position); } }