Beispiel #1
0
        public void RenameTemplateIDs()
        {
            if (this.VisualTreeRoot == null)
            {
                return;
            }
            SceneNodeIDHelper           sceneNodeIdHelper = new SceneNodeIDHelper(this.ViewModel, (SceneNode)this.VisualTreeRoot);
            Dictionary <string, string> renameTable       = new Dictionary <string, string>();

            foreach (SceneElement sceneElement in SceneElementHelper.GetElementTree((SceneElement)this.VisualTreeRoot))
            {
                string name = sceneElement.Name;
                if (name == null || name.StartsWith("~ChildID"))
                {
                    sceneNodeIdHelper.SetValidName((SceneNode)sceneElement, sceneElement.TargetType.Name);
                    if (name != null && sceneElement.Name != name)
                    {
                        renameTable.Add(name, sceneElement.Name);
                    }
                }
            }
            IStoryboardContainer storyboardContainer = (IStoryboardContainer)this;

            if (storyboardContainer == null)
            {
                return;
            }
            this.ViewModel.AnimationEditor.UpdateStoryboardOnElementRename(storyboardContainer, renameTable);
        }
Beispiel #2
0
 public bool IsValidElementID(SceneNode sceneNode, string candidateID)
 {
     if (!SceneNodeIDHelper.IsCSharpID(candidateID))
     {
         return(false);
     }
     return(!this.NameAlreadyUsed(sceneNode != null ? sceneNode.DocumentNode : (DocumentNode)null, candidateID));
 }
Beispiel #3
0
        public VisualStateSceneNode AddState(SceneNode rootNode, string name)
        {
            VisualStateSceneNode visualStateSceneNode = VisualStateSceneNode.Factory.Instantiate(this.ViewModel);

            visualStateSceneNode.ShouldSerialize = this.ShouldSerialize;
            this.States.Add(visualStateSceneNode);
            string validElementId = new SceneNodeIDHelper(this.ViewModel, rootNode).GetValidElementID((SceneNode)visualStateSceneNode, name);

            visualStateSceneNode.Name = validElementId;
            return(visualStateSceneNode);
        }
Beispiel #4
0
        public string GetValidElementID(SceneNode sceneNode, string namePrefix)
        {
            namePrefix = SceneNodeIDHelper.ToCSharpID(namePrefix);
            string namePrefix1 = this.GetNamePrefix(namePrefix);

            if (this.NameAlreadyUsed(sceneNode.DocumentNode, namePrefix))
            {
                return(this.GetFirstAvailableIndexedName(sceneNode.DocumentNode, namePrefix1));
            }
            return(namePrefix);
        }
        private static string CreateBeginActionName(ITriggerContainer storyboardContainer, string timelineName)
        {
            string            str               = timelineName + StringTable.TriggerDefaultActionName;
            SceneNode         sceneNode         = (SceneNode)storyboardContainer;
            SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(sceneNode.ViewModel, sceneNode);

            if (!sceneNodeIdHelper.IsValidElementID(sceneNode, str))
            {
                str = sceneNodeIdHelper.GetValidElementID(sceneNode, str);
            }
            return(str);
        }
Beispiel #6
0
 public string GetValidCopiedElementID(SceneNode sceneNode, string candidateID)
 {
     if (candidateID != null)
     {
         candidateID = SceneNodeIDHelper.ToCSharpID(candidateID);
         if (candidateID.Length == 0 || this.NameAlreadyUsed(sceneNode.DocumentNode, candidateID))
         {
             string namePrefix = this.GetNamePrefix(sceneNode.Name);
             if (namePrefix == null || !namePrefix.EndsWith(StringTable.SceneModelDuplicateLabelSuffix, StringComparison.Ordinal))
             {
                 namePrefix = candidateID + StringTable.SceneModelDuplicateLabelSuffix;
             }
             candidateID = this.GetValidElementID(sceneNode, namePrefix);
         }
     }
     return(candidateID);
 }
Beispiel #7
0
        public static void EnsureNameAvailable(SceneNode rootNode, string name)
        {
            SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(rootNode.ViewModel, rootNode);

            if (sceneNodeIdHelper.IsValidElementID(rootNode, name))
            {
                return;
            }
            DocumentNode node         = sceneNodeIdHelper.FindNode(name);
            SceneElement sceneElement = rootNode.ViewModel.GetSceneNode(node) as SceneElement;

            if (sceneElement == null)
            {
                return;
            }
            sceneElement.Name = sceneNodeIdHelper.GetValidElementID(rootNode, name);
        }
Beispiel #8
0
        public static VisualStateGroupSceneNode AddStateGroup(SceneNode ownerNode, SceneNode rootNode, string groupName)
        {
            ProjectContext projectContext = (ProjectContext)ownerNode.ProjectContext.GetService(typeof(ProjectContext));

            ToolkitHelper.AddToolkitReferenceIfNeeded((ITypeResolver)projectContext, ownerNode.DesignerContext.ViewUpdateManager);
            IType type = projectContext.ResolveType(ProjectNeutralTypes.VisualStateGroup);

            if (type == null || projectContext.PlatformMetadata.IsNullType((ITypeId)type))
            {
                return((VisualStateGroupSceneNode)null);
            }
            VisualStateGroupSceneNode stateGroupSceneNode = VisualStateGroupSceneNode.Factory.Instantiate(ownerNode.ViewModel);

            VisualStateManagerSceneNode.GetStateGroups(ownerNode).Add(stateGroupSceneNode);
            string validElementId = new SceneNodeIDHelper(ownerNode.ViewModel, rootNode).GetValidElementID((SceneNode)stateGroupSceneNode, groupName);

            stateGroupSceneNode.Name = validElementId;
            return(stateGroupSceneNode);
        }