diff --git a/FasdDesktopUi/Basics/UserControls/Badge.xaml b/FasdDesktopUi/Basics/UserControls/Badge.xaml
index 10b98b4..c85f5f4 100644
--- a/FasdDesktopUi/Basics/UserControls/Badge.xaml
+++ b/FasdDesktopUi/Basics/UserControls/Badge.xaml
@@ -3,70 +3,25 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
+ xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
mc:Ignorable="d"
d:DesignHeight="20"
d:DesignWidth="40"
- x:Name="BadgeControl"
- Loaded="BadgeControl_Loaded"
- Unloaded="BadgeControl_Unloaded">
+ x:Name="BadgeControl">
-
-
-
-
-
-
+
-
-
+
diff --git a/FasdDesktopUi/Basics/UserControls/Badge.xaml.cs b/FasdDesktopUi/Basics/UserControls/Badge.xaml.cs
index 2eb9e0c..8c095aa 100644
--- a/FasdDesktopUi/Basics/UserControls/Badge.xaml.cs
+++ b/FasdDesktopUi/Basics/UserControls/Badge.xaml.cs
@@ -1,16 +1,10 @@
-using System;
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
namespace FasdDesktopUi.Basics.UserControls
{
public partial class Badge : UserControl
{
- private readonly Storyboard _sparkleStoryboard;
- private const double SparkleBaseScale = 0.6;
-
public string Text
{
get { return (string)GetValue(TextProperty); }
@@ -20,118 +14,10 @@ namespace FasdDesktopUi.Basics.UserControls
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string), typeof(Badge), new PropertyMetadata("Beta"));
- public bool IsSparkleEnabled
- {
- get { return (bool)GetValue(IsSparkleEnabledProperty); }
- set { SetValue(IsSparkleEnabledProperty, value); }
- }
-
- public static readonly DependencyProperty IsSparkleEnabledProperty =
- DependencyProperty.Register(nameof(IsSparkleEnabled), typeof(bool), typeof(Badge), new PropertyMetadata(false, OnIsSparkleEnabledChanged));
-
public Badge()
{
InitializeComponent();
- _sparkleStoryboard = CreateSparkleStoryboard();
- UpdateSparkleState();
- }
-
- private static void OnIsSparkleEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var control = d as Badge;
- control?.UpdateSparkleState();
- }
-
- private void BadgeControl_Loaded(object sender, RoutedEventArgs e)
- {
- UpdateSparkleState();
- }
-
- private void BadgeControl_Unloaded(object sender, RoutedEventArgs e)
- {
- StopSparkles();
- }
-
- private void UpdateSparkleState()
- {
- if (SparkleCanvas == null || _sparkleStoryboard == null)
- {
- return;
- }
-
- if (IsSparkleEnabled)
- {
- SparkleCanvas.Visibility = Visibility.Visible;
- _sparkleStoryboard.Begin(this, true);
- return;
- }
-
- SparkleCanvas.Visibility = Visibility.Collapsed;
- StopSparkles();
- }
-
- private void StopSparkles()
- {
- _sparkleStoryboard?.Stop(this);
-
- if (SparkleTopRight != null)
- {
- SparkleTopRight.Opacity = 0;
- if (SparkleTopRight.RenderTransform is ScaleTransform topTransform)
- {
- topTransform.ScaleX = SparkleBaseScale;
- topTransform.ScaleY = SparkleBaseScale;
- }
- }
-
- if (SparkleBottomLeft != null)
- {
- SparkleBottomLeft.Opacity = 0;
- if (SparkleBottomLeft.RenderTransform is ScaleTransform bottomTransform)
- {
- bottomTransform.ScaleX = SparkleBaseScale;
- bottomTransform.ScaleY = SparkleBaseScale;
- }
- }
- }
-
- private Storyboard CreateSparkleStoryboard()
- {
- var storyboard = new Storyboard
- {
- RepeatBehavior = RepeatBehavior.Forever
- };
-
- AddKeyFrames(storyboard, SparkleTopRight, "Opacity",
- (0.00, 0.0), (0.18, 1.0), (0.42, 0.0), (2.20, 0.0));
- AddKeyFrames(storyboard, SparkleTopRight, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)",
- (0.00, SparkleBaseScale), (0.22, 1.15), (0.42, SparkleBaseScale), (2.20, SparkleBaseScale));
- AddKeyFrames(storyboard, SparkleTopRight, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)",
- (0.00, SparkleBaseScale), (0.22, 1.15), (0.42, SparkleBaseScale), (2.20, SparkleBaseScale));
-
- AddKeyFrames(storyboard, SparkleBottomLeft, "Opacity",
- (0.00, 0.0), (1.00, 0.0), (1.18, 1.0), (1.42, 0.0), (2.20, 0.0));
- AddKeyFrames(storyboard, SparkleBottomLeft, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)",
- (0.00, SparkleBaseScale), (1.00, SparkleBaseScale), (1.22, 1.15), (1.42, SparkleBaseScale), (2.20, SparkleBaseScale));
- AddKeyFrames(storyboard, SparkleBottomLeft, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)",
- (0.00, SparkleBaseScale), (1.00, SparkleBaseScale), (1.22, 1.15), (1.42, SparkleBaseScale), (2.20, SparkleBaseScale));
-
- return storyboard;
- }
-
- private static void AddKeyFrames(Storyboard storyboard, DependencyObject target, string targetProperty, params (double TimeSeconds, double Value)[] frames)
- {
- var animation = new DoubleAnimationUsingKeyFrames();
-
- foreach (var frame in frames)
- {
- animation.KeyFrames.Add(new LinearDoubleKeyFrame(frame.Value, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(frame.TimeSeconds))));
- }
-
- Storyboard.SetTarget(animation, target);
- Storyboard.SetTargetProperty(animation, new PropertyPath(targetProperty));
- storyboard.Children.Add(animation);
}
}
}
diff --git a/FasdDesktopUi/Basics/UserControls/ComboBoxPageable.xaml.cs b/FasdDesktopUi/Basics/UserControls/ComboBoxPageable.xaml.cs
index 41df5fb..1b52a5d 100644
--- a/FasdDesktopUi/Basics/UserControls/ComboBoxPageable.xaml.cs
+++ b/FasdDesktopUi/Basics/UserControls/ComboBoxPageable.xaml.cs
@@ -1,7 +1,7 @@
using C4IT.FASD.Base;
-using C4IT.MultiLanguage;
-using FasdDesktopUi.Basics.Helper;
-using FasdDesktopUi.Basics.Models;
+using C4IT.MultiLanguage;
+using FasdDesktopUi.Basics.Helper;
+using FasdDesktopUi.Basics.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -125,25 +125,25 @@ namespace FasdDesktopUi.Basics.UserControls
}
- public static readonly DependencyProperty SearchDataChangedProperty =
- DependencyProperty.Register("SearchDataChanged", typeof(EventHandler), typeof(ComboBoxPageable), new PropertyMetadata(null));
-
- #endregion
-
- #region RestoreParentScrollFocusOnDropDownClose
-
- public bool RestoreParentScrollFocusOnDropDownClose
- {
- get { return (bool)GetValue(RestoreParentScrollFocusOnDropDownCloseProperty); }
- set { SetValue(RestoreParentScrollFocusOnDropDownCloseProperty, value); }
- }
-
- public static readonly DependencyProperty RestoreParentScrollFocusOnDropDownCloseProperty =
- DependencyProperty.Register("RestoreParentScrollFocusOnDropDownClose", typeof(bool), typeof(ComboBoxPageable), new PropertyMetadata(false));
-
- #endregion
-
- #region ItemData
+ public static readonly DependencyProperty SearchDataChangedProperty =
+ DependencyProperty.Register("SearchDataChanged", typeof(EventHandler), typeof(ComboBoxPageable), new PropertyMetadata(null));
+
+ #endregion
+
+ #region RestoreParentScrollFocusOnDropDownClose
+
+ public bool RestoreParentScrollFocusOnDropDownClose
+ {
+ get { return (bool)GetValue(RestoreParentScrollFocusOnDropDownCloseProperty); }
+ set { SetValue(RestoreParentScrollFocusOnDropDownCloseProperty, value); }
+ }
+
+ public static readonly DependencyProperty RestoreParentScrollFocusOnDropDownCloseProperty =
+ DependencyProperty.Register("RestoreParentScrollFocusOnDropDownClose", typeof(bool), typeof(ComboBoxPageable), new PropertyMetadata(false));
+
+ #endregion
+
+ #region ItemData
public ObservableCollection> ItemData
{
@@ -222,6 +222,15 @@ namespace FasdDesktopUi.Basics.UserControls
return null;
}
+ public bool CloseDropDownIfOpen()
+ {
+ if (ComboBoxControl?.IsDropDownOpen != true)
+ return false;
+
+ ComboBoxControl.IsDropDownOpen = false;
+ return true;
+ }
+
#region Paging Events
#region PageBack
@@ -316,33 +325,42 @@ namespace FasdDesktopUi.Basics.UserControls
}
}
- private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
- {
- timer.Stop();
- cFocusInvoker.InvokeLostFocus(this, e);
-
- if (RestoreParentScrollFocusOnDropDownClose)
- {
- _ = Dispatcher.BeginInvoke((Action)(() =>
- {
- try
- {
- var parentScrollViewer = cUiElementHelper.GetFirstParentOfType(this);
- Keyboard.ClearFocus();
-
- if (parentScrollViewer != null)
- {
- parentScrollViewer.Focus();
- Keyboard.Focus(parentScrollViewer);
- }
- }
- catch (Exception exception)
- {
- LogException(exception);
- }
- }), System.Windows.Threading.DispatcherPriority.Input);
- }
- }
+ private void SearchTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.Escape)
+ return;
+
+ if (CloseDropDownIfOpen())
+ e.Handled = true;
+ }
+
+ private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
+ {
+ timer.Stop();
+ cFocusInvoker.InvokeLostFocus(this, e);
+
+ if (RestoreParentScrollFocusOnDropDownClose)
+ {
+ _ = Dispatcher.BeginInvoke((Action)(() =>
+ {
+ try
+ {
+ var parentScrollViewer = cUiElementHelper.GetFirstParentOfType(this);
+ Keyboard.ClearFocus();
+
+ if (parentScrollViewer != null)
+ {
+ parentScrollViewer.Focus();
+ Keyboard.Focus(parentScrollViewer);
+ }
+ }
+ catch (Exception exception)
+ {
+ LogException(exception);
+ }
+ }), System.Windows.Threading.DispatcherPriority.Input);
+ }
+ }
private void ComboBoxControl_DropDownOpened(object sender, EventArgs e)
{
@@ -384,6 +402,8 @@ namespace FasdDesktopUi.Basics.UserControls
TextBox searchTextBox = FindVisualChild(partPopup.Child, "SearchTextBox");
if (searchTextBox != null)
{
+ searchTextBox.PreviewKeyDown -= SearchTextBox_PreviewKeyDown;
+ searchTextBox.PreviewKeyDown += SearchTextBox_PreviewKeyDown;
// Setzen des Fokus auf TextBox
searchTextBox.Focus();
}
diff --git a/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml.cs b/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml.cs
index 48b5d8c..192fb18 100644
--- a/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml.cs
+++ b/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml.cs
@@ -1,429 +1,451 @@
-using FasdDesktopUi.Basics.Models;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Threading;
-
-namespace FasdDesktopUi.Basics.UserControls
-{
- public partial class HierarchicalSelectionControl : UserControl
- {
- private readonly ObservableCollection visibleItems = new ObservableCollection();
- private readonly Dictionary itemLookup = new Dictionary();
- private readonly DispatcherTimer searchDelayTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
- private string lastSearchText = string.Empty;
- private bool suppressTreeSelectionChanged;
-
- private TextBox searchTextBox;
- private TreeView treeViewControl;
- private ScrollViewer itemsScrollViewer;
-
- public ObservableCollection VisibleItems => visibleItems;
-
- public event EventHandler DropDownOpened;
- public event EventHandler DropDownClosed;
-
- public HierarchicalSelectionControl()
- {
- InitializeComponent();
- searchDelayTimer.Tick += SearchDelayTimer_Tick;
- }
-
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- EnsureTemplateParts();
- if (treeViewControl != null)
- treeViewControl.ItemsSource = VisibleItems;
- }
-
- #region DependencyProperties
-
- public ObservableCollection ItemsSource
- {
- get => (ObservableCollection)GetValue(ItemsSourceProperty);
- set => SetValue(ItemsSourceProperty, value);
- }
-
- public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
- nameof(ItemsSource),
- typeof(ObservableCollection),
- typeof(HierarchicalSelectionControl),
- new PropertyMetadata(null, OnItemsSourceChanged));
-
- private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is HierarchicalSelectionControl control)
- {
- control.RebuildLookup();
- control.ApplyFilter(control.lastSearchText);
- }
- }
-
- public HierarchicalSelectionItem SelectedItem
- {
- get => (HierarchicalSelectionItem)GetValue(SelectedItemProperty);
- set => SetValue(SelectedItemProperty, value);
- }
-
- public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register(
- nameof(SelectedItem),
- typeof(HierarchicalSelectionItem),
- typeof(HierarchicalSelectionControl),
- new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedItemChanged));
-
- private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is HierarchicalSelectionControl control)
- {
- control.TryExpandToSelectedItem();
- control.SyncTreeSelectionWithSelectedItem(bringIntoView: false);
- }
- }
-
- public Brush ComboBoxBackground
- {
- get => (Brush)GetValue(ComboBoxBackgroundProperty);
- set => SetValue(ComboBoxBackgroundProperty, value);
- }
-
- public static readonly DependencyProperty ComboBoxBackgroundProperty =
- DependencyProperty.Register(nameof(ComboBoxBackground), typeof(Brush), typeof(HierarchicalSelectionControl), new PropertyMetadata(Brushes.Transparent));
-
- public string SearchPlaceholderText
- {
- get => (string)GetValue(SearchPlaceholderTextProperty);
- set => SetValue(SearchPlaceholderTextProperty, value);
- }
-
- public static readonly DependencyProperty SearchPlaceholderTextProperty =
- DependencyProperty.Register(nameof(SearchPlaceholderText), typeof(string), typeof(HierarchicalSelectionControl), new PropertyMetadata(string.Empty));
-
- #endregion
-
- #region UI Event Handling
-
- private void ComboBoxControl_DropDownOpened(object sender, EventArgs e)
- {
- EnsureTemplateParts();
- searchTextBox?.Focus();
- searchTextBox?.SelectAll();
- suppressTreeSelectionChanged = false;
- SyncTreeSelectionWithSelectedItem(bringIntoView: true);
- DropDownOpened?.Invoke(this, e);
- }
-
- private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
- {
- searchDelayTimer.Stop();
- suppressTreeSelectionChanged = false;
- DropDownClosed?.Invoke(this, e);
- }
-
- private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- searchDelayTimer.Stop();
- searchDelayTimer.Start();
- }
-
- private void SearchDelayTimer_Tick(object sender, EventArgs e)
- {
- searchDelayTimer.Stop();
- lastSearchText = searchTextBox?.Text ?? string.Empty;
- ApplyFilter(lastSearchText);
- }
-
- private void TreeViewControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs