示例#1
0
        private void DeleteItem(object sender, RoutedEventArgs e)
        {
            NsTreeItem node = (NsTreeItem)TreeNamespace.SelectedItem;

            if (node == null)
            {
                return;
            }

            var ns = node.Namespace;

            if (string.IsNullOrWhiteSpace(ns))
            {
                return;
            }

            if (node.Parent == null)
            {
                CurrentTreeItems.Remove(node);
            }
            else
            {
                var nodes = node.Parent.Items as List <NsTreeItem>;
                nodes.Remove(node);
                //   node.Parent.IsSelected = true;
            }

            allSettings.RemoveAll(o => o.Namespace.StartsWith(ns));

            RefreshTree();
        }
示例#2
0
        private void TreeNamespace_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            selectedNode = (NsTreeItem)e.NewValue;
            if (selectedNode == null)
            {
                itemMenu.IsEnabled = false;
                return;
            }
            //  selectedNode.IsExpanded = true;
            itemMenu.IsEnabled = true;


            var clickedNamespace = selectedNode.Namespace;

            if (selectedNode.HasItems)
            {
                clickedNamespace += ".";
            }

            if (string.IsNullOrWhiteSpace(clickedNamespace))
            {
                return;
            }

            SearchFilterTextbox.Text = clickedNamespace;
        }
示例#3
0
        private void NewItem(object sender, RoutedEventArgs e)
        {
            NsTreeItem node = (NsTreeItem)TreeNamespace.SelectedItem;
            var        ns   = node == null ? string.Empty : node.Namespace;

            var dialog = new Prompt("New Translation", "Enter the translation name below.", ns);

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(dialog.ResponseText))
            {
                return;
            }

            if (allSettings.NoEmpty().Any(setting => setting.Namespace.Contains(dialog.ResponseText)))
            {
                MessageBox.Show("Duplicate name");
                return;
            }

            var languages = allSettings.ToLanguages().ToList();

            foreach (var language in languages)
            {
                var val = string.Empty;
                allSettings.Add(new LanguageSetting()
                {
                    Namespace = dialog.ResponseText, Value = val, Language = language
                });
            }
            RefreshTree(dialog.ResponseText);
            UpdateSummaryInfo();
        }
示例#4
0
 public void AddChild(NsTreeItem child)
 {
     _storage.Add(child);
 }