Exemplo n.º 1
0
 public void MouseMove(DTkViewer dv, DPoint pt)
 {
     IGlyph glyph;
     if (editingFirstHand)
     {
         firstHandAngle.Value = DGeom.AngleBetweenPoints(GetClockRect().Center, pt);
         dv.Update(GetClockRect());
     }
     else if (editingSecondHand)
     {
         secondHandAngle.Value = DGeom.AngleBetweenPoints(GetClockRect().Center, pt);
         dv.Update(GetClockRect());
     }
     else if (editing && HitTest(pt, null, out glyph) == DHitTest.Body)
         dv.SetCursor(DCursor.Crosshair);
     else
         dv.SetCursor(DCursor.Default);
 }
Exemplo n.º 2
0
 void DoTextEditMouseMove(DTkViewer dv, DPoint pt)
 {
     TextEditFigure tef = (TextEditFigure)currentFigure;
     if (textEditMouseDown)
     {
         if (textEditChangeTextWrap)
         {
             dv.Update(GetBoundingBox(tef));
             if (!tef.WrapText)
             {
                 tef.WrapFontSize = tef.FontSize;
                 tef.WrapThreshold = tef.Width - tef.BorderWidth * 2;
                 tef.WrapText = true;
                 textEditDragWrapOffset = tef.X + tef.BorderWidth + tef.WrapLength - pt.X;
             }
             const int threshBase = 200;
             tef.WrapThreshold = threshBase * ((pt.X - (tef.X + tef.BorderWidth) + textEditDragWrapOffset) /
                 (threshBase * tef.FontSize / tef.WrapFontSize));
             dv.Update(GetBoundingBox(tef));
         }
         else if (textEditMove)
         {
             // bound pt to canvas
             BoundPtToPage(pt);
             // initial update rect
             DRect updateRect = GetBoundingBox(tef);
             // move text edit figure
             tef.X += pt.X - dragPt.X;
             tef.Y += pt.Y - dragPt.Y;
             dragPt = pt;
             // update
             dv.Update(updateRect.Union(GetBoundingBox(tef)));
         }
         else
         {
             tef.SetCursorPoint(pt, true);
             dv.Update(currentFigure.Rect);
         }
     }
     else
     {
         IGlyph glyph;
         if (currentFigure.HitTest(pt, null, out glyph) == DHitTest.Body)
         {
             if (tef.HitTestTextWrapHandle(pt))
                 dv.SetCursor(DCursor.MoveWE);
             else if (tef.HitTestBorder(pt))
                 dv.SetCursor(DCursor.MoveAll);
             else
                 dv.SetCursor(DCursor.IBeam);
         }
         else
             DoSelectDefaultMouseMove(dv, pt);
     }
 }
Exemplo n.º 3
0
 void DoSelectDefaultMouseMove(DTkViewer dv, DPoint pt)
 {
     // set cursor
     DHitTest hitTest;
     List<Figure> children = new List<Figure>();
     IGlyph glyph;
     Figure f = figureHandler.HitTestFigures(pt, out hitTest, children, out glyph);
     // set mouseover
     if (f != null && !f.MouseOver)
     {
         f.MouseOver = true;
         dv.Update(GetBoundingBox(f));
     }
     foreach (Figure otherFig in figureHandler.Figures)
         if (otherFig != f && otherFig.MouseOver)
         {
             otherFig.MouseOver = false;
             dv.Update(GetBoundingBox(otherFig));
         }
     // set cursor
     switch (hitTest)
     {
         case DHitTest.None:
             dv.SetCursor(DCursor.Default);
             break;
         case DHitTest.Body:
             if (f.Locked)
                 dv.SetCursor(DCursor.Default);
             else
                 dv.SetCursor(DCursor.MoveAll);
             if (f.ClickEvent)
                 dv.SetCursor(DCursor.Hand);
             else
                 foreach (Figure child in children)
                     if (child.ClickEvent)
                     {
                         dv.SetCursor(DCursor.Hand);
                         break;
                     }
             break;
         case DHitTest.SelectRect:
             goto case DHitTest.Body;
         case DHitTest.Resize:
             dv.SetCursor(DCursor.MoveNWSE);
             break;
         case DHitTest.RepositionPoint:
             goto case DHitTest.Resize;
         case DHitTest.Rotate:
             dv.SetCursor(DCursor.Rotate);
             break;
         case DHitTest.Context:
             dv.SetCursor(DCursor.Hand);
             break;
         case DHitTest.Lock:
             goto case DHitTest.Context;
         case DHitTest.Glyph:
             dv.SetCursor(glyph.Cursor);
             break;
     }
     #if DEBUG
     DoDebugMessage(string.Format("{0}, {1}", pt.X, pt.Y));
     #endif
 }
Exemplo n.º 4
0
 void DoSelectDefaultMouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     DHitTest hitTest;
     List<Figure> children = new List<Figure>();
     IGlyph glyph;
     if (btn == DMouseButton.Left)
     {
         Figure f = figureHandler.HitTestFigures(pt, out hitTest, children, out glyph);
         if (hitTest == DHitTest.Glyph)
         {
             if (children.Count > 0)
                 glyph.CallClicked(children[0], dv.EngineToClient(pt));
             else
                 glyph.CallClicked(f, dv.EngineToClient(pt));
         }
         else if ((hitTest == DHitTest.Body || hitTest == DHitTest.SelectRect) && FigureClick != null)
         {
             foreach (Figure child in children)
                 if (child.ClickEvent)
                     FigureClick(null, child, dv.EngineToClient(pt));
             if (f.ClickEvent)
                 FigureClick(null, f, dv.EngineToClient(pt));
             if (FiguresDeselectOnSingleClick && !FigureSelectToggleToSelection)
             {
                 figureHandler.SelectFigures(new List<Figure>(new Figure[] { f }), false);
                 dv.Update();
             }
         }
     }
     else if (btn == DMouseButton.Right)
     {
         Figure f = figureHandler.HitTestSelect(pt, out hitTest, null, out glyph, figureSelectToggleToSelection);
         dv.SetCursor(DCursor.Default);
         dv.Update();
         if (ContextClick != null)
             ContextClick(null, f, dv.EngineToClient(pt));
     }
     // nullify current figure for DoSelectDefault -> DHsmSignals.MouseMove:
     currentFigure = null;
 }
Exemplo n.º 5
0
 void DoDrawRectDefaultMouseMove(DTkViewer dv, DPoint pt)
 {
     // set cursor to draw
     dv.SetCursor(DCursor.Crosshair);
 }