/// <summary> /// Clears all content and the tree. /// </summary> public void Clear() { RootItems.Clear(); _contentItems.Clear(); _contentItemMap.Clear(); _pendingItems.Clear(); }
private void CreateContainedFiles() { foreach (var vm in _fileSystem.Root.Files.Select(d => new FileViewModel(d, null))) { RootItems.Add(vm); } }
private void CreateContainedDirectories() { foreach (var vm in _fileSystem.Root.Directories.Select(d => new DirectoryViewModel(d, null))) { RootItems.Add(vm); } }
bool AddTreeViewItemToRootItems(IDebugState content) { var parentID = content.ParentID.GetValueOrDefault(); if (content.StateType == StateType.Message && parentID == Guid.Empty) { RootItems.Add(new DebugStringTreeViewItemViewModel { Content = content.Message, ActivityTypeName = content.ActualType }); } else { var isRootItem = parentID == Guid.Empty || content.ID == parentID; var child = CreateChildTreeViewItem(content); if (!_contentItemMap.ContainsKey(content.ID)) { _contentItemMap.Add(content.ID, child); } if (isRootItem) { RootItems.Add(child); } else { var parent = CreateParentTreeViewItem(content, child); if (AddErrorToParent(content, child, parent)) { return(true); } } } return(false); }
/// <summary> /// 选择行集合变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnSelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e) { // HasSelected状态 bool hasSelected = HasSelected; if (_selectedRows.Count == 0 && hasSelected) { ClearValue(HasSelectedProperty); } else if (_selectedRows.Count > 0 && !hasSelected) { HasSelected = true; } if (e.Action == NotifyCollectionChangedAction.Add) { // 增加 if (e.NewItems != null && e.NewItems.Count > 0) { List <object> adds = new List <object>(); foreach (var row in e.NewItems.OfType <TvItem>()) { row.IsSelected = true; adds.Add(row.Data); } SelectionChanged?.Invoke(this, new SelectionChangedEventArgs(new List <object>(), adds)); } } else if (e.Action == NotifyCollectionChangedAction.Remove) { // 删除 if (e.OldItems != null && e.OldItems.Count > 0) { List <object> removals = new List <object>(); foreach (var row in e.OldItems.OfType <TvItem>()) { row.IsSelected = false; removals.Add(row.Data); } SelectionChanged?.Invoke(this, new SelectionChangedEventArgs(removals, new List <object>())); } } else if (e.Action == NotifyCollectionChangedAction.Reset) { // 清空 var removals = new List <object>(); foreach (var row in RootItems.GetAllItems()) { if (row.IsSelected.HasValue && row.IsSelected.Value) { removals.Add(row.Data); } row.IsSelected = false; } if (removals.Count > 0 && SelectionChanged != null) { SelectionChanged(this, new SelectionChangedEventArgs(removals, new List <object>())); } } }
/// <summary> /// 获取同层下面的节点 /// </summary> /// <param name="p_item"></param> /// <returns></returns> public object GetFollowingBrother(object p_item) { var item = (from row in RootItems.GetAllItems() where row.Data == p_item select row).FirstOrDefault(); if (item == null) { return(null); } int index; if (item.Parent == null) { index = RootItems.IndexOf(item); if (index >= 0 && index < RootItems.Count - 1) { return(RootItems[index + 1].Data); } } else { index = item.Parent.Children.IndexOf(item); if (index >= 0 && index < item.Parent.Children.Count - 1) { return(item.Parent.Children[index + 1].Data); } } return(null); }
private void CreateContainedFiles() { foreach (var vm in _fileSystem.Root.Files.Select(d => new FileTreeNodeViewModel(d, _search, _subFileFactories))) { RootItems.Add(vm); } }
//----------------------------------------------------------------------- public void SetRootItem(DataItem item) { RootItems.Clear(); RootItems.Add(item); m_storedRootItems.Add(item); GraphNodeItems.Clear(); foreach (var i in Descendants) { i.DataModel = this; if (item is GraphNodeItem && !GraphNodeItems.Contains(item)) { if (!GraphNodeItems.Contains(item as GraphNodeItem)) { GraphNodeItems.Add(item as GraphNodeItem); } } } if (RootItems.Any(e => !(e is GraphNodeItem))) { ShowAsGraph = false; ShowAsDataModel = true; } else { ShowAsGraph = true; ShowAsDataModel = false; } RaisePropertyChangedEvent("ShowAsGraph"); RaisePropertyChangedEvent("ShowAsDataModel"); }
public void Clear() { RootItems.Clear(); _allDebugReceived = false; _contentItems.Clear(); _contentItemMap.Clear(); _pendingItems.Clear(); }
void SetAllExpandState(bool p_isExpanded) { foreach (var item in RootItems.GetAllItems()) { item.SetExpandState(p_isExpanded); } RootItems.Invalidate(); }
public void Reset() { if (RootItems == null) { return; } RootItems.Clear(); }
private void CreateContainedDirectories() { var rootDirectories = _fileSystem.Root.Directories.Select(d => new DirectoryTreeNodeViewModel(d, _search, _searchOptions, _uiDispatch, _subFileFactories)); foreach (var directory in rootDirectories) { RootItems.Add(directory); } }
public ContentViewModel(IItem rootItem, IServiceProvider serviceProvider) { rootItem = rootItem ?? throw new ArgumentNullException(nameof(rootItem)); ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _selectedItemService = serviceProvider.GetRequiredService <ISelectedItemService>(); var itemViewModelBuilder = ServiceProvider.GetRequiredService <IItemViewModelBuilder>(); RootItems.Add(itemViewModelBuilder.Build(rootItem)); }
void AddNewTest(IEventAggregator eventPublisher) { var newTestFromDebugMessage = new NewTestFromDebugMessage { ResourceID = ResourceID, ResourceModel = _contextualResourceModel, RootItems = RootItems.ToList() }; eventPublisher.Publish(newTestFromDebugMessage); }
/// <summary> /// 清空所有行 /// </summary> internal void ClearItems() { RootItems.Clear(); if (_selectedRows.Count > 0) { _selectedRows.Clear(); } if (_isLoaded) { _panel.OnRowsChanged(); } }
public BookmarkPage(Bookmarks.BookmarkPage bookmarkPage) { Core = bookmarkPage; if (bookmarkPage.RootItems != null) { foreach (var rootItem in bookmarkPage.RootItems) { RootItems.Add(new BookmarkItem(rootItem, 0)); } } }
/// <summary> /// 滚动到指定的节点 /// </summary> /// <param name="p_item"></param> public void ScrollInto(object p_item) { if (_panel != null) { var item = (from row in RootItems.GetAllItems() where row.Data == p_item select row).FirstOrDefault(); if (item != null) { _panel.ScrollIntoItem(item); } } }
protected override void OnDestroy() { Application.RemoveMessageFilter(this); destroying = true; foreach (var item in RootItems.ToArray()) { item.Dispose(); } RootItems.Clear(); base.OnDestroy(); }
private void FilterRootItems() { var hidden = RootItems.Where(i => !_search.FileResults.Any(r => r.File.Path.StartsWith(i.Path))) .ToArray(); foreach (var item in hidden) { item.Dispose(); _uiDispatch.Do(() => RootItems.Remove(item)); } // show info if no results SearchFoundNoMatch = _search.FileResults.Any() ? null : new SearchFoundNoMatchViewModel(); PropertyChanged.Raise(this, nameof(SearchFoundNoMatch)); }
void AddNewTest(IEventAggregator eventPublisher) { var applicationTracker = CustomContainer.Get <IApplicationTracker>(); if (applicationTracker != null) { applicationTracker.TrackEvent(Warewolf.Studio.Resources.Languages.TrackEventMenu.EventCategory, Warewolf.Studio.Resources.Languages.TrackEventMenu.CreateNewTest); } var newTestFromDebugMessage = new NewTestFromDebugMessage { ResourceID = ResourceID, ResourceModel = _contextualResourceModel, RootItems = RootItems.ToList() }; eventPublisher.Publish(newTestFromDebugMessage); }
private void CreateRootItems() { foreach (var disposable in RootItems) { disposable.Dispose(); } _uiDispatch.Do(() => { RootItems.Clear(); CreateContainedDirectories(); CreateContainedFiles(); }); SearchFoundNoMatch = null; PropertyChanged.Raise(this, nameof(SearchFoundNoMatch)); }
public IUSHierarchyItem GetParentOf(IUSHierarchyItem item) { if (RootItems.Contains(item)) { return(null); } IUSHierarchyItem itemsParent = null; for (var i = 0; i < RootItems.Count; i++) { itemsParent = GetParentOfChild(RootItems[i], item); if (itemsParent != null) { break; } } return(itemsParent); }
/// <summary> /// Rebuilds the tree. /// </summary> void RebuildTree() { lock (_syncContext) { _isRebuildingTree = true; } RootItems.Clear(); _contentItemMap.Clear(); foreach (var content in _contentItems) { AddItemToTreeImpl(content); } lock (_syncContext) { _isRebuildingTree = false; } }
//----------------------------------------------------------------------- public void SetRootItem(DataItem item) { RootItems.Clear(); RootItems.Add(item); m_storedRootItems.Add(item); GraphNodeItems.Clear(); foreach (var i in Descendants) { i.DataModel = this; if (item is GraphNodeItem && !GraphNodeItems.Contains(item)) { if (!GraphNodeItems.Contains(item as GraphNodeItem)) { GraphNodeItems.Add(item as GraphNodeItem); } } } UpdateEditorType(); }
/// <summary> /// 触发加载子节点事件 /// </summary> /// <param name="p_item"></param> /// <returns></returns> internal async Task OnLoadingChild(TvItem p_item) { if (LoadingChild == null) { return; } var args = new LoadingChildArgs(p_item); LoadingChild(this, args); await args.EnsureAllCompleted(); if (args.Children != null) { foreach (var item in args.Children) { TvItem ti = new TvItem(this, item, p_item); ti.ExpandedState = TvItemExpandedState.NotExpanded; p_item.Children.Add(ti); } RootItems.Invalidate(); } p_item.HasLoadedChildren = true; }
void OnKeyDown(object sender, KeyRoutedEventArgs e) { if (SelectionMode == SelectionMode.Multiple || RootItems.Count == 0) { return; } TvItem row; switch (e.Key) { case VirtualKey.Down: row = SelectedRows.LastOrDefault(); if (row == null) { OnToggleSelected(RootItems[0]); } else { using (var ls = RootItems.GetExpandedItems().GetEnumerator()) { while (ls.MoveNext()) { if (ls.Current == row) { if (ls.MoveNext()) { OnToggleSelected(ls.Current); } else { OnToggleSelected(RootItems[0]); } break; } } } } e.Handled = true; return; case VirtualKey.Up: row = SelectedRows.LastOrDefault(); if (row == null) { OnToggleSelected(RootItems[0]); } else { using (var ls = RootItems.GetExpandedItems().GetEnumerator()) { if (ls.MoveNext()) { if (ls.Current == row) { SelectedItem = null; } else { while (true) { TvItem lastRow = ls.Current; if (ls.MoveNext()) { if (ls.Current == row) { OnToggleSelected(lastRow); break; } } } } } } } e.Handled = true; return; case VirtualKey.Enter: row = SelectedRows.LastOrDefault(); if (row != null) { row.OnClick(); } return; default: return; } }
public SideBarViewModel() { RootItems.Add(new ConnectedEntitiesViewModel()); RootItems.Add(new MicrosoftAzure()); RootItems.Add(new AmazonAws()); }
//############################################################################################################## //----------------------------------------------------------------------- public void FocusItem(DataItem item) { if (item == m_proxyRootItem) { m_focusedItemsPath.Clear(); RootItems.Clear(); foreach (var child in m_storedRootItems) { RootItems.Add(child); } } else if (RootItems.Contains(item)) { return; } else { item.Focus(); m_focusedItemsPath.Clear(); DataItem current = null; if (item is GraphNodeItem) { current = (item as GraphNodeItem).LinkParents.FirstOrDefault(); } else { current = item.Parent; } while (current != null) { if (current is CollectionChildItem || current is GraphNodeItem || !(current.Parent is CollectionChildItem)) { m_focusedItemsPath.Add(current); } if (current is GraphNodeItem) { current = (current as GraphNodeItem).LinkParents.FirstOrDefault(); } else { current = current.Parent; } } m_focusedItemsPath.Remove(m_focusedItemsPath.Last()); m_focusedItemsPath.Add(m_proxyRootItem); for (int i = 0; i < m_focusedItemsPath.Count; i++) { m_focusedItemsPath[i].ZIndex = i; m_focusedItemsPath[i].FirstItem = Visibility.Visible; } for (int i = 0; i < m_focusedItemsPath.Count; i++) { m_focusedItemsPath.Move(m_focusedItemsPath.Count - 1, i); } m_focusedItemsPath[0].FirstItem = Visibility.Hidden; RootItems.Clear(); RootItems.Add(item); item.IsExpanded = true; if (m_lastFocusedItem != null) { if (m_lastFocusedItem is CollectionItem) { CollectionItem collectionItem = m_lastFocusedItem as CollectionItem; //collectionItem.IsFocused = false; } } m_lastFocusedItem = item; if (m_lastFocusedItem != null) { if (m_lastFocusedItem is CollectionItem) { CollectionItem collectionItem = m_lastFocusedItem as CollectionItem; //collectionItem.IsFocused = true; } } } IsFocusing = m_focusedItemsPath.Count > 0; RaisePropertyChangedEvent("RootItems"); }
void AddItemToTreeImpl(IDebugState content) { if ((DebugStatus == DebugStatus.Stopping || DebugStatus == DebugStatus.Finished || _allDebugReceived) && string.IsNullOrEmpty(content.Message) && !_continueDebugDispatch && !_dispatchLastDebugState) { return; } Dev2Logger.Log.Debug(string.Format("Debug content to be added ID: {0}" + Environment.NewLine + "Parent ID: {1}" + Environment.NewLine + "Name: {2}", content.ID, content.ParentID, content.DisplayName)); if (_lastStep != null && DebugStatus == DebugStatus.Finished && content.StateType == StateType.Message) { var lastDebugStateProcessed = _lastStep; _lastStep = null; _dispatchLastDebugState = true; AddItemToTreeImpl(new DebugState { StateType = StateType.Message, Message = Resources.CompilerMessage_ExecutionInterrupted, ParentID = lastDebugStateProcessed.ParentID }); AddItemToTreeImpl(lastDebugStateProcessed); _dispatchLastDebugState = false; } if (!string.IsNullOrWhiteSpace(SearchText) && !_debugOutputFilterStrategy.Filter(content, SearchText)) { return; } if (content.StateType == StateType.Message && content.ParentID == Guid.Empty) { RootItems.Add(new DebugStringTreeViewItemViewModel { Content = content.Message }); } else { var isRootItem = content.ParentID == Guid.Empty || content.ID == content.ParentID; IDebugTreeViewItemViewModel child; if (content.StateType == StateType.Message) { child = new DebugStringTreeViewItemViewModel { Content = content.Message }; } else { child = new DebugStateTreeViewItemViewModel(EnvironmentRepository) { Content = content }; } if (!_contentItemMap.ContainsKey(content.ID)) { _contentItemMap.Add(content.ID, child); } if (isRootItem) { RootItems.Add(child); } else { IDebugTreeViewItemViewModel parent; if (!_contentItemMap.TryGetValue(content.ParentID, out parent)) { parent = new DebugStateTreeViewItemViewModel(EnvironmentRepository); _contentItemMap.Add(content.ParentID, parent); } child.Parent = parent; parent.Children.Add(child); if (child.HasError.GetValueOrDefault(false)) { var theParent = parent as DebugStateTreeViewItemViewModel; if (theParent == null) { return; } theParent.AppendError(content.ErrorMessage); theParent.HasError = true; } } } if (content.IsFinalStep()) { DebugStatus = DebugStatus.Finished; } }
/// <summary> /// 删除数据对应的节点,若节点为选择状态,则删除后选择同层后一节点或父节点 /// </summary> /// <param name="p_item"></param> public void DeleteItem(object p_item) { var item = (from row in RootItems.GetAllItems() where row.Data == p_item select row).FirstOrDefault(); if (item == null) { return; } int index; if (item.Parent == null) { index = RootItems.IndexOf(item); if (index > -1) { RootItems.RemoveAt(index); if ((bool)item.IsSelected) { if (index < RootItems.Count) { SelectedItem = RootItems[index].Data; } else if (RootItems.Count > 0) { SelectedItem = RootItems[RootItems.Count - 1].Data; } else { SelectedItem = null; } } } } else { var ls = item.Parent.Children; index = ls.IndexOf(item); if (index > -1) { ls.RemoveAt(index); if ((bool)item.IsSelected) { if (index < ls.Count) { SelectedItem = ls[index].Data; } else if (ls.Count > 0) { SelectedItem = ls[ls.Count - 1].Data; } else { SelectedItem = item.Parent.Data; } } } } RootItems.Invalidate(); }