예제 #1
0
        private DesignerGlyph[] CreateConnectorDragDropGlyphs()
        {
            WorkflowView    parentView = base.ParentView;
            DragDropManager service    = base.GetService(typeof(DragDropManager)) as DragDropManager;

            if (((parentView == null) || (service == null)) || (!parentView.DragDropInProgress || (base.DrawingState != ActivityDesigner.DrawingStates.Valid)))
            {
                return(new DesignerGlyph[0]);
            }
            List <DesignerGlyph> list         = new List <DesignerGlyph>();
            Rectangle            rectangle    = parentView.ClientRectangleToLogical(new Rectangle(Point.Empty, parentView.ViewPortSize));
            AmbientTheme         ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            Rectangle[] connectors        = this.GetConnectors();
            Rectangle   helpTextRectangle = this.HelpTextRectangle;

            for (int i = 0; i < connectors.Length; i++)
            {
                if ((rectangle.IntersectsWith(connectors[i]) && (i != this.CurrentDropTarget)) && service.IsValidDropContext(new ConnectorHitTestInfo(this, HitTestLocations.Designer, i)))
                {
                    Point empty = Point.Empty;
                    if (helpTextRectangle.IsEmpty)
                    {
                        empty = new Point((connectors[i].Location.X + (connectors[i].Size.Width / 2)) + 1, connectors[i].Location.Y + (connectors[i].Size.Height / 2));
                    }
                    else
                    {
                        empty = new Point((helpTextRectangle.Left + (helpTextRectangle.Width / 2)) + 1, helpTextRectangle.Top - (ambientTheme.DropIndicatorSize.Height / 2));
                    }
                    list.Add(new ConnectorDragDropGlyph(i, empty));
                }
            }
            return(list.ToArray());
        }
        private DesignerGlyph GlyphFromPoint(Point point, out ActivityDesigner activityDesigner)
        {
            activityDesigner = null;
            WorkflowView parentView = base.ParentView;

            if (parentView != null)
            {
                RectangleCollection rectangles = new RectangleCollection();
                foreach (ActivityDesigner designer in this.GetActivityDesigners(parentView.ClientRectangleToLogical(new Rectangle(Point.Empty, parentView.ViewPortSize))))
                {
                    if (!rectangles.IsPointInsideAnyRectangle(point))
                    {
                        foreach (DesignerGlyph glyph in this.GetDesignerGlyphs(designer))
                        {
                            if (glyph.GetBounds(designer, false).Contains(point) && glyph.CanBeActivated)
                            {
                                activityDesigner = designer;
                                return(glyph);
                            }
                        }
                    }
                    rectangles.AddRectangle(designer.Bounds);
                }
            }
            return(null);
        }
예제 #3
0
        private DesignerGlyph[] CreateConnectorDragDropGlyphs()
        {
            //see if there's a drag'n'drop operation going on
            WorkflowView    parentView      = ParentView;
            DragDropManager dragDropManager = GetService(typeof(DragDropManager)) as DragDropManager;

            if (parentView == null || dragDropManager == null || !parentView.DragDropInProgress || DrawingState != DrawingStates.Valid)
            {
                return new DesignerGlyph[] { }
            }
            ;

            List <DesignerGlyph> glyphs          = new List <DesignerGlyph>();
            Rectangle            logicalViewPort = parentView.ClientRectangleToLogical(new Rectangle(Point.Empty, parentView.ViewPortSize));
            AmbientTheme         ambientTheme    = WorkflowTheme.CurrentTheme.AmbientTheme;

            Rectangle[] connectors        = GetConnectors();
            Rectangle   helpTextRectangle = HelpTextRectangle;

            for (int i = 0; i < connectors.Length; i++)
            {
                if (logicalViewPort.IntersectsWith(connectors[i]) && i != CurrentDropTarget && dragDropManager.IsValidDropContext(new ConnectorHitTestInfo(this, HitTestLocations.Designer, i)))
                {
                    Point glyphLocation = Point.Empty;
                    if (helpTextRectangle.IsEmpty)
                    {
                        glyphLocation = new Point(connectors[i].Location.X + connectors[i].Size.Width / 2 + 1, connectors[i].Location.Y + connectors[i].Size.Height / 2);
                    }
                    else
                    {
                        glyphLocation = new Point(helpTextRectangle.Left + helpTextRectangle.Width / 2 + 1, helpTextRectangle.Top - ambientTheme.DropIndicatorSize.Height / 2);
                    }

                    glyphs.Add(new ConnectorDragDropGlyph(i, glyphLocation));
                }
            }

            return(glyphs.ToArray());
        }