Exemple #1
0
        public TagModelItem CreateItemByFrame(Frame f)
        {
            TagModelItem item = TagModelItemFactory.Create(f.Description.Type);

            item.Frame = f;
            return(item);
        }
Exemple #2
0
        private void AddTagModelItem(TagModelItem tagModelItem)
        {
            MultiTagModelItem multiTagModelItem = FindBy(tagModelItem);

            if (Object.ReferenceEquals(multiTagModelItem, null) && !IsFixed.Value)
            {
                multiTagModelItem = MultiTagModelItemFactory.Create(tagModelItem.Frame.Description.Type);
                multiTagModelItem.BlockUpdates = BlockUpdates;
                MultiTagModelItems.Add(multiTagModelItem);
            }

            if (!Object.ReferenceEquals(multiTagModelItem, null))
            {
                int index = IsFixed.Value
                    ? TagModelList.SelectedModels.IndexOf(tagModelItem.TagModel)
                    : TagModelList.SelectedModels.IndexOfTagModelItemByFrameId(tagModelItem);

                int clippedIndex = Math.Min(index, multiTagModelItem.Items.Count);
                if (!multiTagModelItem.Items.Contains(tagModelItem))
                {
                    multiTagModelItem.Items.Insert(clippedIndex, tagModelItem);
                }
            }

            tagModelItemToTagModel[tagModelItem] = tagModelItem.TagModel;
        }
Exemple #3
0
        private void UpdateIsFixed(object sender, PropertyChangedEventArgs e)
        {
            Clear();
            MultiTagItems.Clear();

            if (IsFixed.Value)
            {
                foreach (var fm in FixedMeanings)
                {
                    TagDescription desc = TagDescriptionMap.Instance[ID3.Version.v2_3];

                    Frame frame = new Frame(desc, fm);
                    FrameDescription.FrameType type = desc[fm].Type;

                    TagModelItem item = TagModelItemFactory.Create(type);
                    item.Frame = frame;

                    MultiTagModelItem mtmi = MultiTagModelItemFactory.Create(type);
                    mtmi.InitFixed(item);
                    MultiTagModelItems.Add(mtmi);
                }
            }

            adapter.UpdateItems();
        }
Exemple #4
0
 public virtual bool IsEqual(TagModelItem other)
 {
     if (Frame != null && other.Frame != null)
     {
         return(Frame.Content.IsEqual(other.Frame.Content));
     }
     else
     {
         return(false);
     }
 }
Exemple #5
0
 private void OnHook(object sender, EventArgs e)
 {
     History.Instance.ExecuteInTransaction(
         delegate()
     {
         Item.TagModel.Add(Item);
         Item = null;
     },
         sender.GetHashCode(),
         "AddTemplateItemOnEdit");
 }
Exemple #6
0
 public MultiTagModelItem FindBy(TagModelItem item)
 {
     if (IsFixed.Value)
     {
         return(this[item.Meaning]);
     }
     else
     {
         return(this[item.FrameId.Value]);
     }
 }
Exemple #7
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);
        }
Exemple #8
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);
                        }
                    }
                }
            }
        }
Exemple #9
0
        private void RemoveTagModelItem(TagModelItem tagModelItem)
        {
            MultiTagModelItem multiItem = FindBy(tagModelItem);

            if (!Object.ReferenceEquals(multiItem, null))
            {
                multiItem.BlockUpdates = BlockUpdates;

                if (multiItem.Items.Contains(tagModelItem))
                {
                    multiItem.Items.Remove(tagModelItem);
                    tagModelItemToTagModel.Remove(tagModelItem);
                }

                if (multiItem.Items.Count == 0 && !IsFixed.Value)
                {
                    MultiTagModelItems.Remove(multiItem);
                }
            }
        }
Exemple #10
0
        private void UpdateItemFromItems()
        {
            if (BlockUpdates || IsFixed)
            {
                return;
            }

            if (item == null && items.Count > 0)
            {
                if (IsClassIdUnique)
                {
                    Item = (TagModelItem)Activator.CreateInstance(FirstItem.GetType(), new Object[] { });
                }
                else
                {
                    Item = new TagModelItem();
                }
            }
            else if (item != null && items.Count == 0)
            {
                Item = null;
            }
        }
Exemple #11
0
        public static int IndexOfTagModelItemByMeaning(
            this IEnumerable <TagModel> seq,
            TagModelItem toSearchFor)
        {
            int i = 0;

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

                    if (tagModelItem.Meaning == toSearchFor.Meaning)
                    {
                        i++;
                    }
                }
            }

            return(i);
        }
Exemple #12
0
 public void Remove(TagModelItem item)
 {
     Items.Remove(item);
 }
Exemple #13
0
 public override bool IsEqual(TagModelItem other)
 {
     return(Text.Value == other.Text.Value &&
            Description.Value == ((TagModelItemComment)other).Description.Value &&
            Language.Value == ((TagModelItemComment)other).Language.Value);
 }
Exemple #14
0
 public override bool IsEqual(TagModelItem other)
 {
     return(Text.Value == other.Text.Value);
 }
Exemple #15
0
 public void Add(TagModelItem item)
 {
     Items.Add(item);
 }
Exemple #16
0
 public bool Contains(TagModelItem item)
 {
     return(Items.Contains(item));
 }
Exemple #17
0
 public void InitFixed(TagModelItem protoItem)
 {
     IsFixed = true;
     Item    = protoItem;
 }