private void AppFilter(string filter) { if (String.IsNullOrEmpty(filter) || String.IsNullOrEmpty(filter.Trim())) { foreach (TreeItemViewModel model in TreeItems.Where(item => !item.Visibility)) { model.Visible(); } } else { string lowerFilter = filter.ToLower(); foreach (TreeItemViewModel model in TreeItems) { if (!model.Name.ToLower().Contains(lowerFilter)) { model.Hide(); } else { model.Visible(); } } } }
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(); }
private void FillTree() { var topNode = new CompositeViewModel("top node") { IsExpanded = true, }; var subitems = Enumerable.Range(1, 8).Select(num => { var title = string.Format("node 1.{0} level", num); var composite = new CompositeViewModel(title, topNode) { IsExpanded = true, }; if (num % 2 == 0) { title = string.Format("Leaf {0}", num); composite.SubItems.Add(new LeafViewModel(title, composite)); } return(composite); }); topNode.SubItems.AddRange(subitems); TreeItems.Add(topNode); }
public ShellViewModel(IPageManager pageManager) { this.ViewAware = pageManager as PageManagerViewModel; TreeItems.AddRange(MainMenuTreeItemsProvider.GetDatas()); TreeItems.FirstOrDefault().IsSelected = true; TreeViewSelectedChanged(TreeItems.FirstOrDefault()); }
private void ReturnVisibleChekins(CallBackConteiner <List <long> > callBackConteiner) { callBackConteiner.Content = new List <long>(); foreach (TreeItemViewModel treeItemViewModel in TreeItems.Where(item => item.Visibility)) { callBackConteiner.Content.Add(treeItemViewModel.Id); } }
protected override void DeActivate() { base.DeActivate(); eventAggregator.GetEvent <RequestCheckinsEvent>().Unsubscribe(ReturnVisibleChekins); SaveSettings(); DeActivateAllViews(RegionNames.ContentRegion); TreeItems.Clear(); Search = String.Empty; }
private async void OnMarkAllAsRead() { if (TreeItems == null) { return; } var item = TreeItems.FirstOrDefault(); if (item == null) { return; } var dlg = new MessageDialog(Strings.Resources.MarkAllAsReadDialogContent); dlg.Commands.Add(new UICommand(Strings.Resources.DialogCommandYes) { Id = 1 }); dlg.Commands.Add(new UICommand(Strings.Resources.DialogCommandNo) { Id = 0 }); var x = await dlg.ShowAsync(); if ((int)x.Id != 1) { return; } Exception error = null; try { _telemetryClient.TrackEvent(TelemetryEvents.MarkAllAsRead); var timestamp = GetUnixTimeStamp(); await _apiClient.MarkAllAsReadAsync(item.Id, timestamp); LoadSubscriptions(); } catch (Exception ex) { error = ex; _telemetryClient.TrackException(ex); } if (error == null) { return; } MessageDialog msgbox = new MessageDialog(error.Message, Strings.Resources.ErrorDialogTitle); await msgbox.ShowAsync(); }
public void RemovePlacement(int index) { Definition.Placements.RemoveAt(index); TreeItems.RemoveAt(index); var element = Elements[index]; GroupElement.Children.Remove(element); Elements.Remove(element); element.Dispose(); }
public UserControl1() { InitializeComponent(); // foreach (var qs in qss) for (int i = 0; i < 50; i++) { // TreeItems.Add(qs); TreeItems.Add(new MyObject { SetName = "Test1" }); } }
public ObjectPlacement InsertPlacement(int index, ScenarioModel scenario, string paletteKey) { var placement = new ObjectPlacement(scenario, paletteKey); Definition.Placements.Insert(index, placement); TreeItems.Insert(index, new TreeItemModel { Header = placement.GetDisplayName(), IsChecked = true, Tag = null }); Elements.Insert(index, null); return(placement); }
private void UpdateSelectedTreeItem(long?selectedTreeItemId) { TreeItemViewModel findSelectedTreeItem = null; if (selectedTreeItemId.HasValue) { findSelectedTreeItem = TreeItems.FirstOrDefault(item => item.Id.Equals(selectedTreeItemId.Value) && item.Visibility); } if (findSelectedTreeItem == null) { findSelectedTreeItem = TreeItems.FirstOrDefault(item => item.Visibility); } SelectedTreeItem = findSelectedTreeItem; }
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 MainWindowViewModel() { int count = 1; TreeItems.Add(new TreeItemContext($"hoge{count++}")); TreeItems.Add(new TreeItemContext($"hoge{count++}")); TreeItems.Add(new TreeItemContext($"hoge{count++}")); ShowSettingCommand.Subscribe(() => { //設定を開く }); AddTreeItemCommand.Subscribe(() => { //アイテムを追加 TreeItems.Add(new TreeItemContext($"add {count++}")); }); }
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"); }
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); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (TreeItems.Any(item => item.Name == SelectedItem)) { var child = TreeItems.Single(item => item.Name == SelectedItem); if (!child.Children.Any(item => item.Name == ModelName)) { child.Children.Add(new TreeItem { Name = ModelName }); } } else { var tmpItem = new TreeItem { Name = SelectedItem }; tmpItem.Children.Add(new TreeItem { Name = ModelName }); TreeItems.Add(tmpItem); } }
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 void UpdateTreeViewCaption() { TreeViewCaption = $"{Properties.Resources.Checkins} ({TreeItems.Count(item => item.Visibility)}):"; }
void Retrieve(long id) { mTable = db.POS_Orders.Find(id); if (mTable == null) { btnClear_Click(null, null); return; } NewRecord = false; //txtOrderNo.Text = mTable.OrderNo.ToString(); cmbOrderType.SelectedValue = mTable.LookupOrderType_ID; cmbOrderType.SelectedValue = mTable.OrderStatus; LookUpCustomers.EditValue = mTable.Customer_ID; txtCustomerTel.Text = mTable.CustomerTel; txtCustomerAddress.Text = mTable.CustomerAddress; txtNote.Text = mTable.Note; lblTotal.Text = mTable.Total.ToString(); lblTax.Text = mTable.Tax.ToString(); lblDiscount.Text = mTable.Discount.ToString(); lblService.Text = mTable.Service.ToString(); lblDeliveryFees.Text = mTable.DeliveryFees.ToString(); lblTotalNet.Text = mTable.TotalNet.ToString(); var lst = (from mOrderD in db.POS_Orders2 from oitems in db.POS_Items.Where(oitems => oitems.ID == mOrderD.Item_ID).DefaultIfEmpty() from oSizes in db.POS_Sizes.Where(oSizes => oSizes.ID == mOrderD.Size_ID).DefaultIfEmpty() where mOrderD.Master_ID == id && mOrderD.Branch_ID == Settings.CurrentBranch_ID select new { mOrderD.ID, mOrderD.Item_ID, mOrderD.Size_ID, mOrderD.Qty, ItemName = mOrderD.Size_ID == null ? oitems.ItemName : oitems.ItemName + " - " + oSizes.SizeName, mOrderD.Note, mOrderD.Price, mOrderD.value, mOrderD.Discount, mOrderD.isPrint, mOrderD.isDelete, mOrderD.Perant_ID, mOrderD.UserCreate, mOrderD.UserLastModified, mOrderD.CreationDate, mOrderD.LastModified, mOrderD.Deleterow, mOrderD.UserDelete }).ToList(); Itemsdt.Rows.Clear(); foreach (var itm in lst) { Itemsdt.Rows.Add( itm.ID, itm.Item_ID, itm.Size_ID, itm.Qty, itm.ItemName, itm.Note, itm.Price, itm.value, itm.Discount, itm.isPrint, itm.isDelete, itm.Perant_ID, itm.UserCreate, itm.UserLastModified, itm.CreationDate, itm.LastModified, itm.Deleterow, itm.UserDelete ); } TreeItems.Refresh(); }
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); } }
public MainWindowViewModel() { TreeItems.Add(new TreeItemViewModel(this)); TreeItems.Add(new TreeItemViewModel(this)); TreeItems.Add(new TreeItemViewModel(this)); }
public void SetCapacity(int newSize) { Elements.Resize(newSize); TreeItems.Resize(newSize); }