inital
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageDataHistoryCollection"
|
||||
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"
|
||||
xmlns:config="clr-namespace:C4IT.FASD.Base;assembly=F4SD-Cockpit-Client-Base"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Name="_thisCollection"
|
||||
Initialized="UserControl_Initialized">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<DockPanel x:Name="DataHistoryDock"
|
||||
HorizontalAlignment="Left">
|
||||
|
||||
<Grid DockPanel.Dock="Top"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0, 10, 0, 0"
|
||||
Width="{Binding ElementName=DetailsCollectionScrollViewer, Path=ActualWidth}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock x:Name="ToggleCollapseButton"
|
||||
Grid.Column="3"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ControlBar.Text}"
|
||||
Margin="0,0,16,0">
|
||||
|
||||
<Run Text="{Binding Mode=OneWay, Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.History.UnCollapseAll}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ControlBar.Action}"
|
||||
MouseUp="UnCollapseButton_MouseUp"
|
||||
TouchDown="UnCollapseButton_TouchDown" />
|
||||
|
|
||||
<Run Text="{Binding Mode=OneWay, Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.History.CollapseAll}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ControlBar.Action}"
|
||||
MouseUp="CollapseButton_MouseUp"
|
||||
TouchDown="CollapseButton_TouchDown" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer x:Name="DetailsCollectionScrollViewer"
|
||||
DockPanel.Dock="Top"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalAlignment="Left"
|
||||
Padding="0, 0, 8, 8"
|
||||
Margin="0,5,0,0"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
PreviewKeyDown="DetailsCollectionScrollViewer_PreviewKeyDown">
|
||||
|
||||
<StackPanel x:Name="DataHistoryCollectionStackPanel"
|
||||
HorizontalAlignment="Left">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Padding"
|
||||
Value="0, 2.5" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
</StackPanel>
|
||||
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,649 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
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.Threading;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageDataHistoryCollection : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public cSupportCaseDataProvider DataProvider { get; set; }
|
||||
|
||||
#region DetailsGeometry DependencyProperty
|
||||
|
||||
private static bool DidGeometryDataChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
bool didGeometryChange = false;
|
||||
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (e.NewValue != null && e.OldValue != null)
|
||||
{
|
||||
var newValue = e.NewValue as DetailsPageDataHistoryCollectionGeometryModel;
|
||||
var oldValue = e.OldValue as DetailsPageDataHistoryCollectionGeometryModel;
|
||||
|
||||
didGeometryChange = newValue.ColumnCount != oldValue.ColumnCount || didGeometryChange;
|
||||
|
||||
var oldValueSubtitleEnumerator = oldValue.SubtitleCount.GetEnumerator();
|
||||
foreach (var subtitleCount in newValue.SubtitleCount)
|
||||
{
|
||||
if (oldValueSubtitleEnumerator.MoveNext())
|
||||
{
|
||||
didGeometryChange = subtitleCount != oldValueSubtitleEnumerator.Current || didGeometryChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return didGeometryChange;
|
||||
}
|
||||
|
||||
private static void GeometryChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DidGeometryDataChanged(e) is false)
|
||||
return;
|
||||
|
||||
var _me = d as DetailsPageDataHistoryCollection;
|
||||
_me.InitializeCollectionGeometry();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DetailsGeometryProperty =
|
||||
DependencyProperty.Register("DetailsGeometry", typeof(DetailsPageDataHistoryCollectionGeometryModel), typeof(DetailsPageDataHistoryCollection), new PropertyMetadata(new DetailsPageDataHistoryCollectionGeometryModel(), new PropertyChangedCallback(GeometryChangedCallback)));
|
||||
|
||||
public DetailsPageDataHistoryCollectionGeometryModel DetailsGeometry
|
||||
{
|
||||
get { return (DetailsPageDataHistoryCollectionGeometryModel)GetValue(DetailsGeometryProperty); }
|
||||
set { SetValue(DetailsGeometryProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HistoryDataList DependencyProperty
|
||||
|
||||
static void RefreshDataCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailsPageDataHistoryCollection _me)
|
||||
{
|
||||
_me.UpdateDetailsCollection();
|
||||
_me.RefreshData();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HistoryDataListProperty =
|
||||
DependencyProperty.Register("HistoryDataList", typeof(List<cDetailsPageDataHistoryDataModel>), typeof(DetailsPageDataHistoryCollection), new PropertyMetadata(new List<cDetailsPageDataHistoryDataModel>(), new PropertyChangedCallback(RefreshDataCallback)));
|
||||
|
||||
public List<cDetailsPageDataHistoryDataModel> HistoryDataList
|
||||
{
|
||||
get { return (List<cDetailsPageDataHistoryDataModel>)GetValue(HistoryDataListProperty); }
|
||||
set { SetValue(HistoryDataListProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShownValueColumnsCount DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty ShownValueColumnsCountProperty =
|
||||
DependencyProperty.Register("ShownValueColumnsCount", typeof(int), typeof(DetailsPageDataHistoryCollection), new PropertyMetadata(5));
|
||||
|
||||
public int ShownValueColumnsCount
|
||||
{
|
||||
get { return (int)GetValue(ShownValueColumnsCountProperty); }
|
||||
set { SetValue(ShownValueColumnsCountProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageDataHistoryCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
AddCustomEventHandlers();
|
||||
}
|
||||
|
||||
private void AddCustomEventHandlers()
|
||||
{
|
||||
AddHandler(DetailsPageDataHistoryValueColumn.StatusBorderClickedEvent, new RoutedEventHandler(ChangedVerticalCollapseEvent));
|
||||
AddHandler(DetailsPageDataHistoryTitleColumn.StatusBorderClickedEvent, new RoutedEventHandler(ChangedVerticalCollapseEvent));
|
||||
}
|
||||
|
||||
#region SetUpControls
|
||||
|
||||
#region Control Lists
|
||||
|
||||
public readonly List<DetailsPageDataHistorySection> HistorySectionControls = new List<DetailsPageDataHistorySection>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetUp/Initialize Functions
|
||||
|
||||
private delegate void DelegateFunction();
|
||||
|
||||
private void InitializeCollectionGeometry()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this) || DetailsGeometry == null)
|
||||
return;
|
||||
|
||||
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new DelegateFunction(() =>
|
||||
{
|
||||
DataHistoryCollectionStackPanel.Children.Clear();
|
||||
HistorySectionControls.Clear();
|
||||
|
||||
for (int i = 0; i < DetailsGeometry.SubtitleCount.Count; i++)
|
||||
{
|
||||
DetailsPageDataHistorySection historySectionToCreate = new DetailsPageDataHistorySection() { ColumnCount = DetailsGeometry.ColumnCount, SubtitleCount = DetailsGeometry.SubtitleCount[i], Margin = new Thickness(0, 0, 0, 10) };
|
||||
historySectionToCreate.HistoryValueScrollViewer.ScrollChanged += HistoryValueScrollViewer_ScrollChanged;
|
||||
DataHistoryCollectionStackPanel.Children.Add(historySectionToCreate);
|
||||
HistorySectionControls.Add(historySectionToCreate);
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void HistoryValueScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
foreach (var historyControl in HistorySectionControls)
|
||||
{
|
||||
historyControl.HistoryValueScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleHorizontalCollapseHistory(bool isHorizontalVisible)
|
||||
{
|
||||
HistorySectionControls.ForEach(historyControl => historyControl.IsHorizontalCollapsed = !isHorizontalVisible);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Controls
|
||||
|
||||
private void UpdateDetailsCollection()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (HistoryDataList == null)
|
||||
return;
|
||||
|
||||
UpdateHistorySections();
|
||||
UpdateColumnWidths();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHistorySections()
|
||||
{
|
||||
try
|
||||
{
|
||||
int missingDataSections = HistoryDataList.Count - HistorySectionControls.Count;
|
||||
if (missingDataSections > 0)
|
||||
{
|
||||
for (int i = 0; i < missingDataSections; i++)
|
||||
{
|
||||
DetailsPageDataHistorySection historySectionToCreate = new DetailsPageDataHistorySection() { ColumnCount = DetailsGeometry.ColumnCount, SubtitleCount = int.MinValue, Margin = new Thickness(0, 0, 0, 10) };
|
||||
historySectionToCreate.HistoryValueScrollViewer.ScrollChanged += HistoryValueScrollViewer_ScrollChanged;
|
||||
DataHistoryCollectionStackPanel.Children.Add(historySectionToCreate);
|
||||
HistorySectionControls.Add(historySectionToCreate);
|
||||
}
|
||||
}
|
||||
else if (missingDataSections < 0 && HistorySectionControls.Count + missingDataSections >= 0)
|
||||
{
|
||||
var categoriesToHide = HistorySectionControls.Skip(HistorySectionControls.Count + missingDataSections);
|
||||
|
||||
foreach (var categoryToHide in categoriesToHide)
|
||||
{
|
||||
categoryToHide.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
HistorySectionControls.GetRange(0, HistoryDataList.Count).ForEach(section => section.Visibility = Visibility.Visible);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangedVerticalCollapseEvent(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(e.OriginalSource is FrameworkElement senderFrameworkElement))
|
||||
return;
|
||||
|
||||
if (!(senderFrameworkElement.Tag is DetailsPageDataHistorySection senderHistorySection))
|
||||
return;
|
||||
|
||||
if (senderHistorySection.IsVerticalExpandLocked)
|
||||
return;
|
||||
|
||||
bool tempExpandStatus = senderHistorySection.IsVerticalExpanded;
|
||||
|
||||
foreach (var historySection in HistorySectionControls)
|
||||
{
|
||||
if (!historySection.IsVerticalExpandLocked)
|
||||
historySection.IsVerticalExpanded = false;
|
||||
}
|
||||
|
||||
if (!tempExpandStatus)
|
||||
VerticalUncollapseDataHistory(senderHistorySection);
|
||||
else
|
||||
senderHistorySection.IsVerticalExpanded = !tempExpandStatus;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateColumnWidths()
|
||||
{
|
||||
try
|
||||
{
|
||||
const int maxValueColumnWidth = 140;
|
||||
double titleColumnWidth = 50;
|
||||
double valueColumnWidth = 50;
|
||||
|
||||
foreach (var historyData in HistoryDataList)
|
||||
{
|
||||
double tempTitleColumnWidth = GetTitleColumnWidth(historyData);
|
||||
double tempValueColumnWidth = GetValueColumnWidth(historyData);
|
||||
|
||||
titleColumnWidth = tempTitleColumnWidth > titleColumnWidth ? tempTitleColumnWidth : titleColumnWidth;
|
||||
valueColumnWidth = tempValueColumnWidth > valueColumnWidth ? tempValueColumnWidth : valueColumnWidth;
|
||||
}
|
||||
|
||||
valueColumnWidth = Math.Min(valueColumnWidth, maxValueColumnWidth);
|
||||
|
||||
foreach (var historyData in HistoryDataList)
|
||||
{
|
||||
historyData.TitleColumnWidth = titleColumnWidth + 15;
|
||||
historyData.ValueColumnWidth = valueColumnWidth + 10;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefreshData
|
||||
|
||||
private void RefreshData()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (HistoryDataList is null || HistoryDataList.Count == 0)
|
||||
{
|
||||
Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
Visibility = Visibility.Visible;
|
||||
|
||||
var DataEnumerator = HistoryDataList.GetEnumerator();
|
||||
foreach (var Entry in HistorySectionControls)
|
||||
{
|
||||
if (DataEnumerator.MoveNext())
|
||||
{
|
||||
var Data = DataEnumerator.Current;
|
||||
Entry.ShownValueColumnsCount = this.ShownValueColumnsCount;
|
||||
//Entry.Visibility = Visibility.Visible;
|
||||
//Entry.Visibility = Data?.TitleColumn.ColumnValues.Count <= 0 ? Visibility.Collapsed : Visibility.Visible;
|
||||
// && Data?.ValueColumns.Any(column => column.IsLoading) == false
|
||||
// && Data?.ValueColumns.Any(column => column.ColumnValues.Any(columnValue => columnValue.IsLoading)) == false ? Visibility.Collapsed : Visibility.Visible;
|
||||
Entry.HistoryData = Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Entry.Visibility = Visibility.Collapsed;
|
||||
Entry.HistoryData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateData
|
||||
|
||||
public void UpdateHistory(List<cDetailsPageDataHistoryDataModel> historyData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HistoryDataList is null || HistoryDataList.Count == 0)
|
||||
{
|
||||
Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
Visibility = Visibility.Visible;
|
||||
var historyDataEnumerator = HistoryDataList.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < historyData.Count; i++)
|
||||
{
|
||||
var historyCategory = historyData[i];
|
||||
|
||||
historyDataEnumerator.MoveNext();
|
||||
|
||||
var currentHistoryData = historyDataEnumerator.Current;
|
||||
|
||||
if (DidHistoryCategoryChange(currentHistoryData, historyCategory))
|
||||
HistorySectionControls[i]?.UpdateHistoryData(historyCategory);
|
||||
}
|
||||
|
||||
HistoryDataList = historyData;
|
||||
UpdateColumnWidths();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DidHistoryCategoryChange(cDetailsPageDataHistoryDataModel oldValue, cDetailsPageDataHistoryDataModel newValue)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (oldValue is null || newValue is null)
|
||||
return true;
|
||||
|
||||
if (oldValue.ValueColumns.Count != newValue.ValueColumns.Count)
|
||||
return true;
|
||||
|
||||
var newValueColumnEnumeator = newValue.ValueColumns.GetEnumerator();
|
||||
|
||||
foreach (var oldValueColumn in oldValue.ValueColumns)
|
||||
{
|
||||
if (!newValueColumnEnumeator.MoveNext())
|
||||
continue;
|
||||
|
||||
var currentNewValueColumn = newValueColumnEnumeator.Current;
|
||||
var newValueColumnValueEnumerator = currentNewValueColumn.ColumnValues.GetEnumerator();
|
||||
|
||||
foreach (var oldCellValue in oldValueColumn.ColumnValues)
|
||||
{
|
||||
var valueRowIndex = oldValueColumn.ColumnValues.IndexOf(oldCellValue);
|
||||
|
||||
if (!newValueColumnValueEnumerator.MoveNext())
|
||||
continue;
|
||||
|
||||
if (oldCellValue.Content.Equals(newValueColumnValueEnumerator.Current.Content) == false)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleDefinitions
|
||||
|
||||
private Style titleColumnOverViewTitleStyle;
|
||||
private Style titleColumnMainTitleStyle;
|
||||
private Style titleCoumnSubTitleStyle;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
titleColumnOverViewTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.OverviewTitle");
|
||||
titleColumnMainTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.MainTitle");
|
||||
titleCoumnSubTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.SubTitle");
|
||||
}
|
||||
|
||||
private static Size MeasureStringSize(string stringToMeasure, Control controlOfText)
|
||||
{
|
||||
var formattedText = new FormattedText(
|
||||
stringToMeasure,
|
||||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(controlOfText.FontFamily, controlOfText.FontStyle, controlOfText.FontWeight, controlOfText.FontStretch),
|
||||
controlOfText.FontSize,
|
||||
Brushes.Black,
|
||||
new NumberSubstitution(),
|
||||
1);
|
||||
|
||||
return new Size(formattedText.Width, formattedText.Height);
|
||||
}
|
||||
|
||||
private double GetTitleColumnWidth(cDetailsPageDataHistoryDataModel detailsData)
|
||||
{
|
||||
double maxTitleLength = MeasureStringSize(detailsData.TitleColumn.Content, new TextBox { Style = titleColumnOverViewTitleStyle }).Width + 90;
|
||||
|
||||
foreach (var subtitle in detailsData.TitleColumn.ColumnValues)
|
||||
{
|
||||
Style subtitleStyle;
|
||||
|
||||
switch (subtitle.PresentationStyle)
|
||||
{
|
||||
case enumHistoryTitleType.value:
|
||||
subtitleStyle = titleColumnMainTitleStyle;
|
||||
break;
|
||||
case enumHistoryTitleType.subValue:
|
||||
subtitleStyle = titleCoumnSubTitleStyle;
|
||||
break;
|
||||
default:
|
||||
subtitleStyle = titleColumnMainTitleStyle;
|
||||
break;
|
||||
};
|
||||
|
||||
double subtitleLength = MeasureStringSize(subtitle.Content, new TextBox { Style = subtitleStyle }).Width;
|
||||
maxTitleLength = maxTitleLength < subtitleLength ? subtitleLength + 70 : maxTitleLength;
|
||||
}
|
||||
|
||||
return maxTitleLength;
|
||||
}
|
||||
|
||||
private double GetValueColumnWidth(cDetailsPageDataHistoryDataModel detailsData)
|
||||
{
|
||||
double maxValueWidth = 55; //55 to set MinWidth
|
||||
|
||||
foreach (var valueColumn in detailsData.ValueColumns)
|
||||
{
|
||||
foreach (var value in valueColumn.ColumnValues)
|
||||
{
|
||||
var valueSize = MeasureStringSize(value.Content, new Control() { Style = titleColumnOverViewTitleStyle });
|
||||
|
||||
maxValueWidth = valueSize.Width > maxValueWidth ? valueSize.Width : maxValueWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return maxValueWidth + 30; //+30 to include functionmarker width
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Methods
|
||||
|
||||
#region UserControl
|
||||
|
||||
private void UserControl_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Collapse
|
||||
|
||||
#region Vertical Uncollapse Specific DataHistory
|
||||
|
||||
public void VerticalUncollapseDataHistory(DetailsPageDataHistorySection historySection)
|
||||
{
|
||||
try
|
||||
{
|
||||
var historyIndex = DataHistoryCollectionStackPanel.Children.IndexOf(historySection);
|
||||
VerticalUncollapseDataHistory(historyIndex);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void VerticalUncollapseDataHistory(int historyIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (historyIndex >= DataHistoryCollectionStackPanel.Children.Count)
|
||||
return;
|
||||
|
||||
HistorySectionControls.ForEach(historyControl =>
|
||||
{
|
||||
if (!historyControl.IsVerticalExpandLocked)
|
||||
historyControl.IsVerticalExpanded = false;
|
||||
});
|
||||
|
||||
(DataHistoryCollectionStackPanel.Children[historyIndex] as DetailsPageDataHistorySection).IsVerticalExpanded = true;
|
||||
|
||||
var _h = Dispatcher.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(1);
|
||||
var position = (DataHistoryCollectionStackPanel.Children[historyIndex] as DetailsPageDataHistorySection).TranslatePoint(new Point(0, 0), DataHistoryCollectionStackPanel);
|
||||
DetailsCollectionScrollViewer.ScrollToVerticalOffset(position.Y);
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Vertical Collapse Details
|
||||
|
||||
public void ToggleVerticalCollapseDetails(bool collapse)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var detail in HistorySectionControls)
|
||||
{
|
||||
if (detail.IsVerticalExpandLocked)
|
||||
continue;
|
||||
|
||||
detail.IsVerticalExpanded = !collapse;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CollapseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ToggleVerticalCollapseDetails(true);
|
||||
}
|
||||
|
||||
private void CollapseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ToggleVerticalCollapseDetails(true);
|
||||
}
|
||||
|
||||
private void UnCollapseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ToggleVerticalCollapseDetails(false);
|
||||
}
|
||||
private void UnCollapseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ToggleVerticalCollapseDetails(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private void DetailsCollectionScrollViewer_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageDataHistorySection"
|
||||
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:basic="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:local="clr-namespace:FasdDesktopUi.Pages.DetailsPage.UserControls"
|
||||
mc:Ignorable="d"
|
||||
x:Name="DataHistory"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="boolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MinWidth="{Binding ElementName=DataHistory, Path=HistoryData.TitleColumnWidth}"
|
||||
SharedSizeGroup="TitleColumn" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<local:DetailsPageDataHistoryTitleColumn x:Name="TitleColumnUc"
|
||||
MouseEnterTitleRowEventHandler="MouseEnterTitleRow"
|
||||
MouseLeaveTitleRowEventHandler="MouseLeaveTitleRow" />
|
||||
|
||||
<ScrollViewer x:Name="HistoryValueScrollViewer"
|
||||
Height="{Binding ElementName=TitleColumnUc, Path=ActualHeight}"
|
||||
Grid.Column="1"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Disabled"
|
||||
PreviewMouseWheel="HistoryValueScrollViewer_PreviewMouseWheel">
|
||||
<Grid x:Name="MainGrid" />
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="TitleRowEndBorder"
|
||||
Grid.Row="0"
|
||||
Style="{DynamicResource HighlightRowBorder}"
|
||||
CornerRadius="0 7.5 7.5 0"
|
||||
MouseEnter="TitleRowEndBorder_MouseEnter"
|
||||
MouseLeave="TitleRowEndBorder_MouseLeave">
|
||||
<Border.Resources>
|
||||
<Style x:Key="HighlightRowBorder"
|
||||
TargetType="Border">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=DataHistory, Path=TitleRowIsHighlighted}" Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.ValueColumn}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
|
||||
<ico:AdaptableIcon Style="{DynamicResource DetailsPage.DataHistory.Icon.Lock}"
|
||||
Visibility="{Binding ElementName=DataHistory, Path=IsVerticalExpanded, Converter={StaticResource boolToVisibility}}"
|
||||
MouseLeftButtonUp="LockIcon_MouseLeftButtonUp"
|
||||
TouchDown="LockIcon_TouchDown"
|
||||
MouseLeave="LockIcon_MouseLeave" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
CornerRadius="0 0 7.5 0"
|
||||
Visibility="{Binding ElementName=DataHistory, Path=IsVerticalExpanded, Converter={StaticResource boolToVisibility}}">
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.Icon.Chevron}"
|
||||
MouseLeftButtonUp="HorizontalCollapse_MouseLeftButtonUp"
|
||||
TouchDown="HorizontalCollapse_TouchDown"
|
||||
MouseEnter="TitleRowEndBorder_MouseEnter"
|
||||
MouseLeave="TitleRowEndBorder_MouseLeave"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,519 @@
|
||||
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 C4IT.Logging;
|
||||
using C4IT.FASD.Base;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
|
||||
public partial class DetailsPageDataHistorySection : UserControl
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
#region Geometry
|
||||
|
||||
private static bool DidGeometryDataChange(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
bool didGeometryChange = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (e.NewValue != null && e.OldValue != null)
|
||||
{
|
||||
var newValue = (int)e.NewValue;
|
||||
var oldValue = (int)e.OldValue;
|
||||
|
||||
didGeometryChange = newValue != oldValue || didGeometryChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return didGeometryChange;
|
||||
}
|
||||
|
||||
private static void GeometryChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DidGeometryDataChange(e) is false)
|
||||
return;
|
||||
|
||||
if (!(d is DetailsPageDataHistorySection _me))
|
||||
return;
|
||||
|
||||
_me.ClearControls();
|
||||
_me.TitleColumnUc.Tag = _me;
|
||||
_me.TitleColumnUc.SubtitleCount = _me.SubtitleCount;
|
||||
_me.InitializeValueColumns();
|
||||
}
|
||||
|
||||
#region SubtitleCount DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty SubtitleCountProperty =
|
||||
DependencyProperty.Register("SubtitleCount", typeof(int), typeof(DetailsPageDataHistorySection), new PropertyMetadata(-1, new PropertyChangedCallback(GeometryChangedCallback)));
|
||||
|
||||
public int SubtitleCount
|
||||
{
|
||||
get { return (int)GetValue(SubtitleCountProperty); }
|
||||
set { SetValue(SubtitleCountProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColoumnCount DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty ColumnCountProperty =
|
||||
DependencyProperty.Register("ColumnCount", typeof(int), typeof(DetailsPageDataHistorySection), new PropertyMetadata(1));
|
||||
|
||||
public int ColumnCount
|
||||
{
|
||||
get { return (int)GetValue(ColumnCountProperty); }
|
||||
set { SetValue(ColumnCountProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region HistoryData DependencyProperty
|
||||
|
||||
private static void RefreshDataCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistorySection _me))
|
||||
return;
|
||||
|
||||
if (_me.HistoryData == null)
|
||||
{
|
||||
foreach (DetailsPageDataHistoryValueColumn valueColumn in _me.MainGrid.Children)
|
||||
{
|
||||
valueColumn.ColumnValues = new DetailsPageDataHistoryColumnModel() { HighlightColor = Basics.Enums.enumHighlightColor.none, IsLoading = true, ColumnValues = new List<DetailsPageDataHistoryValueModel>() { new DetailsPageDataHistoryValueModel() { Content = "-", IsLoading = true } } };
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_me.TitleColumnUc.ColumnValues = _me.HistoryData.TitleColumn;
|
||||
_me.RefreshValueColumnValues();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HistoryDataProperty =
|
||||
DependencyProperty.Register("HistoryData", typeof(cDetailsPageDataHistoryDataModel), typeof(DetailsPageDataHistorySection), new PropertyMetadata(new cDetailsPageDataHistoryDataModel(), new PropertyChangedCallback(RefreshDataCallback)));
|
||||
|
||||
public cDetailsPageDataHistoryDataModel HistoryData
|
||||
{
|
||||
get { return (cDetailsPageDataHistoryDataModel)GetValue(HistoryDataProperty); }
|
||||
set { SetValue(HistoryDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TitleRowIsHighlighted DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty TitleRowIsHighlightedProperty =
|
||||
DependencyProperty.Register("TitleRowIsHighlighted", typeof(bool), typeof(DetailsPageDataHistorySection), new PropertyMetadata(false));
|
||||
|
||||
public bool TitleRowIsHighlighted
|
||||
{
|
||||
get { return (bool)GetValue(TitleRowIsHighlightedProperty); }
|
||||
set { SetValue(TitleRowIsHighlightedProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsVerticalExpanded
|
||||
|
||||
private static void IsVerticalExpandedChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistorySection _me))
|
||||
return;
|
||||
|
||||
if (!(e.NewValue is bool isVisible))
|
||||
return;
|
||||
|
||||
_me.TitleColumnUc.ToggleVerticalCollapse(isVisible);
|
||||
|
||||
if (isVisible)
|
||||
_me.TitleColumnUc.ClearValue(HeightProperty);
|
||||
else
|
||||
_me.TitleColumnUc.Height = 60;
|
||||
|
||||
_me.TitleRowEndBorder.CornerRadius = isVisible ? new CornerRadius(0, 7.5, 0, 0) : new CornerRadius(0, 7.5, 7.5, 0);
|
||||
_me.TitleColumnUc.TitleRowBorder.CornerRadius = isVisible ? new CornerRadius(7.5, 0, 0, 0) : new CornerRadius(7.5, 0, 0, 7.5);
|
||||
_me.TitleRowIsHighlighted = isVisible;
|
||||
|
||||
for (int i = 0; i < _me.MainGrid.Children.Count; i++)
|
||||
{
|
||||
if (_me.MainGrid.Children[i] is DetailsPageDataHistoryValueColumn valueColumn)
|
||||
valueColumn.ToggleVerticalCollapse(isVisible);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsVerticalExpandedProperty =
|
||||
DependencyProperty.Register("IsVerticalExpanded", typeof(bool), typeof(DetailsPageDataHistorySection), new PropertyMetadata(false, new PropertyChangedCallback(IsVerticalExpandedChangedCallback)));
|
||||
|
||||
public bool IsVerticalExpanded
|
||||
{
|
||||
get { return (bool)GetValue(IsVerticalExpandedProperty); }
|
||||
set { SetValue(IsVerticalExpandedProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsVerticalExpandLocked
|
||||
|
||||
public static readonly DependencyProperty IsVerticalExpandLockedProperty =
|
||||
DependencyProperty.Register("IsVerticalExpandLocked", typeof(bool), typeof(DetailsPageDataHistorySection), new PropertyMetadata(false));
|
||||
|
||||
public bool IsVerticalExpandLocked
|
||||
{
|
||||
get { return (bool)GetValue(IsVerticalExpandLockedProperty); }
|
||||
set { SetValue(IsVerticalExpandLockedProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsHorizontalCollapsed
|
||||
|
||||
public static readonly DependencyProperty IsHorizontalCollapsedProperty =
|
||||
DependencyProperty.Register("IsHorizontalCollapsed", typeof(bool), typeof(DetailsPageDataHistorySection), new PropertyMetadata(true));
|
||||
|
||||
public bool IsHorizontalCollapsed
|
||||
{
|
||||
get { return (bool)GetValue(IsHorizontalCollapsedProperty); }
|
||||
set { SetValue(IsHorizontalCollapsedProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public int ShownValueColumnsCount { get; set; } = 7;
|
||||
|
||||
private List<int> aggregateRowIndexes = new List<int>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Controls
|
||||
|
||||
private readonly List<DetailsPageDataHistoryValueColumn> ValueColumns = new List<DetailsPageDataHistoryValueColumn>();
|
||||
|
||||
#endregion
|
||||
|
||||
private void ClearControls()
|
||||
{
|
||||
if (MainGrid.ColumnDefinitions.Count <= 1)
|
||||
return;
|
||||
|
||||
ValueColumns.ForEach(valueColumn => MainGrid.Children.Remove(valueColumn));
|
||||
MainGrid.ColumnDefinitions.RemoveRange(1, MainGrid.RowDefinitions.Count - 1);
|
||||
ValueColumns.Clear();
|
||||
}
|
||||
|
||||
#region InitalizeControls
|
||||
|
||||
private void InitializeSingleValueColumn(int columnIndex)
|
||||
{
|
||||
MainGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
|
||||
var valueColumn = new DetailsPageDataHistoryValueColumn() { SubtitleCount = this.SubtitleCount, MinWidth = HistoryData.ValueColumnWidth, ColumnWidth = HistoryData.ValueColumnWidth, Margin = new Thickness(-0.25, 0, -0.25, 0), Tag = this };
|
||||
valueColumn.MouseEnterTitleRowEventHandler += MouseEnterTitleRow;
|
||||
valueColumn.MouseLeaveTitleRowEventHandler += MouseLeaveTitleRow;
|
||||
Grid.SetColumn(valueColumn, columnIndex);
|
||||
|
||||
MainGrid.Children.Add(valueColumn);
|
||||
ValueColumns.Add(valueColumn);
|
||||
}
|
||||
|
||||
private void InitializeValueColumns()
|
||||
{
|
||||
for (int i = 0; i <= ColumnCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeSingleValueColumn(i);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RefreshValueColumnValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
var valueColumnEnumerator = HistoryData.ValueColumns.GetEnumerator();
|
||||
|
||||
//MainGrid.ColumnDefinitions[0].Width = new GridLength(HistoryData.ValueColumnWidth);
|
||||
|
||||
foreach (var valueColumnControl in ValueColumns)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!valueColumnEnumerator.MoveNext())
|
||||
{
|
||||
valueColumnControl.Visibility = Visibility.Collapsed;
|
||||
continue;
|
||||
}
|
||||
|
||||
valueColumnControl.Width = HistoryData.ValueColumnWidth;
|
||||
valueColumnControl.Visibility = Visibility.Visible;
|
||||
var titleColumnEnumerator = HistoryData.TitleColumn.ColumnValues.GetEnumerator();
|
||||
|
||||
aggregateRowIndexes = Enumerable.Range(0, HistoryData.TitleColumn.ColumnValues.Count)
|
||||
.Where(subtitleIndex => HistoryData.TitleColumn.ColumnValues[subtitleIndex].PresentationStyle == Basics.Enums.enumHistoryTitleType.aggregate)
|
||||
.ToList();
|
||||
valueColumnControl.AggregateRowIndexes = aggregateRowIndexes;
|
||||
|
||||
valueColumnControl.ColumnValues = valueColumnEnumerator.Current;
|
||||
|
||||
foreach (var rowValue in valueColumnControl.ColumnValues.ColumnValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (titleColumnEnumerator.MoveNext())
|
||||
rowValue.DetailedData = titleColumnEnumerator.Current.DetailedData;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DidColumnDataChange(DetailsPageDataHistoryColumnModel oldData, DetailsPageDataHistoryColumnModel newData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (oldData?.ColumnValues?.Count != newData?.ColumnValues?.Count)
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < newData.ColumnValues.Count; i++)
|
||||
{
|
||||
var oldCellValue = oldData.ColumnValues[i];
|
||||
var newCellValue = newData.ColumnValues[i];
|
||||
|
||||
if (oldCellValue.Content.Equals(newCellValue.Content) == false || oldCellValue.IsLoading != newCellValue.IsLoading)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateHistoryData(cDetailsPageDataHistoryDataModel historyData)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (historyData is null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < historyData.ValueColumns.Count; i++)
|
||||
{
|
||||
var oldColumnValues = HistoryData?.ValueColumns.Count > i ? HistoryData?.ValueColumns[i] : null;
|
||||
var newColumnValues = historyData.ValueColumns[i];
|
||||
|
||||
if (DidColumnDataChange(oldColumnValues, newColumnValues))
|
||||
ValueColumns[i]?.UpdateHistoryValues(newColumnValues);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
public DetailsPageDataHistorySection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region Horizontal Collapse
|
||||
|
||||
public static readonly RoutedEvent HorizontalCollapseClickedEvent = EventManager.RegisterRoutedEvent("HorizontalCollapseClickedEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistorySection));
|
||||
|
||||
public event RoutedEventHandler HorizontalCollapseClickedEventHandler
|
||||
{
|
||||
add { AddHandler(HorizontalCollapseClickedEvent, value); }
|
||||
remove { RemoveHandler(HorizontalCollapseClickedEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseHorizontalCollapseClickedEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(HorizontalCollapseClickedEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void HorizontalCollapse_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
RaiseHorizontalCollapseClickedEvent();
|
||||
}
|
||||
|
||||
private void HorizontalCollapse_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
RaiseHorizontalCollapseClickedEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private void HistoryValueScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (sender is ScrollViewer && !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 LockIcon Events
|
||||
|
||||
private void LockIcon_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is AdaptableIcon senderIcon)
|
||||
{
|
||||
if (IsVerticalExpandLocked)
|
||||
{
|
||||
senderIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.SoftContrast");
|
||||
senderIcon.SelectedInternIcon = enumInternIcons.lock_open;
|
||||
}
|
||||
else
|
||||
{
|
||||
senderIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
senderIcon.SelectedInternIcon = enumInternIcons.lock_closed;
|
||||
}
|
||||
|
||||
senderIcon.BorderPadding = new Thickness(5.5);
|
||||
}
|
||||
|
||||
IsVerticalExpandLocked = !IsVerticalExpandLocked;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void LockIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
LockIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void LockIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
LockIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void LockIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as AdaptableIcon).ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
(sender as AdaptableIcon).ClearValue(AdaptableIcon.SelectedInternIconProperty);
|
||||
(sender as AdaptableIcon).ClearValue(AdaptableIcon.BorderPaddingProperty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HighlightBorder Events
|
||||
|
||||
private void SetTitleRowIsHighlighted(bool isHighlighted)
|
||||
{
|
||||
if (isHighlighted)
|
||||
{
|
||||
TitleRowIsHighlighted = isHighlighted;
|
||||
TitleColumnUc.TitleOverviewControl.SetResourceReference(ForegroundProperty, "Color.FunctionMarker");
|
||||
}
|
||||
else
|
||||
{
|
||||
TitleColumnUc.TitleOverviewControl.ClearValue(ForegroundProperty);
|
||||
if (!IsVerticalExpanded)
|
||||
{
|
||||
TitleRowIsHighlighted = isHighlighted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MouseEnterTitleRow(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetTitleRowIsHighlighted(true);
|
||||
}
|
||||
|
||||
private void MouseLeaveTitleRow(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetTitleRowIsHighlighted(false);
|
||||
}
|
||||
|
||||
private void TitleRowEndBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
SetTitleRowIsHighlighted(true);
|
||||
}
|
||||
|
||||
private void TitleRowEndBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
SetTitleRowIsHighlighted(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageDataHistoryTitleColumn"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Initialized="UserControl_Initialized">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="TitleRowBorder"
|
||||
Padding="10"
|
||||
Cursor="Hand"
|
||||
CornerRadius="7.5 0 0 7.5"
|
||||
Style="{DynamicResource HighlightRowBorder}"
|
||||
MouseEnter="TitleRowBorder_MouseEnter"
|
||||
MouseLeave="TitleRowBorder_MouseLeave"
|
||||
MouseLeftButtonUp="TitleRowBorder_MouseLeftButtonUp"
|
||||
TouchDown="TitleRowBorder_TouchDown">
|
||||
<Border.Resources>
|
||||
<Style x:Key="HighlightRowBorder"
|
||||
TargetType="Border">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:DetailsPageDataHistorySection}, Path=TitleRowIsHighlighted}"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Padding="10"
|
||||
CornerRadius="0 0 0 7.5"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
|
||||
Visibility="Collapsed">
|
||||
<Grid x:Name="MainGrid" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,469 @@
|
||||
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;
|
||||
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using C4IT.FASD.Base;
|
||||
using System.Reflection;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageDataHistoryTitleColumn : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region SubtitleCount DependencyProperty
|
||||
|
||||
private static void SubtitleCountChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistoryTitleColumn _me))
|
||||
return;
|
||||
|
||||
_me.ClearControls();
|
||||
_me.InitializeOverviewTitle();
|
||||
_me.InitializeSubtitleControls((int)e.NewValue);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SubtitleCountProperty =
|
||||
DependencyProperty.Register("SubtitleCount", typeof(int), typeof(DetailsPageDataHistoryTitleColumn), new PropertyMetadata(-1, new PropertyChangedCallback(SubtitleCountChangedCallback)));
|
||||
|
||||
public int SubtitleCount
|
||||
{
|
||||
get { return (int)GetValue(SubtitleCountProperty); }
|
||||
set { SetValue(SubtitleCountProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnValues DependencyProperty
|
||||
|
||||
private static void ColumnValuesChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistoryTitleColumn _me))
|
||||
return;
|
||||
|
||||
var updatedColumnValues = (DetailsPageDataHistoryColumnModel)e.NewValue;
|
||||
_me.UpdateColumnSize(updatedColumnValues.ColumnValues.Count - _me.MainGrid.RowDefinitions.Count);
|
||||
_me.RefreshOverviewTitle(updatedColumnValues);
|
||||
_me.RefreshSubtitleSection(updatedColumnValues);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ColumnValuesProperty =
|
||||
DependencyProperty.Register("ColumnValues", typeof(DetailsPageDataHistoryColumnModel), typeof(DetailsPageDataHistoryTitleColumn), new PropertyMetadata(new DetailsPageDataHistoryColumnModel(), new PropertyChangedCallback(ColumnValuesChangedCallback)));
|
||||
|
||||
public DetailsPageDataHistoryColumnModel ColumnValues
|
||||
{
|
||||
get { return (DetailsPageDataHistoryColumnModel)GetValue(ColumnValuesProperty); }
|
||||
set { SetValue(ColumnValuesProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Controls
|
||||
|
||||
public TextBlock TitleOverviewControl;
|
||||
private FunctionMarker TitleOverviewFunctionMarker;
|
||||
private readonly List<FrameworkElement> SubtitleValueControls = new List<FrameworkElement>();
|
||||
private readonly List<FunctionMarker> SubtitleFunctionMarkers = new List<FunctionMarker>();
|
||||
|
||||
private void ClearControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var functionMarker in SubtitleFunctionMarkers)
|
||||
{
|
||||
if (functionMarker.Parent is FrameworkElement functionMarkerParent)
|
||||
MainGrid.Children.Remove(functionMarkerParent);
|
||||
}
|
||||
|
||||
SubtitleValueControls.Clear();
|
||||
SubtitleFunctionMarkers.Clear();
|
||||
|
||||
if (MainGrid.RowDefinitions.Count > 0)
|
||||
MainGrid.RowDefinitions.Clear();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Initialize Controls
|
||||
|
||||
private void InitializeOverviewTitle()
|
||||
{
|
||||
if (TitleOverviewControl != null)
|
||||
return;
|
||||
|
||||
DockPanel titleDockPanel = new DockPanel();
|
||||
|
||||
TextBlock titleTextBlock = new TextBlock() { Style = titleColumnOverViewTitleStyle };
|
||||
|
||||
TitleOverviewControl = titleTextBlock;
|
||||
TitleOverviewFunctionMarker = FunctionMarker.SetUpFunctionMarker(titleDockPanel, new FunctionMarker.FunctionMarkerClick(FunctionMarker_Click), selectedMarker: enumInternIcons.misc_functionBolt, isTitleFunctionMarker: true);
|
||||
TitleOverviewFunctionMarker.Cursor = Cursors.Hand;
|
||||
DockPanel.SetDock(TitleOverviewFunctionMarker, Dock.Left);
|
||||
|
||||
titleDockPanel.Children.Add(titleTextBlock);
|
||||
|
||||
TitleRowBorder.Child = titleDockPanel;
|
||||
}
|
||||
|
||||
private void InitializeSubtitleRow(int rowIndex)
|
||||
{
|
||||
MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(35) });
|
||||
|
||||
StackPanel subTitleStackPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
|
||||
TextBlock subTitleTextBlock = new TextBlock() { Style = titleColumnMainTitleStyle };
|
||||
SubtitleValueControls.Add(subTitleTextBlock);
|
||||
|
||||
SubtitleFunctionMarkers.Add(FunctionMarker.SetUpFunctionMarker(subTitleStackPanel, new FunctionMarker.FunctionMarkerClick(FunctionMarker_Click), selectedMarker: enumInternIcons.misc_functionBolt));
|
||||
subTitleStackPanel.Children.Add(subTitleTextBlock);
|
||||
|
||||
Grid.SetRow(subTitleStackPanel, rowIndex);
|
||||
MainGrid.Children.Add(subTitleStackPanel);
|
||||
}
|
||||
|
||||
private void InitializeSubtitleControls(int subtitleCount)
|
||||
{
|
||||
for (int i = 0; i < subtitleCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeSubtitleRow(i);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FunctionMarker_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
if (!(FE.Tag is DetailsPageDataHistoryValueModel HistorySubtitleValue))
|
||||
return;
|
||||
|
||||
if (HistorySubtitleValue.UiAction == null)
|
||||
return;
|
||||
cUiActionBase.RaiseEvent(HistorySubtitleValue.UiAction, this, this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void UpdateColumnSize(int rowsToAdd)
|
||||
{
|
||||
if (rowsToAdd > 0)
|
||||
{
|
||||
int rowIndex = MainGrid.RowDefinitions.Count;
|
||||
|
||||
for (int i = rowIndex; i < rowsToAdd + rowIndex; i++)
|
||||
{
|
||||
InitializeSubtitleRow(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainGrid.RowDefinitions.ToList().ForEach(rowDefinitions => rowDefinitions.Height = new GridLength(35));
|
||||
|
||||
var reversedRowList = MainGrid.RowDefinitions.Reverse().ToList();
|
||||
for (int i = 0; i < Math.Abs(rowsToAdd); i++)
|
||||
{
|
||||
reversedRowList[i].Height = new GridLength(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Refresh Values
|
||||
|
||||
private void RefreshOverviewTitle(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TitleOverviewControl is null)
|
||||
{
|
||||
LogEntry("The title overview control wasn't instantiated.", LogLevels.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
//OverviewTitle Control
|
||||
TitleOverviewControl.Text = columnData.Content;
|
||||
TitleOverviewControl.ToolTip = columnData.ContentDescription;
|
||||
TitleRowBorder.ToolTip = columnData.ContentDescription;
|
||||
|
||||
//Functionmarker
|
||||
if (columnData.UiAction != null)
|
||||
{
|
||||
TitleOverviewFunctionMarker.Visibility = Visibility.Visible;
|
||||
TitleOverviewFunctionMarker.Tag = columnData;
|
||||
|
||||
var tempToolTip = columnData.UiAction.Name;
|
||||
if (!string.IsNullOrEmpty(columnData.UiAction.Description))
|
||||
tempToolTip += ": \n" + columnData.UiAction.Description;
|
||||
|
||||
TitleOverviewFunctionMarker.ToolTip = tempToolTip;
|
||||
}
|
||||
else
|
||||
{
|
||||
TitleOverviewFunctionMarker.Visibility = Visibility.Hidden;
|
||||
TitleOverviewFunctionMarker.ClearValue(TagProperty);
|
||||
TitleOverviewFunctionMarker.ClearValue(ToolTipProperty);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshSubtitleValues(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
var dataEnumerator = columnData.ColumnValues.GetEnumerator();
|
||||
|
||||
foreach (var subtitleControl in SubtitleValueControls)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!dataEnumerator.MoveNext())
|
||||
return;
|
||||
|
||||
if (!(subtitleControl is TextBlock subtitleTextBlock))
|
||||
return;
|
||||
|
||||
bool hasRecommendation = dataEnumerator.Current.ContentDescription != null && dataEnumerator.Current.Content != dataEnumerator.Current.ContentDescription;
|
||||
|
||||
subtitleTextBlock.Text = dataEnumerator.Current.Content;
|
||||
|
||||
subtitleTextBlock.Cursor = hasRecommendation ? Cursors.Hand : null;
|
||||
if (!hasRecommendation)
|
||||
subtitleTextBlock.SetResourceReference(ForegroundProperty, dataEnumerator.Current.PresentationStyle == enumHistoryTitleType.subValue ? "FontColor.DetailsPage.DataHistory.TitleColumn.SubTitle" : "FontColor.DetailsPage.DataHistory.TitleColumn.MainTitle");
|
||||
|
||||
subtitleTextBlock.Style = dataEnumerator.Current.PresentationStyle == enumHistoryTitleType.subValue ? titleColumnSubTitleStyle : titleColumnMainTitleStyle;
|
||||
subtitleTextBlock.FontWeight = dataEnumerator.Current.PresentationStyle == enumHistoryTitleType.aggregate ? FontWeights.Bold : FontWeights.Normal;
|
||||
subtitleTextBlock.Visibility = Visibility.Visible;
|
||||
|
||||
subtitleTextBlock.Tag = dataEnumerator.Current;
|
||||
subtitleTextBlock.MouseLeftButtonUp += TitleMouseLeftButtonUpEvent;
|
||||
subtitleTextBlock.TouchDown += TitleTouchedEvent;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Title Click Event
|
||||
|
||||
private void Title_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
if (!(FE.Tag is DetailsPageDataHistoryValueModel HistorySubtitleValue))
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(HistorySubtitleValue.ContentDescription) || HistorySubtitleValue.ContentDescription == HistorySubtitleValue.Content)
|
||||
return;
|
||||
|
||||
cUiActionBase uiAction = new cShowRecommendationAction(HistorySubtitleValue.Content, HistorySubtitleValue.ContentDescription);
|
||||
cUiActionBase.RaiseEvent(uiAction, this, this);
|
||||
}
|
||||
|
||||
private void TitleMouseLeftButtonUpEvent(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Title_Click(sender);
|
||||
}
|
||||
private void TitleTouchedEvent(object sender, TouchEventArgs e)
|
||||
{
|
||||
Title_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RefreshSubtitleFunctionmarker(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
var dataEnumerator = columnData.ColumnValues.GetEnumerator();
|
||||
|
||||
foreach (var functionMarker in SubtitleFunctionMarkers)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!dataEnumerator.MoveNext())
|
||||
return;
|
||||
|
||||
if (dataEnumerator.Current.UiAction != null && dataEnumerator.Current.UiAction.DisplayType == enumActionDisplayType.enabled && !(dataEnumerator.Current.UiAction is cShowDetailedDataAction))
|
||||
{
|
||||
functionMarker.Visibility = Visibility.Visible;
|
||||
functionMarker.Tag = dataEnumerator.Current;
|
||||
|
||||
var tempToolTip = dataEnumerator.Current.UiAction.Name;
|
||||
if (!string.IsNullOrEmpty(dataEnumerator.Current.UiAction.Description))
|
||||
tempToolTip += ": \n" + dataEnumerator.Current.UiAction.Description;
|
||||
|
||||
functionMarker.ToolTip = tempToolTip;
|
||||
}
|
||||
else
|
||||
{
|
||||
functionMarker.Visibility = Visibility.Collapsed;
|
||||
functionMarker.ClearValue(TagProperty);
|
||||
functionMarker.ClearValue(ToolTipProperty);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshSubtitleSection(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
RefreshSubtitleValues(columnData);
|
||||
RefreshSubtitleFunctionmarker(columnData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageDataHistoryTitleColumn()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
private void UserControl_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
#region Vertical Collapse
|
||||
|
||||
public void ToggleVerticalCollapse(bool isVisible)
|
||||
{
|
||||
(MainGrid.Parent as FrameworkElement).Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent StatusBorderClickedEvent = EventManager.RegisterRoutedEvent("StatusBorderClickedEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryTitleColumn));
|
||||
|
||||
public event RoutedEventHandler StatusBorderClickedEventHandler
|
||||
{
|
||||
add { AddHandler(StatusBorderClickedEvent, value); }
|
||||
remove { RemoveHandler(StatusBorderClickedEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseStatusBorderClickedEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(StatusBorderClickedEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!(e.Source is FunctionMarker))
|
||||
RaiseStatusBorderClickedEvent();
|
||||
}
|
||||
|
||||
private void TitleRowBorder_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
if (!(e.Source is FunctionMarker))
|
||||
RaiseStatusBorderClickedEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MouseOverChangedEvent
|
||||
|
||||
#region Enter
|
||||
|
||||
public static readonly RoutedEvent MouseEnterTitleRowEvent = EventManager.RegisterRoutedEvent("MouseEnterTitleRowEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryTitleColumn));
|
||||
|
||||
public event RoutedEventHandler MouseEnterTitleRowEventHandler
|
||||
{
|
||||
add { AddHandler(MouseEnterTitleRowEvent, value); }
|
||||
remove { RemoveHandler(MouseEnterTitleRowEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseMouseEnterTitleRowEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(MouseEnterTitleRowEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
RaiseMouseEnterTitleRowEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Leave
|
||||
|
||||
public static readonly RoutedEvent MouseLeaveTitleRowEvent = EventManager.RegisterRoutedEvent("MouseLeaveTitleRowEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryTitleColumn));
|
||||
|
||||
public event RoutedEventHandler MouseLeaveTitleRowEventHandler
|
||||
{
|
||||
add { AddHandler(MouseLeaveTitleRowEvent, value); }
|
||||
remove { RemoveHandler(MouseLeaveTitleRowEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseMouseLeaveTitleRowEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(MouseLeaveTitleRowEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RaiseMouseLeaveTitleRowEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style Definitions
|
||||
|
||||
private Style titleColumnOverViewTitleStyle;
|
||||
private Style titleColumnMainTitleStyle;
|
||||
private Style titleColumnSubTitleStyle;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
titleColumnOverViewTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.OverviewTitle");
|
||||
titleColumnMainTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.MainTitle");
|
||||
titleColumnSubTitleStyle = (Style)FindResource("DetailsPage.DataHistory.TitleColumn.SubTitle");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageDataHistoryValueColumn"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Initialized="UserControl_Initialized">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="TitleRowBorder"
|
||||
Grid.Row="0"
|
||||
Padding="10"
|
||||
Style="{DynamicResource HighlightRowBorder}"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonUp="TitleRowBorder_MouseLeftButtonUp"
|
||||
TouchDown="TitleRowBorder_TouchDown"
|
||||
MouseEnter="TitleRowBorder_MouseEnter"
|
||||
MouseLeave="TitleRowBorder_MouseLeave">
|
||||
<Border.Resources>
|
||||
<Style x:Key="HighlightRowBorder"
|
||||
TargetType="Border">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:DetailsPageDataHistorySection}, Path=TitleRowIsHighlighted}"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.ValueColumn}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="ColumnHeaderTextBlock"
|
||||
Grid.Row="0"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ColumnHeader}"
|
||||
Margin="5 0 0 0" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="ColumnStatusIcon"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Bottom"
|
||||
IconHeight="25"
|
||||
IconWidth="25"
|
||||
BorderPadding="0"
|
||||
IsHitTestVisible="False"
|
||||
Margin="5 0 0 0" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Padding="10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Visibility="Collapsed">
|
||||
<Grid x:Name="MainGrid" x:FieldModifier="private" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,696 @@
|
||||
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;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.FASD.Base;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using C4IT.Logging;
|
||||
using static C4IT.FASD.Base.cHealthCardTranslator;
|
||||
using FasdDesktopUi.Basics;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageDataHistoryValueColumn : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public List<int> AggregateRowIndexes { get; set; }
|
||||
public double ColumnWidth { get; set; } = 50;
|
||||
|
||||
#region SubtitleCount DependencyProperty
|
||||
|
||||
private static void SubtitleCountChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistoryValueColumn _me))
|
||||
return;
|
||||
|
||||
_me.ClearControls();
|
||||
_me.InitializeValueControls((int)e.NewValue);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty SubtitleCountProperty =
|
||||
DependencyProperty.Register("SubtitleCount", typeof(int), typeof(DetailsPageDataHistoryValueColumn), new PropertyMetadata(1, new PropertyChangedCallback(SubtitleCountChangedCallback)));
|
||||
|
||||
public int SubtitleCount
|
||||
{
|
||||
get { return (int)GetValue(SubtitleCountProperty); }
|
||||
set { SetValue(SubtitleCountProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnValues DependencyProperty
|
||||
|
||||
private static void ColumnValuesChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageDataHistoryValueColumn _me))
|
||||
return;
|
||||
|
||||
var updatedColumnValues = (DetailsPageDataHistoryColumnModel)e.NewValue;
|
||||
|
||||
_me.UpdateColumnSize(updatedColumnValues.ColumnValues.Count - _me.MainGrid.RowDefinitions.Count);
|
||||
_me.RefreshColumnHeader(updatedColumnValues.Content);
|
||||
_me.RefreshColumnStatusIcon(updatedColumnValues.HighlightColor);
|
||||
_me.RefreshValueSection(updatedColumnValues);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ColumnValuesProperty =
|
||||
DependencyProperty.Register("ColumnValues", typeof(DetailsPageDataHistoryColumnModel), typeof(DetailsPageDataHistoryValueColumn), new PropertyMetadata(new DetailsPageDataHistoryColumnModel(), new PropertyChangedCallback(ColumnValuesChangedCallback)));
|
||||
|
||||
public DetailsPageDataHistoryColumnModel ColumnValues
|
||||
{
|
||||
get { return (DetailsPageDataHistoryColumnModel)GetValue(ColumnValuesProperty); }
|
||||
set { SetValue(ColumnValuesProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValueRecommendations DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty ValueRecommendationsProperty =
|
||||
DependencyProperty.Register("ValueRecommendations", typeof(List<cRecommendationDataModel>), typeof(DetailsPageDataHistoryValueColumn), new PropertyMetadata(new List<cRecommendationDataModel>()));
|
||||
|
||||
public List<cRecommendationDataModel> ValueRecommendations
|
||||
{
|
||||
get { return (List<cRecommendationDataModel>)GetValue(ValueRecommendationsProperty); }
|
||||
set { SetValue(ValueRecommendationsProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Controls
|
||||
|
||||
private readonly List<FrameworkElement> ValueControls = new List<FrameworkElement>();
|
||||
private readonly List<FunctionMarker> FunctionMarkers = new List<FunctionMarker>();
|
||||
|
||||
#endregion
|
||||
|
||||
private void ClearControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var functionMarker in FunctionMarkers)
|
||||
{
|
||||
if (functionMarker.Parent is FrameworkElement functionMarkerParent)
|
||||
MainGrid.Children.Remove(functionMarkerParent);
|
||||
}
|
||||
|
||||
ValueControls.Clear();
|
||||
FunctionMarkers.Clear();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBorderThresholdValues(Border border, DetailsPageDataHistoryValueModel valueInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (valueInfo?.HighlightColor)
|
||||
{
|
||||
case enumHighlightColor.none:
|
||||
border.ClearValue(TagProperty);
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder");
|
||||
break;
|
||||
case enumHighlightColor.blue:
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder.Blue");
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder.Green");
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder.Orange");
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder.Red");
|
||||
break;
|
||||
default:
|
||||
border.ClearValue(TagProperty);
|
||||
border.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder");
|
||||
break;
|
||||
};
|
||||
|
||||
border.Tag = valueInfo?.ThresholdValues;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Initialize Controls
|
||||
|
||||
private void InitializeValueRow(int rowIndex)
|
||||
{
|
||||
MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(35) });
|
||||
|
||||
DockPanel valueDockPanel = new DockPanel() { Margin = new Thickness(-19, 0, 0, 0) };
|
||||
Border valueBorder = new Border() { Style = dataHistoryValueBorderStyle };
|
||||
|
||||
#if isNewFeature
|
||||
valueBorder.ToolTip = (ToolTip)FindResource("Tooltip.Treshold");
|
||||
valueBorder.ToolTipOpening += TresholdToolTipEventHandler;
|
||||
#endif
|
||||
|
||||
TextBlock valueTextBlock = new TextBlock();
|
||||
|
||||
valueBorder.Child = valueTextBlock;
|
||||
ValueControls.Add(valueTextBlock);
|
||||
valueDockPanel.Children.Add(valueBorder);
|
||||
|
||||
var valueFunctionMarker = FunctionMarker.SetUpFunctionMarker(valueDockPanel, new FunctionMarker.FunctionMarkerClick(FunctionMarker_Click));
|
||||
FunctionMarkers.Add(valueFunctionMarker);
|
||||
DockPanel.SetDock(valueBorder, Dock.Left);
|
||||
|
||||
Grid.SetRow(valueDockPanel, rowIndex);
|
||||
MainGrid.Children.Add(valueDockPanel);
|
||||
}
|
||||
|
||||
|
||||
public void TresholdToolTipEventHandler(object sender, ToolTipEventArgs e)
|
||||
{
|
||||
#if isNewFeature
|
||||
try
|
||||
{
|
||||
if (!(sender is Border _b) || !(_b.Tag is cStateThresholdValues _v) || !(_b.ToolTip is StatusTreshholdTooltip _t))
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
cUtility.FillTresholdToolTip(_v, _t);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void InitializeValueControls(int valueCount)
|
||||
{
|
||||
for (int i = 0; i < valueCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeValueRow(i);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FunctionMarker_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
if (!(FE.Tag is DetailsPageDataHistoryValueModel HistoryValue))
|
||||
return;
|
||||
|
||||
if (HistoryValue.UiAction == null)
|
||||
return;
|
||||
|
||||
cUiActionBase.RaiseEvent(HistoryValue.UiAction, this, this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Controls
|
||||
|
||||
private void UpdateColumnSize(int rowsToAdd)
|
||||
{
|
||||
if (rowsToAdd > 0)
|
||||
{
|
||||
int rowIndex = MainGrid.RowDefinitions.Count;
|
||||
|
||||
for (int i = rowIndex; i < rowsToAdd + rowIndex; i++)
|
||||
{
|
||||
InitializeValueRow(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainGrid.RowDefinitions.ToList().ForEach(rowDefinitions => rowDefinitions.Height = new GridLength(35));
|
||||
|
||||
var reversedRowList = MainGrid.RowDefinitions.Reverse().ToList();
|
||||
for (int i = 0; i < Math.Abs(rowsToAdd); i++)
|
||||
{
|
||||
reversedRowList[i].Height = new GridLength(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh Values
|
||||
|
||||
private void RefreshColumnHeader(string columnHeader)
|
||||
{
|
||||
string headerContent;
|
||||
|
||||
if (int.TryParse(columnHeader, out int dayIndex))
|
||||
{
|
||||
CultureInfo culture = new CultureInfo(cMultiLanguageSupport.CurrentLanguage);
|
||||
string customDateFormat = cMultiLanguageSupport.GetItem("Global.Date.Format.ShortDateWithDay", "ddd. dd.MM.");
|
||||
headerContent = dayIndex == 0 ? cMultiLanguageSupport.GetItem("Global.Date.Today", DateTime.Now.ToString(customDateFormat, culture)) : DateTime.Today.AddDays(-dayIndex).ToString(customDateFormat, culture);
|
||||
}
|
||||
else
|
||||
headerContent = columnHeader;
|
||||
|
||||
ColumnHeaderTextBlock.Text = headerContent;
|
||||
}
|
||||
|
||||
private void RefreshColumnStatusIcon(enumHighlightColor? statusColor)
|
||||
{
|
||||
ColumnStatusIcon.IconWidth = 25;
|
||||
|
||||
if (ColumnValues.ColumnValues.Any(value => value.IsLoading && value.Content == "-") && statusColor != enumHighlightColor.red)
|
||||
{
|
||||
//todo: replace loading icon
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.menuBar_more;
|
||||
ColumnStatusIcon.PrimaryIconColor = iconColor;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (statusColor)
|
||||
{
|
||||
case enumHighlightColor.blue:
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.status_info;
|
||||
ColumnStatusIcon.PrimaryIconColor = blueBrush;
|
||||
ColumnStatusIcon.SecondaryIconColor = Brushes.White;
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.status_good;
|
||||
ColumnStatusIcon.PrimaryIconColor = greenBrush;
|
||||
ColumnStatusIcon.SecondaryIconColor = Brushes.White;
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.status_danger;
|
||||
ColumnStatusIcon.PrimaryIconColor = orangeBrush;
|
||||
ColumnStatusIcon.SecondaryIconColor = Brushes.White;
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.status_bad;
|
||||
ColumnStatusIcon.PrimaryIconColor = redBrush;
|
||||
ColumnStatusIcon.SecondaryIconColor = Brushes.White;
|
||||
break;
|
||||
default:
|
||||
ColumnStatusIcon.SelectedInternIcon = enumInternIcons.status_empty;
|
||||
ColumnStatusIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.SoftContrast");
|
||||
ColumnStatusIcon.IconWidth = 15;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshColumnValues(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
try
|
||||
{
|
||||
var valueRowEnumerator = columnData.ColumnValues.GetEnumerator();
|
||||
int tempTitleRowIndex = 0;
|
||||
|
||||
foreach (var valueRow in ValueControls)
|
||||
{
|
||||
if (!valueRowEnumerator.MoveNext())
|
||||
continue;
|
||||
|
||||
if (AggregateRowIndexes != null && AggregateRowIndexes.Contains(tempTitleRowIndex))
|
||||
{
|
||||
var valueRowData = valueRowEnumerator.Current;
|
||||
|
||||
if (!(valueRow is TextBlock valueRowTextBlock))
|
||||
continue;
|
||||
|
||||
valueRowTextBlock.Style = dataHistoryValueAggregateStyle;
|
||||
valueRowTextBlock.Text = valueRowData.Content;
|
||||
#if !isNewFeature
|
||||
valueRowTextBlock.ToolTip = valueRowData.ContentDescription;
|
||||
#endif
|
||||
|
||||
|
||||
if (valueRow.Parent is FrameworkElement valueRowParent)
|
||||
{
|
||||
valueRowParent.ClearValue(TagProperty);
|
||||
valueRowParent.SetResourceReference(StyleProperty, "DetailsPage.DataHistory.ValueBorder");
|
||||
}
|
||||
|
||||
switch (valueRowData.HighlightColor)
|
||||
{
|
||||
case enumHighlightColor.none:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
break;
|
||||
case enumHighlightColor.blue:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "Color.Blue");
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "Color.Green");
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "Color.Orange");
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "Color.Red");
|
||||
break;
|
||||
default:
|
||||
valueRowTextBlock.SetResourceReference(ForegroundProperty, "FontColor.DetailsPage.DataHistory.Value");
|
||||
break;
|
||||
};
|
||||
|
||||
valueRow.Visibility = Visibility.Visible;
|
||||
valueRow.Opacity = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var valueRowData = valueRowEnumerator.Current;
|
||||
|
||||
if (!(valueRow is TextBlock valueRowTextBlock))
|
||||
continue;
|
||||
|
||||
valueRowTextBlock.ClearValue(ForegroundProperty);
|
||||
valueRowTextBlock.Style = dataHistoryValueStyle;
|
||||
valueRowTextBlock.Text = valueRowData.Content;
|
||||
|
||||
#if !isNewFeature
|
||||
valueRowTextBlock.ToolTip = valueRowData.ContentDescription;
|
||||
#endif
|
||||
|
||||
Style borderStyle = new Style() { BasedOn = dataHistoryValueBorderStyle };
|
||||
|
||||
if (valueRow.Parent is Border valueRowParentBorder)
|
||||
UpdateBorderThresholdValues(valueRowParentBorder, valueRowData);
|
||||
|
||||
valueRow.Visibility = Visibility.Visible;
|
||||
valueRow.Opacity = 1;
|
||||
|
||||
if (valueRowData.Content == "-" && valueRowData.IsLoading)
|
||||
{
|
||||
valueRowTextBlock.Text = "...";
|
||||
}
|
||||
}
|
||||
|
||||
tempTitleRowIndex++;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshFunctionMarker(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
var valueRowEnumerator = columnData.ColumnValues.GetEnumerator();
|
||||
|
||||
foreach (var valueRow in FunctionMarkers)
|
||||
{
|
||||
if (valueRowEnumerator.MoveNext())
|
||||
{
|
||||
var valueRowData = valueRowEnumerator.Current;
|
||||
|
||||
if (valueRowData.UiAction != null)
|
||||
{
|
||||
valueRow.Tag = valueRowData;
|
||||
|
||||
var tempToolTip = valueRowData.UiAction.Name;
|
||||
if (!string.IsNullOrEmpty(valueRowData.UiAction.Description))
|
||||
tempToolTip += ": \n" + valueRowData.UiAction.Description;
|
||||
|
||||
valueRow.ToolTip = tempToolTip;
|
||||
valueRow.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
valueRow.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshValueSection(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
RefreshColumnValues(columnData);
|
||||
RefreshFunctionMarker(columnData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateValues
|
||||
|
||||
private bool DidCellValueChange(DetailsPageDataHistoryValueModel oldData, DetailsPageDataHistoryValueModel newData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (oldData is null || newData is null)
|
||||
return true;
|
||||
|
||||
if (oldData.Content.Equals(newData.Content) == false || oldData.IsLoading != newData.IsLoading)
|
||||
return true;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateHistoryValues(DetailsPageDataHistoryColumnModel columnData)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (columnData?.ColumnValues is null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < columnData.ColumnValues.Count; i++)
|
||||
{
|
||||
var oldValue = ColumnValues?.ColumnValues?.Count > i ? ColumnValues.ColumnValues[i] : null;
|
||||
var newValue = columnData.ColumnValues[i];
|
||||
|
||||
if (ValueControls.Count < i)
|
||||
continue;
|
||||
|
||||
if (DidCellValueChange(oldValue, newValue))
|
||||
{
|
||||
if (ValueControls[i] is TextBlock valueTextBlock)
|
||||
{
|
||||
valueTextBlock.Text = newValue?.Content;
|
||||
|
||||
#if !isNewFeature
|
||||
valueTextBlock.ToolTip = newValue?.Content;
|
||||
#endif
|
||||
|
||||
valueTextBlock.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
if (ValueControls[i].Parent is Border valueBorder)
|
||||
{
|
||||
UpdateBorderThresholdValues(valueBorder, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (newValue.Content.Equals("Ø"))
|
||||
{
|
||||
if (ValueControls[i] is TextBlock aggregateTextBlock)
|
||||
switch (newValue.HighlightColor)
|
||||
{
|
||||
case enumHighlightColor.green:
|
||||
aggregateTextBlock.Foreground = greenBrush;
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
aggregateTextBlock.Foreground = orangeBrush;
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
aggregateTextBlock.Foreground = redBrush;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ColumnValues is null)
|
||||
ColumnValues = new DetailsPageDataHistoryColumnModel();
|
||||
|
||||
ColumnValues.ColumnValues = columnData.ColumnValues;
|
||||
RefreshColumnStatusIcon(columnData.HighlightColor);
|
||||
Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageDataHistoryValueColumn()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region VerticalCollapse
|
||||
|
||||
#region VerticalCollapsedChanged
|
||||
|
||||
public void ToggleVerticalCollapse(bool isVisible)
|
||||
{
|
||||
(MainGrid.Parent as FrameworkElement).Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent StatusBorderClickedEvent = EventManager.RegisterRoutedEvent("StatusBorderClickedEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryValueColumn));
|
||||
|
||||
public event RoutedEventHandler StatusBorderClickedEventHandler
|
||||
{
|
||||
add { AddHandler(StatusBorderClickedEvent, value); }
|
||||
remove { RemoveHandler(StatusBorderClickedEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseStatusBorderClickedEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(StatusBorderClickedEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
RaiseStatusBorderClickedEvent();
|
||||
}
|
||||
|
||||
private void TitleRowBorder_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
RaiseStatusBorderClickedEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region MouseOver Events
|
||||
|
||||
#region EnterTitleRow
|
||||
|
||||
public static readonly RoutedEvent MouseEnterTitleRowEvent = EventManager.RegisterRoutedEvent("MouseEnterTitleRowEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryValueColumn));
|
||||
|
||||
public event RoutedEventHandler MouseEnterTitleRowEventHandler
|
||||
{
|
||||
add { AddHandler(MouseEnterTitleRowEvent, value); }
|
||||
remove { RemoveHandler(MouseEnterTitleRowEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseMouseEnterTitleRowEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(MouseEnterTitleRowEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
RaiseMouseEnterTitleRowEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LeaveTitleRow
|
||||
|
||||
public static readonly RoutedEvent MouseLeaveTitleRowEvent = EventManager.RegisterRoutedEvent("MouseLeaveTitleRowEventHandler", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageDataHistoryValueColumn));
|
||||
|
||||
public event RoutedEventHandler MouseLeaveTitleRowEventHandler
|
||||
{
|
||||
add { AddHandler(MouseLeaveTitleRowEvent, value); }
|
||||
remove { RemoveHandler(MouseLeaveTitleRowEvent, value); }
|
||||
}
|
||||
|
||||
private void RaiseMouseLeaveTitleRowEvent()
|
||||
{
|
||||
RoutedEventArgs newEventArgs = new RoutedEventArgs(MouseLeaveTitleRowEvent);
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
|
||||
private void TitleRowBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RaiseMouseLeaveTitleRowEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private void UserControl_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style Definitions
|
||||
|
||||
private Style dataHistoryValueStyle;
|
||||
private Style dataHistoryValueAggregateStyle;
|
||||
private Style dataHistoryValueBorderStyle;
|
||||
|
||||
private SolidColorBrush blueBrush;
|
||||
private SolidColorBrush greenBrush;
|
||||
private SolidColorBrush orangeBrush;
|
||||
private SolidColorBrush redBrush;
|
||||
private SolidColorBrush iconColor;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
dataHistoryValueStyle = (Style)FindResource("DetailsPage.DataHistory.Value");
|
||||
dataHistoryValueAggregateStyle = (Style)FindResource("DetailsPage.DataHistory.Value.Aggregate");
|
||||
dataHistoryValueBorderStyle = (Style)FindResource("DetailsPage.DataHistory.ValueBorder");
|
||||
|
||||
blueBrush = (SolidColorBrush)FindResource("Color.Blue");
|
||||
greenBrush = (SolidColorBrush)FindResource("Color.Green");
|
||||
orangeBrush = (SolidColorBrush)FindResource("Color.Orange");
|
||||
redBrush = (SolidColorBrush)FindResource("Color.Red");
|
||||
iconColor = (SolidColorBrush)FindResource("Color.Menu.Icon");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user