示例#1
0
        void TagEntryTextChanged(object sender, TextChangedEventArgs e)
        {
            if (TagSeparators.Any(e.NewTextValue.Contains))
            {
                string tag = e.NewTextValue;
                foreach (var item in TagSeparators)
                {
                    tag = tag.Replace(item, string.Empty);
                }

                var tagBindingContext = TagValidatorFactory(tag);
                var tagEntry          = sender as TagEntry;

                if (tagBindingContext != null)
                {
                    TagItems.Add(tagBindingContext);
                    tagEntry.Text = string.Empty;
                }
                else
                {
                    tagEntry.Text = tag;
                }

                tagEntry.Focus();
            }
        }
示例#2
0
        private void SubscribeMessage()
        {
            MessagingCenter.Subscribe <RecordDetailViewModel, TagItem>(this, "addTag", (sender, tagItem) =>
            {
                TagItems.Add(tagItem);
                UpdateWeekRecords(tagItem);
            });

            MessagingCenter.Subscribe <RecordDetailViewModel, TagItem>(this, "removeTag", (sender, tagItem) =>
            {
                TagItems.Remove(tagItem);
                UpdateWeekRecords(null);
            });

            MessagingCenter.Subscribe <RecordDetailViewModel, WeekRecord>(this, "changeWeekRecord", (sender, weekRecord) =>
            {
                ChangeWeekRecord(weekRecord);
                UpdateWeekRecords(null);
                OnPropertyChanged(nameof(MonthSuccessRate));
            });

            MessagingCenter.Subscribe <RecordDetailViewModel, Record>(this, "deleteRecord", (sender, record) =>
            {
                Records.Remove(record);
                InitRecordsForSearch();
                UpdateWeekRecords(null);
                RefreshRecordsBySearch();
                OnPropertyChanged(nameof(MonthSuccessRate));
            });
        }
示例#3
0
        // The action function for ConnectButtonAction
        /// <summary>
        /// Если в списке уже есть tagItem с таким ТЭГом, то заменяем его, если нет - добавляем в список
        /// </summary>
        private void ConnectButtonAction()
        {
            RevitModel.getTwoElements();

            if (RevitModel.IsTwoElementsSelected)
            {
                connectEvent.Raise();
                int idx;

                if (NewTag != null)
                {
                    //внесение правки в существующий элемент списка или добавление нового
                    if (TagItems.Any(i => i.ModelId == NewTag.ModelId))
                    {
                        TagItem t = TagItems.Where(i => i.ModelId == NewTag.ModelId).First();
                        idx           = TagItems.IndexOf(t);
                        TagItems[idx] = NewTag;
                    }
                    else
                    {
                        TagItems.Add(NewTag);
                    }
                }
            }
        }
示例#4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            TagItems = Cacher.GetTopTags(ItemCount, SubtextContext);
            int tagCount = TagItems.Count();

            if (tagCount == 0)
            {
                Visible = false;
            }
            else
            {
                var tagRepeater = FindControl("Tags") as Repeater;
                if (tagRepeater != null)
                {
                    tagRepeater.DataSource = TagItems;
                    tagRepeater.DataBind();
                }

                var defaultTagLink = ControlHelper.FindControlRecursively(this, "DefaultTagLink") as HyperLink;
                if (defaultTagLink != null)
                {
                    defaultTagLink.NavigateUrl = Url.TagCloudUrl();
                }
            }
        }
示例#5
0
        private void UpdateMonthRecordsByTag(TagItem tagItem)
        {
            var recordsByTag = new List <Record>();
            var tagItems     = new List <TagItem>(TagItems.ToList());

            if (tagItem != null)
            {
                tagItems.Add(tagItem);
            }

            if (tagItems.Count == 0 && recordsByTag.Count == 0)
            {
                MonthRecordsByTag = MonthRecords;
            }
            else
            {
                foreach (var tag in tagItems)
                {
                    var records = MonthRecords.FindAll((r) => string.Compare(r.Name, tag.Name) == 0);
                    foreach (var record in records)
                    {
                        recordsByTag.Add(record);
                    }
                }

                MonthRecordsByTag = recordsByTag.Distinct().ToList();
            }
        }
        public List <Property> Resolve(List <string> tags)
        {
            List <Property> list = new List <Property>();

            if (tags != null)
            {
                foreach (var tag in tags)
                {
                    var parts = tag.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    if (!Exclusions.ContainsKey(_SelectedDomain) || !Exclusions[_SelectedDomain].Contains(parts[0]))
                    {
                        Property property = new Property();
                        if (parts.Length > 1)
                        {
                            property.Value = TypeResolver.Resolve(parts[1]);
                        }

                        string key = parts[0].Trim();

                        var found = TagItems.FirstOrDefault(x => x.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
                        if (found == null)
                        {
                            found = new TagMapViewModel(new TagMap()
                            {
                                Key = key
                            });
                            TagItems.Add(found);
                        }
                        property.Name = found.Key;
                        var counter = found.Model.Counters.FirstOrDefault(y => y.Key.Equals(y.Key, StringComparison.OrdinalIgnoreCase) &&
                                                                          y.Domain.Equals(_SelectedDomain, StringComparison.OrdinalIgnoreCase));
                        if (counter == null)
                        {
                            counter = new Counter()
                            {
                                Key = key, Domain = _SelectedDomain
                            };
                            found.Model.Counters.Add(counter);
                        }
                        counter.Count++;

                        if (recenttags.Add(found.Key))
                        {
                            RecentTags.Insert(0, found);
                            if (RecentTags.Count > MaxRecentTags)
                            {
                                while (RecentTags.Count > MaxRecentTags)
                                {
                                    RecentTags.RemoveAt(RecentTags.Count - 1);
                                }
                            }
                        }
                        list.Add(property);
                    }
                }
            }
            RefreshFiltering();
            return(list);
        }
示例#7
0
 private void RefreshList()
 {
     TagItems.Clear();
     foreach (var t in RevitModel.tagListData())
     {
         TagItems.Add(t);
     }
 }
 internal void SetRecentTags(IEnumerable <string> tags)
 {
     foreach (var tag in tags)
     {
         var found = TagItems.FirstOrDefault(x => x.Key.Equals(tag, StringComparison.OrdinalIgnoreCase));
         if (found != null && recenttags.Add(tag))
         {
             RecentTags.Add(found);
         }
     }
 }
        internal void Load(List <ContentItem> contentItems)
        {
            List <TagMap> maps = new List <TagMap>();

            foreach (var item in contentItems)
            {
                var    domaintag = item.Properties.FirstOrDefault(x => x.Name.Equals("x-domain", StringComparison.OrdinalIgnoreCase));
                string domain    = domaintag != null?domaintag.Value.ToString() : AppConstants.Default;

                foreach (var tag in item.Properties.Where(t => !Exclusions[_SelectedDomain].Contains(t.Name)))
                {
                    string key    = tag.Name;
                    var    tagmap = maps.FirstOrDefault(x => x.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
                    if (tagmap == null)
                    {
                        tagmap = new TagMap()
                        {
                            Key = key
                        };
                        maps.Add(tagmap);
                    }

                    var counter = tagmap.Counters.FirstOrDefault(y => y.Key.Equals(y.Key, StringComparison.OrdinalIgnoreCase) &&
                                                                 y.Domain.Equals(domain, StringComparison.OrdinalIgnoreCase));
                    if (counter == null)
                    {
                        counter = new Counter()
                        {
                            Key = key, Domain = domain
                        };
                        tagmap.Counters.Add(counter);
                    }
                    counter.Count++;
                }
            }


            List <TagMapViewModel> vms = (from x in maps
                                          let z = new TagMapViewModel(x)

                                                  select z).ToList();
            int i = 0;

            foreach (var item in vms.OrderByDescending(o => o.Count))
            {
                if (i++ < MaxPopularTags)
                {
                    PopularTags.Add(item);
                }
                TagItems.Add(item);
            }
        }
        void AddTag(string tag, TagEntry tagEntry)
        {
            var tagBindingContext = TagValidatorFactory(tag);

            if (tagBindingContext != null)
            {
                TagItems.Add(tagBindingContext);
                tagEntry.Text = string.Empty;
            }
            else
            {
                tagEntry.Text = tag;
            }

            tagEntry.Focus();
        }
示例#11
0
        private void InitRecordsForSearch()
        {
            AllRecordsByName.Clear();

            foreach (var record in Records)
            {
                var IsAlreadyExist = AllRecordsByName.Exists(r => r == record.Name);
                if (!IsAlreadyExist)
                {
                    if (TagItems.ToList().Exists(t => t.Name != record.Name))
                    {
                        RecordsBySearch.Add(record.Name);
                    }
                    AllRecordsByName.Add(record.Name);
                }
            }
        }
示例#12
0
        // Search & Tag

        public void RemoveTag(TagItem tagItem)
        {
            SearchTag.RemoveTag(tagItem);

            if (tagItem == null)
            {
                return;
            }

            TagItems.Remove(tagItem);

            UpdateWeekRecords(null);

            RecordsBySearch.Add(tagItem.Name);

            var list = new List <string>(RecordsBySearch);

            list.Sort();

            SortRecordsBySearch(list);
        }