Exemple #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));
        }
        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);
        }
Exemple #5
0
        private DrawingBrush GetIconByVisualValue()
        {
            if (this.VisualValue != null)
            {
                DrawingBrush icon          = null;
                Type         modelItemType = this.VisualValue.ItemType;
                if (modelItemType.IsGenericType)
                {
                    // If Type is generic type, whatever T, it should display same icon, so use generic type instead.
                    modelItemType = this.VisualValue.ItemType.GetGenericTypeDefinition();
                }

                // If the user specifies the attribute, then the Designer would be providing the icon,
                // bypassing the pipeline of retrieving the icons via reflection and attached properties.
                ActivityDesignerOptionsAttribute attr = ExtensibilityAccessor.GetAttribute <ActivityDesignerOptionsAttribute>(modelItemType);
                if (attr != null && attr.OutlineViewIconProvider != null)
                {
                    icon = attr.OutlineViewIconProvider(this.VisualValue);
                }

                if (icon == null && !TreeViewItemViewModel.IconCache.TryGetValue(modelItemType, out icon))
                {
                    EditingContext      context             = this.VisualValue.GetEditingContext();
                    ViewService         service             = context.Services.GetService <ViewService>();
                    WorkflowViewService workflowViewService = service as WorkflowViewService;
                    ActivityDesigner    designer            = null;

                    // first try to create an detached view element that won't participate in the designer,
                    // if the view service is WorkflowViewService
                    if (workflowViewService != null)
                    {
                        designer = workflowViewService.CreateDetachedViewElement(this.VisualValue) as ActivityDesigner;
                        icon     = GetIconFromUnInitializedDesigner(designer);
                    }
                    else
                    {
                        // fall back if the view service is not the default implementation
                        // We only need to get the icon from the designer, so we don't need to make sure the view is parented.
                        designer = this.VisualValue.View as ActivityDesigner;
                        if (designer == null && service != null)
                        {
                            designer = service.GetView(this.VisualValue) as ActivityDesigner;
                        }

                        if (designer != null)
                        {
                            if (designer.Icon != null || designer.IsLoaded)
                            {
                                icon = designer.Icon;
                            }
                            else
                            {
                                icon = GetIconFromUnInitializedDesigner(designer);
                            }
                        }
                    }

                    // Cache even a null icon since answers found above won't change within this AppDomain
                    TreeViewItemViewModel.IconCache.Add(modelItemType, icon);
                }

                return(icon);
            }
            else
            {
                return(null);
            }
        }