Files
C4IT-F4SD-Client/FasdDesktopUi/Basics/UserControls/QuickActionSelector.xaml.cs
Meik 0b52999b1d feat: expand cockpit integrations and support workflows
Add Phoenix remote desktop, action connector, documentation engine, and gamification support. Refactor support-case processing and search/action UI, and update installer assets and dependencies.
2026-07-13 11:16:53 +02:00

243 lines
7.7 KiB
C#

using F4SD_AdaptableIcon.Enums;
using FasdDesktopUi.Basics.Models;
using FasdDesktopUi.Basics.UiActions;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using static C4IT.Logging.cLogManager;
using static FasdDesktopUi.Basics.UserControls.InformationClassSearchBar;
namespace FasdDesktopUi.Basics.UserControls
{
public partial class QuickActionSelector : UserControl, IBlurInvoker
{
#region Properties
public event EventHandler<string> SearchValueChanged;
public Action CloseButtonClickedAction { get; set; }
public Action<bool> LockStatusChanged { get; set; }
public static QuickActionSelector Instance;
#region IsLocked DependencyProperty
public bool IsLocked
{
get { return (bool)GetValue(IsLockedProperty); }
set { SetValue(IsLockedProperty, value); }
}
public static readonly DependencyProperty IsLockedProperty =
DependencyProperty.Register("IsLocked", typeof(bool), typeof(QuickActionSelector), new PropertyMetadata(new PropertyChangedCallback(HandleLockedChanged)));
private static void HandleLockedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
try
{
if (!(d is QuickActionSelector _me))
{
return;
}
_me.CloseButton.IsEnabled = !_me.IsLocked;
}
catch (Exception E)
{
LogException(E);
}
}
#endregion
#region QuickActionSelectorHeading DependencyProperty
public static readonly DependencyProperty QuickActionSelectorHeadingProperty =
DependencyProperty.Register("QuickActionSelectorHeading", typeof(string), typeof(QuickActionSelector), new PropertyMetadata(null));
public string QuickActionSelectorHeading
{
get { return (string)GetValue(QuickActionSelectorHeadingProperty); }
set { SetValue(QuickActionSelectorHeadingProperty, value); }
}
#endregion
#region QuickActionList DependencyProperty
public static readonly DependencyProperty QuickActionListProperty =
DependencyProperty.Register("QuickActionList", typeof(List<cMenuDataBase>), typeof(QuickActionSelector), new PropertyMetadata(null));
public List<cMenuDataBase> QuickActionList
{
get { return (List<cMenuDataBase>)GetValue(QuickActionListProperty); }
set { SetValue(QuickActionListProperty, value); }
}
#endregion
#region TempQuickActionSelectorHeading Property
public string TempQuickActionSelectorHeading { get; set; }
#endregion
#region TempQuickActionList DependencyProperty
public static readonly DependencyProperty TempQuickActionListProperty =
DependencyProperty.Register("TempQuickActionList", typeof(List<cMenuDataBase>), typeof(QuickActionSelector), new PropertyMetadata(null));
public List<cMenuDataBase> TempQuickActionList
{
get { return (List<cMenuDataBase>)GetValue(TempQuickActionListProperty); }
set { SetValue(TempQuickActionListProperty, value); }
}
#endregion
#endregion
public QuickActionSelector()
{
InitializeComponent();
Search.ActivateManualSearch();
Instance = this;
}
public void BlurInvoker_IsActiveChanged(object sender, DependencyPropertyChangedEventArgs e)
{
Search.IsInputEnabled = this.Visibility == Visibility.Visible;
BlurInvoker.InvokeVisibilityChanged(this, new EventArgs());
}
public bool BlurInvoker_IsActive => IsVisible;
#region LockButton_Click
private void LockButton_MouseLeave(object sender, MouseEventArgs e)
{
try
{
(sender as AdaptableIcon.AdaptableIcon).ClearValue(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty);
(sender as AdaptableIcon.AdaptableIcon).ClearValue(AdaptableIcon.AdaptableIcon.SelectedInternIconProperty);
(sender as AdaptableIcon.AdaptableIcon).ClearValue(AdaptableIcon.AdaptableIcon.BorderPaddingProperty);
}
catch (Exception E)
{
LogException(E);
}
}
private void LockButton_Click(object sender)
{
try
{
if (sender is AdaptableIcon.AdaptableIcon senderIcon)
{
if (IsLocked)
{
senderIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.SoftContrast");
senderIcon.SelectedInternIcon = enumInternIcons.lock_open;
}
else
{
senderIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
senderIcon.SelectedInternIcon = enumInternIcons.lock_closed;
}
senderIcon.BorderPadding = new Thickness(5.5);
}
IsLocked = !IsLocked;
LockStatusChanged?.Invoke(IsLocked);
}
catch (Exception E)
{
LogException(E);
}
}
private void LockButton_TouchDown(object sender, TouchEventArgs e)
{
LockButton_Click(sender);
}
private void LockButton_MouseUp(object sender, MouseButtonEventArgs e)
{
LockButton_Click(sender);
}
#endregion
#region CloseButton
public void CloseButton_Click()
{
try
{
if (IsLocked)
return;
QuickActionList = null;
Visibility = Visibility.Collapsed;
Search.IsEnabled = true;
Window window = Window.GetWindow(this);
if (window != null)
{
FocusManager.SetFocusedElement(window, window);
Keyboard.Focus(window);
}
CloseButtonClickedAction?.Invoke();
}
catch (Exception E)
{
LogException(E);
}
}
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
{
CloseButton_Click();
}
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
{
CloseButton_Click();
}
#endregion
#region BackButton
private void BackButton_Click()
{
QuickActionSelectorHeading = TempQuickActionSelectorHeading;
TempQuickActionSelectorHeading = null;
QuickActionList = TempQuickActionList;
TempQuickActionList = null;
Search.IsEnabled = true;
Search.FocusInput();
}
private void BackButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
BackButton_Click();
}
private void BackButton_TouchDown(object sender, TouchEventArgs e)
{
BackButton_Click();
}
#endregion
private void SearchBar_SearchValueChanged(object sender, string e)
=> SearchValueChanged?.Invoke(this, e);
}
}