Exemple #1
0
        public void lineScenes_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            StoryLineViewModel storylineModel = sender as StoryLineViewModel;
            if (storylineModel == null)
            {
                return;
            }

            StoryViewModel storyModel = storylineModel.StoryModel;
            Story story = storyModel.Story;

            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
            {
                SceneViewModel removedSceneModel = e.OldItems[0] as SceneViewModel;
                m_removedItem = removedSceneModel;
                InteractiveScene removedScene = removedSceneModel.CurrentScene as InteractiveScene;  
                IList<IScene> oldSuccessors = removedScene.PossibleScenes;

                if (removedScene == story.StartScene && oldSuccessors.Count == 1)
                {
                    story.StartScene = oldSuccessors[0];
                }
                else
                {
                    InteractiveScene oldPredecessor = GetPredecessor(e.OldStartingIndex, storylineModel);

                    oldPredecessor.PossibleScenes.Remove(removedScene);
                    foreach(IScene scene in oldSuccessors)
                    {
                        oldPredecessor.PossibleScenes.Add(scene);
                    }
                }
                
            }

            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                SceneViewModel addedSceneModel = e.NewItems[0] as SceneViewModel;
                InteractiveScene addedScene = addedSceneModel.CurrentScene as InteractiveScene;                

                if (story.StartScene == null)
                {
                    story.StartScene = addedScene;
                    return;
                }

                int addedSceneIndex = e.NewStartingIndex;

                InteractiveScene newPredecessor = GetPredecessor(addedSceneIndex, storylineModel);
                InteractiveScene newSuccessor = GetSuccessor(addedSceneIndex, storylineModel);                
                if (newPredecessor != null)
                {
                    newPredecessor.PossibleScenes.Remove(newSuccessor);
                    newPredecessor.PossibleScenes.Add(addedScene);                                        
                }
                else
                {
                    if (newSuccessor == story.StartScene)
                    {
                        story.StartScene = addedScene;
                    }
                }

                if (newSuccessor != null)
                {
                    addedScene.PossibleScenes.Clear();
                    addedScene.PossibleScenes.Add(newSuccessor);
                }
                else {
                    addedScene.PossibleScenes.Clear();
                }

                if (m_removedItem != null && m_removedItem == addedSceneModel)
                {
                    m_removedItem = null;
                    HandleReorder(storyModel, storylineModel);
                }
                
            }
        }
 void sceneViewModel_SceneTagsChanged(SceneViewModel sender)
 {
     OnPropertyChanged("Tags");
 }
 private static bool isFavorited(StoryLineViewModel targetStoryLine, SceneViewModel scene)
 {
     ObservableCollection<SceneTag> favoriteTags = targetStoryLine.StoryModel.FavoriteTags;
     if (favoriteTags.Count == 0)
     {
         return false;
     }
     foreach (SceneTag sceneTag in scene.Tags)
     {
         foreach (SceneTag favoriteTag in favoriteTags)
         {
             if (favoriteTag.Content.Equals(sceneTag.Content))
             {
                 return true;
             }
         }
     }
     return false;
 }
 private SceneViewModel CreateSceneViewModel(IScene scene)
 {
     SceneViewModel sceneViewModel = new SceneViewModel(scene);
     sceneViewModel.NavigateRequest += sceneViewModel_NavigateRequest;
     sceneViewModel.PickSceneRequest += sceneViewModel_PickSceneRequest;
     sceneViewModel.BonusSceneChanged += sceneViewModel_BonusSceneChanged;
     sceneViewModel.SceneTagsChanged += sceneViewModel_SceneTagsChanged;
     return sceneViewModel;
 }