Example #1
0
 void IComponentConnector.Connect(int connectionId, object target)
 {
     if (connectionId == 1)
     {
         this.StatePickerEditorControl = (StatePickerEditor)target;
     }
     else
     {
         this._contentLoaded = true;
     }
 }
Example #2
0
        private void Rebuild()
        {
            if (this.EditingProperty == null)
            {
                return;
            }
            this.EditingProperty.Recache();
            this.states.Clear();
            if (this.EditingProperty.ObjectSet.IsHomogenous && this.EditingProperty.ObjectSet.Count > 0)
            {
                BehaviorTargetedTriggerActionNode triggerActionNode = this.EditingProperty.SceneNodeObjectSet.Objects[0] as BehaviorTargetedTriggerActionNode;
                if (triggerActionNode == null || triggerActionNode.TargetObject == null && string.IsNullOrEmpty(triggerActionNode.TargetName))
                {
                    SceneNode editingContainer = this.viewModel.ActiveEditingContainer;
                    SceneNode hostNode         = VisualStateManagerSceneNode.GetHostNode(this.viewModel.ActiveEditingContainer);
                    if (hostNode != null)
                    {
                        foreach (VisualStateGroupSceneNode stateGroupSceneNode in (IEnumerable <VisualStateGroupSceneNode>)VisualStateManagerSceneNode.GetStateGroups(hostNode))
                        {
                            foreach (SceneNode sceneNode in (IEnumerable <VisualStateSceneNode>)stateGroupSceneNode.States)
                            {
                                this.states.Add(new StateInfo(sceneNode.Name, stateGroupSceneNode.Name));
                            }
                        }
                    }
                    ControlTemplateElement controlTemplateElement = this.viewModel.ActiveEditingContainer as ControlTemplateElement;
                    if (controlTemplateElement != null)
                    {
                        IType type = this.viewModel.ProjectContext.ResolveType(controlTemplateElement.ControlTemplateTargetTypeId);
                        foreach (DefaultStateRecord defaultStateRecord in ProjectAttributeHelper.GetDefaultStateRecords(type, (ITypeResolver)(this.viewModel.ProjectContext as ProjectContext)))
                        {
                            this.AddStateInfoIfNeeded(defaultStateRecord.StateName, defaultStateRecord.GroupName, type);
                        }
                    }
                }
                else if (triggerActionNode.TargetNode != null && triggerActionNode.TargetNode.IsViewObjectValid)
                {
                    IViewControl viewControl = triggerActionNode.TargetNode.ViewObject as IViewControl;
                    if (viewControl != null)
                    {
                        object stateManagerHost = viewControl.VisualStateManagerHost;
                        if (stateManagerHost != null)
                        {
                            foreach (object group in (IEnumerable)StatePickerEditor.GetVisualStateGroups(stateManagerHost, (ITypeResolver)triggerActionNode.ProjectContext))
                            {
                                string stateGroupName = this.GetStateGroupName(group);
                                foreach (object state in (IEnumerable)this.GetStates(group))
                                {
                                    this.states.Add(new StateInfo(this.GetStateName(state), stateGroupName));
                                }
                            }
                        }
                        IType type = triggerActionNode.TargetNode.ProjectContext.GetType(triggerActionNode.TargetNode.TargetType);
                        foreach (DefaultStateRecord defaultStateRecord in ProjectAttributeHelper.GetDefaultStateRecords(triggerActionNode.TargetNode.Type, (ITypeResolver)(this.viewModel.ProjectContext as ProjectContext)))
                        {
                            this.AddStateInfoIfNeeded(defaultStateRecord.StateName, defaultStateRecord.GroupName, type);
                        }
                    }
                }
            }
            this.states.RemoveAll((Predicate <StateInfo>)(stateInfo =>
            {
                if (!string.IsNullOrEmpty(stateInfo.GroupName) && !string.IsNullOrEmpty(stateInfo.StateName) && !stateInfo.GroupName.StartsWith(VisualStateManagerSceneNode.SketchFlowAnimationXamlDelimiter, StringComparison.Ordinal))
                {
                    return(stateInfo.StateName.StartsWith("_BlendEditTimeState-", StringComparison.Ordinal));
                }
                return(true);
            }));
            this.statesView = CollectionViewSource.GetDefaultView(this.states);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription();

            groupDescription.PropertyName = "GroupName";
            this.statesView.GroupDescriptions.Clear();
            this.statesView.GroupDescriptions.Add((GroupDescription)groupDescription);
            this.OnPropertyChanged("CurrentState");
            this.OnPropertyChanged("States");
        }