public TagModelItem CreateItemByFrame(Frame f) { TagModelItem item = TagModelItemFactory.Create(f.Description.Type); item.Frame = f; return(item); }
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; }
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(); }
public virtual bool IsEqual(TagModelItem other) { if (Frame != null && other.Frame != null) { return(Frame.Content.IsEqual(other.Frame.Content)); } else { return(false); } }
private void OnHook(object sender, EventArgs e) { History.Instance.ExecuteInTransaction( delegate() { Item.TagModel.Add(Item); Item = null; }, sender.GetHashCode(), "AddTemplateItemOnEdit"); }
public MultiTagModelItem FindBy(TagModelItem item) { if (IsFixed.Value) { return(this[item.Meaning]); } else { return(this[item.FrameId.Value]); } }
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); }
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); } } } } }
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); } } }
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; } }
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); }
public void Remove(TagModelItem item) { Items.Remove(item); }
public override bool IsEqual(TagModelItem other) { return(Text.Value == other.Text.Value && Description.Value == ((TagModelItemComment)other).Description.Value && Language.Value == ((TagModelItemComment)other).Language.Value); }
public override bool IsEqual(TagModelItem other) { return(Text.Value == other.Text.Value); }
public void Add(TagModelItem item) { Items.Add(item); }
public bool Contains(TagModelItem item) { return(Items.Contains(item)); }
public void InitFixed(TagModelItem protoItem) { IsFixed = true; Item = protoItem; }