/// <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="select">慖戰懏惈</param> /// <returns> /// 巜掕偝傟偨慖戰懏惈偲堦抳偡傞恾宍傪曉偟傑偡丅 /// 尒偮偐傜側偗傟偽 null 傪曉偟傑偡丅 /// </returns> public virtual FVIL.GDI.CFviGdiFigure GetSelectedFigure(bool select) { // 攝楍偺枛旜(倅曽岦偺慜柺)偐傜張棟偡傞. for (int i = Figures.Count - 1; i >= 0; i--) { FVIL.GDI.CFviGdiFigure figure = Figures[i]; if (figure.Select == select) { return(figure); } } return(null); }
/// <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="location">巜掕埵抲 (僋儔僀傾儞僩嵗昗)</param> /// <returns> /// 巜掕埵抲偵偁傞恾宍傪曉偟傑偡丅 /// 尒偮偐傟側偗傟偽 null 傪曉偟傑偡丅 /// </returns> public virtual FVIL.GDI.CFviGdiFigure GetFigure(Point location) { // View僋儔僀傾儞僩椞堟忋偱偺嵗昗. // Scaling = true 偺帪偼丄夋憸嵗昗偵曄姺. FVIL.Data.CFviPoint position = (Scaling) ? DPtoIP(location, ScalingMode) : new FVIL.Data.CFviPoint(location); // 攝楍偺枛旜(倅曽岦偺慜柺)偐傜張棟偡傞. for (int i = Figures.Count - 1; i >= 0; i--) { FVIL.GDI.CFviGdiFigure figure = Figures[i]; int iGripPosition = figure.CheckFocusMarkPosition(position, 8 / Magnification); if (iGripPosition != 0) { return(figure); } } return(null); }
/// <summary> /// 儅僂僗僇乕僜儖偑堏摦偟偰偄傞帪偺張棟 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnMouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (Active == false) { return; } if (m_MouseInfo.bGrip) { // View僋儔僀傾儞僩椞堟忋偱偺嵗昗. // Scaling = true 偺帪偼丄夋憸嵗昗偵曄姺. FVIL.Data.CFviPoint current = (Scaling) ? DPtoIP(e.Location, ScalingMode) : new FVIL.Data.CFviPoint(e.Location); FVIL.GDI.CFviGdiFigure figure = m_MouseInfo.figure; // 恾宍偺憖嶌. HandlingFigure(m_MouseInfo.figure, current, m_MouseInfo, m_KeyboardInfo); ((System.Windows.Forms.Control)sender).Refresh(); } }
/// <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="sender">儅僂僗僀儀儞僩偑敪惗偟偨僐儞僩儘乕儖</param> /// <param name="e">敪惗偟偨儅僂僗僀儀儞僩</param> /// <param name="AllowChange">僇乕僜儖曄峏嫋壜僗僥乕僞僗</param> public override void CanChangeCursor(System.Object sender, System.Windows.Forms.MouseEventArgs e, ref bool AllowChange) { if (!Active) { return; // 姳徛偟側偄. } try { System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursors.Default; // sender 傑偨偼 e 偑柍岠側応崌偼柍帇偡傞. if (ReferenceEquals(sender, null)) { return; } if (ReferenceEquals(e, null)) { return; } System.Windows.Forms.Control control = (System.Windows.Forms.Control)sender; // // 張棟懳徾偺恾宍. // bool selected = false; bool redraw = false; // View僋儔僀傾儞僩椞堟忋偱偺嵗昗. // Scaling = true 偺帪偼丄夋憸嵗昗偵曄姺. FVIL.Data.CFviPoint position = (Scaling) ? DPtoIP(e.Location, ScalingMode) : new FVIL.Data.CFviPoint(e.Location); // 攝楍偺枛旜(倅曽岦偺慜柺)偐傜張棟偡傞. for (int i = Figures.Count - 1; i >= 0; i--) { FVIL.GDI.CFviGdiFigure figure = Figures[i]; if (m_MouseInfo.bGrip == true) { if (ReferenceEquals(figure, m_MouseInfo.figure)) { if (figure.Select != true) { redraw = true; } figure.Select = true; selected = true; } } else if (figure.Enable) { int iGripPosition = figure.CheckFocusMarkPosition(position, 8 / Magnification); if (iGripPosition != 0 && selected == false) { if (figure.Select != true) { redraw = true; } figure.Select = true; selected = true; } else { if (figure.Select != false) { redraw = true; } figure.Select = false; } } } if (redraw) { ((System.Windows.Forms.Control)sender).Refresh(); } cursor = System.Windows.Forms.Cursors.SizeAll; // (!) 僇乕僜儖宍忬偺曄峏張棟 // AllowChange 偼丄懠偺僆乕僶儗僀偺僇乕僜儖曄峏張棟偲姳徛偟側偄傛偆偵偡傞堊偺僼儔僌偱偡. // 婛偵 AllowChange 偑 false 偺帪偼丄偙偺僆乕僶儗僀偱偺僇乕僜儖曄峏張棟傪峴偄傑偣傫丅 // AllowChange 偑 true 偺帪丄僇乕僜儖宍忬偺曄峏張棟傪峴偄傑偡丅 // 僇乕僜儖曄峏屻丄AllowChange 傪 false 偵曄峏偟傑偡丅 // 僇乕僜儖曄峏. if (AllowChange && selected == true) { control.Cursor = cursor; AllowChange = false; // 曄峏傪嫋壜偟側偄. } } catch (System.Exception) { } return; }
/// <summary> /// 儅僂僗僌儕僢僾壜斲敾掕 /// </summary> /// <param name="sender">儅僂僗僀儀儞僩偑敪惗偟偨僐儞僩儘乕儖</param> /// <param name="e">敪惗偟偨儅僂僗僀儀儞僩</param> /// <param name="AllowGrip">僌儕僢僾嫋壜僗僥乕僞僗</param> public override void CanMouseGrip(System.Object sender, System.Windows.Forms.MouseEventArgs e, ref bool AllowGrip) { if (!Active) { return; // 姳徛偟側偄. } if (AllowGrip) { try { FVIL.Data.CFviPoint position = (Scaling) ? DPtoIP(e.Location, ScalingMode) : new FVIL.Data.CFviPoint(e.Location); // 攝楍偺枛旜(倅曽岦偺慜柺)偐傜張棟偡傞. for (int i = Figures.Count - 1; i >= 0; i--) { FVIL.GDI.CFviGdiFigure figure = Figures[i]; if (m_MouseInfo.bGrip == true) { if (ReferenceEquals(figure, m_MouseInfo.figure)) { // 懠偺僆乕僶儗僀偱偺僌儕僢僾傪嫋壜偟側偄. AllowGrip = false; break; } } else if (figure.Enable) { int iGripPosition = figure.CheckFocusMarkPosition(position, 8 / Magnification); if (iGripPosition != 0) { if (figure is FVIL.GDI.CFviGdiPolyline) { // (!) 懡妏宍偵懳偡傞巄掕揑側張抲. // CFviGdiPolyline 偑 Close 偺偲偒傕捀揰偱斀墳偝偣傞張抲. // 僗儗僢僪僙乕僼偱偼側偄偺偱拲堄. // 杮棃偼丄宲彸偟偰 CheckFocusMarkPosition 傪僆乕僶乕儔僀僪偡傞傋偒. FVIL.GDI.CFviGdiPolyline _figure = (FVIL.GDI.CFviGdiPolyline)figure; if (_figure.Close) { _figure.Close = false; int iGripVetex = _figure.CheckFocusMarkPosition(position, 8 / Magnification); _figure.Close = true; // 捀揰傑偨偼曈埲奜偱奜愙嬮宍撪偺偲偒偼堏摦(-1)偲偡傞. iGripPosition = (iGripVetex != 0) ? iGripVetex : -1; } } // View僋儔僀傾儞僩椞堟忋偱偺嵗昗. // Scaling = true 偺帪偼丄夋憸嵗昗偵曄姺. FVIL.Data.CFviPoint mouse = (Scaling) ? DPtoIP(e.Location, ScalingMode) : new FVIL.Data.CFviPoint(e.Location); // 僌儕僢僾埵抲偲恾宍偺忬懺傪曐帩偡傞. m_MouseInfo.bGrip = true; m_MouseInfo.iGripPosition = iGripPosition; m_MouseInfo.mouse = mouse; m_MouseInfo.figure = figure; m_MouseInfo.position = figure.Position; m_MouseInfo.axis = figure.Axis; m_MouseInfo.angle = figure.Angle; m_MouseInfo.clip = figure.GetClipRect(); Validate(ref m_MouseInfo); // 桳岠壔. // 懠偺僆乕僶儗僀偱偺僌儕僢僾傪嫋壜偟側偄. AllowGrip = false; break; } } } } catch (System.Exception) { } } return; }