예제 #1
0
 private void Lookup_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     //already open?
     if (_themekeywords != null)
     {
         return;
     }
     _themekeywords         = new MTK_MD_ThemeKeywords();
     _themekeywords.Owner   = FrameworkApplication.Current.MainWindow;
     _themekeywords.Closed += (o, args) => { KeywordsWindowClosed(); };
     _themekeywords.Show();
 }
예제 #2
0
        private void KeywordsWindowClosed()
        {
            var selectedKeywords = _themekeywords.SelectedKeywords;

            if (selectedKeywords != null && selectedKeywords.Count > 0)
            {
                var    keywords             = selectedKeywords.Select((k) => k.Label).ToList();
                object context              = Utils.Utils.GetDataContext(this);
                IEnumerable <XmlNode> nodes = Utils.Utils.GetXmlDataContext(context);
                if (nodes != null)
                {
                    var node = nodes.First();
                    var bag  = node.SelectSingleNode("bag");

                    if (string.IsNullOrWhiteSpace(bag.InnerText))
                    {
                        string newKeywords = string.Join("\n", keywords);
                        bag.InnerText = newKeywords;
                        return;
                    }

                    string newText          = bag.InnerText;
                    var    originalTextList = newText.Split('\n').ToList();
                    foreach (string kw in keywords)
                    {
                        if (originalTextList.Contains(kw))
                        {
                            continue;
                        }

                        newText += $"\n" + kw;
                    }

                    bag.InnerText = newText;
                }
            }

            _themekeywords = null;
        }