Пример #1
0
 private void SampleTreeView_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
 {
     if (e.OriginalSource is ListViewItemPresenter)
     {
         ListViewItemPresenter lvip = (ListViewItemPresenter)e.OriginalSource;
         lastTreeNode = (TreeNode)lvip.Content;
         EsSystemData data = lastTreeNode.Data as EsSystemData;
         if (data != null && data.ItemType == EsTreeItemType.esConnection)
         {
             if (data.IsConnect)
             {
                 Menu_Open.IsEnabled  = false;
                 Menu_Close.IsEnabled = true;
             }
             else
             {
                 Menu_Open.IsEnabled  = true;
                 Menu_Close.IsEnabled = false;
             }
             ItemMenuFlyout.ShowAt(sampleTreeView, e.GetPosition(sampleTreeView));
         }
     }
     else if (e.OriginalSource is Grid)
     {
         //Grid grid = (Grid)e.OriginalSource;
         //BlankMenuFlyout.ShowAt(sampleTreeView, e.GetPosition(sampleTreeView));
     }
 }
Пример #2
0
        private void SampleTreeView_TreeViewItemClick(TreeView sender, TreeViewItemClickEventArgs args)
        {
            TreeNode node = (TreeNode)args.ClickedItem;

            EsSystemData data = node.Data as EsSystemData;
            PivotItem    pi   = pivot1.Items[0] as PivotItem;

            switch (data.ItemType)
            {
            case EsTreeItemType.esIndex:
                contentFrame.Navigate(typeof(Page_Index), node.ParentNode.Data as EsSystemData);
                pi.Header = "Index";
                break;

            case EsTreeItemType.esTemplate:
                contentFrame.Navigate(typeof(Template), node.ParentNode.Data as EsSystemData);
                pi.Header = "Template";
                break;

            case EsTreeItemType.esPlugin:
                contentFrame.Navigate(typeof(Page_Plugin), node.ParentNode.Data as EsSystemData);
                pi.Header = "Plugin";
                break;

            case EsTreeItemType.esNode:
                break;
                //case default:
                //    contentFrame.Navigate(typeof(BlankPage1), args);
                //    break;
            }
        }
Пример #3
0
        private async void Menu_Delete_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var dialog = new MessageDialog("Are you sure to delete this connection?");

            dialog.Commands.Add(new UICommand("ok", cmd => { }, commandId: 0));
            dialog.Commands.Add(new UICommand("cancel", cmd => { }, commandId: 1));

            //设置默认按钮,不设置的话默认的确认按钮是第一个按钮
            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex  = 1;

            //获取返回值
            IUICommand result = await dialog.ShowAsync();

            if (result.Label == "ok")
            {
                if (lastTreeNode != null && lastTreeNode.Data != null)
                {
                    EsSystemData esSD = (EsSystemData)lastTreeNode.Data;

                    Menu_Close_Click(sender, e); //先关闭,再删除

                    EsService.DelEsFile(esSD.EsConnInfo);
                    lastTreeNode.ParentNode.Remove(lastTreeNode);
                }
            }
        }
Пример #4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter == null)
            {
                return;
            }

            esdata = e.Parameter as EsSystemData;
            await InitData();
        }
Пример #5
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter == null)
            {
                return;
            }

            EsSystemData esSystemData = e.Parameter as EsSystemData;

            txtBlock1.Text = await EsService.GetPlugin(esSystemData.EsConnInfo);
        }
Пример #6
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter == null)
            {
                return;
            }

            esdata    = e.Parameter as EsSystemData;
            indexName = esdata.Tag.ToString();

            await GetBrowsePageData(indexName, pageIndex);
        }
Пример #7
0
 private void SampleTreeView_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
 {
     if (e.OriginalSource is ListViewItemPresenter)
     {
         ListViewItemPresenter lvip = (ListViewItemPresenter)e.OriginalSource;
         lastTreeNode = (TreeNode)lvip.Content;
         EsSystemData data = lastTreeNode.Data as EsSystemData;
         if (data != null && data.ItemType == EsTreeItemType.esConnection)
         {
             lastTreeNode.IsExpanded = !lastTreeNode.IsExpanded;
             Menu_Open_Click(sender, e);
         }
     }
 }
Пример #8
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter == null)
            {
                return;
            }

            esdata = e.Parameter as EsSystemData;
            if (esdata.Tag != null)
            {
                txtBoxCommand.Text = AutoIndent(esdata.Tag.ToString());
            }
        }
Пример #9
0
        /// <summary>
        /// 添加一个新的item,并且加载对应的页面,并且切换过去
        /// </summary>
        /// <param name="sourcePageType"></param>
        /// <param name="esSystemData"></param>
        /// <param name="title"></param>
        public void AddPivotItem(Type sourcePageType, EsSystemData esSystemData, string title)
        {
            PivotItem pi = new PivotItem()
            {
                Header = title + "$" + Guid.NewGuid().ToString()
            };

            Frame frame = new Frame();

            //frame.Background = new SolidColorBrush() { Color = Colors.AliceBlue };
            pi.Content = frame;
            //frame.Tag = esSystemData;
            frame.Navigate(sourcePageType, esSystemData);

            pivot1.Items.Add(pi);
            pivot1.SelectedIndex = pivot1.Items.Count - 1;
        }
Пример #10
0
        private void Menu_Open_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            PageUtil.SetLoadingCursor();
            try
            {
                if (lastTreeNode != null && lastTreeNode.Data != null)
                {
                    if (lastTreeNode.HasItems)
                    {
                        PageUtil.SetDefaultCursor();
                        return;
                        //lastTreeNode.Clear();
                    }

                    EsSystemData esSD = (EsSystemData)lastTreeNode.Data;

                    if (esSD.EsConnInfo.isUseSSH)
                    {
                        if (esSD.SSHClient == null || esSD.SSHClient.IsConnected == false)
                        {
                            esSD.SSHClient = EsService.GetSshClient(esSD.EsConnInfo);
                        }
                    }

                    if (EsService.ConnectionTest(esSD.EsConnInfo) == false)   //最终检查是否能获取到Es 版本信息 为判断依据
                    {
                        PageUtil.ShowMsg("connect fail!");
                        //(new MessageDialog("连接失败!")).ShowAsync();
                        return;
                    }
                    (lastTreeNode.Data as EsSystemData).IsConnect = true;
                    lastTreeNode.Data = esSD;
                    if (lastTreeNode.IsExpanded == false)
                    {
                        lastTreeNode.IsExpanded = true;
                    }
                    AddTreeNodeChild(lastTreeNode);
                }
                PageUtil.SetDefaultCursor();
            }
            catch
            {
                PageUtil.ShowMsg("connect error!");
                //(new MessageDialog("连接异常!")).ShowAsync();
            }
        }
Пример #11
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter == null)
            {
                return;
            }

            esdata = e.Parameter as EsSystemData;

            if (MainPage.mainPage.listIndex.Count == 0)
            {
                MainPage.mainPage.listIndex = await EsService.GetIndexList(esdata.EsConnInfo);
            }
            comboxIndex.ItemsSource   = MainPage.mainPage.listIndex;
            comboxIndex.SelectedIndex = 0;
        }
Пример #12
0
        private void Menu_Close_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (lastTreeNode != null && lastTreeNode.Data != null)
            {
                EsSystemData esSD = (EsSystemData)lastTreeNode.Data;
                if (esSD != null && esSD.EsConnInfo.isUseSSH && esSD.SSHClient != null && esSD.SSHClient.IsConnected)
                {
                    esSD.SSHClient.Disconnect();
                    esSD.SSHClient.Dispose();
                    esSD.SSHClient = null;
                }
                //(lastTreeNode.Data as EsSystemData).IsConnect = false;
                esSD.IsConnect          = false;
                lastTreeNode.Data       = esSD;
                lastTreeNode.IsExpanded = false;
                lastTreeNode.Clear();

                contentFrame.Navigate(typeof(Welcome), e);
            }
        }
Пример #13
0
        public void AddPivotItem(Type sourcePageType, String title)
        {
            if (sampleTreeView.SelectedItem != null)
            {
                TreeNode     treeNode     = sampleTreeView.SelectedItem as TreeNode;
                EsSystemData esSystemData = treeNode.Data as EsSystemData;

                if (esSystemData.ItemType == EsTreeItemType.esConnection)
                {
                    if (esSystemData.IsConnect)
                    {
                        AddPivotItem(sourcePageType, esSystemData, title + "@" + esSystemData.Name);
                    }
                }
                else
                {
                    esSystemData = treeNode.ParentNode.Data as EsSystemData;
                    if (esSystemData.IsConnect)
                    {
                        AddPivotItem(sourcePageType, esSystemData, title + "@" + esSystemData.Name);
                    }
                }
            }
        }