예제 #1
0
        private void txtTags_LostFocus(object sender, RoutedEventArgs e)
        {
            List <string> tags = new List <string>();

            if (!string.IsNullOrWhiteSpace(txtTags.Text))
            {
                tags.AddRange(txtTags.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(t => t.Trim()).Distinct());
            }
            _loading = true;
            try
            {
                foreach (var tag in tags.Where(t => !_note.Tags.Contains(t)))
                {
                    _note.AddTag(tag);
                }
                foreach (var tag in _note.Tags.Where(t => !tags.Contains(t)).ToList())
                {
                    _note.RemoveTag(tag);
                }
                LoadTags();
            }
            finally
            {
                _loading = false;
            }
        }