public void SetTreeView(ISyntaxEntity node, string label)
        {
            //Cleaning UI
            listView.Visibility = Visibility.Collapsed;
            treeView.Visibility = Visibility.Visible;
            TreeItems.Clear();

            treeRootViewModel = null;

            //Modifed by prvai
            //buildTree(node, null);
            BuildTreeViewModel(node, null);

            //modified by prvai
            TreeItems.Add(treeRootViewModel);

            treeView.Focus();

            if (treeView.HasItems)
            {
                var selectedItem = treeView.Items[0] as MenuItemViewModel;
                selectedItem.IsSelected = true;
                //TreeViewItem item = treeView.ItemContainerGenerator.Items[0] as TreeViewItem;
                //item.IsSelected = true;
            }

            isTreeViewActive = true;

            ResizeControl();
        }
 protected override void DeActivate()
 {
     base.DeActivate();
     eventAggregator.GetEvent <RequestCheckinsEvent>().Unsubscribe(ReturnVisibleChekins);
     SaveSettings();
     DeActivateAllViews(RegionNames.ContentRegion);
     TreeItems.Clear();
     Search = String.Empty;
 }
 void TreeLoad(string drive)
 {
     TreeItems.Clear();
     try
     {
         foreach (var item in Directory.GetDirectories(drive))
         {
             DirectoryInfo dirInfo = new DirectoryInfo(item);
             TreeItems.Add(new TreeItemViewModel(dirInfo.Name, dirInfo.FullName, 1));
         }
         foreach (var item in Directory.GetFiles(drive))
         {
             FileInfo fileInfo = new FileInfo(item);
             TreeItems.Add(new TreeItemViewModel(fileInfo.Name, fileInfo.FullName, 1));
         }
     }catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
        public void ReloadTreeView()
        {
            if (string.IsNullOrEmpty(RootPath))
            {
                return;
            }
            ObservableCollection <TreeData> oldTreeItems = TreeItems_;

            ObservableCollection <TreeData> newTreeItems = new ObservableCollection <TreeData>();

            newTreeItems.Add(CreateRootNode(RootPath));

            CompareAndUpdate(oldTreeItems, newTreeItems);

            TreeItems.Clear();
            foreach (var item in newTreeItems)
            {
                TreeItems.Add(item);
            }

            NotifyPropertyChanged("TreeItems");
        }
Exemple #5
0
        private void GetItemList()
        {
            try
            {
                TreeItems.Clear();

                var dir = new DirectoryInfo(SelectedLogicalDrive);

                var folders = dir
                              .GetDirectories()
                              .Select(x => x.ConvertToTreeItemModel())
                              .ToList();

                foreach (var folder in folders)
                {
                    folder.LoadChildItems(folder);
                    TreeItems.Add(folder);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
            }
        }
Exemple #6
0
        private void LoadBase()
        {
            TreeItems.Clear();
            var ssss = Convert.ToInt32(SqlLiteHelper.ExecuteQuery(
                                           "SELECT COUNT(*) as count FROM sqlite_master WHERE type='table' and name= 'menu_instances_relation'").
                                       Tables[0].Rows[0][0].ToString().Trim());


            if (ssss < 1)
            {
                SqlLiteHelper.ExecuteQuery(
                    "CREATE TABLE 'menu_instances_relation' ('father_id' integer,'id' integer,'sort_index' integer,'name' text,'" +
                    "instances_id' integer)");
            }


            try
            {
                DataSet ds = SqlLiteHelper.ExecuteQuery("select * from menu_instances_relation", null);
                if (ds == null)
                {
                    return;
                }
                int mCount = ds.Tables[0].Rows.Count;
                for (int i = 0; i < mCount; i++)
                {
                    try
                    {
                        // (id integer NOT NULL,tag text,name text NOT NULL,tooltips text)
                        int fatherId = Convert.ToInt32(ds.Tables[0].Rows[i]["father_id"].ToString().Trim());
                        int id       = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString().Trim());

                        if ((id >= MenuIdControlAssign.MenuFileGroupIdMin &&
                             id <= MenuIdControlAssign.MenuFileGroupIdMax) ||
                            (id >= MenuIdControlAssign.MenuIdMin &&
                             id <= MenuIdControlAssign.MenuIdMax))
                        {
                            int    sortIndex   = Convert.ToInt32(ds.Tables[0].Rows[i]["sort_index"].ToString().Trim());
                            string name        = ds.Tables[0].Rows[i]["name"].ToString().Trim();
                            int    instancesId = Convert.ToInt32(ds.Tables[0].Rows[i]["instances_id"].ToString().Trim());

                            if (instancesId == 2920022) //moban weizhi

                            {
                                if (fatherId == 0)
                                {
                                    if (!DicType.ContainsKey(id))
                                    {
                                        DicType.Add(id, name);
                                    }
                                    else
                                    {
                                        DicType[id] = name;
                                    }
                                }
                                else
                                {
                                    if (DicType.ContainsKey(fatherId))
                                    {
                                        TreeItems.Add(new TreeItemViewMode()
                                        {
                                            Id          = id,
                                            Name        = name,
                                            IsChecked   = false,
                                            Description = DicType[fatherId],
                                            FatherId    = fatherId
                                        });
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog.WriteLogError(ex.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogError(
                    "Class MenuInstanceRelationHoldingExtend Function loadItem from SQLlite table menu_instances_relation  Occer an Error:" +
                    ex.ToString());
            }
            var args = new PublishEventArgs()
            {
                EventId =
                    EventIdAssign.MenuInstanceRelationLoadUpdate,
                EventType = PublishEventType.Core
            };

            EventPublish.PublishEvent(args);


            //var lst = new List<MenuInstancesRelation>();
            //foreach (var f in TreeItems)
            //    lst.Add(new MenuInstancesRelation()
            //                {
            //                    FatherId = f.FatherId,
            //                    Id = f.Id,
            //                    InstancesId = 2920022,
            //                    Name = f.Name,
            //                    SortIndex =0,
            //                });
            //ServerInstanceRelation.UpdateMenuInstanceRelation(2920022, "MainMenuMa", lst);
        }
        private async void extractBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var watch = new Stopwatch();
                watch.Start();
                var worditem = (sender as Button).DataContext as AssociativeWord;
                switch (worditem.Status)
                {
                case SensitiveStatus.未处理:
                {
                    worditem.Status = SensitiveStatus.获取AS树;
                    Debug.WriteLine("----------------获取ASTree Start");
                    var resultStr = await LinqHelper.GetBingWS("娇蛮之吻", 3, QueryEntryFlag.AS.ToString().ToLower());

                    //GenerateCategory(worditem.Text + worditem.cycleNum, worditem.cycleNum++).ContinueWith(_ =>
                    //{
                    //    if (_.Result == null)
                    //        worditem.Status = SensitiveStatus.完结;
                    //    else
                    //    {
                    //        worditem.ResultData = JsonConvert.SerializeObject(_.Result);
                    //        worditem.Status = SensitiveStatus.已获取;

                    //        watch.Stop();
                    //        Debug.WriteLine(watch.ElapsedMilliseconds);
                    //        Debug.WriteLine("----------------获取ASTree Stop");
                    //    }
                    //}, TaskScheduler.FromCurrentSynchronizationContext());

                    break;
                }

                case SensitiveStatus.已获取:
                {
                    var list = JsonConvert.DeserializeObject <List <SensitiveWords> >(worditem.ResultData);
                    TreeItems.Clear();
                    list.ForEach(item => { TreeItems.Add(item); });
                    SensitiveWordsContentDialog dialog = new SensitiveWordsContentDialog(TreeItems);
                    var result = await dialog.ShowAsync();

                    if (result == ContentDialogResult.Primary)
                    {
                        worditem.Status = SensitiveStatus.处理中;
                        Debug.WriteLine("----------------AStree submit处理中 Start");
                        TreeItems.Where(x => x.isSelected).ToList();
                        //Thread.Sleep(5000);
                        //worditem.Status = SensitiveStatus.已处理;
                        //watch.Stop();
                        //Debug.WriteLine(watch.ElapsedMilliseconds);
                        //Debug.WriteLine("----------------AStree submit处理 结束 Stop");
                        Task.Delay(1000 * 2).ContinueWith(x => {
                                worditem.Status = SensitiveStatus.已处理;
                                watch.Stop();
                                Debug.WriteLine(watch.ElapsedMilliseconds);
                                Debug.WriteLine("----------------AStree submit处理 结束 Stop");
                            });
                    }
                    break;
                }

                case SensitiveStatus.已处理:
                {
                    worditem.Status = SensitiveStatus.未处理;
                    break;
                }

                case SensitiveStatus.完结:
                {
                    AssociativeWords.Remove(worditem);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MainPage.ShowErrorMessage(ex.Message);
            }
        }