inital
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.QuickTip.QuickTipStatusMonitor"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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.QuickTip"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="400"
|
||||
MinWidth="400"
|
||||
MinHeight="200"
|
||||
IsVisibleChanged="QuickTipStatusMonitorUc_IsVisibleChanged"
|
||||
x:Name="QuickTipStatusMonitorUc">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<Style x:Key="BorderButtonWithText" TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
<Setter Property="Background" Value="{DynamicResource Color.AppBackground}"/>
|
||||
<Setter Property="Height" Value="35"/>
|
||||
<EventSetter Event="MouseEnter" Handler="ButtonBorder_MouseEnter"/>
|
||||
<EventSetter Event="MouseLeave" Handler="ButtonBorder_MouseLeave"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundColor.Menu.MainCategory}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Padding="10"
|
||||
Margin="0 0 0 10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
VerticalAlignment="Top">
|
||||
|
||||
<DockPanel>
|
||||
<DockPanel LastChildFill="False" DockPanel.Dock="Top">
|
||||
|
||||
<ico:AdaptableIcon
|
||||
x:Name="HeadingIcon"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Base}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="7.5 0 0 0"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
SelectedInternIcon="{Binding QuickTipIcon.Intern, ElementName=QuickTipStatusMonitorUc}"
|
||||
SelectedMaterialIcon="{Binding QuickTipIcon.Material, ElementName=QuickTipStatusMonitorUc}"/>
|
||||
|
||||
<TextBlock
|
||||
x:Name="HeadingText"
|
||||
Text="{Binding QuickTipName, ElementName=QuickTipStatusMonitorUc}"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10" />
|
||||
|
||||
</DockPanel>
|
||||
|
||||
|
||||
|
||||
<Grid Margin="0,5,0,0" DockPanel.Dock="Bottom">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
x:Name="CompleteButton"
|
||||
Grid.Column="1"
|
||||
Style="{DynamicResource BorderButtonWithText}"
|
||||
MouseLeftButtonUp="CompleteButton_Click"
|
||||
TouchDown="CompleteButton_Click">
|
||||
|
||||
<TextBlock
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Complete}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
x:Name="CancelButton"
|
||||
Grid.Column="3"
|
||||
Style="{DynamicResource BorderButtonWithText}"
|
||||
MouseLeftButtonUp="CancelButton_Click"
|
||||
TouchDown="CancelButton_Click">
|
||||
|
||||
<TextBlock
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Cancel}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
x:Name="StepCountTextBlock"
|
||||
TextAlignment="Center"
|
||||
Text="0 von 0 Schritten abgeschlossen"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
DockPanel.Dock="Bottom"/>
|
||||
|
||||
<ScrollViewer
|
||||
x:Name="QuickTipElementViewer"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
DockPanel.Dock="Top">
|
||||
<StackPanel
|
||||
x:Name="QuickTipElementPanel">
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</ScrollViewer>
|
||||
|
||||
</DockPanel>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,363 @@
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using F4SD_AdaptableIcon;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Pages.CustomMessageBox;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static FasdDesktopUi.Basics.UiActions.cUiQuickTipAction;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls.QuickTip
|
||||
{
|
||||
public partial class QuickTipStatusMonitor : UserControl
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
#region QuickTipName
|
||||
|
||||
public string QuickTipName
|
||||
{
|
||||
get { return (string)GetValue(QuickTipNameProperty); }
|
||||
set { SetValue(QuickTipNameProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for QuickTipName. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty QuickTipNameProperty =
|
||||
DependencyProperty.Register("QuickTipName", typeof(string), typeof(QuickTipStatusMonitor), new PropertyMetadata("Quick Tip Name"));
|
||||
|
||||
#endregion
|
||||
|
||||
#region QuickTipIcon
|
||||
|
||||
public IconData QuickTipIcon
|
||||
{
|
||||
get { return (IconData)GetValue(QuickTipIconProperty); }
|
||||
set { SetValue(QuickTipIconProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for QuickTipIcon. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty QuickTipIconProperty =
|
||||
DependencyProperty.Register("QuickTipIcon", typeof(IconData), typeof(QuickTipStatusMonitor), new PropertyMetadata(new IconData(enumInternIcons.none)));
|
||||
|
||||
#endregion
|
||||
|
||||
#region QuickTipElementData
|
||||
|
||||
public List<cUiQuickTipElement> QuickTipElementData
|
||||
{
|
||||
get { return (List<cUiQuickTipElement>)GetValue(QuickTipElementDataProperty); }
|
||||
set { SetValue(QuickTipElementDataProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for QuickTipElementData. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty QuickTipElementDataProperty =
|
||||
DependencyProperty.Register("QuickTipElementData", typeof(List<cUiQuickTipElement>), typeof(QuickTipStatusMonitor), new PropertyMetadata(new List<cUiQuickTipElement>(), HandleQuickTipElementDataChanged));
|
||||
|
||||
private static void HandleQuickTipElementDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is QuickTipStatusMonitor quickTip)
|
||||
{
|
||||
quickTip.QuickTipElementPanel.Children.Clear();
|
||||
quickTip._stepList.Clear();
|
||||
quickTip._indexOfStepWithFocus = -1;
|
||||
quickTip.FillElements();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly List<QuickTipStep> _stepList = new List<QuickTipStep>();
|
||||
|
||||
private int _indexOfStepWithFocus = -1;
|
||||
|
||||
#region StepCount
|
||||
|
||||
public enum enumQuickTipCompletionStatus
|
||||
{
|
||||
incomplete,
|
||||
requiredComplete,
|
||||
complete
|
||||
}
|
||||
|
||||
private enumQuickTipCompletionStatus completionStatus = enumQuickTipCompletionStatus.incomplete;
|
||||
|
||||
private int stepsCompletedCount = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region HasFocusIndex
|
||||
|
||||
public int HasFocusIndex
|
||||
{
|
||||
get { return (int)GetValue(HasFocusIndexProperty); }
|
||||
set { SetValue(HasFocusIndexProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for HasFocusIndex. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty HasFocusIndexProperty =
|
||||
DependencyProperty.Register("HasFocusIndex", typeof(int), typeof(QuickTipStatusMonitor), new PropertyMetadata(0));
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public QuickTipStatusMonitor()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void FillElements()
|
||||
{
|
||||
foreach (cUiQuickTipElement element in QuickTipElementData)
|
||||
{
|
||||
switch (element.ElementType)
|
||||
{
|
||||
case enumQuickTipElementType.Text:
|
||||
TextBlock textBlock = new TextBlock
|
||||
{
|
||||
Text = element.TextBlock,
|
||||
Margin = new Thickness(0, 0, 0, 5)
|
||||
};
|
||||
textBlock.SetResourceReference(TextBlock.ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
QuickTipElementPanel.Children.Add(textBlock);
|
||||
break;
|
||||
case enumQuickTipElementType.Automated:
|
||||
case enumQuickTipElementType.Manual:
|
||||
QuickTipStep step = new QuickTipStep { StepData = element };
|
||||
QuickTipElementPanel.Children.Add(step);
|
||||
_stepList.Add(step);
|
||||
step.RequestFocus += HandleStepRequestedFocus;
|
||||
step.SuccessStateChanged += HandleSuccessStateChanged;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetStepCount();
|
||||
}
|
||||
|
||||
private void SetStepCount()
|
||||
{
|
||||
int stepCount = _stepList.Count;
|
||||
int stepsCompleted = _stepList.Count(step => step.SuccessState != enumQuickActionSuccess.unknown &&
|
||||
(!(step.SuccessState == enumQuickActionSuccess.error && step.StepData.IsRequired)));
|
||||
|
||||
string stepCountText = cMultiLanguageSupport.GetItem("QuickTips.Control.StepCount");
|
||||
stepCountText = string.Format(stepCountText, stepsCompleted, stepCount);
|
||||
StepCountTextBlock.Text = stepCountText;
|
||||
|
||||
stepsCompletedCount = stepsCompleted;
|
||||
CheckCompletionStatus();
|
||||
}
|
||||
|
||||
private void CheckCompletionStatus()
|
||||
{
|
||||
|
||||
if (stepsCompletedCount == 0)
|
||||
{
|
||||
completionStatus = enumQuickTipCompletionStatus.incomplete;
|
||||
return;
|
||||
}
|
||||
else if (stepsCompletedCount == _stepList.Count)
|
||||
{
|
||||
completionStatus = enumQuickTipCompletionStatus.complete;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QuickTipStep step in _stepList)
|
||||
{
|
||||
if (step.StepData.IsRequired && (step.SuccessState == enumQuickActionSuccess.unknown || step.SuccessState == enumQuickActionSuccess.error))
|
||||
{
|
||||
completionStatus = enumQuickTipCompletionStatus.incomplete;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
completionStatus = enumQuickTipCompletionStatus.requiredComplete;
|
||||
}
|
||||
|
||||
public void UpdateAutomatedStepStatus(enumQuickActionRevisionStatus status, cFasdQuickAction quickAction)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stepToUpdate = _stepList.FirstOrDefault(step => step.StepData.StepUiAction.Name == quickAction.Name);
|
||||
|
||||
if (stepToUpdate is null)
|
||||
return;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case enumQuickActionRevisionStatus.unknown:
|
||||
case enumQuickActionRevisionStatus.inProgress:
|
||||
case enumQuickActionRevisionStatus.canceled:
|
||||
stepToUpdate.SuccessState = enumQuickActionSuccess.unknown;
|
||||
break;
|
||||
case enumQuickActionRevisionStatus.finishedSuccessfull:
|
||||
stepToUpdate.SuccessState = enumQuickActionSuccess.finished;
|
||||
break;
|
||||
case enumQuickActionRevisionStatus.finishedWithError:
|
||||
stepToUpdate.SuccessState = enumQuickActionSuccess.error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void HandleStepRequestedFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is QuickTipStep step))
|
||||
return;
|
||||
int indexOfSender = _stepList.IndexOf(step);
|
||||
|
||||
if (indexOfSender == _indexOfStepWithFocus)
|
||||
return;
|
||||
|
||||
QuickTipStep currentlySelectedStep = _stepList.ElementAtOrDefault(_indexOfStepWithFocus);
|
||||
|
||||
if (currentlySelectedStep != null)
|
||||
currentlySelectedStep.HasFocus = false;
|
||||
|
||||
_indexOfStepWithFocus = indexOfSender;
|
||||
step.HasFocus = true;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSuccessStateChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SetStepCount();
|
||||
|
||||
if (!(sender is QuickTipStep step))
|
||||
return;
|
||||
|
||||
if (step.SuccessState == enumQuickActionSuccess.unknown || step.StepData.ElementType != enumQuickTipElementType.Manual)
|
||||
return;
|
||||
|
||||
bool wasSuccessfull = step.SuccessState == enumQuickActionSuccess.finished || step.SuccessState == enumQuickActionSuccess.successfull;
|
||||
F4SDProtocoll.Instance.Add(new QuickTipStepProtocollEntry(step.StepData.QuickTipElementDefinition, wasSuccessfull));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!(sender is Border border))
|
||||
return;
|
||||
|
||||
if (!(border.Child is TextBlock textBlock))
|
||||
return;
|
||||
|
||||
textBlock.SetResourceReference(Control.ForegroundProperty, "Color.FunctionMarker");
|
||||
}
|
||||
|
||||
private void ButtonBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!(sender is Border border && border.Child is TextBlock textBlock))
|
||||
return;
|
||||
|
||||
textBlock.SetResourceReference(Control.ForegroundProperty, "FontColor.DetailsPage.DataHistory.TitleColumn.OverviewTitle");
|
||||
}
|
||||
|
||||
private void CompleteButton_Click(object sender, InputEventArgs e)
|
||||
{
|
||||
int finishedStepCount = _stepList.Count(step => step.SuccessState == enumQuickActionSuccess.finished);
|
||||
|
||||
switch (completionStatus)
|
||||
{
|
||||
case enumQuickTipCompletionStatus.incomplete:
|
||||
HighlightRequiredButUndoneSteps();
|
||||
break;
|
||||
case enumQuickTipCompletionStatus.requiredComplete:
|
||||
string completeDialogText = cMultiLanguageSupport.GetItem("QuickTips.Dialog.Complete");
|
||||
completeDialogText = string.Format(completeDialogText, stepsCompletedCount, _stepList.Count);
|
||||
var completeDialogResult = CustomMessageBox.Show(completeDialogText, "Quick Tip", enumHealthCardStateLevel.Warning, null, true);
|
||||
if (completeDialogResult != true)
|
||||
break;
|
||||
|
||||
AddQuickTipEndToProtocoll(QuickTipName, finishedStepCount, _stepList.Count, false);
|
||||
ResetQuickTip();
|
||||
break;
|
||||
case enumQuickTipCompletionStatus.complete:
|
||||
AddQuickTipEndToProtocoll(QuickTipName, finishedStepCount, _stepList.Count, false);
|
||||
ResetQuickTip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void HighlightRequiredButUndoneSteps()
|
||||
{
|
||||
QuickTipStep currentlySelectedStep = _stepList.ElementAtOrDefault(_indexOfStepWithFocus);
|
||||
|
||||
if (currentlySelectedStep != null)
|
||||
currentlySelectedStep.HasFocus = false;
|
||||
_indexOfStepWithFocus = -1;
|
||||
|
||||
foreach (QuickTipStep step in _stepList.Where(step => step.StepData.IsRequired))
|
||||
{
|
||||
if (step.SuccessState != enumQuickActionSuccess.successfull && step.SuccessState != enumQuickActionSuccess.finished)
|
||||
step.HighlightAsRequired();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetQuickTip()
|
||||
{
|
||||
Visibility = Visibility.Collapsed;
|
||||
QuickTipElementData = new List<cUiQuickTipElement>();
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, InputEventArgs args) => CancelQuickTip();
|
||||
|
||||
private void CancelQuickTip()
|
||||
{
|
||||
if (_stepList.Any(step => step.SuccessState != enumQuickActionSuccess.unknown))
|
||||
if (CustomMessageBox.Show(cMultiLanguageSupport.GetItem("QuickTips.Dialog.Cancel"), "Quick Tip", enumHealthCardStateLevel.Warning, null, true) != true)
|
||||
return;
|
||||
|
||||
Visibility = Visibility.Collapsed;
|
||||
|
||||
int finishedStepCount = _stepList.Count(step => step.SuccessState == enumQuickActionSuccess.finished);
|
||||
AddQuickTipEndToProtocoll(QuickTipName, finishedStepCount, _stepList.Count, true);
|
||||
QuickTipElementData = new List<cUiQuickTipElement>();
|
||||
}
|
||||
|
||||
private void AddQuickTipEndToProtocoll(string quickTipName, int finishedStepCount, int totalStepCount, bool wasCanceled)
|
||||
{
|
||||
string ascii = wasCanceled ? cMultiLanguageSupport.GetItem("QuickTips.Copy.Cancel") : cMultiLanguageSupport.GetItem("QuickTips.Copy.Finish");
|
||||
ascii = string.Format(ascii, quickTipName, finishedStepCount, totalStepCount);
|
||||
F4SDProtocoll.Instance.Add(new TextualProtocollEntry(ascii, ascii));
|
||||
}
|
||||
|
||||
private void QuickTipStatusMonitorUc_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
string ascii = cMultiLanguageSupport.GetItem("QuickTips.Copy.Start");
|
||||
ascii = string.Format(ascii, QuickTipName);
|
||||
F4SDProtocoll.Instance.Add(new TextualProtocollEntry(ascii, ascii));
|
||||
}
|
||||
}
|
||||
}
|
||||
167
FasdDesktopUi/Basics/UserControls/QuickTip/QuickTipStep.xaml
Normal file
167
FasdDesktopUi/Basics/UserControls/QuickTip/QuickTipStep.xaml
Normal file
@@ -0,0 +1,167 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.QuickTip.QuickTipStep"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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.QuickTip"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="380"
|
||||
Cursor="Hand"
|
||||
x:Name="StepUc">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<Style x:Key="StatusIcon" TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="BorderPadding" Value="0"/>
|
||||
<Setter Property="Margin" Value="0,-2"/>
|
||||
<Setter Property="IconWidth" Value="20"/>
|
||||
<Setter Property="IconHeight" Value="20"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="PrimaryIconColor" Value="{DynamicResource Color.Menu.Icon}"/>
|
||||
<Setter Property="Opacity" Value="0.35"/>
|
||||
<EventSetter Event="MouseLeftButtonUp" Handler="SelectStatus_MouseLeftButtonUp"/>
|
||||
<EventSetter Event="TouchDown" Handler="SelectStatus_TouchDown"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="StepBorder" TargetType="Border">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundColor.Menu.MainCategory}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundColor.Menu.MainCategory.Hover}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border
|
||||
x:Name="MainBorder"
|
||||
x:FieldModifier="private"
|
||||
Style="{DynamicResource StepBorder}"
|
||||
BorderThickness="2"
|
||||
CornerRadius="10"
|
||||
Padding="8"
|
||||
Margin="0 0 0 2.5"
|
||||
MouseLeftButtonUp="MainBorder_MouseLeftButtonUp"
|
||||
TouchDown="MainBorder_TouchDown"
|
||||
MouseEnter="MainBorder_MouseEnter"
|
||||
MouseLeave="MainBorder_MouseLeave">
|
||||
|
||||
<StackPanel>
|
||||
|
||||
<ico:AdaptableIcon
|
||||
x:Name="RequiredIcon"
|
||||
Margin=" 0 -10 -10 -5 "
|
||||
BorderPadding="5"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
HorizontalAlignment="Right"
|
||||
SelectedInternIcon="misc_dot"
|
||||
PrimaryIconColor="{DynamicResource HighlightColor.Red}"
|
||||
Visibility="Hidden"
|
||||
IsHitTestVisible="False"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Steps.Required}"/>
|
||||
|
||||
|
||||
<DockPanel LastChildFill="False">
|
||||
|
||||
<ico:AdaptableIcon
|
||||
x:Name="StepTypeIcon"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Base}"
|
||||
VerticalAlignment="Center"
|
||||
Margin=" 0 0 7.5 0 "
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
SelectedInternIcon="{Binding StepTypeIconData.Intern, ElementName=StepUc}"/>
|
||||
|
||||
<ico:AdaptableIcon
|
||||
x:Name="HeadingIcon"
|
||||
DockPanel.Dock="Left"
|
||||
PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="7.5 0 0 0"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
SelectedInternIcon="{Binding StepIcon.Intern, ElementName=StepUc}"
|
||||
SelectedMaterialIcon="{Binding StepIcon.Material, ElementName=StepUc}"/>
|
||||
|
||||
<TextBlock
|
||||
x:Name="HeadingText"
|
||||
Text="{Binding StepData.ElementName, ElementName=StepUc}"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="5" />
|
||||
|
||||
</DockPanel>
|
||||
|
||||
<TextBlock
|
||||
x:Name="DescriptionTextBlock"
|
||||
Text="{Binding StepData.TextBlock, ElementName=StepUc}"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
FontFamily="Calibri"
|
||||
FontSize="14"
|
||||
FontWeight="Regular"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"/>
|
||||
|
||||
<Border
|
||||
x:Name="StatusControl"
|
||||
HorizontalAlignment="Right"
|
||||
Width="70"
|
||||
Height="20"
|
||||
BorderBrush="{DynamicResource FontColor.Menu.Categories}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="10"
|
||||
IsHitTestVisible="False"
|
||||
Margin="0,5,0,0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ErrorIcon"
|
||||
Tag="Error"
|
||||
Grid.Column="0"
|
||||
SelectedMaterialIcon="ic_cancel"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource StatusIcon}"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Steps.Failed}"/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="UnknownIcon"
|
||||
Tag="Unknown"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_do_not_disturb_on"
|
||||
HorizontalAlignment="Center"
|
||||
Style="{DynamicResource StatusIcon}"
|
||||
Opacity="1"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Steps.Unknown}" />
|
||||
<ico:AdaptableIcon
|
||||
x:Name="FinishedIcon"
|
||||
Tag="Finished"
|
||||
Grid.Column="2"
|
||||
SelectedMaterialIcon="ic_check_circle"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource StatusIcon}"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickTips.Steps.Succeeded}" />
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
331
FasdDesktopUi/Basics/UserControls/QuickTip/QuickTipStep.xaml.cs
Normal file
331
FasdDesktopUi/Basics/UserControls/QuickTip/QuickTipStep.xaml.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using F4SD_AdaptableIcon;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics.Converter;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using static FasdDesktopUi.Basics.UiActions.cUiQuickTipAction;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls.QuickTip
|
||||
{
|
||||
public partial class QuickTipStep : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
#region Events
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
#region RequestFocus
|
||||
|
||||
public static readonly RoutedEvent RequestFocusEvent = EventManager.RegisterRoutedEvent(
|
||||
name: nameof(RequestFocus),
|
||||
routingStrategy: RoutingStrategy.Bubble,
|
||||
handlerType: typeof(RoutedEventHandler),
|
||||
ownerType: typeof(QuickTipStep));
|
||||
|
||||
public event RoutedEventHandler RequestFocus
|
||||
{
|
||||
add { AddHandler(RequestFocusEvent, value); }
|
||||
remove { RemoveHandler(RequestFocusEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SuccessStateChanged
|
||||
|
||||
public static readonly RoutedEvent SuccessStateChangedEvent = EventManager.RegisterRoutedEvent(
|
||||
name: nameof(SuccessStateChanged),
|
||||
routingStrategy: RoutingStrategy.Bubble,
|
||||
handlerType: typeof(RoutedEventHandler),
|
||||
ownerType: typeof(QuickTipStep));
|
||||
|
||||
public event RoutedEventHandler SuccessStateChanged
|
||||
{
|
||||
add { AddHandler(SuccessStateChangedEvent, value); }
|
||||
remove { RemoveHandler(SuccessStateChangedEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#region StepData
|
||||
|
||||
public cUiQuickTipElement StepData
|
||||
{
|
||||
get { return (cUiQuickTipElement)GetValue(StepDataProperty); }
|
||||
set { SetValue(StepDataProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty StepDataProperty =
|
||||
DependencyProperty.Register("StepData", typeof(cUiQuickTipElement), typeof(QuickTipStep), new PropertyMetadata(null, HandleStepDataChanged));
|
||||
|
||||
private static void HandleStepDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is QuickTipStep step))
|
||||
return;
|
||||
|
||||
step.UpdateStepIcon();
|
||||
step.UpdateStepTypeIcon();
|
||||
step.UpdateRequiredIcon();
|
||||
}
|
||||
|
||||
private void UpdateStepIcon()
|
||||
{
|
||||
if (StepData.ElementType == Enums.enumQuickTipElementType.Automated)
|
||||
{
|
||||
if (!(StepData.StepUiAction is cUiQuickAction quickAction))
|
||||
return;
|
||||
|
||||
StepIcon = IconDataConverter.Convert(quickAction.QuickActionConfig.Icon);
|
||||
}
|
||||
else if (StepData.ElementType == Enums.enumQuickTipElementType.Manual)
|
||||
StepIcon = StepData.Icon;
|
||||
|
||||
}
|
||||
|
||||
private void UpdateStepTypeIcon()
|
||||
{
|
||||
if (StepData.ElementType == Enums.enumQuickTipElementType.Automated)
|
||||
{
|
||||
StepTypeIconData = new IconData(enumInternIcons.misc_functionBolt);
|
||||
StepTypeIcon.ToolTip = cMultiLanguageSupport.GetItem("QuickTips.Steps.Automated");
|
||||
}
|
||||
else if (StepData.ElementType == Enums.enumQuickTipElementType.Manual)
|
||||
{
|
||||
StepTypeIconData = new IconData(enumInternIcons.misc_tool);
|
||||
StepTypeIcon.ToolTip = cMultiLanguageSupport.GetItem("QuickTips.Steps.Manual");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRequiredIcon()
|
||||
{
|
||||
if (StepData.IsRequired && (SuccessState == enumQuickActionSuccess.error || SuccessState == enumQuickActionSuccess.unknown))
|
||||
{
|
||||
RequiredIcon.Visibility = Visibility.Visible;
|
||||
RequiredIcon.IsHitTestVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RequiredIcon.Visibility = Visibility.Hidden;
|
||||
RequiredIcon.IsHitTestVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StepTypeIconData
|
||||
private IconData _stepTypeIconData;
|
||||
|
||||
public IconData StepTypeIconData
|
||||
{
|
||||
get => _stepTypeIconData;
|
||||
set
|
||||
{
|
||||
_stepTypeIconData = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(StepTypeIconData)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region HasFocus
|
||||
|
||||
public bool HasFocus
|
||||
{
|
||||
get { return (bool)GetValue(HasFocusProperty); }
|
||||
set { SetValue(HasFocusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HasFocusProperty =
|
||||
DependencyProperty.Register("HasFocus", typeof(bool), typeof(QuickTipStep), new PropertyMetadata(false, HandleHasFocusChanged));
|
||||
|
||||
private static void HandleHasFocusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is QuickTipStep step)
|
||||
{
|
||||
step.UpdateFocusBorder();
|
||||
step.Cursor = step.HasFocus ? null : Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
private void RunStepUiAction()
|
||||
{
|
||||
if (!HasFocus)
|
||||
return;
|
||||
|
||||
cUiActionBase.RaiseEvent(StepData.StepUiAction, this, this);
|
||||
}
|
||||
|
||||
private void UpdateFocusBorder()
|
||||
{
|
||||
if (HasFocus)
|
||||
{
|
||||
if (StepData.ElementType == Enums.enumQuickTipElementType.Manual)
|
||||
StatusControl.IsHitTestVisible = true;
|
||||
|
||||
MainBorder.SetResourceReference(BorderBrushProperty, "Color.FunctionMarker");
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusControl.IsHitTestVisible = false;
|
||||
MainBorder.SetResourceReference(BorderBrushProperty, "BackgroundColor.DetailsPage.DataHistory.TitleColumn");
|
||||
}
|
||||
}
|
||||
|
||||
public void HighlightAsRequired() => MainBorder.SetResourceReference(BorderBrushProperty, "Color.Red");
|
||||
|
||||
#endregion
|
||||
|
||||
#region StepIcon
|
||||
|
||||
public IconData StepIcon
|
||||
{
|
||||
get { return (IconData)GetValue(StepIconProperty); }
|
||||
set { SetValue(StepIconProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty StepIconProperty =
|
||||
DependencyProperty.Register("StepIcon", typeof(IconData), typeof(QuickTipStep), new PropertyMetadata(new IconData(enumInternIcons.misc_dot)));
|
||||
|
||||
#endregion
|
||||
|
||||
#region SuccessState
|
||||
|
||||
public enumQuickActionSuccess SuccessState
|
||||
{
|
||||
get { return (enumQuickActionSuccess)GetValue(SuccessStateProperty); }
|
||||
set { SetValue(SuccessStateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SuccessStateProperty =
|
||||
DependencyProperty.Register("SuccessState", typeof(enumQuickActionSuccess), typeof(QuickTipStep), new PropertyMetadata(enumQuickActionSuccess.unknown, HandleSuccessStateChanged));
|
||||
|
||||
private static void HandleSuccessStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is QuickTipStep step))
|
||||
return;
|
||||
|
||||
step.UpdateStatusControl();
|
||||
}
|
||||
|
||||
private void UpdateStatusControl()
|
||||
{
|
||||
ErrorIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
UnknownIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
FinishedIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
|
||||
ErrorIcon.Opacity = 0.35;
|
||||
UnknownIcon.Opacity = 0.35;
|
||||
FinishedIcon.Opacity = 0.35;
|
||||
|
||||
switch (SuccessState)
|
||||
{
|
||||
case enumQuickActionSuccess.error:
|
||||
ErrorIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "HighlightColor.Red");
|
||||
ErrorIcon.Opacity = 1;
|
||||
break;
|
||||
case enumQuickActionSuccess.unknown:
|
||||
UnknownIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
UnknownIcon.Opacity = 1;
|
||||
break;
|
||||
case enumQuickActionSuccess.finished:
|
||||
case enumQuickActionSuccess.successfull:
|
||||
FinishedIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "HighlightColor.Green");
|
||||
FinishedIcon.Opacity = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateStepCount();
|
||||
UpdateRequiredIcon();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public QuickTipStep()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MainBorder_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SetFocusForStep();
|
||||
RunStepUiAction();
|
||||
}
|
||||
|
||||
private void MainBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SetFocusForStep();
|
||||
RunStepUiAction();
|
||||
}
|
||||
|
||||
private void SetFocusForStep()
|
||||
{
|
||||
if (HasFocus)
|
||||
return;
|
||||
|
||||
RoutedEventArgs eventArgs = new RoutedEventArgs(routedEvent: RequestFocusEvent);
|
||||
|
||||
RaiseEvent(eventArgs);
|
||||
}
|
||||
|
||||
private void UpdateStepCount()
|
||||
{
|
||||
RoutedEventArgs eventArgs = new RoutedEventArgs(routedEvent: SuccessStateChangedEvent);
|
||||
RaiseEvent(eventArgs);
|
||||
}
|
||||
|
||||
private void SelectStatus_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SetSuccessState(sender);
|
||||
}
|
||||
|
||||
private void SelectStatus_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SetSuccessState(sender);
|
||||
}
|
||||
|
||||
private void SetSuccessState(object sender)
|
||||
{
|
||||
if (!(StepData.ElementType == Enums.enumQuickTipElementType.Manual))
|
||||
return;
|
||||
|
||||
if (!(sender is FrameworkElement frameworkElement))
|
||||
return;
|
||||
|
||||
switch (frameworkElement.Tag)
|
||||
{
|
||||
case "Error":
|
||||
SuccessState = enumQuickActionSuccess.error;
|
||||
break;
|
||||
case "Unknown":
|
||||
SuccessState = enumQuickActionSuccess.unknown;
|
||||
break;
|
||||
case "Finished":
|
||||
SuccessState = enumQuickActionSuccess.finished;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
HeadingIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon.Hover");
|
||||
}
|
||||
|
||||
private void MainBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
HeadingIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user