예제 #1
0
        /// <summary>
        /// 当鼠标点击树形列表右键菜单的选项时发生。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Root_Click(object sender, RoutedEventArgs e)
        {
            MenuItem         item     = sender as MenuItem;
            NodeInfo         nodeInfo = item.Tag as NodeInfo;
            ConnectionConfig config   = GlobalBusiness.DictConnectionConfig[nodeInfo.ConfigId];

            if (MenuItemType.OPEN.Equals(nodeInfo.Type))
            {
                if (this.currentSelectedTreeViewItem.HasItems)
                {
                    return;
                }
                this.CreateDBNode(this.currentSelectedTreeViewItem);
                this.currentSelectedTreeViewItem.IsExpanded = true;

                return;
            }
            if (MenuItemType.REFRESH.Equals(nodeInfo.Type))
            {
                this.currentSelectedTreeViewItem.Items.Clear();
                this.CreateDBNode(this.currentSelectedTreeViewItem);
                this.currentSelectedTreeViewItem.IsExpanded = true;

                return;
            }
            if (MenuItemType.EDIT.Equals(nodeInfo.Type))
            {
                if (this.currentSelectedTreeViewItem.HasItems &&
                    MessageBox.Show("该操作将关闭连接!是否继续?", "操作提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    this.currentSelectedTreeViewItem.Items.Clear();
                }

                WinAddConnection winAddConnection = new WinAddConnection(nodeInfo.ConfigId, ConfigOperationType.EDIT);
                winAddConnection.SavedConnectionConfig += this.WinAddConnection_SavedConnectionConfig;
                winAddConnection.ShowDialog();
                winAddConnection.SavedConnectionConfig -= this.WinAddConnection_SavedConnectionConfig;

                return;
            }
            if (MenuItemType.DELETE.Equals(nodeInfo.Type))
            {
                if (MessageBox.Show($"确定删除{config.Name}连接配置吗?", "删除提示",
                                    MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    TreeView tree = this.currentSelectedTreeViewItem.Parent as TreeView;
                    this.gridRedisList.Children.Remove(tree);
                    GlobalBusiness.RemoveConfig(config.Id);
                }

                return;
            }
            if (MenuItemType.CLOSE.Equals(nodeInfo.Type))
            {
                this.currentSelectedTreeViewItem.Items.Clear();
                this.currentSelectedTreeViewItem.IsExpanded = false;

                return;
            }
        }
예제 #2
0
        /// <summary>
        /// 当鼠标点击添加按钮时发生。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            WinAddConnection winAddConnection = new WinAddConnection(ConfigOperationType.ADD);

            winAddConnection.SavedConnectionConfig += this.WinAddConnection_SavedConnectionConfig;
            winAddConnection.ShowDialog();
            winAddConnection.SavedConnectionConfig -= this.WinAddConnection_SavedConnectionConfig;
        }