Beispiel #1
0
        /// <summary>
        /// Ensure a point on the diagram is visible.
        /// </summary>
        /// <param name="point">Relative point in pixels</param>
        public void EnsurePointVisible(Point point)
        {
            PointD zeroPoint  = myClientView.DeviceToWorld(new Point(0, 0));
            PointD worldPoint = myClientView.DeviceToWorld(point);

            myClientView.EnsureVisible(new RectangleD(new PointD(worldPoint.X - zeroPoint.X, worldPoint.Y - zeroPoint.Y), new SizeD(1d, 1d)));
            SendKeys.Flush();
        }
 private PointD ImageToDiagram(Point imagePoint)
 {
     Debug.Assert(Enabled);
     if (Enabled)
     {
         var s = DiagramClientView.DeviceToWorld(
             new Size(
                 (int)(imagePoint.X / _imageScale),
                 (int)(imagePoint.Y / _imageScale)));
         return(new PointD(s.Width, s.Height));
     }
     else
     {
         return(PointD.Empty);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Helper function for TranslateAccessibleObject and EnsureAccessibleObjectVisible
        /// </summary>
        private DiagramItem TranslateAccessibleObjectToDiagramItem(AccessibleObject accessibleObject, bool returnShape)
        {
            if (accessibleObject == null)
            {
                return(null);
            }
            DiagramItem        hitItem    = null;
            DiagramClientView  clientView = myClientView;
            DiagramHitTestInfo hitInfo    = new DiagramHitTestInfo(clientView);
            RectangleD         boundsD    = clientView.DeviceToWorld(clientView.RectangleToClient(accessibleObject.Bounds));

            if (clientView.Diagram.DoHitTest(boundsD.Center, hitInfo, false))
            {
                hitItem = hitInfo.HitDiagramItem;
                if (!returnShape)
                {
                    // Wind back out the parent stack if the hit test went too far
                    if (hitItem.SubField != null)
                    {
                        if (!(accessibleObject is SubfieldAccessibleObject))
                        {
                            if (!(accessibleObject is FieldAccessibleObject))
                            {
                                hitItem = new DiagramItem(hitItem.Shape);
                            }
                            else
                            {
                                hitItem = new DiagramItem(hitItem.Shape, hitItem.Field);
                            }
                        }
                    }
                    else if (hitItem.Field != null && !(accessibleObject is FieldAccessibleObject))
                    {
                        hitItem = new DiagramItem(hitItem.Shape);
                    }
                }
            }
            return(hitItem);
        }