inital
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.AdjustableParameterSection"
|
||||
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"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
CornerRadius="10"
|
||||
Padding="7.5">
|
||||
|
||||
<StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
<ico:AdaptableIcon x:Name="CollapseButton"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
BorderPadding="5"
|
||||
SelectedMaterialIcon="ic_remove"
|
||||
MouseLeftButtonUp="CollapseButton_MouseLeftButtonUp"
|
||||
TouchDown="CollapseButton_TouchDown" />
|
||||
|
||||
<TextBlock Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Parameter}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Border x:Name="ParameterBorder"
|
||||
Padding="10 7.5">
|
||||
<StackPanel x:Name="ParameterStack" />
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,376 @@
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class AdjustableParameterSection : UserControl, IFocusInvoker
|
||||
{
|
||||
#region Variables & Properties
|
||||
|
||||
private double parameterBorderHeight = 0.0;
|
||||
|
||||
public int? ParentIndex { get; private set; }
|
||||
|
||||
public UIElement ParentElement { get; private set; }
|
||||
|
||||
#region Parameters
|
||||
public Dictionary<string, cAdjustableParameter> AdjustableParameters
|
||||
{
|
||||
get { return (Dictionary<string, cAdjustableParameter>)GetValue(AdjustableParametersProperty); }
|
||||
set { SetValue(AdjustableParametersProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AdjustableParametersProperty =
|
||||
DependencyProperty.Register("AdjustableParameters", typeof(Dictionary<string, cAdjustableParameter>), typeof(AdjustableParameterSection), new PropertyMetadata(new Dictionary<string, cAdjustableParameter>(), new PropertyChangedCallback(AdjustableParametersChanged)));
|
||||
|
||||
private static void AdjustableParametersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is AdjustableParameterSection _me))
|
||||
return;
|
||||
|
||||
_me.UpdateAdjustableParameters();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Dictionary<cAdjustableParameter, object> ParameterValues { get; set; } = new Dictionary<cAdjustableParameter, object>();
|
||||
|
||||
#endregion
|
||||
|
||||
public AdjustableParameterSection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void UpdateIFocusInvokerValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Parent is UIElement parentElement)
|
||||
{
|
||||
ParentElement = parentElement;
|
||||
|
||||
if (parentElement is Panel panel)
|
||||
ParentIndex = panel.Children.IndexOf(this);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAdjustableParameters()
|
||||
{
|
||||
try
|
||||
{
|
||||
ParameterStack.Children.Clear();
|
||||
ParameterValues.Clear();
|
||||
|
||||
ParameterBorder.BeginAnimation(HeightProperty, null);
|
||||
ParameterBorder.Height = double.NaN;
|
||||
|
||||
if (AdjustableParameters is null)
|
||||
return;
|
||||
|
||||
foreach (var parameter in AdjustableParameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(ParameterValues.ContainsKey(parameter.Value)))
|
||||
ParameterValues.Add(parameter.Value, null);
|
||||
|
||||
var parameterValue = parameter.Value;
|
||||
|
||||
switch (parameterValue)
|
||||
{
|
||||
case cAdjustableParameterBoolean booleanParameter:
|
||||
AddBooleanParameter(parameter.Key, booleanParameter);
|
||||
break;
|
||||
case cAdjustableParameterNumerical numericalParameter:
|
||||
AddNumericalParameter(parameter.Key, numericalParameter);
|
||||
break;
|
||||
case cAdjustableParameterDropDown dropDownParameter:
|
||||
AddDropDownParameter(parameter.Key, dropDownParameter);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
ParameterBorder.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
parameterBorderHeight = ParameterBorder.DesiredSize.Height;
|
||||
ParameterBorder.Height = parameterBorderHeight;
|
||||
|
||||
UpdateIFocusInvokerValues();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#region Helper
|
||||
|
||||
private void AddBooleanParameter(string parameterKey, cAdjustableParameterBoolean booleanParameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
DockPanel outerPanel = new DockPanel() { Margin = new Thickness(2.5) };
|
||||
|
||||
ParameterValues[booleanParameter] = booleanParameter.Default ? $"-{booleanParameter.ParameterName}" : string.Empty;
|
||||
|
||||
CheckBox valueCheckBox = new CheckBox() { IsChecked = booleanParameter.Default };
|
||||
valueCheckBox.Checked += new RoutedEventHandler((sender, e) => ParameterValues[booleanParameter] = $"-{booleanParameter.ParameterName}");
|
||||
valueCheckBox.Unchecked += new RoutedEventHandler((sender, e) => ParameterValues[booleanParameter] = string.Empty);
|
||||
|
||||
DockPanel.SetDock(valueCheckBox, Dock.Right);
|
||||
valueCheckBox.SetResourceReference(StyleProperty, "ToggleSwitch");
|
||||
outerPanel.Children.Add(valueCheckBox);
|
||||
|
||||
TextBlock parameterNameTextBlock = new TextBlock() { Text = booleanParameter.Names.GetValue(), Margin = new Thickness(0, 0, 7.5, 0) };
|
||||
if(!string.IsNullOrEmpty(booleanParameter.Descriptions.GetValue()))
|
||||
{
|
||||
parameterNameTextBlock.ToolTip = booleanParameter.Descriptions.GetValue();
|
||||
}
|
||||
parameterNameTextBlock.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
outerPanel.Children.Add(parameterNameTextBlock);
|
||||
|
||||
ParameterStack.Children.Add(outerPanel);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNumericalParameter(string parameterKey, cAdjustableParameterNumerical numericalParameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
DockPanel outerPanel = new DockPanel() { Margin = new Thickness(2.5) };
|
||||
|
||||
ParameterValues[numericalParameter] = numericalParameter.Default;
|
||||
|
||||
TextBox valueTextBox = new TextBox() { Text = numericalParameter.Default.ToString(), Width = 35, TextAlignment = TextAlignment.Center };
|
||||
valueTextBox.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
valueTextBox.SetResourceReference(BackgroundProperty, "BackgroundColor.DetailsPage.DataHistory.TitleColumn");
|
||||
valueTextBox.SetResourceReference(BorderBrushProperty, "BackgroundColor.DetailsPage.DataHistory.ValueColumn");
|
||||
|
||||
valueTextBox.PreviewKeyDown += ((sender, e) =>
|
||||
{
|
||||
if (double.TryParse(valueTextBox.Text, out var parsedValue))
|
||||
ParameterValues[numericalParameter] = parsedValue;
|
||||
});
|
||||
|
||||
valueTextBox.PreviewTextInput += new TextCompositionEventHandler((sender, e) =>
|
||||
{
|
||||
var plannedValue = valueTextBox.Text.Insert(valueTextBox.CaretIndex, e.Text);
|
||||
if (double.TryParse(plannedValue, out var parsedValue))
|
||||
ParameterValues[numericalParameter] = parsedValue;
|
||||
else
|
||||
e.Handled = true;
|
||||
});
|
||||
|
||||
DockPanel.SetDock(valueTextBox, Dock.Right);
|
||||
outerPanel.Children.Add(valueTextBox);
|
||||
|
||||
TextBlock parameterNameTextBlock = new TextBlock() { Text = numericalParameter.Names.GetValue(), Margin = new Thickness(0, 0, 7.5, 0) };
|
||||
if (!string.IsNullOrEmpty(numericalParameter.Descriptions.GetValue()))
|
||||
{
|
||||
parameterNameTextBlock.ToolTip = numericalParameter.Descriptions.GetValue();
|
||||
}
|
||||
parameterNameTextBlock.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
outerPanel.Children.Add(parameterNameTextBlock);
|
||||
|
||||
ParameterStack.Children.Add(outerPanel);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddDropDownParameter(string parameterKey, cAdjustableParameterDropDown dropDownParameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
DockPanel outerPanel = new DockPanel() { Margin = new Thickness(2.5) };
|
||||
|
||||
ParameterValues[dropDownParameter] = dropDownParameter.Default;
|
||||
|
||||
ComboBox valueComboBox = new ComboBox() { SelectedItem = dropDownParameter.Default, MinWidth = 125 };
|
||||
valueComboBox.Style = (Style)FindResource("DarkComboBox");
|
||||
|
||||
valueComboBox.DropDownOpened += (sender, e) => cFocusInvoker.InvokeGotFocus(this, e);
|
||||
valueComboBox.DropDownClosed += (sender, e) => cFocusInvoker.InvokeLostFocus(this, e);
|
||||
|
||||
foreach (var dropDownValue in dropDownParameter.DropdownValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempComboBoxItem = new ComboBoxItem() { Content = dropDownValue.DisplayValues.GetValue(), Tag = dropDownValue.Value };
|
||||
|
||||
if (dropDownParameter.DropdownValues?.First() == dropDownValue && dropDownParameter.DropdownValues?.Last() == dropDownValue)
|
||||
tempComboBoxItem.SetResourceReference(StyleProperty, "ComboBoxSingleItem");
|
||||
else if (dropDownParameter.DropdownValues?.First() == dropDownValue)
|
||||
tempComboBoxItem.SetResourceReference(StyleProperty, "ComboBoxFirstItem");
|
||||
else if (dropDownParameter.DropdownValues?.Last() == dropDownValue)
|
||||
tempComboBoxItem.SetResourceReference(StyleProperty, "ComboBoxLastItem");
|
||||
|
||||
valueComboBox.Items.Add(tempComboBoxItem);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
var selectedIndex = -1;
|
||||
var defaultValue = dropDownParameter.DropdownValues.FirstOrDefault(value => value.Value == dropDownParameter.Default);
|
||||
if (defaultValue != null)
|
||||
selectedIndex = dropDownParameter.DropdownValues.IndexOf(defaultValue);
|
||||
|
||||
|
||||
valueComboBox.SelectionChanged += ((sender, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is ComboBox senderComboBox))
|
||||
return;
|
||||
|
||||
if (!(senderComboBox.SelectedItem is FrameworkElement selectedElement))
|
||||
return;
|
||||
|
||||
ParameterValues[dropDownParameter] = selectedElement.Tag;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
});
|
||||
|
||||
valueComboBox.SelectedIndex = selectedIndex;
|
||||
DockPanel.SetDock(valueComboBox, Dock.Right);
|
||||
outerPanel.Children.Add(valueComboBox);
|
||||
|
||||
TextBlock parameterNameTextBlock = new TextBlock() { VerticalAlignment = VerticalAlignment.Center, Text = dropDownParameter.Names.GetValue(), Margin = new Thickness(0, 0, 7.5, 0) };
|
||||
if (!string.IsNullOrEmpty(dropDownParameter.Descriptions.GetValue()))
|
||||
{
|
||||
parameterNameTextBlock.ToolTip = dropDownParameter.Descriptions.GetValue();
|
||||
}
|
||||
parameterNameTextBlock.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
outerPanel.Children.Add(parameterNameTextBlock);
|
||||
|
||||
ParameterStack.Children.Add(outerPanel);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ToggleCollapse(bool shouldCollapse)
|
||||
{
|
||||
try
|
||||
{
|
||||
const double animatinDurationInSeconds = 0.2;
|
||||
|
||||
if (shouldCollapse)
|
||||
ParameterBorder.BeginAnimation(HeightProperty, new DoubleAnimation(0, TimeSpan.FromSeconds(animatinDurationInSeconds)));
|
||||
else
|
||||
ParameterBorder.BeginAnimation(HeightProperty, new DoubleAnimation(parameterBorderHeight, TimeSpan.FromSeconds(animatinDurationInSeconds)));
|
||||
|
||||
CollapseButton.SelectedMaterialIcon = shouldCollapse ? MaterialIcons.MaterialIconType.ic_add : MaterialIcons.MaterialIconType.ic_remove;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleIsActive(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isActive)
|
||||
{
|
||||
UpdateAdjustableParameters();
|
||||
foreach (UIElement element in ParameterStack.Children)
|
||||
{
|
||||
element.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleCollapse(true);
|
||||
foreach (UIElement element in ParameterStack.Children)
|
||||
{
|
||||
element.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region CollapseButton_Click
|
||||
|
||||
private void CollapseButton_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
bool shouldCollapse = ParameterBorder.ActualHeight - ParameterBorder.Padding.Top - ParameterBorder.Padding.Bottom != 0;
|
||||
ToggleCollapse(shouldCollapse);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void CollapseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CollapseButton_Click();
|
||||
}
|
||||
|
||||
private void CollapseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CollapseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
45
FasdDesktopUi/Basics/UserControls/DataCanvas/DataCanvas.xaml
Normal file
45
FasdDesktopUi/Basics/UserControls/DataCanvas/DataCanvas.xaml
Normal file
@@ -0,0 +1,45 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DataCanvas"
|
||||
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"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="400"
|
||||
Name="DataCanvasUc">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<converter:DataCanvasIsCloseButtonVisibileConverter x:Key="IsCloseButtonVisible" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel x:Name="MainStackPanel">
|
||||
<local:QuickActionStatusMonitor x:Name="QuickActionStatusUc"
|
||||
QuickActionFinished="QuickActionStatusUc_QuickActionFinished"
|
||||
IsCloseButtonVisible="{Binding ElementName=DataCanvasUc, Path=DataCanvasData, Converter={StaticResource IsCloseButtonVisible}, ConverterParameter={x:Static converter:enumDataCanvasTypes.quickActionStatusMonitor} }" />
|
||||
|
||||
<local:DetailedData x:Name="DetailedDataUc"
|
||||
Visibility="{Binding ElementName=DataCanvasUc, Path=IsDetailedLayout, Converter={StaticResource BoolToVisibility}}"
|
||||
IsCloseButtonVisible="{Binding ElementName=DataCanvasUc, Path=DataCanvasData, Converter={StaticResource IsCloseButtonVisible}, ConverterParameter={x:Static converter:enumDataCanvasTypes.detailedData} }" />
|
||||
|
||||
<local:DetailedChart x:Name="DetailedChartUc"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="385"
|
||||
Visibility="{Binding ElementName=DataCanvasUc, Path=IsDetailedLayout, Converter={StaticResource BoolToVisibility}}"
|
||||
IsCloseButtonVisible="{Binding ElementName=DataCanvasUc, Path=DataCanvasData, Converter={StaticResource IsCloseButtonVisible}, ConverterParameter={x:Static converter:enumDataCanvasTypes.detailedData} }" />
|
||||
|
||||
<local:DynamicChart x:Name="DynamicChartUc"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="385"
|
||||
Visibility="{Binding ElementName=DataCanvasUc, Path=IsDetailedLayout, Converter={StaticResource BoolToVisibility}}"
|
||||
IsCloseButtonVisible="{Binding ElementName=DataCanvasUc, Path=DataCanvasData, Converter={StaticResource IsCloseButtonVisible}, ConverterParameter={x:Static converter:enumDataCanvasTypes.detailedData} }" />
|
||||
|
||||
<local:DetailedRecommendation x:Name="RecommendationUc"
|
||||
Width="{Binding ElementName=DetailedDataUc, Path=ActualWidth, UpdateSourceTrigger=PropertyChanged}"
|
||||
MinWidth="300"
|
||||
Visibility="{Binding ElementName=DataCanvasUc, Path=IsDetailedLayout, Converter={StaticResource BoolToVisibility}}"
|
||||
IsCloseButtonVisible="{Binding ElementName=DataCanvasUc, Path=DataCanvasData, Converter={StaticResource IsCloseButtonVisible}, ConverterParameter={x:Static converter:enumDataCanvasTypes.recommendation} }" />
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
259
FasdDesktopUi/Basics/UserControls/DataCanvas/DataCanvas.xaml.cs
Normal file
259
FasdDesktopUi/Basics/UserControls/DataCanvas/DataCanvas.xaml.cs
Normal file
@@ -0,0 +1,259 @@
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class DataCanvas : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private cSupportCaseDataProvider dataProvider;
|
||||
public cSupportCaseDataProvider DataProvider
|
||||
{
|
||||
get => dataProvider;
|
||||
set
|
||||
{
|
||||
if (DataCanvasData.GetDetailedDataAsync != null)
|
||||
{
|
||||
if (dataProvider != null)
|
||||
dataProvider.HealthCardDataHelper.DataRefreshed -= HealthCardDataHelper_DataRefreshed;
|
||||
value.HealthCardDataHelper.DataRefreshed += HealthCardDataHelper_DataRefreshed;
|
||||
}
|
||||
|
||||
dataProvider = value;
|
||||
QuickActionStatusUc.DataProvider = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region DataCanvasData
|
||||
|
||||
private static void DataCanvasDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var oldData = e.OldValue as cDataCanvasDataModel;
|
||||
var newData = e.NewValue as cDataCanvasDataModel;
|
||||
|
||||
if (!(d is DataCanvas _me))
|
||||
return;
|
||||
|
||||
if (_me.dataProvider != null)
|
||||
{
|
||||
if (oldData.GetDetailedDataAsync != null)
|
||||
_me.dataProvider.HealthCardDataHelper.DataRefreshed -= _me.HealthCardDataHelper_DataRefreshed;
|
||||
|
||||
if (newData.GetDetailedDataAsync != null)
|
||||
_me.dataProvider.HealthCardDataHelper.DataRefreshed += _me.HealthCardDataHelper_DataRefreshed;
|
||||
}
|
||||
|
||||
_me.QuickActionStatusUc.CancelQuickAction();
|
||||
|
||||
_me.RecommendationUc.RecommendationData = _me.DataCanvasData.RecommendationData;
|
||||
_me.RecommendationUc.CloseButtonClickedAction = _me.CloseDataCanvas;
|
||||
|
||||
if (_me.DataCanvasData.ChartData is null && _me.DataCanvasData.DetailedChartData is null)
|
||||
{
|
||||
_me.DetailedDataUc.DetailedInformationData = _me.DataCanvasData.DetailedData;
|
||||
_me.DetailedDataUc.CloseButtonClickedAction = _me.CloseDataCanvas;
|
||||
_me.DetailedChartUc.ChartData = null;
|
||||
_me.DynamicChartUc.ChartData = null;
|
||||
}
|
||||
else if (_me.DataCanvasData.ChartData is null)
|
||||
{
|
||||
_me.DetailedChartUc.ChartData = _me.DataCanvasData.DetailedChartData;
|
||||
_me.DynamicChartUc.ChartData = null;
|
||||
_me.DetailedDataUc.DetailedInformationData = null;
|
||||
_me.DetailedChartUc.CloseButtonClickedAction = _me.CloseDataCanvas;
|
||||
}
|
||||
else
|
||||
{
|
||||
_me.DynamicChartUc.ChartData = _me.DataCanvasData.ChartData;
|
||||
_me.DetailedChartUc.ChartData = null;
|
||||
_me.DetailedDataUc.DetailedInformationData = null;
|
||||
_me.DynamicChartUc.CloseButtonClickedAction = _me.CloseDataCanvas;
|
||||
}
|
||||
|
||||
_me.QuickActionStatusUc.QuickActionData = _me.DataCanvasData.QuickActionStatusMonitorData;
|
||||
_me.QuickActionStatusUc.CloseButtonClickedAction = _me.CloseDataCanvas;
|
||||
|
||||
_me.QuickActionStatusUc.QuickActionOutputs.Clear();
|
||||
_me.QuickActionStatusUc.MeasureValues = null;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent DataCanvasWasClosedEvent = EventManager.RegisterRoutedEvent("DataCanvasWasClosed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DataCanvas));
|
||||
|
||||
public event RoutedEventHandler DataCanvasWasClosed
|
||||
{
|
||||
add { AddHandler(DataCanvasWasClosedEvent, value); }
|
||||
remove { RemoveHandler(DataCanvasWasClosedEvent, value); }
|
||||
}
|
||||
|
||||
private void CloseDataCanvas()
|
||||
{
|
||||
//Visibility = Visibility.Collapsed;
|
||||
|
||||
if (this.Parent is FrameworkElement parentElement)
|
||||
parentElement.Visibility = Visibility.Collapsed;
|
||||
|
||||
QuickActionStatusUc.CancelQuickAction();
|
||||
RaiseEvent(new RoutedEventArgs(DataCanvasWasClosedEvent));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DataCanvasDataProperty =
|
||||
DependencyProperty.Register("DataCanvasData", typeof(cDataCanvasDataModel), typeof(DataCanvas), new PropertyMetadata(new cDataCanvasDataModel(), new PropertyChangedCallback(DataCanvasDataChangedCallback)));
|
||||
|
||||
public cDataCanvasDataModel DataCanvasData
|
||||
{
|
||||
get { return (cDataCanvasDataModel)GetValue(DataCanvasDataProperty); }
|
||||
set { SetValue(DataCanvasDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SubMenuData
|
||||
|
||||
private static void SubMenuDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DataCanvas _me))
|
||||
return;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SubMenuDataProperty =
|
||||
DependencyProperty.Register("SubMenuData", typeof(List<cMenuDataBase>), typeof(DataCanvas), new PropertyMetadata(new List<cMenuDataBase>(), new PropertyChangedCallback(SubMenuDataChangedCallback)));
|
||||
|
||||
public List<cMenuDataBase> SubMenuData
|
||||
{
|
||||
get { return (List<cMenuDataBase>)GetValue(SubMenuDataProperty); }
|
||||
set { SetValue(SubMenuDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region isDetailedLayout
|
||||
|
||||
public static readonly DependencyProperty IsDetailedLayoutProperty =
|
||||
DependencyProperty.Register("IsDetailedLayout", typeof(bool), typeof(DataCanvas), new PropertyMetadata(false));
|
||||
|
||||
public bool IsDetailedLayout
|
||||
{
|
||||
get { return (bool)GetValue(IsDetailedLayoutProperty); }
|
||||
set { SetValue(IsDetailedLayoutProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public DataCanvas()
|
||||
{
|
||||
InitializeComponent();
|
||||
DetailedChartUc.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public DataCanvas(bool drawInScrollViewer)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (!drawInScrollViewer)
|
||||
return;
|
||||
|
||||
var tempDataCanvas = MainStackPanel;
|
||||
ScrollViewer scrollViewer = new ScrollViewer() { Padding = new Thickness(0, 0, 10, 10), VerticalScrollBarVisibility = ScrollBarVisibility.Auto };
|
||||
DataCanvasUc.Content = scrollViewer;
|
||||
scrollViewer.Content = tempDataCanvas;
|
||||
}
|
||||
|
||||
private async void HealthCardDataHelper_DataRefreshed(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detailedData = DataCanvasData.DetailedData;
|
||||
var detailedChartData = DataCanvasData.DetailedChartData;
|
||||
var chartData = DataCanvasData.ChartData;
|
||||
|
||||
if (DataCanvasData.GetDetailedDataAsync != null)
|
||||
detailedData = await DataCanvasData.GetDetailedDataAsync.Invoke();
|
||||
|
||||
if (DataCanvasData.GetDatailedChartDataAsync != null)
|
||||
detailedChartData = await DataCanvasData.GetDatailedChartDataAsync.Invoke();
|
||||
|
||||
if (DataCanvasData.GetChartDataAsync != null)
|
||||
chartData = await DataCanvasData.GetChartDataAsync.Invoke();
|
||||
|
||||
var tempDataCanvasData = new cDataCanvasDataModel()
|
||||
{
|
||||
GetDetailedDataAsync = DataCanvasData.GetDetailedDataAsync,
|
||||
GetDatailedChartDataAsync = DataCanvasData.GetDatailedChartDataAsync,
|
||||
GetChartDataAsync = DataCanvasData.GetChartDataAsync,
|
||||
RecommendationData = DataCanvasData.RecommendationData,
|
||||
QuickActionStatusMonitorData = DataCanvasData.QuickActionStatusMonitorData,
|
||||
};
|
||||
|
||||
if (detailedChartData is null && chartData is null)
|
||||
tempDataCanvasData.DetailedData = detailedData;
|
||||
else if (chartData is null)
|
||||
tempDataCanvasData.DetailedChartData = detailedChartData;
|
||||
else
|
||||
tempDataCanvasData.ChartData = chartData;
|
||||
|
||||
DataCanvasData = tempDataCanvasData;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertNewDetailedData(List<object> newDetailedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempDetailedData = DetailedDataUc.DetailedInformationData.FullDetailedData;
|
||||
|
||||
if (tempDetailedData == null || tempDetailedData.Count <= 0)
|
||||
return;
|
||||
|
||||
tempDetailedData.Insert(1, newDetailedData);
|
||||
|
||||
DetailedDataUc.DetailedInformationData = new cDetailedDataModel() { Heading = DetailedDataUc.DetailedInformationData.Heading, FullDetailedData = tempDetailedData };
|
||||
DetailedDataUc.DetailedDataListView.SelectedItem = DetailedDataUc.DetailedDataListView.Items[0]; // todo: check if best solution with index = 0
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void QuickActionStatusUc_QuickActionFinished(object sender, QuickActionEventArgs e)
|
||||
{
|
||||
if (Window.GetWindow(this) is Pages.DetailsPage.DetailsPageView)
|
||||
InsertNewDetailedData(e.QuickActionResult);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
303
FasdDesktopUi/Basics/UserControls/DataCanvas/DetailedChart.xaml
Normal file
303
FasdDesktopUi/Basics/UserControls/DataCanvas/DetailedChart.xaml
Normal file
@@ -0,0 +1,303 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DetailedChart"
|
||||
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"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
Name="ChartUc"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Margin="0 0 0 10"
|
||||
Height="270"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Visibility="{Binding ElementName=ChartUc, Path=ChartData, Converter={StaticResource NullToVisibility}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="42" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="45" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
CornerRadius="10,0,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
x:Name="TitleBlock"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,5,-42,0"
|
||||
FontFamily="Calibri"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="1"
|
||||
x:Name="DateBlock"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,-42,0"
|
||||
FontFamily="Calibri"
|
||||
FontSize="13"
|
||||
FontWeight="Regular"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Column="2"
|
||||
SelectedInternIcon="window_close"
|
||||
MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
Visibility="{Binding ElementName=ChartUc, Path=IsCloseButtonVisible, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1"
|
||||
Margin="10,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="32" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="28" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.RowSpan="5"
|
||||
x:Name="GraphicBorder"
|
||||
Panel.ZIndex="1">
|
||||
<Border x:Name="CanvasBorder">
|
||||
<Canvas x:Name="GraphicCanvas"
|
||||
Panel.ZIndex="1" />
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
BorderThickness="1"
|
||||
Height="1"
|
||||
Margin="5,0,5,0">
|
||||
<Border.BorderBrush>
|
||||
<DrawingBrush Viewport="0,0,10,10"
|
||||
ViewportUnits="Absolute"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource HorizontalLineColor}">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,50,50" />
|
||||
<RectangleGeometry Rect="50,50,50,0" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
</Border>
|
||||
<Border Grid.Row="1"
|
||||
BorderThickness="1"
|
||||
Height="1"
|
||||
Margin="5,0,5,0">
|
||||
<Border.BorderBrush>
|
||||
<DrawingBrush Viewport="0,0,10,10"
|
||||
ViewportUnits="Absolute"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource HorizontalLineColor}">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,50,50" />
|
||||
<RectangleGeometry Rect="50,50,50,0" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
</Border>
|
||||
<Border Grid.Row="2"
|
||||
BorderThickness="1"
|
||||
Height="1"
|
||||
Margin="5,0,5,0">
|
||||
<Border.BorderBrush>
|
||||
<DrawingBrush Viewport="0,0,10,10"
|
||||
ViewportUnits="Absolute"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource HorizontalLineColor}">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,50,50" />
|
||||
<RectangleGeometry Rect="50,50,50,0" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
</Border>
|
||||
<Border Grid.Row="3"
|
||||
BorderThickness="1"
|
||||
Height="1"
|
||||
Margin="5,0,5,0">
|
||||
<Border.BorderBrush>
|
||||
<DrawingBrush Viewport="0,0,10,10"
|
||||
ViewportUnits="Absolute"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource HorizontalLineColor}">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,50,50" />
|
||||
<RectangleGeometry Rect="50,50,50,0" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
</Border>
|
||||
<Border Grid.Row="4"
|
||||
BorderThickness="1"
|
||||
Height="1"
|
||||
Margin="5,0,5,0">
|
||||
<Border.BorderBrush>
|
||||
<DrawingBrush Viewport="0,0,10,10"
|
||||
ViewportUnits="Absolute"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource HorizontalLineColor}">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,50,50" />
|
||||
<RectangleGeometry Rect="50,50,50,0" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Border Name="PercentBorder"
|
||||
Grid.Column="2"
|
||||
Grid.Row="0"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="100%"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Text="75%"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
Text="50%"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="3"
|
||||
Text="25%"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="4"
|
||||
Text="0%"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid x:Name="TimeStampGrid"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Margin="0,0,0,15">
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,435 @@
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
[Obsolete("Instead use " + nameof(DynamicChart))]
|
||||
public partial class DetailedChart : UserControl
|
||||
{
|
||||
#region Variables
|
||||
static bool wasRendered = false;
|
||||
int DataDurationStart = 0;
|
||||
int DataDurationEnd = 0;
|
||||
int DataDurationTotal = 0;
|
||||
int ReducedTimeStamps = 0;
|
||||
DateTime firstTime;
|
||||
#endregion
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
#region ChartData
|
||||
|
||||
public cDetailedChartModel ChartData
|
||||
{
|
||||
get { return (cDetailedChartModel)GetValue(ChartDataProperty); }
|
||||
set { SetValue(ChartDataProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ChartDataProperty =
|
||||
DependencyProperty.Register("ChartData", typeof(cDetailedChartModel), typeof(DetailedChart), new PropertyMetadata(null, new PropertyChangedCallback(HandleDependancyPropertyChanged)));
|
||||
|
||||
|
||||
private static void HandleDependancyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailedChart me)) return;
|
||||
me.BindingValueChange();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCloseButtonVisible
|
||||
|
||||
public static readonly DependencyProperty IsCloseButtonVisibleProperty =
|
||||
DependencyProperty.Register("IsCloseButtonVisible", typeof(bool), typeof(DetailedChart), new PropertyMetadata(false));
|
||||
|
||||
public bool IsCloseButtonVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsCloseButtonVisibleProperty); }
|
||||
set { SetValue(IsCloseButtonVisibleProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public Action CloseButtonClickedAction { get; set; }
|
||||
|
||||
[Obsolete("Instead use " + nameof(DynamicChart))]
|
||||
public DetailedChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Binding
|
||||
|
||||
public void BindingValueChange()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (ChartData?.Data == null || ChartData.Data.Count <= 0) return;
|
||||
GraphicCanvas.Children.Clear();
|
||||
TimeStampGrid.Children.Clear();
|
||||
TimeStampGrid.ColumnDefinitions.Clear();
|
||||
GraphicDataProperty.Clear();
|
||||
ReducedTimeStamps = 0;
|
||||
FillGraphicDataProperty();
|
||||
FillVariables();
|
||||
CreateDateTitle();
|
||||
SetCanvasBorderPadding();
|
||||
CreateTimeStamps();
|
||||
DrawGraphicData();
|
||||
|
||||
if (!wasRendered)
|
||||
{
|
||||
wasRendered = true;
|
||||
var _h = Dispatcher.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(50);
|
||||
BindingValueChange();
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GraphicDataProperty
|
||||
|
||||
public List<cChartValue> GraphicDataProperty { get; set; } = new List<cChartValue>();
|
||||
|
||||
public void FillGraphicDataProperty()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (ChartData?.Data == null) return;
|
||||
var reverseData = ChartData.Data.ToList();
|
||||
reverseData.Reverse();
|
||||
|
||||
if ((DateTime)reverseData[0][ChartData.TimeIndex] < (DateTime)reverseData[reverseData.Count() - 1][ChartData.TimeIndex])
|
||||
{
|
||||
foreach (var item in reverseData)
|
||||
{
|
||||
cChartValue data = new cChartValue();
|
||||
data.Value = (double)item[ChartData.ValueIndex];
|
||||
data.Duration = int.Parse(item[ChartData.DurationIndex].ToString());
|
||||
data.Time = (DateTime)item[ChartData.TimeIndex];
|
||||
data.Time = data.Time.ToLocalTime();
|
||||
GraphicDataProperty.Add(data);
|
||||
}
|
||||
}
|
||||
else if ((DateTime)ChartData.Data[0][ChartData.TimeIndex] < (DateTime)ChartData.Data[ChartData.Data.Count() - 1][ChartData.TimeIndex] || ChartData.Data.Count == 1)
|
||||
{
|
||||
foreach (var item in ChartData.Data)
|
||||
{
|
||||
cChartValue data = new cChartValue();
|
||||
data.Value = (double)item[ChartData.ValueIndex];
|
||||
data.Duration = int.Parse(item[ChartData.DurationIndex].ToString());
|
||||
data.Time = (DateTime)item[ChartData.TimeIndex];
|
||||
data.Time = data.Time.ToLocalTime();
|
||||
GraphicDataProperty.Add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FillVariables
|
||||
|
||||
public void FillVariables()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
firstTime = GraphicDataProperty.First<cChartValue>().Time;
|
||||
DateTime lastTime = GraphicDataProperty.Last<cChartValue>().Time;
|
||||
int lastDuration = GraphicDataProperty.Last<cChartValue>().Duration;
|
||||
|
||||
lastTime = lastTime.AddMilliseconds(lastDuration);
|
||||
|
||||
DataDurationStart = firstTime.Hour;
|
||||
if (lastTime.Minute != 0)
|
||||
{
|
||||
lastTime = lastTime.AddMinutes(60 - (lastDuration / 60000));
|
||||
}
|
||||
DataDurationEnd = lastTime.Hour;
|
||||
DataDurationTotal = DataDurationEnd - DataDurationStart;
|
||||
if (firstTime.Date < lastTime.Date)
|
||||
{
|
||||
if (DataDurationTotal < 2)
|
||||
{
|
||||
DataDurationTotal = (24 - DataDurationStart) + DataDurationEnd;
|
||||
}
|
||||
}
|
||||
if (DataDurationTotal > 18)
|
||||
{
|
||||
ReducedTimeStamps = 3;
|
||||
if (DataDurationTotal % 4 == 3)
|
||||
{
|
||||
DataDurationTotal += 3;
|
||||
}
|
||||
else if (DataDurationTotal % 4 == 2)
|
||||
{
|
||||
DataDurationTotal += 2;
|
||||
}
|
||||
else if (DataDurationTotal % 4 == 1)
|
||||
{
|
||||
DataDurationTotal += 1;
|
||||
}
|
||||
}
|
||||
else if (DataDurationTotal > 12)
|
||||
{
|
||||
ReducedTimeStamps = 2;
|
||||
if (DataDurationTotal % 3 == 2)
|
||||
{
|
||||
DataDurationTotal += 2;
|
||||
}
|
||||
else if (DataDurationTotal % 3 == 1)
|
||||
{
|
||||
DataDurationTotal += 1;
|
||||
}
|
||||
}
|
||||
else if (DataDurationTotal > 6)
|
||||
{
|
||||
ReducedTimeStamps = 1;
|
||||
if (DataDurationTotal % 2 == 1)
|
||||
{
|
||||
DataDurationTotal += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Create Date Title
|
||||
|
||||
public void CreateDateTitle()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
DateTime dataDate = GraphicDataProperty.First<cChartValue>().Time;
|
||||
dataDate = dataDate.Date;
|
||||
DateBlock.Text = dataDate.ToString("dddd, dd.MM.yyyy");
|
||||
TitleBlock.Text = ChartData.ChartTitle;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetCanvasBorderPadding
|
||||
|
||||
public void SetCanvasBorderPadding()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
double borderWidth = GraphicBorder.ActualWidth;
|
||||
double paddingWidth = borderWidth / (((double)DataDurationTotal + 1) * 2.0);
|
||||
double borderHeight = GraphicBorder.ActualHeight;
|
||||
double paddingHeight = borderHeight / 10.0;
|
||||
paddingHeight = Math.Max(0, paddingHeight);
|
||||
paddingWidth = Math.Max(0, paddingWidth);
|
||||
GraphicBorder.Padding = new Thickness(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
|
||||
GraphicBorder.UpdateLayout();
|
||||
CanvasBorder.UpdateLayout();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Time Stamps
|
||||
|
||||
public void CreateTimeStamps()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i <= DataDurationTotal; i++)
|
||||
{
|
||||
ColumnDefinition timeStamp = new ColumnDefinition();
|
||||
timeStamp.Width = new GridLength(1, GridUnitType.Star);
|
||||
TimeStampGrid.ColumnDefinitions.Add(timeStamp);
|
||||
if (ReducedTimeStamps == 3 && i % 4 != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ReducedTimeStamps == 2 && i % 3 != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ReducedTimeStamps == 1 && i % 2 != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TextBlock TimeStampText = new TextBlock()
|
||||
{
|
||||
Text = (firstTime.AddHours(i)).Hour.ToString() + ":00",
|
||||
FontFamily = new FontFamily("Calibri"),
|
||||
FontSize = 11,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
TextTrimming = TextTrimming.None,
|
||||
};
|
||||
|
||||
TimeStampText.SetResourceReference(TextBlock.ForegroundProperty, "Color.Menu.Icon");
|
||||
|
||||
if (DataDurationTotal > 10)
|
||||
{
|
||||
TimeStampText.Margin = new Thickness(-7, 0, -7, 0);
|
||||
}
|
||||
Grid.SetColumn(TimeStampText, i);
|
||||
TimeStampGrid.Children.Add(TimeStampText);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Draw Data
|
||||
|
||||
public double CalculateSetLeft(DateTime dataTime)
|
||||
{
|
||||
double setLeft = (double)dataTime.Hour + ((double)dataTime.Minute / 60.0);
|
||||
setLeft = (setLeft - (double)DataDurationStart) * ((double)CanvasBorder.ActualWidth / ((double)DataDurationTotal));
|
||||
return setLeft;
|
||||
}
|
||||
|
||||
public void DrawGraphicData()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
double setLeft = 0.0;
|
||||
double setFactor = 0.0;
|
||||
|
||||
setFactor = (GraphicCanvas.ActualHeight - 8.0) / 100.0;
|
||||
|
||||
foreach (var data in GraphicDataProperty)
|
||||
{
|
||||
|
||||
DateTime dataTime = data.Time;
|
||||
double dataValue = data.Value;
|
||||
int dataDuration = data.Duration;
|
||||
|
||||
Border border = new Border
|
||||
{
|
||||
Height = 8.0,
|
||||
Width = (double)dataDuration * ((double)CanvasBorder.ActualWidth / ((double)DataDurationTotal)) / 3600000.0,
|
||||
CornerRadius = new CornerRadius(4.0),
|
||||
ToolTip = dataTime.ToShortTimeString() + " - " + dataTime.AddMilliseconds(dataDuration).ToShortTimeString() + " | " + (int)dataValue + "%"
|
||||
};
|
||||
if (border.Width < 8)
|
||||
{
|
||||
border.Width = 8;
|
||||
}
|
||||
if (ChartData.IsThresholdActive == false)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(0, 157, 221));
|
||||
}
|
||||
else if (dataValue >= ChartData.ErrorThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(206, 61, 54));
|
||||
}
|
||||
else if (dataValue >= ChartData.WarningThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(251, 157, 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(117, 177, 89));
|
||||
}
|
||||
setLeft = CalculateSetLeft(dataTime);
|
||||
Canvas.SetBottom(border, dataValue * setFactor);
|
||||
Canvas.SetLeft(border, setLeft);
|
||||
GraphicCanvas.Children.Add(border);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Close Button
|
||||
|
||||
private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
CloseButtonClickedAction?.Invoke();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class cChartValue
|
||||
{
|
||||
public DateTime Time { get; set; }
|
||||
public double Value { get; set; }
|
||||
public int Duration { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
146
FasdDesktopUi/Basics/UserControls/DataCanvas/DetailedData.xaml
Normal file
146
FasdDesktopUi/Basics/UserControls/DataCanvas/DetailedData.xaml
Normal file
@@ -0,0 +1,146 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DetailedData"
|
||||
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"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:Name="DetailedDataUc">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<converter:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<converter:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<Style TargetType="GridViewColumnHeader" x:Key="NoColumnHeaderStyle">
|
||||
<Setter Property="Template" Value="{x:Null}"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Margin="0 0 0 10"
|
||||
Visibility="{Binding ElementName=DetailedDataUc, Path=DetailedInformationData, Converter={StaticResource NullToVisibility}}"
|
||||
CornerRadius="10"
|
||||
Padding="10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">
|
||||
|
||||
<StackPanel x:Name="mainStackPanel">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="GridViewColumnHeader">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
|
||||
<TextBlock Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
Text="{TemplateBinding Content}"
|
||||
Margin="0 0 15 5"
|
||||
Padding="5"
|
||||
TextAlignment="Left"
|
||||
HorizontalAlignment="Left" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListViewItem"
|
||||
BasedOn="{StaticResource DetailsPage.DataHistory.Value}">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.DetailsPage.DataHistory.Value}" />
|
||||
<Setter Property="FontWeight"
|
||||
Value="Regular" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Border Margin="0 0.5"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
Background="{TemplateBinding Background}">
|
||||
<GridViewRowPresenter Height="30"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Width="Auto"
|
||||
Content="{TemplateBinding Content}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
</Style>
|
||||
|
||||
</StackPanel.Resources>
|
||||
|
||||
<DockPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Visibility="{Binding IsCloseButtonVisible, ElementName=DetailedDataUc, Converter={StaticResource BoolToVisibility}}">
|
||||
<ico:AdaptableIcon x:Name="CopyButton" x:FieldModifier="private"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
SelectedInternIcon="menuBar_copy"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.DetailTable.CopyContent}"
|
||||
MouseUp="CopyButton_MouseUp" TouchDown="CopyButton_TouchDown"
|
||||
/>
|
||||
<ico:AdaptableIcon x:Name="DownloadButton" x:FieldModifier="private"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
SelectedMaterialIcon="ic_file_download"
|
||||
Margin="-12,0,0,0"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.DetailTable.ContentDownload}"
|
||||
MouseUp="DownloadButton_MouseUp" TouchDown="DownloadButton_TouchDown"
|
||||
/>
|
||||
<ico:AdaptableIcon x:Name="CloseButton" x:FieldModifier="private"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
SelectedInternIcon="window_close"
|
||||
Margin="-12,0,0,0"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<ico:AdaptableIcon DockPanel.Dock="Left"
|
||||
VerticalAlignment="Center"
|
||||
PrimaryIconColor="{DynamicResource Color.FunctionMarker}"
|
||||
BorderPadding="0"
|
||||
IconHeight="10"
|
||||
IconWidth="10"
|
||||
SelectedInternIcon="misc_dot" />
|
||||
|
||||
<TextBlock Text="{Binding DetailedInformationData.Heading, ElementName=DetailedDataUc}"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10" />
|
||||
|
||||
</DockPanel>
|
||||
|
||||
<ListView x:Name="DetailedDataListView"
|
||||
ItemsSource="{Binding ListViewData, ElementName=DetailedDataUc}"
|
||||
BorderThickness="0"
|
||||
Background="Transparent"
|
||||
PreviewMouseWheel="ListView_PreviewMouseWheel">
|
||||
</ListView>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class DetailedData : UserControl
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
#region ListViewDataSource
|
||||
|
||||
#region ListViewHeaders
|
||||
|
||||
public List<object> ListViewHeaders
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DetailedInformationData.FullDetailedData?.Count > 0)
|
||||
{
|
||||
var _retVal = DetailedInformationData.FullDetailedData[0];
|
||||
var _ret = _retVal as List<object>;
|
||||
return _ret;
|
||||
}
|
||||
|
||||
return new List<object>();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListViewData
|
||||
|
||||
internal static readonly DependencyPropertyKey ListViewDataKey = DependencyProperty.RegisterReadOnly("ListViewData", typeof(List<object>), typeof(DetailedData), new PropertyMetadata(new List<object>()));
|
||||
|
||||
public static readonly DependencyProperty ListViewDataProperty = ListViewDataKey.DependencyProperty;
|
||||
|
||||
public List<object> ListViewData => (List<object>)GetValue(ListViewDataProperty);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DetailedData
|
||||
|
||||
private static void DetailedDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailedData _me))
|
||||
return;
|
||||
|
||||
|
||||
if (_me.DetailedInformationData == null)
|
||||
return;
|
||||
|
||||
int _skip = _me.DetailedInformationData.HasColumnHeaders? 1 : 0;
|
||||
|
||||
if (_me.DetailedInformationData.FullDetailedData.Count < _skip)
|
||||
return;
|
||||
|
||||
var listViewDataKeyValue = _me.DetailedInformationData.FullDetailedData.Count > _skip ? _me.DetailedInformationData.FullDetailedData.Skip(_skip).ToList() : new List<object>();
|
||||
_me.SetValue(ListViewDataKey, listViewDataKeyValue);
|
||||
_me.UpdateListView();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DetailedInformationDataProperty =
|
||||
DependencyProperty.Register("DetailedInformationData", typeof(cDetailedDataModel), typeof(DetailedData), new PropertyMetadata(new cDetailedDataModel(), new PropertyChangedCallback(DetailedDataChangedCallback)));
|
||||
|
||||
public cDetailedDataModel DetailedInformationData
|
||||
{
|
||||
get { return (cDetailedDataModel)GetValue(DetailedInformationDataProperty); }
|
||||
set { SetValue(DetailedInformationDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCloseButtonVisible
|
||||
|
||||
public static readonly DependencyProperty IsCloseButtonVisibleProperty =
|
||||
DependencyProperty.Register("IsCloseButtonVisible", typeof(bool), typeof(DetailedData), new PropertyMetadata(false));
|
||||
|
||||
public bool IsCloseButtonVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsCloseButtonVisibleProperty); }
|
||||
set { SetValue(IsCloseButtonVisibleProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Action CloseButtonClickedAction { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailedData()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void UpdateListView()
|
||||
{
|
||||
DetailedDataListView.ClearValue(ListView.ViewProperty);
|
||||
|
||||
if (ListViewHeaders.Count < 0)
|
||||
return;
|
||||
|
||||
GridView newGridView = new GridView() { AllowsColumnReorder = false };
|
||||
|
||||
// set the header style (header present or not)
|
||||
var _data = DetailedInformationData;
|
||||
if (!_data.HasColumnHeaders)
|
||||
{
|
||||
object _objStyle = this.FindResource("NoColumnHeaderStyle");
|
||||
if (_objStyle is Style _style)
|
||||
if (!DetailedDataListView.Resources.Contains(typeof(GridViewColumnHeader)))
|
||||
DetailedDataListView.Resources.Add(typeof(GridViewColumnHeader), _style);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DetailedDataListView.Resources.Contains(typeof(GridViewColumnHeader)))
|
||||
DetailedDataListView.Resources.Remove(typeof(GridViewColumnHeader));
|
||||
}
|
||||
|
||||
// create the header columns
|
||||
for (int i = 0; i < ListViewHeaders.Count; i++)
|
||||
{
|
||||
BindingBase bindingBase = new Binding($"[{i}]");
|
||||
object _header = null;
|
||||
if (_data.HasColumnHeaders)
|
||||
_header = ListViewHeaders[i];
|
||||
var _gvColumn = new GridViewColumn() { Header = _header, DisplayMemberBinding = bindingBase };
|
||||
newGridView.Columns.Add(_gvColumn);
|
||||
}
|
||||
|
||||
DetailedDataListView.View = newGridView;
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (sender is ListView && !e.Handled)
|
||||
{
|
||||
e.Handled = true;
|
||||
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
|
||||
{
|
||||
RoutedEvent = MouseWheelEvent,
|
||||
Source = sender
|
||||
};
|
||||
var parent = ((Control)sender).Parent as UIElement;
|
||||
parent.RaiseEvent(eventArg);
|
||||
}
|
||||
}
|
||||
|
||||
#region CloseButton_Click
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
if (CloseButtonClickedAction != null)
|
||||
CloseButtonClickedAction.Invoke();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyButton_Click
|
||||
|
||||
private async Task CopyButton_ClickAsync()
|
||||
{
|
||||
var uiAction = new cUiCopyDetailsTableContent(DetailedInformationData);
|
||||
cUiActionBase.RaiseEvent(uiAction, this, this);
|
||||
|
||||
await cUtility.ChangeIconToCheckAsync(CopyButton);
|
||||
|
||||
}
|
||||
|
||||
private async void CopyButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await CopyButton_ClickAsync();
|
||||
}
|
||||
|
||||
private async void CopyButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
await CopyButton_ClickAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DownloadButton_Click
|
||||
|
||||
private void DownloadButton_Click()
|
||||
{
|
||||
var uiAction = new cUiSaveDetailsTableContent(DetailedInformationData);
|
||||
cUiActionBase.RaiseEvent(uiAction, this, this);
|
||||
}
|
||||
|
||||
private void DownloadButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DownloadButton_Click();
|
||||
}
|
||||
|
||||
private void DownloadButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
DownloadButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DetailedRecommendation"
|
||||
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.Pages.DetailsPage.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
x:Name="RecommendationUc"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
|
||||
<converter:NullValueToVisibilityConverter x:Key="NullToVisibility"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Visibility="{Binding ElementName=RecommendationUc, Path=RecommendationData, Converter={StaticResource NullToVisibility}}"
|
||||
Padding="10"
|
||||
CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">
|
||||
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
Visibility="{Binding ElementName=RecommendationUc, Path=IsCloseButtonVisible, Converter={StaticResource BoolToVisibility}}"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="RecommendationIcon"
|
||||
x:FieldModifier="private"
|
||||
DockPanel.Dock="Left"
|
||||
VerticalAlignment="Center"
|
||||
PrimaryIconColor="{DynamicResource Color.Blue}"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
SelectedInternIcon="status_info" />
|
||||
|
||||
<TextBlock Text="{Binding RecommendationData.Category, ElementName=RecommendationUc}"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10" />
|
||||
|
||||
</DockPanel>
|
||||
|
||||
<Border Padding="10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
|
||||
CornerRadius="10">
|
||||
<TextBlock Text="{Binding ElementName=RecommendationUc, Path=RecommendationData.Recommendation}"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
FontFamily="Calibri"
|
||||
FontSize="14"
|
||||
FontWeight="Regular"
|
||||
TextWrapping="Wrap"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,116 @@
|
||||
using F4SD_AdaptableIcon;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics.Helper;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class DetailedRecommendation : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region RecommendationData
|
||||
|
||||
public static readonly DependencyProperty RecommendationDataProperty =
|
||||
DependencyProperty.Register("RecommendationData", typeof(cRecommendationDataModel), typeof(DetailedRecommendation), new PropertyMetadata(new cRecommendationDataModel()));
|
||||
|
||||
public cRecommendationDataModel RecommendationData
|
||||
{
|
||||
get { return (cRecommendationDataModel)GetValue(RecommendationDataProperty); }
|
||||
set { SetValue(RecommendationDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCloseButtonVisible
|
||||
|
||||
public static readonly DependencyProperty IsCloseButtonVisibleProperty =
|
||||
DependencyProperty.Register("IsCloseButtonVisible", typeof(bool), typeof(DetailedRecommendation), new PropertyMetadata(false));
|
||||
|
||||
public bool IsCloseButtonVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsCloseButtonVisibleProperty); }
|
||||
set { SetValue(IsCloseButtonVisibleProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Icon
|
||||
|
||||
public IconData Icon
|
||||
{
|
||||
get { return (IconData)GetValue(IconProperty); }
|
||||
set { SetValue(IconProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconProperty =
|
||||
DependencyProperty.Register("Icon", typeof(IconData), typeof(DetailedRecommendation), new PropertyMetadata(new IconData(enumInternIcons.status_info), HandleIconChanged));
|
||||
|
||||
private static void HandleIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailedRecommendation recommendation && e.NewValue is IconData iconData)
|
||||
{
|
||||
IconHelper.SetIconValue(recommendation.RecommendationIcon, iconData);
|
||||
}
|
||||
}
|
||||
|
||||
public string PrimaryIconColorResourceName
|
||||
{
|
||||
get { return (string)GetValue(PrimaryIconColorResourceNameProperty); }
|
||||
set { SetValue(PrimaryIconColorResourceNameProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PrimaryIconColorResourceNameProperty =
|
||||
DependencyProperty.Register("PrimaryIconColorResourceName", typeof(string), typeof(DetailedRecommendation), new PropertyMetadata("Color.Blue", HandleColorChanged));
|
||||
|
||||
private static void HandleColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailedRecommendation recommendation)
|
||||
{
|
||||
recommendation.RecommendationIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Action CloseButtonClickedAction { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailedRecommendation()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
if (CloseButtonClickedAction != null)
|
||||
CloseButtonClickedAction.Invoke();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
127
FasdDesktopUi/Basics/UserControls/DataCanvas/DynamicChart.xaml
Normal file
127
FasdDesktopUi/Basics/UserControls/DataCanvas/DynamicChart.xaml
Normal file
@@ -0,0 +1,127 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DynamicChart"
|
||||
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"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
Name="DynChartUc"
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="UserControl_SizeChanged"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Margin="0 0 0 10"
|
||||
Height="270"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Visibility="{Binding ElementName=DynChartUc, Path=ChartData, Converter={StaticResource NullToVisibility}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="42" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--#region Kopfzeile -->
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="45" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="45" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="BarChartButton"
|
||||
Grid.Column="0"
|
||||
SelectedMaterialIcon="ic_sort"
|
||||
MouseLeftButtonUp="ChangeChartType_MouseLeftButtonUp"
|
||||
TouchDown="ChangeChartType_TouchDown"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Color}"
|
||||
Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
|
||||
<ico:AdaptableIcon.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform Angle="-90"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</ico:AdaptableIcon.RenderTransform>
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<ico:AdaptableIcon x:Name="LineGraphButton"
|
||||
Grid.Column="0"
|
||||
SelectedMaterialIcon="ic_clear_all"
|
||||
MouseLeftButtonUp="ChangeChartType_MouseLeftButtonUp"
|
||||
TouchDown="ChangeChartType_TouchDown"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Color}"
|
||||
Visibility="Visible"/>
|
||||
|
||||
<Border Grid.Column="2"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
CornerRadius="10,0,0,0">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
x:Name="TitleBlock"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,5,0,0"
|
||||
FontFamily="Calibri"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="1"
|
||||
x:Name="DateBlock"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontSize="13"
|
||||
FontWeight="Regular"
|
||||
Foreground="{DynamicResource Color.Menu.Icon}">
|
||||
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Column="4"
|
||||
SelectedInternIcon="window_close"
|
||||
MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
Visibility="{Binding ElementName=DynChartUc, Path=IsCloseButtonVisible, Converter={StaticResource BoolToVisibility}}"/>
|
||||
|
||||
</Grid>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Inhalt -->
|
||||
<Grid Grid.Row="1"
|
||||
Margin="10">
|
||||
|
||||
<Border x:Name="GraphicBorder"
|
||||
Panel.ZIndex="1">
|
||||
<Border x:Name="CanvasBorder">
|
||||
<Canvas x:Name="GraphicCanvas"
|
||||
Panel.ZIndex="1"/>
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
<!--#endregion-->
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,832 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
|
||||
public partial class DynamicChart : UserControl
|
||||
{
|
||||
|
||||
#region Variables
|
||||
|
||||
int DataDurationStart;
|
||||
int DataDurationEnd;
|
||||
int DataDurationTotal;
|
||||
int timeSkip;
|
||||
|
||||
private double PaddingTop;
|
||||
private double PaddingBottom;
|
||||
private double PaddingLeft;
|
||||
private double PaddingRight;
|
||||
private double DataHeight;
|
||||
private double DataWidth;
|
||||
|
||||
private LinearTransformation xCoordinate;
|
||||
private LinearTransformation yCoordinate;
|
||||
|
||||
Size sizeY;
|
||||
Size sizeX;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#region ChartData
|
||||
|
||||
public cChartModel ChartData
|
||||
{
|
||||
get { return (cChartModel)GetValue(ChartDataProperty); }
|
||||
set { SetValue(ChartDataProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ChartDataProperty =
|
||||
DependencyProperty.Register("ChartData", typeof(cChartModel), typeof(DynamicChart), new PropertyMetadata(null, new PropertyChangedCallback(HandleDependancyPropertyChanged)));
|
||||
|
||||
|
||||
private static void HandleDependancyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DynamicChart me)) return;
|
||||
me.BindingValueChange();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCloseButtonVisible
|
||||
public bool IsCloseButtonVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsCloseButtonVisibleProperty); }
|
||||
set { SetValue(IsCloseButtonVisibleProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsCloseButtonVisibleProperty =
|
||||
DependencyProperty.Register("IsCloseButtonVisible", typeof(bool), typeof(DynamicChart), new PropertyMetadata(false));
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsBarChart
|
||||
|
||||
|
||||
|
||||
public bool isBarChart
|
||||
{
|
||||
get { return (bool)GetValue(isBarChartProperty); }
|
||||
set { SetValue(isBarChartProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for isBarChart. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty isBarChartProperty =
|
||||
DependencyProperty.Register("isBarChart", typeof(bool), typeof(DynamicChart), new PropertyMetadata(true, new PropertyChangedCallback(HandleBarChartPropertyChanged)));
|
||||
|
||||
private static void HandleBarChartPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DynamicChart me)) return;
|
||||
me.ChartTypeChange();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GraphicDataProperty
|
||||
|
||||
public List<cChartValue> GraphicDataProperty { get; set; } = new List<cChartValue>();
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Classes
|
||||
|
||||
public class cChartValue
|
||||
{
|
||||
public DateTime Time { get; set; }
|
||||
public double Value { get; set; }
|
||||
public int Duration { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class LinearTransformation
|
||||
{
|
||||
|
||||
private double x0;
|
||||
private double x1;
|
||||
private double z0;
|
||||
private double z1;
|
||||
private double a;
|
||||
private double c;
|
||||
|
||||
public LinearTransformation(double x0, double x1, double z0, double z1)
|
||||
{
|
||||
this.x0 = x0;
|
||||
this.x1 = x1;
|
||||
this.z0 = z0;
|
||||
this.z1 = z1;
|
||||
|
||||
a = (x1 - x0) / (z1 - z0);
|
||||
c = x0 - (a * z0);
|
||||
|
||||
}
|
||||
|
||||
public double GetCoordinate(double x)
|
||||
{
|
||||
return a * x + c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public Action CloseButtonClickedAction { get; set; }
|
||||
|
||||
#region Restructure
|
||||
|
||||
public void BindingValueChange()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
ClearControl();
|
||||
|
||||
if (ChartData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ActualHeight == 0 || this.ActualWidth == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetGraphicDataProperty();
|
||||
SetTitle();
|
||||
SetDate();
|
||||
SetTime();
|
||||
SetCanvas();
|
||||
SetScale();
|
||||
SetTimeStamps();
|
||||
SetLines();
|
||||
if (isBarChart == true)
|
||||
{
|
||||
SetValuesBarChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetValuesLineGraph();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ChartTypeChange()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
GraphicCanvas.Children.Clear();
|
||||
|
||||
if (isBarChart == true)
|
||||
{
|
||||
BarChartButton.Visibility = Visibility.Collapsed;
|
||||
LineGraphButton.Visibility = Visibility.Visible;
|
||||
SetScale();
|
||||
SetTimeStamps();
|
||||
SetLines();
|
||||
SetValuesBarChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
BarChartButton.Visibility = Visibility.Visible;
|
||||
LineGraphButton.Visibility = Visibility.Collapsed;
|
||||
SetScale();
|
||||
SetTimeStamps();
|
||||
SetLines();
|
||||
SetValuesLineGraph();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void SetGraphicDataProperty()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ChartData?.Data == null) return;
|
||||
var reverseData = ChartData.Data.ToList();
|
||||
reverseData.Reverse();
|
||||
|
||||
if ((DateTime)reverseData[0][ChartData.TimeIndex] < (DateTime)reverseData[reverseData.Count() - 1][ChartData.TimeIndex])
|
||||
{
|
||||
foreach (var item in reverseData)
|
||||
{
|
||||
if (item[ChartData.ValueIndex] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
cChartValue data = new cChartValue();
|
||||
data.Value = (double)Convert.ChangeType(item[ChartData.ValueIndex], typeof(double));
|
||||
if (ChartData.DurationIndex > -1)
|
||||
data.Duration = int.Parse(item[ChartData.DurationIndex].ToString());
|
||||
data.Time = (DateTime)item[ChartData.TimeIndex];
|
||||
data.Time = data.Time.ToLocalTime();
|
||||
GraphicDataProperty.Add(data);
|
||||
}
|
||||
}
|
||||
else if ((DateTime)ChartData.Data[0][ChartData.TimeIndex] < (DateTime)ChartData.Data[ChartData.Data.Count() - 1][ChartData.TimeIndex] || ChartData.Data.Count == 1)
|
||||
{
|
||||
foreach (var item in ChartData.Data)
|
||||
{
|
||||
if (item[ChartData.ValueIndex] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
cChartValue data = new cChartValue();
|
||||
data.Value = (double)Convert.ChangeType(item[ChartData.ValueIndex], typeof(double));
|
||||
if (ChartData.DurationIndex > -1)
|
||||
data.Duration = int.Parse(item[ChartData.DurationIndex].ToString());
|
||||
data.Time = (DateTime)item[ChartData.TimeIndex];
|
||||
data.Time = data.Time.ToLocalTime();
|
||||
GraphicDataProperty.Add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearControl()
|
||||
{
|
||||
TitleBlock.Text = string.Empty;
|
||||
DateBlock.Text = string.Empty;
|
||||
GraphicCanvas.Children.Clear();
|
||||
GraphicDataProperty.Clear();
|
||||
}
|
||||
|
||||
public void SetTitle()
|
||||
{
|
||||
TitleBlock.Text = ChartData.ChartTitle;
|
||||
}
|
||||
|
||||
public void SetDate()
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dataDate = GraphicDataProperty.First<cChartValue>().Time;
|
||||
dataDate = dataDate.Date;
|
||||
DateBlock.Text = $"{dataDate.ToString("dddd", new CultureInfo(cFasdCockpitConfig.Instance.SelectedLanguage))}, {dataDate.ToString("d", new CultureInfo(cFasdCockpitConfig.Instance.SelectedLanguage))}";
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTime()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
DateTime firstTime = GraphicDataProperty.First<cChartValue>().Time;
|
||||
DateTime lastTime = GraphicDataProperty.Last<cChartValue>().Time;
|
||||
int lastDuration = GraphicDataProperty.Last<cChartValue>().Duration;
|
||||
|
||||
lastTime = lastTime.AddMilliseconds(lastDuration);
|
||||
|
||||
DataDurationStart = firstTime.Hour;
|
||||
DataDurationEnd = lastTime.Hour + 1;
|
||||
|
||||
TimeSpan totalDuration = lastTime - firstTime;
|
||||
|
||||
DataDurationTotal = DataDurationEnd - DataDurationStart + (24 * totalDuration.Days);
|
||||
DataDurationTotal = GetNextLogicalTotalDuration(DataDurationTotal);
|
||||
|
||||
// temp fix
|
||||
DataDurationEnd = DataDurationStart + DataDurationTotal;
|
||||
|
||||
timeSkip = (int)Math.Ceiling(DataDurationTotal / 5.0);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
|
||||
// this is a temporary helper method to keep the structure of the current state of the charts.
|
||||
// however the logic should be rethought and maybe finally replaced for a even more dynamic approach
|
||||
int GetNextLogicalTotalDuration(int totalDuration)
|
||||
{
|
||||
if (totalDuration < 0)
|
||||
return 24 + totalDuration;
|
||||
else if (totalDuration <= 3)
|
||||
return 3;
|
||||
else if (totalDuration <= 5)
|
||||
return 5;
|
||||
else if (totalDuration <= 8)
|
||||
return 8;
|
||||
else if (totalDuration <= 10)
|
||||
return 10;
|
||||
else if (totalDuration <= 12)
|
||||
return 12;
|
||||
else if (totalDuration <= 15)
|
||||
return 15;
|
||||
else if (totalDuration <= 18)
|
||||
return 18;
|
||||
else if (totalDuration <= 20)
|
||||
return 20;
|
||||
else return 24;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCanvas()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
string textY;
|
||||
if (ChartData.UnitFormat.Contains("{0}"))
|
||||
{
|
||||
textY = String.Format(ChartData.UnitFormat, ChartData.MaxValue.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
textY = ChartData.MaxValue.ToString() + ChartData.UnitFormat;
|
||||
}
|
||||
sizeY = GetStringSize(textY, 11, new System.Windows.Media.FontFamily("Calibri"));
|
||||
|
||||
string textX = "09:00";
|
||||
sizeX = GetStringSize(textX, 11, new System.Windows.Media.FontFamily("Calibri"));
|
||||
|
||||
PaddingTop = 5 + (sizeY.Height / 2);
|
||||
PaddingRight = 10 + sizeY.Width;
|
||||
PaddingBottom = 10 + sizeX.Height + PaddingTop;
|
||||
PaddingLeft = 10 + (sizeX.Width / 2);
|
||||
|
||||
DataHeight = GraphicCanvas.ActualHeight - PaddingTop - PaddingBottom;
|
||||
DataWidth = GraphicCanvas.ActualWidth - PaddingLeft - PaddingRight;
|
||||
|
||||
yCoordinate = new LinearTransformation(PaddingTop + DataHeight, PaddingTop, ChartData.MinValue, ChartData.MaxValue);
|
||||
xCoordinate = new LinearTransformation(PaddingLeft, PaddingLeft + DataWidth, DataDurationStart * 3600000, (DataDurationStart + DataDurationTotal) * 3600000);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SetScale()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
int Minimum = 0;
|
||||
|
||||
if ((ChartData.MinValue / ChartData.StepLengthScale) % 1 != 0)
|
||||
{
|
||||
int Multiplikator = ChartData.MinValue / ChartData.StepLengthScale;
|
||||
Multiplikator++;
|
||||
Minimum = Multiplikator * ChartData.MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Minimum = ChartData.MinValue;
|
||||
}
|
||||
|
||||
for (int i = Minimum; i <= ChartData.MaxValue; i += ChartData.StepLengthScale)
|
||||
{
|
||||
string text;
|
||||
|
||||
if (ChartData.UnitFormat.Contains("{0}"))
|
||||
{
|
||||
text = String.Format(ChartData.UnitFormat, i.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
text = i.ToString() + ChartData.UnitFormat;
|
||||
}
|
||||
|
||||
TextBlock textBlock = new TextBlock()
|
||||
{
|
||||
Text = text,
|
||||
FontFamily = new FontFamily("Calibri"),
|
||||
FontSize = 11,
|
||||
};
|
||||
textBlock.SetResourceReference(TextBlock.ForegroundProperty, "Color.Menu.Icon");
|
||||
Canvas.SetTop(textBlock, yCoordinate.GetCoordinate(i) - (sizeY.Height / 2));
|
||||
Canvas.SetLeft(textBlock, PaddingLeft + DataWidth + 1);
|
||||
GraphicCanvas.Children.Add(textBlock);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
public void SetTimeStamps()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (int i = DataDurationStart; i <= DataDurationEnd; i++)
|
||||
{
|
||||
|
||||
if ((DataDurationStart - i) % timeSkip != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string timeStamp;
|
||||
int timeStampTime = i;
|
||||
if (timeStampTime > 24)
|
||||
{
|
||||
timeStampTime -= 24;
|
||||
}
|
||||
|
||||
if (i < 10)
|
||||
{
|
||||
timeStamp = "0" + timeStampTime.ToString() + ":00";
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStamp = timeStampTime.ToString() + ":00";
|
||||
}
|
||||
|
||||
TextBlock textBlock = new TextBlock()
|
||||
{
|
||||
Text = timeStamp,
|
||||
FontFamily = new FontFamily("Calibri"),
|
||||
FontSize = 11,
|
||||
};
|
||||
|
||||
textBlock.SetResourceReference(TextBlock.ForegroundProperty, "Color.Menu.Icon");
|
||||
|
||||
Canvas.SetTop(textBlock, PaddingTop + DataHeight + (sizeX.Height / 2));
|
||||
Canvas.SetLeft(textBlock, (xCoordinate.GetCoordinate(i * 3600000)) - (sizeX.Width / 2));
|
||||
GraphicCanvas.Children.Add(textBlock);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLines()
|
||||
{
|
||||
try
|
||||
{
|
||||
int Minimum = 0;
|
||||
|
||||
if ((ChartData.MinValue / ChartData.StepLengthLine) % 1 != 0)
|
||||
{
|
||||
int Multiplikator = ChartData.MinValue / ChartData.StepLengthLine;
|
||||
Multiplikator++;
|
||||
Minimum = Multiplikator * ChartData.MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Minimum = ChartData.MinValue;
|
||||
}
|
||||
|
||||
for (int i = Minimum; i <= ChartData.MaxValue; i += ChartData.StepLengthLine)
|
||||
{
|
||||
|
||||
Point point1 = new Point(PaddingLeft, yCoordinate.GetCoordinate(i));
|
||||
Point point2 = new Point(PaddingLeft + DataWidth, yCoordinate.GetCoordinate(i));
|
||||
|
||||
Line dottedLine = new Line();
|
||||
|
||||
dottedLine.SetResourceReference(Line.StrokeProperty, "HorizontalLineColor");
|
||||
dottedLine.StrokeThickness = 1;
|
||||
|
||||
dottedLine.StrokeDashArray = new DoubleCollection { 5, 5 };
|
||||
|
||||
dottedLine.X1 = point1.X;
|
||||
dottedLine.Y1 = point1.Y;
|
||||
dottedLine.X2 = point2.X;
|
||||
dottedLine.Y2 = point2.Y;
|
||||
|
||||
GraphicCanvas.Children.Add(dottedLine);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetValuesLineGraph()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var data in GraphicDataProperty)
|
||||
{
|
||||
DateTime dataTime = data.Time;
|
||||
double dataValue = data.Value;
|
||||
int dataDuration = data.Duration;
|
||||
|
||||
double time = dataTime.TimeOfDay.TotalMilliseconds;
|
||||
|
||||
double xLeft = xCoordinate.GetCoordinate(time);
|
||||
double xRight = xCoordinate.GetCoordinate(time + dataDuration);
|
||||
|
||||
double y = 0;
|
||||
|
||||
if (dataValue > ChartData.MaxValue)
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(ChartData.MaxValue) - 5;
|
||||
}
|
||||
else if (dataValue < ChartData.MinValue)
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(ChartData.MinValue) + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(dataValue);
|
||||
}
|
||||
|
||||
|
||||
Border border = new Border()
|
||||
{
|
||||
Height = 6.0,
|
||||
Width = xRight - xLeft,
|
||||
CornerRadius = new CornerRadius(4.0),
|
||||
ToolTip = dataTime.ToShortTimeString() + " - " + dataTime.AddMilliseconds(dataDuration).ToShortTimeString() + " | " + dataValue,
|
||||
};
|
||||
if (border.Width < 6)
|
||||
{
|
||||
border.Width = 6;
|
||||
}
|
||||
if (ChartData.IsThresholdActive == false)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(0, 157, 221));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ChartData.IsDirectionUp == false)
|
||||
{
|
||||
if (dataValue <= ChartData.ErrorThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(206, 61, 54));
|
||||
}
|
||||
else if (dataValue <= ChartData.WarningThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(251, 157, 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(117, 177, 89));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataValue >= ChartData.ErrorThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(206, 61, 54));
|
||||
}
|
||||
else if (dataValue >= ChartData.WarningThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(251, 157, 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(117, 177, 89));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.SetTop(border, y - (border.Height / 2));
|
||||
Canvas.SetLeft(border, xLeft);
|
||||
GraphicCanvas.Children.Add(border);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetValuesBarChart()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var data in GraphicDataProperty)
|
||||
{
|
||||
DateTime dataTime = data.Time;
|
||||
double dataValue = data.Value;
|
||||
int dataDuration = data.Duration;
|
||||
|
||||
double time = dataTime.TimeOfDay.TotalMilliseconds;
|
||||
|
||||
double xLeft = xCoordinate.GetCoordinate(time);
|
||||
double xRight = xCoordinate.GetCoordinate(time + dataDuration);
|
||||
|
||||
double y = 0;
|
||||
|
||||
if (dataValue > ChartData.MaxValue)
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(ChartData.MaxValue) - 5;
|
||||
}
|
||||
else if (dataValue < ChartData.MinValue)
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(ChartData.MinValue) + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = yCoordinate.GetCoordinate(dataValue);
|
||||
}
|
||||
|
||||
Border border = new Border()
|
||||
{
|
||||
Height = yCoordinate.GetCoordinate(0) - y,
|
||||
Width = xRight - xLeft,
|
||||
CornerRadius = new CornerRadius(2, 2, 0, 0),
|
||||
ToolTip = dataTime.ToShortTimeString() + " - " + dataTime.AddMilliseconds(dataDuration).ToShortTimeString() + " | " + dataValue,
|
||||
};
|
||||
|
||||
if (border.Width < 6)
|
||||
{
|
||||
border.Width = 6;
|
||||
}
|
||||
|
||||
if (ChartData.IsThresholdActive == false)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(0, 157, 221));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ChartData.IsDirectionUp == false)
|
||||
{
|
||||
|
||||
if (dataValue <= ChartData.ErrorThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(206, 61, 54));
|
||||
}
|
||||
else if (dataValue <= ChartData.WarningThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(251, 157, 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(117, 177, 89));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataValue >= ChartData.ErrorThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(206, 61, 54));
|
||||
}
|
||||
else if (dataValue >= ChartData.WarningThreshold)
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(251, 157, 40));
|
||||
}
|
||||
else
|
||||
{
|
||||
border.Background = new SolidColorBrush(Color.FromRgb(117, 177, 89));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.SetTop(border, y);
|
||||
Canvas.SetLeft(border, xLeft);
|
||||
GraphicCanvas.Children.Add(border);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public DynamicChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region CloseButton_Click
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
if (CloseButtonClickedAction != null)
|
||||
CloseButtonClickedAction.Invoke();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChangeChartType_Click
|
||||
|
||||
private void ChangeChartType_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (senderElement.Name == "BarChartButton")
|
||||
{
|
||||
isBarChart = true;
|
||||
}
|
||||
|
||||
if (senderElement.Name == "LineGraphButton")
|
||||
{
|
||||
isBarChart = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ChangeChartType_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ChangeChartType_Click(sender);
|
||||
}
|
||||
|
||||
private void ChangeChartType_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ChangeChartType_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
BindingValueChange();
|
||||
}
|
||||
|
||||
public static Size GetStringSize(string text, double fontSize, FontFamily fontFamily)
|
||||
{
|
||||
|
||||
CultureInfo cultureInfo = CultureInfo.GetCultureInfo("de-DE");
|
||||
FlowDirection flowDirection = FlowDirection.LeftToRight;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
FormattedText formattedText = new FormattedText(
|
||||
text,
|
||||
cultureInfo,
|
||||
flowDirection,
|
||||
new Typeface(fontFamily.Source),
|
||||
fontSize,
|
||||
Brushes.Black
|
||||
);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
return new Size(formattedText.Width, formattedText.Height);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitor"
|
||||
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"
|
||||
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="800"
|
||||
x:Name="QuickActionStatusMonitorUc"
|
||||
IsVisibleChanged="BlurInvoker_IsActiveChanged">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<converter:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Visibility="{Binding ElementName=QuickActionStatusMonitorUc, Path=QuickActionData, Converter={StaticResource NullToVisibility}}"
|
||||
CornerRadius="10"
|
||||
Padding="10"
|
||||
Margin="0 0 0 10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">
|
||||
|
||||
<StackPanel>
|
||||
<DockPanel LastChildFill="False">
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
Visibility="{Binding ElementName=QuickActionStatusMonitorUc, Path=IsCloseButtonVisible, Converter={StaticResource BoolToVisibility}}"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="ExecuteButton"
|
||||
DockPanel.Dock="Left"
|
||||
VerticalAlignment="Center"
|
||||
BorderPadding="2.5"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseUp="ExecuteButton_MouseUp"
|
||||
TouchDown="ExecuteButton_TouchDown"
|
||||
SelectedInternIcon="misc_play" />
|
||||
|
||||
<ico:AdaptableIcon DockPanel.Dock="Left"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Base}"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Permission.User}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="7.5 0 0 0"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
Visibility="{Binding ElementName=QuickActionStatusMonitorUc, Path=QuickActionData.RequiresUserPermission, Converter={StaticResource BoolToVisibility}}"
|
||||
SelectedInternIcon="misc_user" />
|
||||
|
||||
<TextBlock Text="{Binding QuickActionData.ActionName, ElementName=QuickActionStatusMonitorUc}"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="CopyButton"
|
||||
Visibility="Collapsed"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
VerticalAlignment="Center"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
MouseLeftButtonUp="CopyButton_MouseLeftButtonUp"
|
||||
TouchDown="CopyButton_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="SecretButton"
|
||||
Visibility="Collapsed"
|
||||
DockPanel.Dock="Left"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
Margin="5 0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
BorderPadding="0"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
MouseLeftButtonUp="SecretButton_MouseLeftButtonUp"
|
||||
TouchDown="SecretButton_TouchDown"
|
||||
SelectedMaterialIcon="ic_visibility" />
|
||||
</DockPanel>
|
||||
|
||||
<Border Padding="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
CornerRadius="10">
|
||||
<DockPanel x:Name="CompletionStatusPanel">
|
||||
<DockPanel.Resources>
|
||||
<Style TargetType="TextBlock"
|
||||
BasedOn="{StaticResource DetailsPage.DataHistory.Value}">
|
||||
<Setter Property="FontWeight"
|
||||
Value="Regular" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.DetailsPage.DataHistory.Value}" />
|
||||
<Setter Property="TextAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="TextWrapping"
|
||||
Value="Wrap" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource SlimPage.Widget.Header.Icon}">
|
||||
<Setter Property="Margin"
|
||||
Value="7.5 2.5" />
|
||||
</Style>
|
||||
|
||||
</DockPanel.Resources>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel x:Name="QuickActionResultStack" />
|
||||
|
||||
<Border Padding="7.5"
|
||||
CornerRadius="10"
|
||||
Margin="0 7.5 0 0"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Visibility="{Binding ElementName=QuickActionStatusMonitorUc, Path=MeasureValues, Converter={StaticResource NullToVisibility}}">
|
||||
<Grid x:Name="MeasureValueGrid" />
|
||||
</Border>
|
||||
|
||||
<local:AdjustableParameterSection x:Name="AdjustableParameterSectionUc"
|
||||
Margin="0 7.5 0 0"
|
||||
AdjustableParameters="{Binding ElementName=QuickActionStatusMonitorUc, Path=QuickActionData.QuickActionParameters}"
|
||||
Visibility="{Binding ElementName=QuickActionStatusMonitorUc, Path=QuickActionData.QuickActionParameters, Converter={StaticResource NullToVisibility}}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,162 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitorResultElement"
|
||||
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"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<Style TargetType="TextBlock"
|
||||
BasedOn="{StaticResource DetailsPage.DataHistory.Value}">
|
||||
<Setter Property="FontWeight"
|
||||
Value="Bold" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.DetailsPage.DataHistory.Value}" />
|
||||
<Setter Property="TextAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="TextWrapping"
|
||||
Value="Wrap" />
|
||||
|
||||
<Style.Triggers>
|
||||
<EventTrigger RoutedEvent="Control.MouseLeftButtonUp">
|
||||
<EventTrigger.Actions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation From="0.4"
|
||||
Duration="0:0:1"
|
||||
FillBehavior="Stop"
|
||||
Storyboard.TargetProperty="Opacity" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger.Actions>
|
||||
</EventTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource SlimPage.Widget.Header.Icon}">
|
||||
<Setter Property="Margin"
|
||||
Value="2.5 -7.5 2.5 2.5" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="0" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="35" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="35" />
|
||||
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0"
|
||||
x:Name="QuickActionErrorContainer"
|
||||
Padding="7.5"
|
||||
Margin="0 7.5 0 0"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
CornerRadius="10">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Result.ErrorInfo}"
|
||||
Margin="0 0 0 3"
|
||||
Foreground="{DynamicResource Color.Red}" />
|
||||
<Grid x:Name="QuickActionErrorGrid"
|
||||
Grid.Row="1">
|
||||
<Grid.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Padding"
|
||||
Value="5 0" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0"
|
||||
Margin="8 0 0 0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
x:Name="ResultCodeLabel"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Result.ErrorInfo.ResultCode}"/>
|
||||
<TextBlock Grid.Row="1"
|
||||
x:Name="ErrorCodeLabel"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Result.ErrorInfo.ErrorCode}" />
|
||||
<TextBlock Grid.Row="2"
|
||||
x:Name="ErrorDescrLabel"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=QuickAction.Result.ErrorInfo.ErrorDescription}" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
x:Name="ResultCodeText"
|
||||
Margin="3 0 0 0"
|
||||
Cursor="{DynamicResource Cursor.Copy}"
|
||||
MouseLeftButtonUp="ValueTextBlock_Click"
|
||||
TouchDown="ValueTextBlock_Click" />
|
||||
<TextBlock Grid.Row="1"
|
||||
x:Name="ErrorCodeText"
|
||||
Margin="3 0 0 0"
|
||||
Cursor="{DynamicResource Cursor.Copy}"
|
||||
MouseLeftButtonUp="ValueTextBlock_Click"
|
||||
TouchDown="ValueTextBlock_Click" />
|
||||
<TextBlock Grid.Row="2"
|
||||
x:Name="ErrorDescrText"
|
||||
Margin="3 0 0 0"
|
||||
Cursor="{DynamicResource Cursor.Copy}"
|
||||
MouseLeftButtonUp="ValueTextBlock_Click"
|
||||
TouchDown="ValueTextBlock_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<Border Grid.Row="1"
|
||||
Padding="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
CornerRadius="10"
|
||||
Margin="0 7.5 0 0">
|
||||
<DockPanel>
|
||||
<ico:AdaptableIcon DockPanel.Dock="Left"
|
||||
x:Name="PartyPopperGif"
|
||||
Visibility="Collapsed"
|
||||
SelectedInternGif="partyPopper" />
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Grid x:Name="QuickActionResultGrid">
|
||||
<Grid.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Padding"
|
||||
Value="5 0" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,388 @@
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
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.UserControls.QuickActionStatusMonitor;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class QuickActionStatusMonitorResultElement : UserControl
|
||||
{
|
||||
private const string secretTag = "Secret";
|
||||
private const string veiledTextTag = "ClearText";
|
||||
|
||||
public QuickActionStatusMonitorResultElement()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetQuickActionOutputData(cF4sdQuickActionRevision.cOutput output, cSupportCaseDataProvider dataProvider, cFasdQuickAction quickActionDefinition)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResetQuickActionResultGrid();
|
||||
|
||||
if (output is null)
|
||||
return;
|
||||
|
||||
if (output.ResultCode == enumQuickActionSuccess.successfull)
|
||||
PartyPopperGif.Visibility = Visibility.Visible;
|
||||
|
||||
if (cQuickActionOutput.HasError(output))
|
||||
SetErrorOutput(output);
|
||||
else
|
||||
QuickActionErrorContainer.Visibility = Visibility.Collapsed;
|
||||
|
||||
var quickActionOutput = cQuickActionOutput.GetQuickActionOutput(output, dataProvider);
|
||||
|
||||
switch (quickActionOutput)
|
||||
{
|
||||
case cQuickActionOutputSingle singleOutput:
|
||||
SetSingleOutput(singleOutput, quickActionDefinition);
|
||||
break;
|
||||
case cQuickActionOutputList listOutput:
|
||||
SetListOutput(listOutput, quickActionDefinition);
|
||||
break;
|
||||
case cQuickActionOutputObject objectOutput:
|
||||
SetObjectOutput(objectOutput, quickActionDefinition);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetQuickActionResultGrid()
|
||||
{
|
||||
QuickActionResultGrid.Children.Clear();
|
||||
QuickActionResultGrid.RowDefinitions.Clear();
|
||||
QuickActionResultGrid.ColumnDefinitions.Clear();
|
||||
}
|
||||
|
||||
private void SetErrorOutput(cF4sdQuickActionRevision.cOutput output)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (output is null)
|
||||
return;
|
||||
|
||||
if (output.ResultCode != null
|
||||
&& output.ResultCode.Value != enumQuickActionSuccess.unknown
|
||||
&& output.ResultCode.Value != enumQuickActionSuccess.error)
|
||||
{
|
||||
ResultCodeLabel.Visibility = Visibility.Collapsed;
|
||||
ResultCodeText.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResultCodeLabel.Visibility = Visibility.Visible;
|
||||
ResultCodeText.Visibility = Visibility.Visible;
|
||||
ResultCodeText.Text = output?.ResultCode?.ToString();
|
||||
}
|
||||
|
||||
if (output?.ErrorCode != null && output?.ErrorCode != 0)
|
||||
{
|
||||
ErrorCodeLabel.Visibility = Visibility.Visible;
|
||||
ErrorCodeText.Visibility = Visibility.Visible;
|
||||
var strErr = output?.ErrorCode?.ToString() ?? "";
|
||||
|
||||
var unsigned = (uint)(output.ErrorCode);
|
||||
var strHex = unsigned.ToString("X");
|
||||
strErr += " (0x" + strHex + ")";
|
||||
|
||||
ErrorCodeText.Text = strErr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCodeLabel.Visibility = Visibility.Collapsed;
|
||||
ErrorCodeText.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(output?.ErrorDescription))
|
||||
{
|
||||
ErrorDescrLabel.Visibility = Visibility.Visible;
|
||||
ErrorDescrText.Visibility = Visibility.Visible;
|
||||
ErrorDescrText.Text = output?.ErrorDescription;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorDescrLabel.Visibility = Visibility.Collapsed;
|
||||
ErrorDescrText.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
QuickActionErrorContainer.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSingleOutput(cQuickActionOutputSingle output, cFasdQuickAction quickActionDefinition)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (output.Value is null)
|
||||
return;
|
||||
|
||||
string displayValue = output.GetDisplayValue(quickActionDefinition.ColumnOutputFormattings);
|
||||
var resultTextBlock = new TextBlock() { Text = !string.IsNullOrWhiteSpace(displayValue) ? displayValue : null };
|
||||
resultTextBlock.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
resultTextBlock.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
resultTextBlock.TouchDown += ValueTextBlock_Click;
|
||||
|
||||
cColumnOutputFormatting formatting = null;
|
||||
if (output.Key != null)
|
||||
quickActionDefinition.ColumnOutputFormattings.TryGetValue(output.Key, out formatting);
|
||||
formatting = formatting ?? quickActionDefinition.ColumnOutputFormattings?.Values?.FirstOrDefault();
|
||||
|
||||
if (formatting != null)
|
||||
{
|
||||
string displayValueSecret = output.GetDisplayValue(quickActionDefinition.ColumnOutputFormattings, true);
|
||||
var resultTextBlockSecret = new TextBlock() { Text = !string.IsNullOrWhiteSpace(displayValueSecret) ? displayValueSecret : null, Visibility = Visibility.Collapsed, Tag = secretTag };
|
||||
resultTextBlockSecret.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
resultTextBlockSecret.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
resultTextBlockSecret.TouchDown += ValueTextBlock_Click;
|
||||
ReplaceClickSenderOf(resultTextBlock, resultTextBlockSecret);
|
||||
|
||||
resultTextBlock.Tag = veiledTextTag;
|
||||
QuickActionResultGrid.Children.Add(resultTextBlockSecret);
|
||||
}
|
||||
|
||||
QuickActionResultGrid.Children.Add(resultTextBlock);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetListOutput(cQuickActionOutputList listOutput, cFasdQuickAction quickActionDefinition)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (listOutput.Values is null || listOutput.Values.Count <= 0)
|
||||
return;
|
||||
|
||||
var columnFormattings = quickActionDefinition.ColumnOutputFormattings;
|
||||
List<KeyValuePair<string, object>> headingValues = listOutput.Values[0];
|
||||
|
||||
QuickActionResultGrid.RowDefinitions.Add(new RowDefinition());
|
||||
|
||||
for (int i = 0; i < headingValues.Count; i++)
|
||||
{
|
||||
QuickActionResultGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
|
||||
|
||||
string columnKey = headingValues[i].Key;
|
||||
|
||||
if (cUtility.ShouldHideQuickActionOutput(columnKey, quickActionDefinition))
|
||||
continue;
|
||||
|
||||
string displayValue = columnKey;
|
||||
if (quickActionDefinition.ColumnOutputFormattings?.TryGetValue(columnKey, out var columnFormatting) ?? false)
|
||||
displayValue = columnFormatting.Names.GetValue();
|
||||
|
||||
TextBlock headingTextBlock = new TextBlock() { Text = displayValue };
|
||||
Border headingBorder = new Border() { Child = headingTextBlock };
|
||||
Grid.SetRow(headingBorder, 0);
|
||||
Grid.SetColumn(headingBorder, i);
|
||||
QuickActionResultGrid.Children.Add(headingBorder);
|
||||
}
|
||||
|
||||
for (int row = 0; row < listOutput.Values.Count; row++)
|
||||
{
|
||||
QuickActionResultGrid.RowDefinitions.Add(new RowDefinition());
|
||||
|
||||
for (int column = 0; column < listOutput.Values[row].Count; column++)
|
||||
{
|
||||
string columnKey = listOutput.Values[0][column].Key;
|
||||
|
||||
if (cUtility.ShouldHideQuickActionOutput(columnKey, quickActionDefinition))
|
||||
continue;
|
||||
|
||||
string displayValue = listOutput.GetDisplayValue(row, column, columnFormattings);
|
||||
|
||||
if (string.IsNullOrEmpty(displayValue))
|
||||
continue;
|
||||
|
||||
TextBlock valueTextBlock = new TextBlock { FontWeight = FontWeights.Normal, Text = displayValue };
|
||||
valueTextBlock.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
valueTextBlock.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
valueTextBlock.TouchDown += ValueTextBlock_Click;
|
||||
Border valueBorder = new Border() { Child = valueTextBlock };
|
||||
Grid.SetRow(valueBorder, row + 1);
|
||||
Grid.SetColumn(valueBorder, column);
|
||||
|
||||
bool hasSecretValue = columnFormattings?[columnKey]?.IsSecret ?? false;
|
||||
if (hasSecretValue)
|
||||
{
|
||||
string displayValueSecret = listOutput.GetDisplayValue(row, column, columnFormattings, true);
|
||||
TextBlock valueTextBlockSecret = new TextBlock { FontWeight = FontWeights.Normal, Text = displayValueSecret };
|
||||
valueTextBlockSecret.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
valueTextBlockSecret.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
valueTextBlockSecret.TouchDown += ValueTextBlock_Click;
|
||||
ReplaceClickSenderOf(valueTextBlock, valueTextBlockSecret);
|
||||
|
||||
Border valueBorderSecret = new Border() { Child = valueTextBlockSecret, Visibility = Visibility.Collapsed, Tag = secretTag };
|
||||
|
||||
valueBorder.Tag = veiledTextTag;
|
||||
|
||||
Grid.SetRow(valueBorderSecret, row + 1);
|
||||
Grid.SetColumn(valueBorderSecret, column);
|
||||
QuickActionResultGrid.Children.Add(valueBorderSecret);
|
||||
}
|
||||
|
||||
QuickActionResultGrid.Children.Add(valueBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetObjectOutput(cQuickActionOutputObject objectOutput, cFasdQuickAction quickActionDefinition)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (objectOutput.Values?.Count <= 0)
|
||||
return;
|
||||
|
||||
QuickActionResultGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
|
||||
|
||||
for (int i = 0; i < objectOutput.Values.Count; i++)
|
||||
{
|
||||
string columnKey = objectOutput.Values[i].Key;
|
||||
|
||||
// Has to be done, no matter if value should be hidden. Else the following Grid.SetRow's affect the wrong row.
|
||||
QuickActionResultGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
|
||||
|
||||
if (cUtility.ShouldHideQuickActionOutput(columnKey, quickActionDefinition))
|
||||
continue;
|
||||
|
||||
string displayValue = columnKey;
|
||||
if (quickActionDefinition.ColumnOutputFormattings?.TryGetValue(columnKey, out var columnFormatting) ?? false)
|
||||
displayValue = columnFormatting.Names.GetValue();
|
||||
|
||||
TextBlock headingTextBlock = new TextBlock() { Text = displayValue };
|
||||
|
||||
Border headingBorder = new Border() { Child = headingTextBlock };
|
||||
Grid.SetColumn(headingBorder, 0);
|
||||
Grid.SetRow(headingBorder, i);
|
||||
QuickActionResultGrid.Children.Add(headingBorder);
|
||||
}
|
||||
|
||||
QuickActionResultGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
|
||||
|
||||
for (int i = 0; i < objectOutput.Values.Count; i++)
|
||||
{
|
||||
string columnKey = objectOutput.Values[i].Key;
|
||||
if (cUtility.ShouldHideQuickActionOutput(columnKey, quickActionDefinition))
|
||||
continue;
|
||||
|
||||
string displayValue = objectOutput.GetDisplayValue(i, quickActionDefinition.ColumnOutputFormattings);
|
||||
if (string.IsNullOrWhiteSpace(displayValue))
|
||||
continue;
|
||||
|
||||
TextBlock valueTextBlock = new TextBlock() { FontWeight = FontWeights.Normal, Text = displayValue };
|
||||
valueTextBlock.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
valueTextBlock.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
valueTextBlock.TouchDown += ValueTextBlock_Click;
|
||||
|
||||
Border valueBorder = new Border() { Child = valueTextBlock };
|
||||
Grid.SetRow(valueBorder, i);
|
||||
Grid.SetColumn(valueBorder, 1);
|
||||
QuickActionResultGrid.Children.Add(valueBorder);
|
||||
|
||||
if (quickActionDefinition.ColumnOutputFormattings is null || string.IsNullOrWhiteSpace(columnKey))
|
||||
continue;
|
||||
|
||||
if (quickActionDefinition.ColumnOutputFormattings.TryGetValue(columnKey, out var formatting) && (formatting?.IsSecret ?? false))
|
||||
{
|
||||
string displayValueSecret = objectOutput.GetDisplayValue(i, quickActionDefinition.ColumnOutputFormattings, true);
|
||||
|
||||
TextBlock valueTextBlockSecret = new TextBlock() { FontWeight = FontWeights.Normal, Text = displayValueSecret };
|
||||
valueTextBlockSecret.SetResourceReference(Control.CursorProperty, "Cursor.Copy");
|
||||
valueTextBlockSecret.MouseLeftButtonUp += ValueTextBlock_Click;
|
||||
valueTextBlockSecret.TouchDown += ValueTextBlock_Click;
|
||||
ReplaceClickSenderOf(valueTextBlock, valueTextBlockSecret);
|
||||
|
||||
Border valueBorderSecret = new Border() { Child = valueTextBlockSecret, Visibility = Visibility.Collapsed, Tag = secretTag };
|
||||
Grid.SetRow(valueBorderSecret, i);
|
||||
Grid.SetColumn(valueBorderSecret, 1);
|
||||
QuickActionResultGrid.Children.Add(valueBorderSecret);
|
||||
|
||||
valueBorder.Tag = veiledTextTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void ValueTextBlock_Click(object sender, InputEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is TextBlock textBlock))
|
||||
return;
|
||||
|
||||
System.Windows.Forms.Clipboard.SetText(textBlock.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ReplaceClickSenderOf(UIElement from, UIElement to)
|
||||
{
|
||||
try
|
||||
{
|
||||
from.MouseLeftButtonUp -= ValueTextBlock_Click;
|
||||
from.TouchDown -= ValueTextBlock_Click;
|
||||
|
||||
from.MouseLeftButtonUp += (s, e) => ValueTextBlock_Click(to, e);
|
||||
from.TouchDown += (s, e) => ValueTextBlock_Click(to, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ToggleSecretVisibility(bool secretsAreShown)
|
||||
{
|
||||
try
|
||||
{
|
||||
var taggedResultElements = QuickActionResultGrid.Children.OfType<FrameworkElement>().Where(element => element.Tag != null);
|
||||
|
||||
foreach (var resultElement in taggedResultElements)
|
||||
{
|
||||
if (resultElement.Tag.Equals(secretTag))
|
||||
resultElement.Visibility = secretsAreShown ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (resultElement.Tag.Equals(veiledTextTag))
|
||||
resultElement.Visibility = secretsAreShown ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user