Ejemplo n.º 1
0
 public FigureStylePopup(int x, int y, Type figureClass, DAuthorProperties dap, bool antiAlias)
     : base(x, y)
 {
     this.figureClass = figureClass;
     this.dap = dap;
     // create the viewer
     vc = new WFViewerControl();
     vc.Parent = this;
     vc.Dock = DockStyle.Fill;
     dv = new WFViewer(vc);
     dv.Preview = true;
     dv.AntiAlias = antiAlias;
     // create the DEngine
     de = new DEngine(null);
     de.AddViewer(dv);
     // set page height to viewer size
     de.UndoRedo.Start("blah");
     de.PageSize = new DPoint(vc.Width, vc.Height);
     de.UndoRedo.Commit();
     // add the figure
     WorkBookUtils.PreviewFigure(de, dv, figureClass, dap, new DPoint(vc.Width, vc.Height));
     // buttons
     Panel pnlTop = new Panel();
     pnlTop.Dock = DockStyle.Top;
     pnlTop.Height = 25;
     pnlTop.Parent = this;
     Button btnEdit = new Button();
     btnEdit.FlatStyle = FlatStyle.Popup;
     btnEdit.Text = "Edit";
     btnEdit.Location = new Point(1, 1);
     btnEdit.Parent = pnlTop;
     btnEdit.Click += new EventHandler(btnEdit_Click);
 }
Ejemplo n.º 2
0
 public AnnotationForm()
 {
     InitializeComponent();
     // screen size
     Size screenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
     // get screen cap
     Bitmap bmp = new Bitmap(screenSize.Width, screenSize.Height);
     Graphics g = Graphics.FromImage(bmp);
     g.CopyFromScreen(0, 0, 0, 0, screenSize);
     g.Dispose();
     // create dv & de
     dv = new WFViewer(wfViewerControl1);
     dv.Preview = true;
     dv.EditFigures = true;
     dv.AntiAlias = true;
     de = new DEngine(null);
     de.AddedFigure += new AddedFigureHandler(de_AddedFigure);
     de.AddViewer(dv);
     WorkBookUtils.SetupDEngine(de);
     // setup undo/redo sensitive stuff
     de.UndoRedo.Start("initial setup");
     de.PageSize = new DPoint(screenSize.Width, screenSize.Height);
     BackgroundFigure bf = new BackgroundFigure(); // background figure
     bf.ImageData = WFHelper.ToImageData(bmp);
     bf.FileName = "screen_capture.png";
     bf.BitmapPosition = DBitmapPosition.Normal;
     de.SetBackgroundFigure(bf, true);
     de.UndoRedo.Commit();
     de.UndoRedo.ClearHistory();
     // set form to full screen
     Location = new Point(0, 0);
     Size = screenSize;
 }
Ejemplo n.º 3
0
 public PtButtonForm()
 {
     InitializeComponent();
     dv = new WFViewer(vcCustomFigure);
     dv.EditFigures = false;
     dv.AntiAlias = true;
     dv.Preview = true;
     de = new DEngine(null);
     de.AddViewer(dv);
     // set page height to viewer size
     de.UndoRedo.Start("blah");
     de.PageSize = new DPoint(vcCustomFigure.Width, vcCustomFigure.Height);
     de.UndoRedo.Commit();
     // default to toolbutton edit
     SetupToolButtonEdit();
 }
Ejemplo n.º 4
0
        public PropertiesForm()
        {
            InitializeComponent();
            LocalizeUI();
            dv = new WFViewer(vc);
            dv.EditFigures = false;
            dv.AntiAlias = true;
            dv.Preview = true;
            de = new DEngine(null);
            de.AddViewer(dv);
            // set page height to viewer size
            de.UndoRedo.Start("blah");
            de.PageSize = new DPoint(vc.Width, vc.Height);
            de.UndoRedo.Commit();

            tsFigureProps.De = de;
            tsFigureProps.Dv = dv;
        }
Ejemplo n.º 5
0
 public void KeyPress(DTkViewer dv, int k)
 {
     switch ((DKeys)k)
     {
         case DKeys.Enter:
             DoEditFinished();
             break;
         case DKeys.Escape:
             goto case DKeys.Enter;
     }
 }
Ejemplo n.º 6
0
 public QKeyEvent(int qSignal, DTkViewer dv, DKey key)
     : base(qSignal, dv)
 {
     this.key = key;
 }
Ejemplo n.º 7
0
 public MainForm()
 {
     // Init localization
     WbLocale.Init(System.Globalization.CultureInfo.CurrentUICulture);
     // Init Component
     InitializeComponent();
     LocalizeUI();
     // create temp paths
     tempFilesDir = WorkBookUtils.GetTempFileName("tempfiles", TempDir);
     autoSaveDir = Path.Combine(TempDir, "autosave");
     try
     {
         if (!Directory.Exists(TempDir))
             Directory.CreateDirectory(TempDir);
         if (!Directory.Exists(tempFilesDir))
             Directory.CreateDirectory(tempFilesDir);
         if (!Directory.Exists(autoSaveDir))
             Directory.CreateDirectory(autoSaveDir);
     }
     catch { }
     attachmentView1.TempDir = tempFilesDir;
     // set icon
     Icon = Resource1._2touch;
     // Create Handle (so we can respond to ipc events from other threads without showing the form)
     IntPtr h = Handle;
     // Initialze DGraphics
     WFHelper.InitGraphics();
     // undo redo
     undoRedoArea.CommandDone += new EventHandler<CommandDoneEventArgs>(undoRedoArea_UndoRedoChanged);
     // edit viewer
     dvEditor = new WFViewer(wfvcEditor);
     dvEditor.EditFigures = true;
     #if DEBUG
     dvEditor.DebugMessage += new DebugMessageHandler(DebugMessage);
     #else
     statusStrip1.Parent = null;
     #endif
     // highlight selection
     #if !BEHAVIOURS
     highlightSelectionToolStripMenuItem.Visible = false;
     #endif
     // glyphs
     linkGlyph = new BitmapGlyph(WFHelper.MakeBitmap(Resource1.link), DGlyphPosition.BottomLeft);
     linkGlyph.Visiblility = DGlyphVisiblity.Always;
     linkGlyph.Cursor = DCursor.Hand;
     linkGlyph.Clicked += new GlyphClickedHandler(linkGlyph_Clicked);
     // figure defaults
     Figure._handleSize = 6;
     Figure._handleBorder = 4;
     Figure._rotateHandleStemLength = Figure._handleSize - Figure._handleBorder;
     LinebaseFigure._hitTestExtension = 5;
     // setup autosave
     autoSaveTimer = new Timer();
     autoSaveTimer.Tick += new EventHandler(autoSaveTimer_Tick);
     // set toolstrip properties
     tsPropState.Dv = dvEditor;
     // connect to ipc messages
     ipc.MessageReceived += new MessageReceivedHandler(ipc_MessageReceived);
     ipc.P2pMessageRecieved += new P2pMessageReceivedHandler(ipc_P2pMessageRecieved);
     // get command line arguments
     ActionCommandLine();
 }
Ejemplo n.º 8
0
 public MainWindow()
     : base("MainWindow")
 {
     // create the table and pack into the window
     Table table = new Table(2, 3, false);
     Add(table);
     // Initialze DGraphics
     GTKHelper.InitGraphics();
     // create DViewerControl and attach to table
     GTKViewerControl dvc = new GTKViewerControl();
     table.Attach(dvc, 0, 1, 0, 1, AttachOptions.Fill | AttachOptions.Expand,
                  AttachOptions.Fill | AttachOptions.Expand, 0, 0);
     // create the scrollbars and pack into the table
     VScrollbar vsb = new VScrollbar(null);
     table.Attach(vsb, 1, 2, 0, 1, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     HScrollbar hsb = new HScrollbar(null);
     table.Attach(hsb, 0, 1, 1, 2, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     // tell the scrollbars to use the DViewerControl widget's adjustments
     vsb.Adjustment = dvc.Vadjustment;
     hsb.Adjustment = dvc.Hadjustment;
     // create debuging label
     l = new Label("debug");
     table.Attach(l, 0, 1, 2, 3, AttachOptions.Fill|AttachOptions.Shrink,
                  AttachOptions.Fill|AttachOptions.Shrink, 0, 0);
     // create DViewer and DEngine
     dv = new GTKViewer(dvc);
     dv.EditFigures = true;
     #if DEBUG
     dv.DebugMessage += new DebugMessageHandler(DebugMessage);
     #endif
     de = new DEngine(null);
     de.AddViewer(dv);
     de.HsmState = DHsmState.Select;
     #if DEBUG
     de.DebugMessage += new DebugMessageHandler(DebugMessage);
     #endif
     de.ContextClick += new ClickHandler(de_ContextClick);
     // add figures
     de.UndoRedo.Start("add initial figures");
     de.AddFigure(new EllipseFigure(new DRect(20, 30, 100, 100), 0));
     RectFigure rf = new RectFigure(new DRect(10, 20, 100, 100), 0);
     rf.Alpha = 0.7;
     rf.Fill = new DColor(80, 80, 80);
     de.AddFigure(rf);
     TextFigure tf = new TextFigure(new DPoint(150, 30), "hello", 0);
     tf.FontName = "Arial";
     tf.Underline = true;
     tf.Strikethrough = true;
     tf.Italics = true;
     de.AddFigure(tf);
     // compositing figure
     Figure f = new CompositedExampleFigure();
     f.Rect = new DRect(20, 150, 50, 50);
     de.AddFigure(f);
     // clock (IEditable) figure
     f = new ClockFigure();
     f.Rect = new DRect(200, 200, 100, 100);
     de.AddFigure(f);
     // triangle figure
     f = new TriangleFigure();
     f.Rect = new DRect(200, 100, 100, 100);
     ((TriangleFigure)f).StrokeWidth = 10;
     de.AddFigure(f);
     // line figure
     f = new LineFigure2(new DPoint(100, 100), new DPoint(200, 200));
     ((LineFigure2)f).StrokeStyle = DStrokeStyle.DashDot;
     ((LineFigure2)f).StrokeWidth = 5;
     de.AddFigure(f);
     de.UndoRedo.Commit();
     de.UndoRedo.ClearHistory();
     // resize window
     Resize(400, 300);
 }
Ejemplo n.º 9
0
 void viewerHandler_MouseMove(DTkViewer dv, DPoint pt)
 {
     if (MouseMove != null)
         MouseMove(dv, pt);
 }
Ejemplo n.º 10
0
 public void AddViewer(DTkViewer dv)
 {
     dv.SetPageSize(PageSize);
     viewerHandler.Add(dv);
 }
Ejemplo n.º 11
0
 void DoDragSelectMouseMove(DTkViewer dv, DPoint pt)
 {
     // rectangular area to update with paint event
     DRect updateRect = new DRect();
     // initial update rect
     updateRect = figureHandler.SelectionFigure.Rect;
     // drag select figure
     figureHandler.SelectionFigure.TopLeft = dragPt;
     figureHandler.SelectionFigure.BottomRight = pt;
     if (figureHandler.SelectionFigure.Width < 0)
     {
         figureHandler.SelectionFigure.X += figureHandler.SelectionFigure.Width;
         figureHandler.SelectionFigure.Width = -figureHandler.SelectionFigure.Width;
     }
     if (figureHandler.SelectionFigure.Height < 0)
     {
         figureHandler.SelectionFigure.Y += figureHandler.SelectionFigure.Height;
         figureHandler.SelectionFigure.Height = -figureHandler.SelectionFigure.Height;
     }
     // final update rect
     updateRect = updateRect.Union(figureHandler.SelectionFigure.Rect);
     // update drawing
     dv.Update(updateRect);
 }
Ejemplo n.º 12
0
 void DoDragFigureMouseMove(DTkViewer dv, DPoint pt)
 {
     // rectangular area to update with paint event
     DRect updateRect = new DRect();
     // move selected figures
     switch (mouseHitTest)
     {
         case DHitTest.Body:
             System.Diagnostics.Trace.Assert(currentFigure != null, "currentFigure is null");
             // drag figure event
             if (DragFigureEvt != null)
                 DragFigureEvt(null, currentFigure, dv.EngineToClient(pt));
             // if figure drag op is cancelled then quit this function
             if (cancelledFigureDrag)
             {
                 cancelledFigureDrag = false;
                 return;
             }
             // bound pt to canvas
             BoundPtToPage(pt);
             // initial update rect
             updateRect = GetBoundingBox(currentFigure);
             foreach (Figure f in figureHandler.SelectedFigures)
                 updateRect = updateRect.Union(GetBoundingBox(f));
             // apply x/y delta to figures
             DPoint dPos = CalcDragDelta(pt);
             if (gridSnapPosition && grid > 0)
             {
                 DPoint o = GridSnapOffset(currentFigure.X + dPos.X, currentFigure.Y + dPos.Y);
                 dPos.X += o.X;
                 dPos.Y += o.Y;
                 pt.X += o.X;
                 pt.Y += o.Y;
             }
             if (dPos.X != 0 || dPos.Y != 0)
                 foreach (Figure f in figureHandler.SelectedFigures)
                     if (!f.Locked)
                     {
                         f.X += dPos.X;
                         f.Y += dPos.Y;
                     }
             // store drag pt for reference later (eg. next mousemove event)
             dragPt = pt;
             // final update rect
             foreach (Figure f in figureHandler.SelectedFigures)
                 updateRect = updateRect.Union(GetBoundingBox(f));
             break;
         case DHitTest.SelectRect:
             goto case DHitTest.Body;
         case DHitTest.Resize:
             System.Diagnostics.Trace.Assert(currentFigure != null, "currentFigure is null");
             // bound pt to canvas
             BoundPtToPage(pt);
             // alert figure we are going to resize it
             currentFigure.BeforeResize();
             // inital update rect
             updateRect = GetBoundingBox(currentFigure);
             // translate point onto the same rotated plane as the figure
             pt = currentFigure.RotatePointToFigure(pt);
             // apply width/height delta to figure
             DPoint dSize = CalcSizeDelta(pt, currentFigure, LockingAspectRatio || currentFigure.LockAspectRatio);
             if (lockInitialAspectRatio && !(figureLockAspectRatioMode == DHsmLockAspectRatioMode.Always || currentFigure.LockAspectRatio))
             {
                 DPoint dSizeUnlocked = CalcSizeDelta(pt, currentFigure, false);
                 if (figureLockAspectRatioMode == DHsmLockAspectRatioMode.Never ||
                     Math.Abs(dSizeUnlocked.X - dSize.X) >= unlockInitalAspectRatioThreshold ||
                     Math.Abs(dSizeUnlocked.Y - dSize.Y) >= unlockInitalAspectRatioThreshold)
                 {
                      lockInitialAspectRatio = false;
                     dSize = dSizeUnlocked;
                 }
             }
             if (currentFigure.Width > 0 && currentFigure.Width + dSize.X < currentFigure.MinSize)
             {
                 dSize.X = currentFigure.MinSize - currentFigure.Width;
                 if (LockingAspectRatio || currentFigure.LockAspectRatio)
                     dSize.Y = (currentFigure.Height / currentFigure.Width) * dSize.X;
             }
             if (currentFigure.Height > 0 && currentFigure.Height + dSize.Y < currentFigure.MinSize)
             {
                 dSize.Y = currentFigure.MinSize - currentFigure.Height;
                 if (LockingAspectRatio || currentFigure.LockAspectRatio)
                     dSize.X = (currentFigure.Width / currentFigure.Height) * dSize.Y;
             }
             DRect oldRect = currentFigure.Rect;
             currentFigure.Width += dSize.X;
             currentFigure.Height += dSize.Y;
             // snap resize
             if (gridSnapResize && grid > 0)
             {
                 DPoint o2 = GridSnapOffset(currentFigure.Width, currentFigure.Height);
                 currentFigure.Width += o2.X;
                 currentFigure.Height += o2.Y;
             }
             DGeom.UpdateRotationPosition(currentFigure, oldRect, currentFigure.Rect);
             // final update rect
             updateRect = updateRect.Union(GetBoundingBox(currentFigure));
             // alert figure we have finished resizing
             currentFigure.AfterResize();
             // debug message
     #if DEBUG
             DoDebugMessage(string.Format("{0} {1}", dSize.X, dSize.Y));
     #endif
             break;
         case DHitTest.RepositionPoint:
             System.Diagnostics.Trace.Assert(currentFigure != null, "currentFigure is null");
             // bound pt to canvas
             BoundPtToPage(pt);
             // inital update rect
             updateRect = GetBoundingBox(currentFigure);
             // get our reposition point interface
             IRepositionPoint rp = (IRepositionPoint)currentFigure;
             // setup points
             DPoint newPoint;
             newPoint = new DPoint(pt.X, pt.Y);
             SetPointDelegate setPoint = delegate(DPoint point)
             {
                 // snap point to grid
                 if (gridSnapLines && grid > 0)
                 {
                     DPoint o3 = GridSnapOffset(point.X, point.Y);
                     point.X += o3.X;
                     point.Y += o3.Y;
                 }
                 // now set point
                 rp.RepositionPoint = point;
             };
             GetRotationalSnapDelegate getRotationalSnap = delegate(double angleRemainder)
             {
                 if (angleRemainder < figureSnapRange)
                     return -angleRemainder;
                 else if (angleRemainder > figureSnapAngle - figureSnapRange)
                     return figureSnapAngle - angleRemainder;
                 else
                     return 0;
             };
             if (rp.AnglePoint != null)
             {
                 // find the current angle of the line and the remainder when divided by the snap angle
                 double currentAngle = DGeom.AngleBetweenPoints(rp.RepositionPoint, rp.AnglePoint);
                 double ar = currentAngle % figureSnapAngle;
                 // reposition line
                 double newAngle;
                 switch (FigureSnapAngleMode)
                 {
                     case DHsmSnapAngleMode.Always:
                         // slide point along snap angle
                         newAngle = DGeom.AngleBetweenPoints(newPoint, rp.AnglePoint);
                         ar = newAngle % figureSnapAngle;
                         if (ar < figureSnapAngle / 2)
                             setPoint(DGeom.RotatePoint(newPoint, rp.AnglePoint, -ar));
                         else
                             setPoint(DGeom.RotatePoint(newPoint, rp.AnglePoint, figureSnapAngle - ar));
                         break;
                     case DHsmSnapAngleMode.Default:
                         if (ar == 0)
                         {
                             // line is snapped, test if new angle will unsnap the line
                             newAngle = DGeom.AngleBetweenPoints(newPoint, rp.AnglePoint);
                             ar = newAngle % figureSnapAngle;
                             if (ar > figureSnapRange && ar < figureSnapAngle - figureSnapRange)
                                 // unsnapped, set new point
                                 setPoint(newPoint);
                             else
                             {
                                 // slide point along snap angle
                                 newPoint = DGeom.RotatePoint(newPoint, rp.AnglePoint, getRotationalSnap(ar));
                                 setPoint(newPoint);
                             }
                         }
                         else
                         {
                             // set new point
                             setPoint(newPoint);
                             // test whether to snap our line
                             newAngle = DGeom.AngleBetweenPoints(newPoint, rp.AnglePoint);
                             ar = newAngle % figureSnapAngle;
                             double rotationalSnap = getRotationalSnap(ar);
                             // snap it
                             if (rotationalSnap != 0)
                                 setPoint(DGeom.RotatePoint(newPoint, rp.AnglePoint, rotationalSnap));
                         }
                         break;
                     case DHsmSnapAngleMode.Never:
                         // set new point
                         setPoint(newPoint);
                         break;
                 }
             }
             else
                 setPoint(newPoint);
             // final update rect
             updateRect = updateRect.Union(GetBoundingBox(currentFigure));
             break;
         case DHitTest.Rotate:
             System.Diagnostics.Trace.Assert(currentFigure != null, "currentFigure is null");
             // initial update rect
             updateRect = GetBoundingBox(currentFigure);
             // apply rotation to figure
             double newRot = GetRotationOfPointComparedToFigure(currentFigure, pt) - dragRot;
             double r = newRot % figureSnapAngle;
             switch (figureSnapAngleMode)
             {
                 case DHsmSnapAngleMode.Always:
                     if (r < figureSnapAngle / 2)
                         currentFigure.Rotation = newRot - r;
                     else
                         currentFigure.Rotation = newRot + figureSnapAngle - r;
                     break;
                 case DHsmSnapAngleMode.Default:
                     if (r < figureSnapRange)
                         currentFigure.Rotation = newRot - r;
                     else if (r > figureSnapAngle - figureSnapRange)
                         currentFigure.Rotation = newRot + figureSnapAngle - r;
                     else
                         currentFigure.Rotation = newRot;
                     break;
                 case DHsmSnapAngleMode.Never:
                     currentFigure.Rotation = newRot;
                     break;
             }
             // final update rect
             updateRect = updateRect.Union(GetBoundingBox(currentFigure));
     #if DEBUG
             // debug message
             DoDebugMessage((currentFigure.Rotation * 180 / Math.PI).ToString());
     #endif
             break;
     }
     // update drawing
     dv.Update(updateRect);
 }
Ejemplo n.º 13
0
 void DoDragFigureMouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     if (btn == DMouseButton.Left)
     {
         // drag figure end event
         if ((mouseHitTest == DHitTest.Body || mouseHitTest == DHitTest.SelectRect) &&
             !currentFigure.Locked && DragFigureEnd != null)
             DragFigureEnd(null, currentFigure, dv.EngineToClient(pt));
         // nullify currentFigure
         currentFigure = null;
         // transition
         TransitionTo(SelectDefault);
     }
 }
Ejemplo n.º 14
0
 public QViewerEvent(int qSignal, DTkViewer dv)
     : base(qSignal)
 {
     this.dv = dv;
 }
Ejemplo n.º 15
0
 public QMouseEvent(int qSignal, DTkViewer dv, DMouseButton button, DPoint pt)
     : base(qSignal, dv)
 {
     this.button = button;
     this.pt = pt;
 }
Ejemplo n.º 16
0
 public QKeyPressEvent(int qSignal, DTkViewer dv, int key)
     : base(qSignal, dv)
 {
     this.key = key;
 }
Ejemplo n.º 17
0
 void dv_MouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     Dispatch(new QMouseEvent((int)DHsmSignals.MouseUp, dv, btn, pt));
 }
Ejemplo n.º 18
0
 void DoDrawingLineMouseMove(DTkViewer dv, DPoint pt)
 {
     // initial update rect
     DRect updateRect = currentFigure.GetSelectRect();
     // bound pt to canvas
     BoundPtToPage(pt);
     // add point
     if (currentFigure is IPolyline)
     {
         if (!(currentFigure is IRepositionPoint))
             ((IPolyline)currentFigure).AddPoint(pt);
         else
             ((IPolyline)currentFigure).LastPoint = pt;
     }
     // update drawing
     dv.Update(updateRect.Union(currentFigure.GetSelectRect()));
 }
Ejemplo n.º 19
0
 void ShowPagePreview(int engineIdx)
 {
     // bound engine index to 0 <-> engines.Count - 1
     if (engineIdx >= engines.Count)
         engineIdx = 0;
     if (engineIdx < 0)
         engineIdx = engines.Count - 1;
     // setup new preview
     if (currentPreviewEngine != null && currentPreviewViewer != null)
         currentPreviewEngine.RemoveViewer(currentPreviewViewer);
     currentPreviewViewer = new WFViewer(wfViewerControl1);
     currentPreviewViewer.AntiAlias = true;
     currentPreviewViewer.EditFigures = false;
     currentPreviewViewer.Preview = true;
     currentPreviewEngine = engines[engineIdx];
     currentPreviewEngine.AddViewer(currentPreviewViewer);
 }
Ejemplo n.º 20
0
 void DoDrawingLineMouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     if (currentFigure is IPolyline)
     {
         if (!(currentFigure is IRepositionPoint))
         {
             // test for finished line
             bool lineNotFinished = false;
             if (((IPolyline)currentFigure).Points.Count < 2)
             {
                 if (UsePolylineDots)
                 {
                     DPoint currentPt = ((IPolyline)currentFigure).Points[0];
                     DPoint newPt = new DPoint(currentPt.X + 0.01, currentPt.Y + 0.01);
                     ((IPolyline)currentFigure).Points.Add(newPt);
                 }
                 else
                     lineNotFinished = true;
             }
             if (!lineNotFinished)
             {
                 // simplify polyline
                 if (SimplifyPolylines && currentFigure is IPolyline)
                 {
                     ((IPolyline)currentFigure).Points = DGeom.SimplifyPolyline(((IPolyline)currentFigure).Points, simplifyPolylinesTolerance);
                     dv.Update(currentFigure.GetSelectRect());
                 }
                 // auto group
                 if (autoGroupPolylineTimeoutMet)
                 {
                     autoGroupPolylineXLimitMet = DGeom.DistXBetweenRects(autoGroupPolylineFigure.GetEncompassingRect(),
                         currentFigure.GetEncompassingRect()) < autoGroupPolylinesXLimit;
                     autoGroupPolylineYLimitMet = DGeom.DistYBetweenRects(autoGroupPolylineFigure.GetEncompassingRect(),
                         currentFigure.GetEncompassingRect()) < autoGroupPolylinesYLimit;
                     if (autoGroupPolylineXLimitMet && autoGroupPolylineYLimitMet)
                     {
                         if (autoGroupPolylineFigure is GroupFigure)
                         {
                             figureHandler.Remove(currentFigure);
                             IChildFigureable cf = (IChildFigureable)autoGroupPolylineFigure;
                             cf.ChildFigures.Add(currentFigure);
                             cf.ChildFigures = cf.ChildFigures;
                         }
                         else if (autoGroupPolylineFigure is IPolyline)
                         {
                             figureHandler.Remove(autoGroupPolylineFigure);
                             figureHandler.Remove(currentFigure);
                             GroupFigure gf = new GroupFigure(new List<Figure>(new Figure[] { autoGroupPolylineFigure, currentFigure }));
                             figureHandler.Add(gf, false);
                             autoGroupPolylineFigure = gf;
                         }
                     }
                     else
                         autoGroupPolylineFigure = currentFigure;
                 }
             }
             autoGroupPolylineStart = Environment.TickCount;
         }
     }
     // commit to undo/redo
     CommitOrRollback(false);
     // transition
     TransitionTo(DrawLineDefault);
 }
Ejemplo n.º 21
0
 public static void PreviewFigure(DEngine de, DTkViewer dv, Type figureClass, DAuthorProperties dap, DPoint viewerSize)
 {
     // add figure de so it shows on the viewer
     de.UndoRedo.Start("blah");
     de.ClearPage();
     Figure f = (Figure)Activator.CreateInstance(figureClass);
     dap.ApplyPropertiesToFigure(f);
     if (f is PolylineFigure)
     {
         DPoints pts = new DPoints();
         pts.Add(new DPoint(viewerSize.X / 4.0, viewerSize.Y / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.25 / 4.0, viewerSize.Y * 1.10 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.50 / 4.0, viewerSize.Y * 1.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.75 / 4.0, viewerSize.Y * 1.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.00 / 4.0, viewerSize.Y * 1.75 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.25 / 4.0, viewerSize.Y * 2.00 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.50 / 4.0, viewerSize.Y * 2.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.75 / 4.0, viewerSize.Y * 2.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 3 / 4.0, viewerSize.Y * 3 / 4.0));
         ((PolylineFigure)f).Points = pts;
     }
     else if (f is ITextable)
         ((ITextable)f).Text = "Aa";
     f.Left = viewerSize.X / 4.0;
     f.Top = viewerSize.Y / 4.0;
     f.Width = viewerSize.X / 2.0;
     f.Height = viewerSize.Y / 2.0;
     if (f is TextFigure)
     {
         f.Left = viewerSize.X / 8.0;
         f.Width = viewerSize.X * 3 / 4.0;
     }
     de.AddFigure(f);
     de.UndoRedo.Commit();
     dv.Update();
 }
Ejemplo n.º 22
0
 public void MouseDown(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     IGlyph glyph;
     if (editing && HitTest(pt, null, out glyph) == DHitTest.Body)
     {
         DRect r = GetClockRect();
         DPoint fhp = FirstHandPoint(r);
         DPoint shp = SecondHandPoint(r);
         if (DGeom.DistBetweenTwoPts(pt, fhp) <= DGeom.DistBetweenTwoPts(pt, shp))
         {
             editingFirstHand = true;
             firstHandAngle.Value = DGeom.AngleBetweenPoints(r.Center, pt);
         }
         else
         {
             editingSecondHand = true;
             secondHandAngle.Value = DGeom.AngleBetweenPoints(r.Center, pt);
         }
         dv.Update(r);
     }
     else
         DoEditFinished();
 }
Ejemplo n.º 23
0
 public void RemoveViewer(DTkViewer dv)
 {
     viewerHandler.Remove(dv);
 }
Ejemplo n.º 24
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);
 }
Ejemplo n.º 25
0
 void viewerHandler_MouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     if (MouseUp != null)
         MouseUp(dv, btn, pt);
 }
Ejemplo n.º 26
0
 void dv_MouseMove(DTkViewer dv, DPoint pt)
 {
     Dispatch(new QMouseEvent((int)DHsmSignals.MouseMove, dv, DMouseButton.NotApplicable, pt));
 }
Ejemplo n.º 27
0
 void de_MouseDown(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     textInsertionPoint = pt;
 }
Ejemplo n.º 28
0
 public void DoubleClick(DTkViewer dv, DPoint pt)
 {
 }
Ejemplo n.º 29
0
 public void MouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     editingFirstHand = false;
     editingSecondHand = false;
 }
Ejemplo n.º 30
0
 // viewer events
 void dv_NeedRepaint(DTkViewer dv,DGraphics dg)
 {
     Figure[] controlFigures = null;
     if (drawSelection || drawEraser)
     {
         controlFigures = new Figure[0];
         if (drawSelection)
         {
             Array.Resize(ref controlFigures, controlFigures.Length + 1);
             controlFigures[controlFigures.Length - 1] = figureHandler.SelectionFigure;
         }
         if (drawEraser)
         {
             Array.Resize(ref controlFigures, controlFigures.Length + 1);
             controlFigures[controlFigures.Length - 1] = figureHandler.EraserFigure;
         }
     }
     dv.Paint(dg, figureHandler.BackgroundFigure, figureHandler.Figures, controlFigures);
 }