コード例 #1
0
        internal void RegisterAttachedProperty <T>(string propertyName, bool isBrowsable, bool isVisibleToModelItem, T defaultValue)
        {
            AttachedProperty <T> attachedProperty = new AttachedProperty <T>
            {
                IsBrowsable          = isBrowsable,
                IsVisibleToModelItem = isVisibleToModelItem,
                Name      = propertyName,
                OwnerType = modelType,
                Getter    = (modelItem) =>
                {
                    T result = (T)viewStateService.RetrieveViewState(modelItem, propertyName);
                    return(result == null ? defaultValue : result);
                },
                Setter = (modelItem, value) =>
                {
                    if (value == null || value.Equals(defaultValue))
                    {
                        viewStateService.StoreViewStateWithUndo(modelItem, propertyName, null);
                    }
                    else
                    {
                        viewStateService.StoreViewStateWithUndo(modelItem, propertyName, value);
                    }
                }
            };

            attachedPropertiesService.AddProperty(attachedProperty);
            attachedProperties.Add(propertyName, attachedProperty);
        }
コード例 #2
0
        protected override void OnModelItemChanged(object newItem)
        {
            ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>();

            if (viewStateService != null)
            {
                // Make StateMachine designer always collapsed by default, but only if the user didn't explicitly specify collapsed or expanded.
                bool?isExpanded = (bool?)viewStateService.RetrieveViewState((ModelItem)newItem, ExpandViewStateKey);
                if (isExpanded == null)
                {
                    viewStateService.StoreViewState((ModelItem)newItem, ExpandViewStateKey, false);
                }
            }
            base.OnModelItemChanged(newItem);
        }
コード例 #3
0
        void UpdateViewState(string oldValue, string newValue)
        {
            EditingContext   context          = this.flowSwitchModelItem.GetEditingContext();
            ViewStateService viewStateService = (ViewStateService)context.Services.GetService(typeof(ViewStateService));

            if (viewStateService != null)
            {
                object viewState = viewStateService.RetrieveViewState(this.flowSwitchModelItem, oldValue);
                if (viewState != null)
                {
                    viewStateService.StoreViewStateWithUndo(this.flowSwitchModelItem, oldValue, null);
                    viewStateService.StoreViewStateWithUndo(this.flowSwitchModelItem, newValue, viewState);
                }
            }
        }
コード例 #4
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.Context.Items.Subscribe <Selection>(OnSelectionChanged);
            this.ModelItem.PropertyChanged += OnModelItemPropertyChanged;

            ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>();

            foreach (ModelItem modelItem in this.ModelItem.Properties["Cases"].Dictionary.Properties["ItemsCollection"].Collection)
            {
                bool?isExpanded = (bool?)viewStateService.RetrieveViewState(modelItem, ExpandViewStateKey);
                if (isExpanded != null && isExpanded.Value)
                {
                    this.SelectedCase = modelItem;
                    CollapseDefaultView();
                    break;
                }
            }
        }
コード例 #5
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.Context.Items.Subscribe <Selection>(OnSelectionChanged);
            // at this time, this.ModelItem is already set
            this.ModelItem.PropertyChanged += OnModelItemPropertyChanged;
            this.ModelItem.Properties[CatchesPropertyName].Collection.CollectionChanged += OnModelItemCollectionChanged;

            ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>();

            foreach (ModelItem modelItem in this.ModelItem.Properties["Catches"].Collection)
            {
                bool?isExpanded = (bool?)viewStateService.RetrieveViewState(modelItem, ExpandViewStateKey);
                if (isExpanded != null && isExpanded.Value)
                {
                    this.SelectedCatch = modelItem;
                    CollapseTryView();
                    CollapseFinallyView();
                    break;
                }
            }
        }