Exemplo n.º 1
0
        /// <summary>
        /// 编辑树节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeNodeEdit_Clicked(object sender, RoutedEventArgs e)
        {
            if (viewModel.SelectedTreeNode == null)
            {
                return;
            }

            TreeNodeEditWindow window = null;

            if (viewModel.SelectedTreeNode.Deepth == 1)
            {
                window = new TreeNodeEditWindow(NodeType.Dev, viewModel.SelectedTreeNode.DisplayName);
            }
            else if (viewModel.SelectedTreeNode.Deepth == 2)
            {
                window = new TreeNodeEditWindow(NodeType.Group, viewModel.SelectedTreeNode.DisplayName);
            }
            if (window != null)
            {
                window.Owner = this;
                var ret = window.ShowDialog();
                if (!string.IsNullOrEmpty(ret))
                {
                    viewModel.SelectedTreeNode.DisplayName = ret;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 新增树节点(Dev)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeNodeNewDev_Clicked(object sender, RoutedEventArgs e)
        {
            if (viewModel.SelectedTreeNode == null || viewModel.SelectedTreeNode.Deepth == 1)
            {
                var window = new TreeNodeEditWindow(NodeType.Dev, null);
                window.Owner = this;
                var ret = window.ShowDialog();

                if (string.IsNullOrEmpty(ret))
                {
                    return;
                }

                var dev = new Dev()
                {
                    DevName = ret
                };

                if (viewModel.Config.Devs == null)
                {
                    viewModel.Config.Devs = new List <Dev>();
                }

                viewModel.Config.Devs.Add(dev);
                viewModel.LeftTree     = TreeViewModel.CreateTreeFromConfig(viewModel.Config);
                ConfigTree.ItemsSource = viewModel.LeftTree;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增树节点(Group)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeNodeNewGroup_Clicked(object sender, RoutedEventArgs e)
        {
            var window = new TreeNodeEditWindow(NodeType.Group, null);

            window.Owner = this;
            var ret = window.ShowDialog();

            if (string.IsNullOrEmpty(ret))
            {
                return;
            }

            var group = new Group()
            {
                GroupName = ret
            };

            if (viewModel.SelectedTreeNode?.Deepth == 1)
            {
                if ((viewModel.SelectedTreeNode.ConfigItem as Dev).Groups == null)
                {
                    (viewModel.SelectedTreeNode.ConfigItem as Dev).Groups = new List <Group>();
                }
                (viewModel.SelectedTreeNode.ConfigItem as Dev).Groups.Add(group);
            }

            else if (viewModel.SelectedTreeNode?.Deepth == 2)
            {
                if ((viewModel.SelectedTreeNode.Parent.ConfigItem as Dev).Groups == null)
                {
                    (viewModel.SelectedTreeNode.Parent.ConfigItem as Dev).Groups = new List <Group>();
                }
                (viewModel.SelectedTreeNode.Parent.ConfigItem as Dev).Groups.Add(group);
            }

            viewModel.LeftTree     = TreeViewModel.CreateTreeFromConfig(viewModel.Config);
            ConfigTree.ItemsSource = viewModel.LeftTree;
        }