コード例 #1
0
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                FrameworkElement fe = e.OriginalSource as FrameworkElement;
                if (fe != null)
                {
                    object           original             = fe.DataContext;
                    ActivityDesigner baseActivityDesigner = original as ActivityDesigner;
                    if (baseActivityDesigner == null)
                    {
                        baseActivityDesigner = this.ActivityDesignerFinder((DependencyObject)e.OriginalSource);
                    }

                    if (baseActivityDesigner != null)
                    {
                        MessageBox.Show(baseActivityDesigner.GetHashCode().ToString());
                        e.Handled = true;
                    }
                }
            }
        }
        public static void GetRoutingObstacles(IServiceProvider serviceProvider, object source, object target, out List <Rectangle> rectanglesToExclude, out List <Point> linesToExclude, out List <Point> pointsToExclude)
        {
            AmbientTheme     ambientTheme                 = WorkflowTheme.CurrentTheme.AmbientTheme;
            ActivityDesigner safeRootDesigner             = ActivityDesigner.GetSafeRootDesigner(serviceProvider);
            ConnectionPoint  point                        = source as ConnectionPoint;
            Point            point2                       = (point != null) ? point.Location : ((Point)source);
            ActivityDesigner designer                     = (point != null) ? point.AssociatedDesigner : safeRootDesigner.HitTest(point2).AssociatedDesigner;
            ConnectionPoint  point3                       = target as ConnectionPoint;
            Point            point4                       = (point3 != null) ? point3.Location : ((Point)target);
            ActivityDesigner designer3                    = (point3 != null) ? point3.AssociatedDesigner : safeRootDesigner.HitTest(point4).AssociatedDesigner;
            Dictionary <int, ActivityDesigner> dictionary = new Dictionary <int, ActivityDesigner>();

            if (designer != null)
            {
                for (CompositeActivityDesigner designer4 = designer.ParentDesigner; designer4 != null; designer4 = designer4.ParentDesigner)
                {
                    if (dictionary.ContainsKey(designer4.GetHashCode()))
                    {
                        break;
                    }
                    dictionary.Add(designer4.GetHashCode(), designer4);
                }
            }
            if (designer3 != null)
            {
                for (CompositeActivityDesigner designer5 = designer3.ParentDesigner; designer5 != null; designer5 = designer5.ParentDesigner)
                {
                    if (dictionary.ContainsKey(designer5.GetHashCode()))
                    {
                        break;
                    }
                    dictionary.Add(designer5.GetHashCode(), designer5);
                }
            }
            rectanglesToExclude = new List <Rectangle>();
            pointsToExclude     = new List <Point>();
            foreach (CompositeActivityDesigner designer6 in dictionary.Values)
            {
                ReadOnlyCollection <ActivityDesigner> containedDesigners = designer6.ContainedDesigners;
                for (int i = 0; i < containedDesigners.Count; i++)
                {
                    ActivityDesigner designer7 = containedDesigners[i];
                    if ((designer7.IsVisible && !dictionary.ContainsKey(designer7.GetHashCode())) && ((designer7 != designer) && (designer7 != designer3)))
                    {
                        Rectangle bounds = designer7.Bounds;
                        bounds.Inflate(ambientTheme.Margin);
                        rectanglesToExclude.Add(bounds);
                    }
                }
            }
            linesToExclude = new List <Point>();
            if (((designer != null) && (designer == designer3)) && !designer.IsRootDesigner)
            {
                linesToExclude.AddRange(GetDesignerEscapeCover(designer, new object[] { source, target }));
            }
            else
            {
                if ((designer != null) && !designer.IsRootDesigner)
                {
                    linesToExclude.AddRange(GetDesignerEscapeCover(designer, new object[] { source }));
                }
                if ((designer3 != null) && !designer3.IsRootDesigner)
                {
                    bool flag = true;
                    for (CompositeActivityDesigner designer8 = (designer != null) ? designer.ParentDesigner : null; designer8 != null; designer8 = (designer != null) ? designer8.ParentDesigner : null)
                    {
                        if (designer3 == designer8)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        linesToExclude.AddRange(GetDesignerEscapeCover(designer3, new object[] { target }));
                    }
                }
            }
        }