Example #1
0
        internal bool ShouldAppearOnBreadCrumb(ModelItem modelItem, bool checkIfCanBeMadeRoot)
        {
            bool shouldAppearOnBreadCrumb = false;

            if (modelItem != null)
            {
                Type designerType = this.GetDesignerType(modelItem.ItemType);
                if (null != designerType)
                {
                    if (checkIfCanBeMadeRoot)
                    {
                        ActivityDesignerOptionsAttribute options = WorkflowViewService.GetAttribute <ActivityDesignerOptionsAttribute>(modelItem.ItemType);
                        shouldAppearOnBreadCrumb = (typeof(WorkflowViewElement).IsAssignableFrom(designerType) &&
                                                    (typeof(ActivityDesigner) != designerType || ActivityDelegateUtilities.HasActivityDelegate(modelItem.ItemType)) &&
                                                    typeof(WorkflowService) != designerType &&
                                                    (options == null || options.AllowDrillIn));
                    }
                    else
                    {
                        shouldAppearOnBreadCrumb = typeof(WorkflowViewElement).IsAssignableFrom(designerType);
                    }
                }
            }
            return(shouldAppearOnBreadCrumb);
        }
        private static bool HasView(ModelItem modelItem, WorkflowViewService viewService, bool allowDrillIn)
        {
            ActivityDesignerOptionsAttribute options = WorkflowViewService.GetAttribute <ActivityDesignerOptionsAttribute>(modelItem.ItemType);
            Type viewType = viewService.GetDesignerType(modelItem.ItemType);

            return(typeof(WorkflowViewElement).IsAssignableFrom(viewType) && (!allowDrillIn || options == null || options.AllowDrillIn));
        }
        private static bool IsDefaultDesigner(EditingContext context, ModelItem item)
        {
            WorkflowViewService viewService = GetViewService(context);
            Type viewType = viewService.GetDesignerType(item.ItemType);

            return(viewType == typeof(ActivityDesigner));
        }
Example #4
0
        public override void Initialize(EditingContext context)
        {
            this.context = context;
            AttachedPropertiesService propertiesService = this.context.Services.GetService <AttachedPropertiesService>();

            helpService = this.context.Services.GetService <IIntegratedHelpService>();

            oldSelection = this.context.Items.GetValue <Selection>();
            isPrimarySelectionProperty = new AttachedProperty <bool>()
            {
                Getter    = (modelItem) => (this.context.Items.GetValue <Selection>().PrimarySelection == modelItem),
                Name      = "IsPrimarySelection",
                OwnerType = typeof(Object)
            };

            isSelectionProperty = new AttachedProperty <bool>()
            {
                Getter    = (modelItem) => (((IList)this.context.Items.GetValue <Selection>().SelectedObjects).Contains(modelItem)),
                Name      = "IsSelection",
                OwnerType = typeof(Object)
            };


            propertiesService.AddProperty(isPrimarySelectionProperty);
            propertiesService.AddProperty(isSelectionProperty);



            if (this.context.Services.GetService <ViewService>() == null)
            {
                view = new System.Activities.Presentation.View.DesignerView(this.context);
                WorkflowViewService      viewService      = new WorkflowViewService(context);
                WorkflowViewStateService viewStateService = new WorkflowViewStateService(context);
                this.context.Services.Publish <ViewService>(viewService);
                this.context.Services.Publish <VirtualizedContainerService>(new VirtualizedContainerService(this.context));
                this.context.Services.Publish <ViewStateService>(viewStateService);
                this.context.Services.Publish <DesignerView>(view);

                WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService();
                annotationService.Initialize(this.context, view.scrollViewer);
                this.context.Services.Publish <AnnotationAdornerService>(annotationService);

                this.context.Services.Subscribe <ModelService>(delegate(ModelService modelService)
                {
                    this.modelService = modelService;
                    if (modelService.Root != null)
                    {
                        view.MakeRootDesigner(modelService.Root);
                    }
                    view.RestoreDesignerStates();
                    this.context.Items.Subscribe <Selection>(new SubscribeContextCallback <Selection>(OnItemSelected));
                });
            }

            if (helpService != null)
            {
                helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || value == DependencyProperty.UnsetValue)
            {
                return(false);
            }

            ActivityDesignerOptionsAttribute attr = WorkflowViewService.GetAttribute <ActivityDesignerOptionsAttribute>(value.GetType());

            return(attr == null || !attr.AlwaysCollapseChildren);
        }
        internal static bool DoesParentAlwaysCollapseChildren(ModelItem modelItem, EditingContext context)
        {
            bool parentAlwaysCollapsesChild = false;
            Type parentDesignerType         = GetParentDesignerType(modelItem, context);

            if (typeof(WorkflowViewElement).IsAssignableFrom(parentDesignerType))
            {
                ActivityDesignerOptionsAttribute options = WorkflowViewService.GetAttribute <ActivityDesignerOptionsAttribute>(parentDesignerType);
                parentAlwaysCollapsesChild = (options != null && options.AlwaysCollapseChildren);
            }
            return(parentAlwaysCollapsesChild);
        }
        // Get the first parent ModelItem that has a view
        internal static ModelItem GetParentModelItemWithView(ModelItem modelItem, EditingContext context, bool allowDrillIn)
        {
            if (modelItem == null || modelItem.Parent == null)
            {
                return(null);
            }

            WorkflowViewService viewService = GetViewService(context);

            return(ModelUtilities.ReverseFindFirst(modelItem.Parent, (ModelItem current) =>
            {
                return HasView(current, viewService, allowDrillIn);
            }));
        }
        // Determines whether a particular ModelItem's view will be visible for a given breadcrumb root.
        //It depends on whether the intermediate designers are expanded or collapsed.
        internal static bool IsViewVisible(ModelItem child, ModelItem root, EditingContext context)
        {
            if (child == root)
            {
                return(!IsDefaultDesigner(context, root));
            }

            if (child.Parent == null)
            {
                return(false);
            }

            WorkflowViewService viewService = GetViewService(context);
            ModelItem           parent      = ModelUtilities.ReverseFindFirst(child.Parent, (ModelItem current) =>
            {
                return(object.Equals(current, root) ||
                       HasView(current, viewService, false) &&
                       (!IsViewExpanded(current, context) || IsDefaultDesigner(context, current)));
            });

            return(object.Equals(parent, root) && !IsDefaultDesigner(context, root));
        }