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 void AddProperty(AttachedProperty property)
 {
     if (property == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("property"));
     }
     if (string.IsNullOrEmpty(property.Name))
     {
         throw FxTrace.Exception.AsError(new ArgumentException(SR.AttachedPropertyNameShouldNotBeEmpty));
     }
     this.properties.Add(property);
 }
 public void AddSupportForUpdatingTypeArgument(Type modelItemType)
 {
     AttachedProperty<Type> typeArgumentProperty = new AttachedProperty<Type>
     {
         Name = TypeArgumentPropertyName,
         OwnerType = modelItemType,
         Getter = (modelItem) => modelItem.Parent == null ? null : GetTypeArgument(modelItem),
         Setter = (modelItem, value) => UpdateTypeArgument(modelItem, value),
         IsBrowsable = true
     };
     this.context.Services.GetService<AttachedPropertiesService>().AddProperty(typeArgumentProperty);
 }
 public void AddProperty(AttachedProperty property)
 {
     if (property == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("property"));
     }
     if (string.IsNullOrEmpty(property.Name))
     {
         throw FxTrace.Exception.AsError(new ArgumentException(SR.AttachedPropertyNameShouldNotBeEmpty));
     }
     this.properties.Add(property);
 }
Example #5
0
        public void AddSupportForUpdatingTypeArgument(Type modelItemType)
        {
            AttachedProperty <Type> typeArgumentProperty = new AttachedProperty <Type>
            {
                Name        = TypeArgumentPropertyName,
                OwnerType   = modelItemType,
                Getter      = (modelItem) => modelItem.Parent == null ? null : GetTypeArgument(modelItem),
                Setter      = (modelItem, value) => UpdateTypeArgument(modelItem, value),
                IsBrowsable = true
            };

            this.context.Services.GetService <AttachedPropertiesService>().AddProperty(typeArgumentProperty);
        }
 void AttachDisplayName()
 {
     AttachedPropertiesService attachedPropertiesService = this.Context.Services.GetService<AttachedPropertiesService>();
     Fx.Assert(attachedPropertiesService != null, "AttachedPropertiesService is not available.");
     Type modelItemType = this.ModelItem.ItemType;
     foreach (AttachedProperty property in attachedPropertiesService.GetAttachedProperties(modelItemType))
     {
         if (property.Name == "DisplayName" && property.OwnerType == modelItemType)
         {
             return;
         }
     }
     AttachedProperty<string> displayNameProperty = new AttachedProperty<string>
     {
         Name = "DisplayName",
         OwnerType = modelItemType,
         Getter = (modelItem) => { return "Case"; }
     };
     attachedPropertiesService.AddProperty(displayNameProperty);
 }
 public AttachedPropertyDescriptor(AttachedProperty AttachedProperty, ModelItem owner)
     : base(AttachedProperty.Name, null)
 {
     this.AttachedProperty = AttachedProperty;
     this.owner            = owner;
 }
 public AttachedPropertyDescriptor(AttachedProperty AttachedProperty, ModelItem owner)
     : base(AttachedProperty.Name, null)
 {
     this.AttachedProperty = AttachedProperty;
     this.owner = owner;
 }
        internal void Initialize(EditingContext editingContext, ScrollViewer scrollViewer)
        {
            this.scrollViewer = scrollViewer;
            this.enabled = editingContext.Services.GetService<DesignerConfigurationService>().AnnotationEnabled;

            if (!this.enabled)
            {
                return;
            }

            AttachedPropertiesService attachedPropertiesService = editingContext.Services.GetService<AttachedPropertiesService>();
            AttachedProperty<string> attachedProperty = new AttachedProperty<string>
            {
                IsBrowsable = false,
                IsVisibleToModelItem = true,
                Name = Annotation.AnnotationTextPropertyName,
                OwnerType = typeof(object),
                Getter = (modelItem) =>
                {
                    string annotation = null;
                    AttachablePropertyServices.TryGetProperty<string>(modelItem.GetCurrentValue(), Annotation.AnnotationTextProperty, out annotation);
                    return annotation;
                },
                Setter = (modelItem, value) =>
                {
                    string oldValue = null;
                    AttachablePropertyServices.TryGetProperty<string>(modelItem.GetCurrentValue(), Annotation.AnnotationTextProperty, out oldValue);
                    if (oldValue == value)
                    {
                        return;
                    }

                    ModelTreeManager treeManager = modelItem.GetEditingContext().Services.GetService<ModelTreeManager>();

                    AttachablePropertyChange change = new AttachablePropertyChange()
                    {
                        Owner = modelItem,
                        AttachablePropertyIdentifier = Annotation.AnnotationTextProperty,
                        OldValue = oldValue,
                        NewValue = value,
                        PropertyName = Annotation.AnnotationTextPropertyName
                    };

                    treeManager.AddToCurrentEditingScope(change);
                }
            };

            attachedPropertiesService.AddProperty(attachedProperty);
        }
        private void SetPropertyValue(ModelItem oldModelItem, AttachedProperty property, ModelItem newModelItem)
        {
            // update the previous ModelItem (what was current before)
            if (oldModelItem != null)
            {
                property.NotifyPropertyChanged(oldModelItem);
            }

            // update the current Modelitem
            if (newModelItem != null)
            {
                property.NotifyPropertyChanged(newModelItem);
            }
        }
        void OnAttachedPropertiesServiceAvailable(AttachedPropertiesService attachedPropertiesService)
        {
            this.isBreakpointEnabledProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => IsBreakpointOfType(modelItem, BreakpointTypes.Enabled),
                    Name = "IsBreakpointEnabled",
                    OwnerType = typeof(object)
                };

            this.isBreakpointBoundedProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => IsBreakpointOfType(modelItem, BreakpointTypes.Bounded),
                    Name = "IsBreakpointBounded",
                    OwnerType = typeof(object)
                };

            this.isBreakpointConditionalProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => IsBreakpointOfType(modelItem, BreakpointTypes.Conditional),
                    Name = "IsBreakpointConditional",
                    OwnerType = typeof(object)
                };

            this.isCurrentLocationProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => IsCurrentLocation(modelItem),
                    Name = "IsCurrentLocation",
                    OwnerType = typeof(object)
                };

            this.isCurrentContextProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => IsCurrentContext(modelItem),
                    Name = "IsCurrentContext",
                    OwnerType = typeof(object)
                };

            attachedPropertiesService.AddProperty(isBreakpointEnabledProperty);
            attachedPropertiesService.AddProperty(isBreakpointBoundedProperty);
            attachedPropertiesService.AddProperty(isBreakpointConditionalProperty);
            attachedPropertiesService.AddProperty(isCurrentLocationProperty);
            attachedPropertiesService.AddProperty(isCurrentContextProperty);
        }
 public DisplayNameUpdater(EditingContext context)
 {
     activityBuilderDisplayNameProperty = new AttachedProperty<string>
     {
         Name = "DisplayName",
         OwnerType = typeof(ActivityBuilder),
         Getter = (modelItem) => ViewUtilities.GetActivityBuilderDisplayName(modelItem)
     };
     activityTemplateFactoryBuilderDisplayNameProperty = new AttachedProperty<string>
     {
         Name = "DisplayName",
         OwnerType = typeof(ActivityTemplateFactoryBuilder),
         Getter = (modelItem) => ViewUtilities.GetActivityBuilderDisplayName(modelItem)
     };
     AttachedPropertiesService attachedPropertiesService = context.Services.GetService<AttachedPropertiesService>();
     attachedPropertiesService.AddProperty(activityBuilderDisplayNameProperty);
     attachedPropertiesService.AddProperty(activityTemplateFactoryBuilderDisplayNameProperty);
     context.Services.GetService<ModelService>().ModelChanged += new EventHandler<ModelChangedEventArgs>(ModelChanged);
 }
        void OnAttachedPropertiesServiceAvailable(AttachedPropertiesService attachedPropertiesService)
        {
            this.validationStateProperty = new AttachedProperty<ValidationState>()
            {
                Getter = (modelItem) => GetValidationState(modelItem),
                Name = "ValidationState",
                OwnerType = typeof(object)
            };

            attachedPropertiesService.AddProperty(this.validationStateProperty);

            this.validationMessageProperty = new AttachedProperty<string>()
            {
                Getter = (modelItem) => GetValidationMessage(modelItem),
                Name = "ValidationMessage",
                OwnerType = typeof(object)
            };

            attachedPropertiesService.AddProperty(this.validationMessageProperty);
        }