Exemplo n.º 1
0
 private void TreeView_DragItemsStarting(MUXC.TreeView sender, MUXC.TreeViewDragItemsStartingEventArgs args)
 {
     foreach (TreeViewData item in args.Items)
     {
         DraggedItems.Add(item);
     }
 }
Exemplo n.º 2
0
    private async void TreeView_Expanding(winui.TreeView sender, winui.TreeViewExpandingEventArgs args)
    {
        if (!args.Node.HasUnrealizedChildren)
        {
            return;
        }

        sender.IsEnabled = false;

        try
        {
            if (args.Item is ViewModels.FileItemViewModel vm)
            {
                if (vm.Children is null)
                {
                    await vm.UpdateChildren();
                }
                args.Node.Children.Clear();
                foreach (var item in vm.Folders)
                {
                    args.Node.Children.Add(new winui.TreeViewNode()
                    {
                        IsExpanded            = false,
                        Content               = item,
                        HasUnrealizedChildren = item.IsFolder,
                    });
                }
            }
        }
        finally
        {
            args.Node.HasUnrealizedChildren = false;
            sender.IsEnabled = true;
        }
    }
Exemplo n.º 3
0
        private void TreeViewItem_Invoked(WinUI.TreeView sender, WinUI.TreeViewItemInvokedEventArgs args)
        {
            ItemInvokedWithThisClick = true;
            SelectedItem             = args.InvokedItem as FolderItem;
            var cont = treeView.ContainerFromItem(SelectedItem);

            SelectedNode = treeView.NodeFromContainer(cont);
        }
 private async void Tree_Expanding(MUXC.TreeView sender, MUXC.TreeViewExpandingEventArgs args)
 {
     if (args.Item is ListWrapper listWrapper && listWrapper.HasUnrealizedChildren)
     {
         listWrapper.TokenSource = new CancellationTokenSource();
         listWrapper.Expanded    = true;
         await FillItem(listWrapper);
     }
 }
Exemplo n.º 5
0
        private void TreeView_DragItemsCompleted(MUXC.TreeView sender, MUXC.TreeViewDragItemsCompletedEventArgs args)
        {
            foreach (TreeViewData item in args.Items)
            {
                item.Parent = args.NewParent as TreeViewData;
            }

            DraggedItems.Clear();
        }
 private void Tree_Collapsed(MUXC.TreeView sender, MUXC.TreeViewCollapsedEventArgs args)
 {
     if (args.Node is CancellableTreeViewNode ctvn)
     {
         ctvn.TokenSource.Cancel();
         ctvn.IsExpanded = false;
     }
     args.Node.Children.Clear();
     args.Node.HasUnrealizedChildren = true;
 }
 private void Tree_Collapsed(MUXC.TreeView sender, MUXC.TreeViewCollapsedEventArgs args)
 {
     if (args.Item is ListWrapper listWrapper)
     {
         listWrapper.TokenSource.Cancel();
         listWrapper.Expanded = false;
         listWrapper.Children.Clear();
         listWrapper.HasUnrealizedChildren = true;
     }
 }
Exemplo n.º 8
0
    private async void Treeview_ItemInvoked(winui.TreeView sender, winui.TreeViewItemInvokedEventArgs args)
    {
        if (args.InvokedItem is winui.TreeViewNode tvn && tvn.Content is ViewModels.FileItemViewModel vm)
        {
            await content.SetFolder(vm);

            if (tvn.IsExpanded == false)
            {
                tvn.IsExpanded = true;
            }
        }
    }
 private async void Tree_Expanding(MUXC.TreeView sender, MUXC.TreeViewExpandingEventArgs args)
 {
     if (args.Node.HasUnrealizedChildren)
     {
         if (args.Node is CancellableTreeViewNode ctvn)
         {
             ctvn.TokenSource = new CancellationTokenSource();
             ctvn.IsExpanded  = true;
         }
         await FillNode(args.Node);
     }
 }
        private async void CategoriesTree_ItemInvoked(muxc.TreeView sender, muxc.TreeViewItemInvokedEventArgs e)
        {
            muxc.TreeViewNode selected = (muxc.TreeViewNode)e.InvokedItem;

            if (selected.Content.GetType() == typeof(SearchableTreeNode))
            {
                SamplePageContainer.Visibility = Visibility.Collapsed;
                SampleSelectionGrid.Visibility = Visibility.Visible;
                List <SampleInfo> samples = selected.Children.ToList().Select(x => (SampleInfo)x.Content).ToList();
                SamplesGridView.ItemsSource = samples;
            }
            else if (selected.Content.GetType() == typeof(SampleInfo))
            {
                await SelectSample((SampleInfo)selected.Content);
            }
        }
Exemplo n.º 11
0
        public Control_Files(TreeView _tree, BreadcrumbBar _bar)
        {
            m_tree         = _tree;
            m_breadcrumbar = _bar;

            m_control.PopulateTreeView(
                m_tree,
                m_control.GetRelativePaths(
                    Directory.GetFiles(
                        Directory.GetCurrentDirectory()
                        + "\\Assets"),
                    Directory.GetCurrentDirectory())
                , '\\');

            m_breadcrumbar.ItemsSource = Directory.GetFiles(
                Directory.GetCurrentDirectory()
                + "\\Assets");
        }
        private async Task InitializeTreeView()
        {
            if (Combo.SelectedItem == null)
            {
                return;
            }
            if (Tree != null)
            {
                Tree.Expanding -= Tree_Expanding;
                Tree.Collapsed -= Tree_Collapsed;

                Tree.RootNodes.Clear();
            }

            DataStorage.Singleton.resetContents();

            Tree = new MUXC.TreeView();
            object resource;

            this.Resources.TryGetValue("Selector", out resource);
            if (resource is ContentModeItemTemplateSelector selector)
            {
                Tree.ItemTemplateSelector = selector;
            }
            else
            {
                Debug.WriteLine("Selector is no ContentModeItemTemplateSelector!");
            }
            Tree.Expanding         += Tree_Expanding;
            Tree.Collapsed         += Tree_Collapsed;
            Tree.SelectionMode      = MUXC.TreeViewSelectionMode.Single;
            Tree.IsDoubleTapEnabled = false;
            Tree.AllowDrop          = true;
            Tree.CanDragItems       = false;
            Tree.CanReorderItems    = true;
            Tree.ItemsSource        = new ObservableCollection <WrapperBase>();

            WrapViewer.Content = Tree;

            this.rootCts   = new CancellationTokenSource();
            this.rootToken = rootCts.Token;

            await FillNodeListWithData((ObservableCollection <WrapperBase>) Tree.ItemsSource, this.ComboBoxSelected, rootCts.Token);
        }
Exemplo n.º 13
0
    private async void TreeView_Expanding(Microsoft.UI.Xaml.Controls.TreeView sender, Microsoft.UI.Xaml.Controls.TreeViewExpandingEventArgs args)
    {
        if (!args.Node.HasUnrealizedChildren)
        {
            return;
        }

        sender.IsEnabled = false;

        try
        {
            if (args.Item is ViewModels.IBookmarkItem vm)
            {
                var container = sender.ContainerFromItem(args.Item);

                if (!vm.IsFolder)
                {
                    return;
                }
                var child = (await vm.GetChilderenAsync())?.Where(a => a.IsFolder && !a.IsReadOnly);
                if (child is null)
                {
                    return;
                }
                if (container is Microsoft.UI.Xaml.Controls.TreeViewItem tvi)
                {
                    tvi.ItemsSource = child;
                }
            }
        }
        finally
        {
            args.Node.HasUnrealizedChildren = false;
            sender.IsEnabled = true;
        }
    }
Exemplo n.º 14
0
 private void OnItemInvoked(WinUI.TreeView sender, WinUI.TreeViewItemInvokedEventArgs args)
 => SelectedItem = args.InvokedItem;
Exemplo n.º 15
0
 private void UnrealizedTreeViewSelection_Expanding(Microsoft.UI.Xaml.Controls.TreeView sender, Microsoft.UI.Xaml.Controls.TreeViewExpandingEventArgs args)
 {
     VirtualizingDataSource.FillTreeNode(args.Node);
 }
Exemplo n.º 16
0
 private void OnItemInvoked(Microsoft.UI.Xaml.Controls.TreeView sender, Microsoft.UI.Xaml.Controls.TreeViewItemInvokedEventArgs args)
 {
     StatusTextBlock.Text = $"{DateTime.UtcNow.ToLongTimeString()}: {(args.InvokedItem as Microsoft.UI.Xaml.Controls.TreeViewNode)?.Content}";
 }
Exemplo n.º 17
0
 private void UnrealizedTreeViewSelection_Collapsed(Microsoft.UI.Xaml.Controls.TreeView sender, Microsoft.UI.Xaml.Controls.TreeViewCollapsedEventArgs args)
 {
     VirtualizingDataSource.EmptyTreeNode(args.Node);
 }
Exemplo n.º 18
0
 private void sampleTreeView_ItemInvoked(mux.TreeView sender, mux.TreeViewItemInvokedEventArgs args)
 {
     return;
 }
Exemplo n.º 19
0
 // 选中书,列出所有卷的详细列表;
 // 选中卷,列出所有子卷或章的详细列表;
 // 选中章,加载章节内容。
 private void Outline_ItemInvoked(MUXC.TreeView sender, MUXC.TreeViewItemInvokedEventArgs args)
 {
     SetButtonStatus(true);
     m_current           = args.InvokedItem as ItemDetailViewModel;
     Details.ItemsSource = m_current.Children;
 }