예제 #1
0
        public static TagVersionEnum SelectedVersionItemProvider(object item)
        {
            TagModel model = item as TagModel;

            if (model.IsSelected.Value)
            {
                return((item as TagModel).Version);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
 private TagModelItem FindTemplateItem(TagModel tagModel, FrameMeaning meaning)
 {
     if (Object.ReferenceEquals(this[meaning], null))
     {
         return(null);
     }
     else
     {
         return
             ((from tagModelItem in this[meaning].Items
               where tagModelItem.TagModel == tagModel && !tagModel.Contains(tagModelItem)
               select tagModelItem).FirstOrDefault());
     }
 }
예제 #3
0
        public void Add(string fileName, Tag tag, int bitrate)
        {
            if (Contains(fileName))
            {
                throw new Exception("Can't add twice!");
            }

            TagModel model = DocNode.Create <TagModel>();

            model.Init(fileName, tag, bitrate);

            model.IsSelected.TransactionIdModeToUse = DocObj <bool> .TransactionIdMode.UseFixed;
            model.IsSelected.FixedTransactionId     = GetHashCode();
            Items.Add(model);
        }
예제 #4
0
        private TagModelItem CreateTemplateItem(TagModel tagModel, FrameMeaning meaning)
        {
            TagModelItem item = tagModel.CreateItemByMeaning(meaning);

            item.TagModel             = tagModel;
            item.IsTemplateItem.Value = true;

            if (meaning == FrameMeaning.Title)
            {
                item.Text.Value = tagModel.NameWithoutExtension;
            }

            TagModelItemHook hook = new TagModelItemHook();

            hook.Item = item;

            return(item);
        }
예제 #5
0
        public static int IndexOf(
            this IEnumerable <TagModel> seq,
            TagModel item)
        {
            int i = 0;

            foreach (var tagModel in seq)
            {
                if (Object.ReferenceEquals(tagModel, item))
                {
                    return(i);
                }

                i++;
            }

            return(i);
        }
예제 #6
0
        private void OnTagModelChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (object obj in e.OldItems)
                {
                    TagModelItem item = obj as TagModelItem;

                    if (IsFixed.Value)
                    {
                        TagModel tagModel = tagModelItemToTagModel[item];
                        if (FixedMeanings.Contains(item.Meaning) && !tagModel.Contains(item.Meaning))
                        {
                            AddTagModelItem(CreateTemplateItem(tagModel, item.Meaning));
                        }
                    }

                    RemoveTagModelItem(item);
                }
            }

            if (e.NewItems != null)
            {
                foreach (object obj in e.NewItems)
                {
                    TagModelItem item = obj as TagModelItem;

                    AddTagModelItem(item);

                    if (IsFixed.Value)
                    {
                        TagModel     tagModel     = tagModelItemToTagModel[item];
                        TagModelItem templateItem = FindTemplateItem(tagModel, item.Meaning);

                        if (!Object.ReferenceEquals(templateItem, null))
                        {
                            RemoveTagModelItem(templateItem);
                        }
                    }
                }
            }
        }
예제 #7
0
 public bool HasTagModel(TagModel tagModel)
 {
     return(TagModels.Contains(tagModel));
 }
예제 #8
0
 public TagConversionAction(TagModel model, Tag oldTag, Tag newTag)
     : base(model)
 {
     OldTag = oldTag;
     NewTag = newTag;
 }