Exemple #1
0
 public TopicWrap(Topic topic)
 {
     this.Topic = topic;
     foreach (var e in topic.Items)
     {
         var child = new TopicWrap(e);
         Items.Add(child);
         child.Parent = this;
     }
 }
Exemple #2
0
        public PublishViewModel(GlobalData globalData)
        {
            Levels = new ObservableCollection<TopicLevel>();
            this.GlobalData = globalData;
            Root = new TopicWrap[] { new TopicWrap(globalData.TopicsRoot) };
            UnassignedVideos = new ObservableCollection<VideoWrap>();
            foreach (var e in GlobalData.VideoData.Where(z => z.TopicGuid == Guid.Empty))
                UnassignedVideos.Add(new VideoWrap(e));
            foreach(var e in Root[0].Subtree.OfType<TopicWrap>())
                foreach (var v in GlobalData.VideoData.Where(z => z.TopicGuid == e.Topic.Guid).OrderBy(z => z.NumberInTopic))
                {
                    var vw = new VideoWrap(v);
                    e.Items.Add(vw);
                    vw.Parent = e;
                }
            foreach (var level in globalData.TopicLevels)
                Levels.Add(level);

            AddCommand = new RelayCommand(Add, () => SelectedItem != null && SelectedItem is TopicWrap);
            RemoveCommand = new RelayCommand(Remove, () => SelectedItem != null && SelectedItem != Root[0]);
            DeleteCommand = new RelayCommand(DeleteFromList, () => SelectedItemInUnassignedList != null);
        }
Exemple #3
0
 public void Commit(TopicWrap wrap)
 {
     wrap.Topic.Items.Clear();
     foreach (var e in wrap.Items)
     {
         if (e is TopicWrap)
         {
             var tw = e as TopicWrap;
             Commit(tw);
             wrap.Topic.Items.Add(tw.Topic);
             continue;
         }
         if (e is VideoWrap)
         {
             var vw = e as VideoWrap;
             vw.Video.TopicGuid = wrap.Topic.Guid;
             vw.Video.NumberInTopic = wrap.Items.IndexOf(vw);
         }
     }
 }