From 79cb09df777bffbb304bcc3bca3724de21211c07 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Tue, 22 Jun 2021 00:03:59 +0200 Subject: [PATCH] click --- FModel/ViewModels/Commands/MenuCommand.cs | 2 +- .../Resources/Controls/Breadcrumb.xaml.cs | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/FModel/ViewModels/Commands/MenuCommand.cs b/FModel/ViewModels/Commands/MenuCommand.cs index ae5c5a44..7528761b 100644 --- a/FModel/ViewModels/Commands/MenuCommand.cs +++ b/FModel/ViewModels/Commands/MenuCommand.cs @@ -15,7 +15,7 @@ namespace FModel.ViewModels.Commands { } - public override async void Execute(ApplicationViewModel contextViewModel, object parameter) + public override void Execute(ApplicationViewModel contextViewModel, object parameter) { switch (parameter) { diff --git a/FModel/Views/Resources/Controls/Breadcrumb.xaml.cs b/FModel/Views/Resources/Controls/Breadcrumb.xaml.cs index 7ba461bd..0ddf764c 100644 --- a/FModel/Views/Resources/Controls/Breadcrumb.xaml.cs +++ b/FModel/Views/Resources/Controls/Breadcrumb.xaml.cs @@ -1,7 +1,10 @@ -using System.Windows; +using System.Linq; +using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Media; using System.Windows.Shapes; +using FModel.Services; namespace FModel.Views.Resources.Controls { @@ -22,11 +25,17 @@ namespace FModel.Views.Resources.Controls var folders = pathAtThisPoint.Split('/'); for (var i = 0; i < folders.Length; i++) { - InMeDaddy.Children.Add(new TextBlock + var textBlock = new TextBlock { Text = folders[i], + Background = Brushes.Transparent, + Cursor = Cursors.Hand, + Tag = i + 1, Margin = new Thickness(0, 3, 0, 0) - }); + }; + textBlock.MouseUp += OnMouseClick; + + InMeDaddy.Children.Add(textBlock); if (i >= folders.Length - 1) continue; InMeDaddy.Children.Add(new Viewbox @@ -47,5 +56,15 @@ namespace FModel.Views.Resources.Controls }); } } + + private void OnMouseClick(object sender, MouseButtonEventArgs e) + { + if (sender is not TextBlock {DataContext: string pathAtThisPoint, Tag: int index}) return; + + var directory = string.Join('/', pathAtThisPoint.Split('/').Take(index)); + if (pathAtThisPoint.Equals(directory)) return; + + ApplicationService.ApplicationView.CustomDirectories.GoToCommand.JumpTo(directory); + } } } \ No newline at end of file