inital
This commit is contained in:
33
FasdDesktopUi/Pages/DetailsPage/Commands/BaseCommand.cs
Normal file
33
FasdDesktopUi/Pages/DetailsPage/Commands/BaseCommand.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Commands
|
||||
{
|
||||
public abstract class BaseCommand : ICommand
|
||||
{
|
||||
private bool _canExecute;
|
||||
private bool canExecute
|
||||
{
|
||||
get { return _canExecute; }
|
||||
set
|
||||
{
|
||||
_canExecute = value;
|
||||
CanExecuteChanged?.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
canExecute = true;
|
||||
return canExecute;
|
||||
}
|
||||
|
||||
public abstract void Execute(object parameter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.UserControls;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Commands
|
||||
{
|
||||
public class InformationCommand : BaseCommand
|
||||
{
|
||||
public override bool CanExecute(object parameter = null)
|
||||
{
|
||||
return parameter is ValueTuple<object, List<List<string>>, string>;
|
||||
}
|
||||
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
if (!(parameter is ValueTuple<object, List<object>, string> tempTuple))
|
||||
return;
|
||||
|
||||
(object Title, List<object> DetailedData, string DayIndex) commandProperties = tempTuple;
|
||||
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
if (detailsPage == null)
|
||||
return;
|
||||
|
||||
if (detailsPage.FindName("DataCanvasUserControl") is DataCanvas dataCanvas)
|
||||
{
|
||||
var detailedData = new cDetailedDataModel();
|
||||
|
||||
if (int.TryParse(commandProperties.DayIndex, out int dayIndex))
|
||||
detailedData.Heading = commandProperties.Title is string ? $"Details - {commandProperties.Title} vom {DateTime.Today.AddDays(-dayIndex):d}" : "Detailed Data";
|
||||
else
|
||||
detailedData.Heading = commandProperties.Title is string ? $"Details - {commandProperties.Title}" : "Detailed Data";
|
||||
|
||||
detailedData.FullDetailedData = commandProperties.DetailedData;
|
||||
|
||||
dataCanvas.DataCanvasData = new cDataCanvasDataModel() { DetailedData = detailedData };
|
||||
|
||||
dataCanvas.DetailedDataUc.Visibility = Visibility.Visible;
|
||||
dataCanvas.QuickActionStatusUc.Visibility = Visibility.Collapsed;
|
||||
detailsPage.DataHistoryCollectionUserControl.ToggleHorizontalCollapseHistory(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
FasdDesktopUi/Pages/DetailsPage/Commands/SubMenuCommand.cs
Normal file
30
FasdDesktopUi/Pages/DetailsPage/Commands/SubMenuCommand.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Commands
|
||||
{
|
||||
public class SubMenuCommand : BaseCommand
|
||||
{
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
if (detailsPage == null)
|
||||
return;
|
||||
|
||||
var dataCanvas = detailsPage.QuickActionSelectorUc;
|
||||
|
||||
if (parameter is List<cMenuDataBase> subMenuData)
|
||||
{
|
||||
dataCanvas.QuickActionSelectorUc.TempQuickActionList = dataCanvas.QuickActionSelectorUc.QuickActionList;
|
||||
dataCanvas.QuickActionSelectorUc.TempQuickActionSelectorHeading = dataCanvas.QuickActionSelectorUc.QuickActionSelectorHeading;
|
||||
dataCanvas.QuickActionList = subMenuData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
354
FasdDesktopUi/Pages/DetailsPage/DetailsPageView.xaml
Normal file
354
FasdDesktopUi/Pages/DetailsPage/DetailsPageView.xaml
Normal file
@@ -0,0 +1,354 @@
|
||||
<detailspagebase:SupportCasePageBase xmlns:detailspagebase="clr-namespace:FasdDesktopUi.Pages"
|
||||
x:Class="FasdDesktopUi.Pages.DetailsPage.DetailsPageView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FasdDesktopUi.Pages.DetailsPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:uc="clr-namespace:FasdDesktopUi.Pages.DetailsPage.UserControls"
|
||||
xmlns:buc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:quc="clr-namespace:FasdDesktopUi.Basics.UserControls.QuickTip"
|
||||
xmlns:vm="clr-namespace:FasdDesktopUi.Pages.DetailsPage.ViewModels"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
Title="First Aid Service Desk"
|
||||
x:Name="DetailsPage"
|
||||
Height="1024"
|
||||
Width="680"
|
||||
MinHeight="1024"
|
||||
MinWidth="680"
|
||||
Background="{DynamicResource Color.AppBackground}"
|
||||
Initialized="DetailsPage_Initialized"
|
||||
Closing="Window_Closing"
|
||||
IsVisibleChanged="Window_IsVisibleChanged"
|
||||
PreviewKeyDown="Window_PreviewKeyDown"
|
||||
WindowState="Normal"
|
||||
PreviewMouseWheel="Window_PreviewMouseWheel"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
ResizeMode="CanResize"
|
||||
WindowStyle="None"
|
||||
Loaded="DetailsPage_Loaded"
|
||||
SourceInitialized="DetailsPage_SourceInitialized"
|
||||
PreviewKeyUp="Window_PreviewKeyUp">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="20" />
|
||||
</WindowChrome.WindowChrome>
|
||||
<Window.DataContext>
|
||||
<vm:DetailsPageViewModel />
|
||||
</Window.DataContext>
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:PercentToDecimalConverter x:Key="PercentToDecimal" />
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="10 10 10 10">
|
||||
<Grid x:Name="MainContent"
|
||||
x:FieldModifier="private"
|
||||
Margin="10 0 10 10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas x:Name="FocusCanvas"
|
||||
x:FieldModifier="private"
|
||||
Grid.RowSpan="999"
|
||||
Panel.ZIndex="5"
|
||||
Margin="-20 -10">
|
||||
<Border x:Name="FocusBorder"
|
||||
x:FieldModifier="private"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Grid.RowSpan="999"
|
||||
Opacity="0.4"
|
||||
Visibility="Collapsed"
|
||||
Panel.ZIndex="-1"
|
||||
Width="{Binding ElementName=DetailsPage, Path=ActualWidth}"
|
||||
Height="{Binding ElementName=DetailsPage, Path=ActualHeight}">
|
||||
</Border>
|
||||
|
||||
<Decorator x:Name="FocusDecorator"
|
||||
x:FieldModifier="private">
|
||||
<Decorator.LayoutTransform>
|
||||
<ScaleTransform CenterX="0"
|
||||
CenterY="0"
|
||||
ScaleX="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
|
||||
ScaleY="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}" />
|
||||
</Decorator.LayoutTransform>
|
||||
</Decorator>
|
||||
</Canvas>
|
||||
|
||||
<Border x:Name="Header"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="2"
|
||||
PreviewMouseLeftButtonDown="Header_PreviewMouseLeftButtonDown">
|
||||
<DockPanel LastChildFill="False"
|
||||
Margin="0,-7,0,0">
|
||||
|
||||
<Border x:Name="DialogCloseElement"
|
||||
x:FieldModifier="private"
|
||||
DockPanel.Dock="Bottom"
|
||||
Width="{Binding ElementName=WindowStateBarUserControl, Path=ActualWidth}"
|
||||
HorizontalAlignment="Right"
|
||||
Cursor="Hand"
|
||||
CornerRadius="5"
|
||||
Margin="0 2.5 7.5 -30"
|
||||
Padding="0 2.5"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Value}"
|
||||
MouseLeftButtonUp="CloseCaseWithTicketIcon_MouseLeftButtonUp"
|
||||
TouchDown="CloseCaseWithTicketIcon_TouchDown">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<ico:AdaptableIcon x:Name="CloseCaseWithTicketIcon"
|
||||
x:FieldModifier="private"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 5 0"
|
||||
Panel.ZIndex="2"
|
||||
BorderPadding="0"
|
||||
IconHeight="25"
|
||||
IconWidth="25"
|
||||
SelectedMaterialIcon="ic_mail">
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase}">
|
||||
<TextBlock.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="FontSize"
|
||||
Value="16" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Resources>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel DockPanel.Dock="Right"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
|
||||
<Border x:Name="ZoomValueBorder"
|
||||
Grid.Row="1"
|
||||
Margin="0 10 10 0"
|
||||
Opacity="0"
|
||||
CornerRadius="7.5"
|
||||
Padding="10 5"
|
||||
Background="{DynamicResource Color.SoftContrast}">
|
||||
<TextBlock x:Name="ZoomValueTextBlock"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
FontWeight="Bold"
|
||||
FontSize="20" />
|
||||
</Border>
|
||||
|
||||
<uc:DetailsPageWindowStateBar x:Name="WindowStateBarUserControl" />
|
||||
</StackPanel>
|
||||
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="Body"
|
||||
Padding="10"
|
||||
Grid.Row="1">
|
||||
<Border.LayoutTransform>
|
||||
<ScaleTransform CenterX="0"
|
||||
CenterY="0"
|
||||
ScaleX="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
|
||||
ScaleY="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}" />
|
||||
</Border.LayoutTransform>
|
||||
|
||||
<Grid x:Name="MainGrid"
|
||||
Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="42" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="BlurBorder"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Grid.RowSpan="999"
|
||||
Opacity="0.3"
|
||||
Margin="-30 -65"
|
||||
Visibility="{Binding ElementName=DetailsPage, Path=IsBlurred, Converter={StaticResource BoolToVisibility}}"
|
||||
Panel.ZIndex="3"
|
||||
MouseUp="BlurBorder_MouseUp"
|
||||
TouchDown="BlurBorder_TouchDown">
|
||||
</Border>
|
||||
<buc:BlurInvokerContainer x:Name="OverlayBorder"
|
||||
x:FieldModifier="private"
|
||||
HorizontalAlignment="Center"
|
||||
MaxWidth="990"
|
||||
Grid.RowSpan="999"
|
||||
Panel.ZIndex="4"
|
||||
Padding="75 25" />
|
||||
|
||||
<uc:DetailsPageNavigationHeading x:Name="NavigationHeadingUc"
|
||||
Grid.Row="0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.RowSpan="3"
|
||||
Panel.ZIndex="1"/>
|
||||
|
||||
<uc:DetailsPageWidgetCollection x:Name="WidgetCollection"
|
||||
Grid.Row="1"
|
||||
Margin="0 35 0 10"
|
||||
WidgetGeometryList="{Binding WidgetGeometryList}"
|
||||
WidgetDataList="{Binding WidgetDataList}" />
|
||||
|
||||
<uc:DetailsPageRefreshControl x:Name="RefreshControl"
|
||||
Grid.Row="2"
|
||||
Margin="0 10 5.5 0"
|
||||
VerticalAlignment="Top" />
|
||||
|
||||
<DockPanel LastChildFill="False"
|
||||
Grid.Row="2">
|
||||
|
||||
<buc:QuickActionSelector x:Name="QuickActionSelectorUc"
|
||||
DockPanel.Dock="Right"
|
||||
Margin="15 27.5 0 0"
|
||||
MaxWidth="300"
|
||||
MinWidth="280"
|
||||
VerticalAlignment="Top"
|
||||
IsVisibleChanged="DynamicElement_IsVisibleChanged" />
|
||||
|
||||
<DockPanel LastChildFill="True">
|
||||
|
||||
<Decorator x:Name="QuickActionDecorator"
|
||||
DockPanel.Dock="Right"
|
||||
MaxWidth="400"
|
||||
Margin="19 27.5 0 0"
|
||||
Visibility="Collapsed"
|
||||
IsVisibleChanged="DynamicElement_IsVisibleChanged" />
|
||||
|
||||
<Decorator x:Name="NotepadDecorator"
|
||||
DockPanel.Dock="Right"
|
||||
MaxWidth="400"
|
||||
Margin="19 27.5 0 0"
|
||||
Visibility="Visible"
|
||||
IsVisibleChanged="DynamicElement_IsVisibleChanged" />
|
||||
|
||||
<Decorator x:Name="QuickTipDecorator"
|
||||
DockPanel.Dock="Right"
|
||||
MaxWidth="400"
|
||||
Margin="19 27.5 0 0"
|
||||
Visibility="Visible">
|
||||
|
||||
<quc:QuickTipStatusMonitor x:Name="QuickTipStatusMonitorUc"
|
||||
Visibility="Collapsed"
|
||||
IsVisibleChanged="QuickTipStatusMonitorUc_IsVisibleChanged" />
|
||||
|
||||
</Decorator>
|
||||
|
||||
<uc:DetailsPageDataHistoryCollection x:Name="DataHistoryCollectionUserControl"
|
||||
DockPanel.Dock="Left"
|
||||
HorizontalAlignment="Left"
|
||||
DetailsGeometry="{Binding DetailsGeometry}" />
|
||||
|
||||
<uc:CustomizableSection x:Name="CustomizableSectionUc"
|
||||
DockPanel.Dock="Left"
|
||||
HorizontalAlignment="Left"
|
||||
Visibility="Collapsed"
|
||||
IsVisibleChanged="DynamicElement_IsVisibleChanged" />
|
||||
|
||||
</DockPanel>
|
||||
|
||||
</DockPanel>
|
||||
|
||||
<Border x:Name="SearchResultBorder"
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="2"
|
||||
Padding="10"
|
||||
Margin="0 -30 -10 0"
|
||||
Panel.ZIndex="2"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}">
|
||||
<buc:CustomSearchResultCollection x:Name="SearchResultsUc"
|
||||
x:FieldModifier="private" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
<Border x:Name="Footer"
|
||||
Grid.Row="2"
|
||||
Panel.ZIndex="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
PreviewMouseLeftButtonDown="Footer_PreviewMouseLeftButtonDown">
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<buc:MenuBar x:Name="MenuBarUserControl"
|
||||
x:FieldModifier="private"
|
||||
MenuBarItemData="{Binding MenuBarData}" />
|
||||
<buc:SearchBar x:Name="SearchBarUserControl"
|
||||
x:FieldModifier="private"
|
||||
Visibility="Collapsed"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
<StackPanel x:Name="IconTimerPanel"
|
||||
Orientation="Horizontal"
|
||||
PreviewMouseLeftButtonDown="IconTimerPanel_PreviewMouseLeftButtonDown">
|
||||
<ico:AdaptableIcon x:Name="F4SDIcon"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Bottom"
|
||||
PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
|
||||
BorderPadding="0"
|
||||
MouseLeftButtonUp="F4SDIcon_MouseLeftButtonUp"
|
||||
SelectedInternIcon="f4sd_outline" />
|
||||
|
||||
<buc:TimerView x:Name="CaseTimer"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="15 -2.5"
|
||||
OnPauseStarted="CaseTimer_OnPauseStarted" />
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="PauseOverlay"
|
||||
x:FieldModifier="private"
|
||||
Grid.RowSpan="999"
|
||||
Grid.ColumnSpan="999"
|
||||
Panel.ZIndex="999"
|
||||
Visibility="Collapsed"
|
||||
Margin="-10">
|
||||
<Border Background="{DynamicResource Color.BlurBorder}"
|
||||
Opacity="0.25"
|
||||
CornerRadius="5">
|
||||
</Border>
|
||||
<buc:PauseCaseOverlay HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
OnPauseEnd="PauseCaseOverlay_OnPauseEnd" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</detailspagebase:SupportCasePageBase>
|
||||
1688
FasdDesktopUi/Pages/DetailsPage/DetailsPageView.xaml.cs
Normal file
1688
FasdDesktopUi/Pages/DetailsPage/DetailsPageView.xaml.cs
Normal file
File diff suppressed because it is too large
Load Diff
286
FasdDesktopUi/Pages/DetailsPage/DetailsPageViewModel.cs
Normal file
286
FasdDesktopUi/Pages/DetailsPage/DetailsPageViewModel.cs
Normal file
@@ -0,0 +1,286 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using FasdDesktopUi.Basics;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.ViewModels
|
||||
{
|
||||
public class DetailsPageViewModel : BaseViewModel
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private int shownValueColumnsCount;
|
||||
|
||||
public cSupportCaseDataProvider DataProvider { get; set; }
|
||||
|
||||
#region ZoomInPercent
|
||||
|
||||
private int zoomInPercent;
|
||||
|
||||
public int ZoomInPercent
|
||||
{
|
||||
get { return zoomInPercent; }
|
||||
set
|
||||
{
|
||||
if (value < 50)
|
||||
value = 50;
|
||||
else if (value > 250)
|
||||
value = 250;
|
||||
|
||||
zoomInPercent = value;
|
||||
cFasdCockpitConfig.Instance.SetDetailsPageZoom(value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Header Properties
|
||||
|
||||
#region PageTitle Property
|
||||
|
||||
private string pageTitle;
|
||||
public string PageTitle
|
||||
{
|
||||
get { return pageTitle; }
|
||||
set
|
||||
{
|
||||
pageTitle = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HeadingData Property
|
||||
|
||||
private List<cHeadingDataModel> headingData;
|
||||
|
||||
public List<cHeadingDataModel> HeadingData
|
||||
{
|
||||
get { return headingData; }
|
||||
set
|
||||
{
|
||||
headingData = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Widget Properties
|
||||
|
||||
#region WidgetData Property
|
||||
private List<List<cWidgetValueModel>> widgetDataList;
|
||||
public List<List<cWidgetValueModel>> WidgetDataList
|
||||
{
|
||||
get { return widgetDataList; }
|
||||
set
|
||||
{
|
||||
widgetDataList = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WidgetGeometry Property
|
||||
private List<DetailsPageWidgetGeometryModel> widgetGeometryList;
|
||||
public List<DetailsPageWidgetGeometryModel> WidgetGeometryList
|
||||
{
|
||||
get { return widgetGeometryList; }
|
||||
set
|
||||
{
|
||||
widgetGeometryList = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Details Properties
|
||||
|
||||
#region TimeSinceLastRefresh property
|
||||
private TimeSpan timeSinceLastRefresh;
|
||||
public TimeSpan TimeSinceLastRefresh
|
||||
{
|
||||
get { return timeSinceLastRefresh; }
|
||||
set
|
||||
{
|
||||
timeSinceLastRefresh = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DetailsGeometry property
|
||||
|
||||
private DetailsPageDataHistoryCollectionGeometryModel detailsGeometry;
|
||||
|
||||
public DetailsPageDataHistoryCollectionGeometryModel DetailsGeometry
|
||||
{
|
||||
get { return detailsGeometry; }
|
||||
set
|
||||
{
|
||||
detailsGeometry = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DetailsData property
|
||||
|
||||
private List<cDetailsPageDataHistoryDataModel> detailsDataList;
|
||||
public List<cDetailsPageDataHistoryDataModel> DetailsDataList
|
||||
{
|
||||
get { return detailsDataList; }
|
||||
set
|
||||
{
|
||||
detailsDataList = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShownValueColumnsCount
|
||||
public int ShownValueColumnsCount
|
||||
{
|
||||
get => shownValueColumnsCount; set
|
||||
{
|
||||
shownValueColumnsCount = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menu Properties
|
||||
|
||||
#region MenuBarData property
|
||||
|
||||
private List<cMenuDataBase> menuBarData;
|
||||
|
||||
public List<cMenuDataBase> MenuBarData
|
||||
{
|
||||
get { return menuBarData; }
|
||||
set
|
||||
{
|
||||
menuBarData = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(MenuDrawerData));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MenuDrawerData Property
|
||||
|
||||
public List<cMenuDataBase> MenuDrawerData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MenuBarData != null)
|
||||
return MenuBarData.Where(x => x.IconPositionIndex < 0).ToList();
|
||||
|
||||
return new List<cMenuDataBase>();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public DetailsPageViewModel()
|
||||
{
|
||||
cFasdCockpitConfig.Instance.UiSettingsChanged += CockpitConfig_UiSettingsChanged;
|
||||
}
|
||||
|
||||
private void CockpitConfig_UiSettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
ZoomInPercent = cFasdCockpitConfig.Instance.DetailsPageZoom;
|
||||
}
|
||||
|
||||
#region Set DataContext
|
||||
|
||||
public void SetGeometryValues(DetailsPageGeometry geometryValues)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
WidgetGeometryList = geometryValues.WidgetGeometryList;
|
||||
DetailsGeometry = geometryValues.DetailsCollectionGeometry;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogEntry($"Passed geometry values: {geometryValues}");
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPropertyValues(cDetailsPageData propertyValues)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
DataProvider = propertyValues.DataProvider;
|
||||
|
||||
//Heading Properties
|
||||
HeadingData = propertyValues.HeadingData;
|
||||
|
||||
//Widget Properties
|
||||
WidgetDataList = propertyValues.WidgetData;
|
||||
|
||||
//Details Properties
|
||||
TimeSinceLastRefresh = propertyValues.TimeSinceLastRefresh;
|
||||
ShownValueColumnsCount = propertyValues.ShownValueColumnsCount;
|
||||
DetailsDataList = propertyValues.DataHistoryList;
|
||||
|
||||
//Menu Properties
|
||||
MenuBarData = propertyValues.MenuBarData;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogEntry($"Passed history values: {propertyValues}");
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Enums
|
||||
{
|
||||
public enum enumHistoryTitleType
|
||||
{
|
||||
none,
|
||||
header,
|
||||
value,
|
||||
subValue,
|
||||
aggregate
|
||||
}
|
||||
}
|
||||
45
FasdDesktopUi/Pages/DetailsPage/Models/DetailsPageBase.cs
Normal file
45
FasdDesktopUi/Pages/DetailsPage/Models/DetailsPageBase.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using FasdDesktopUi.Pages.DetailsPage.ViewModels;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Models
|
||||
{
|
||||
public class DetailsPageGeometry
|
||||
{
|
||||
public List<DetailsPageWidgetGeometryModel> WidgetGeometryList { get; set; }
|
||||
|
||||
public DetailsPageDataHistoryCollectionGeometryModel DetailsCollectionGeometry { get; set; }
|
||||
}
|
||||
|
||||
public class cDetailsPageData
|
||||
{
|
||||
public cSupportCaseDataProvider DataProvider { get; set; }
|
||||
|
||||
//Header
|
||||
public List<cHeadingDataModel> HeadingData { get; set; }
|
||||
|
||||
//Widget
|
||||
public List<List<cWidgetValueModel>> WidgetData { get; set; }
|
||||
|
||||
//Details
|
||||
public TimeSpan TimeSinceLastRefresh { get; set; } = new TimeSpan(0, 1, 0);
|
||||
public List<cDetailsPageDataHistoryDataModel> DataHistoryList { get; set; }
|
||||
public int ShownValueColumnsCount { get; set; }
|
||||
|
||||
//Customizable Section
|
||||
public List<cContainerCollectionData> DataContainerCollectionList { get; set; }
|
||||
|
||||
//Menu
|
||||
public List<cMenuDataBase> MenuBarData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Models
|
||||
{
|
||||
public class DetailsPageDataHistoryCollectionGeometryModel
|
||||
{
|
||||
public int ColumnCount { get; set; }
|
||||
public List<int> SubtitleCount { get; set; }
|
||||
|
||||
public DetailsPageDataHistoryCollectionGeometryModel()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Models
|
||||
{
|
||||
public class DetailsPageWidgetGeometryModel
|
||||
{
|
||||
public int WidgetTitleCount { get; set; }
|
||||
public int WidgetDetailCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.Models
|
||||
{
|
||||
public class DetailsPageDataHistoryValueModel : cDataHistoryValueModel
|
||||
{
|
||||
public enumHistoryTitleType? PresentationStyle { get; set; }
|
||||
|
||||
public List<List<string>> DetailedData { get; set; }
|
||||
}
|
||||
|
||||
public class DetailsPageDataHistoryColumnModel : DetailsPageDataHistoryValueModel
|
||||
{
|
||||
public List<DetailsPageDataHistoryValueModel> ColumnValues { get; set; }
|
||||
}
|
||||
|
||||
public class cDetailsPageDataHistoryDataModel
|
||||
{
|
||||
public DetailsPageDataHistoryColumnModel TitleColumn { get; set; }
|
||||
public List<DetailsPageDataHistoryColumnModel> ValueColumns { get; set; }
|
||||
public double TitleColumnWidth { get; set; } = 250;
|
||||
public double ValueColumnWidth { get; set; } = 100;
|
||||
}
|
||||
|
||||
public class DataHistoryEventArgs : RoutedEventArgs
|
||||
{
|
||||
public DetailsPageDataHistoryValueModel HistoryValueData { get; set; }
|
||||
|
||||
public DataHistoryEventArgs()
|
||||
{
|
||||
}
|
||||
|
||||
public DataHistoryEventArgs(RoutedEvent routedEvent) : base(routedEvent)
|
||||
{
|
||||
}
|
||||
|
||||
public DataHistoryEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.CustomizableSection"
|
||||
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:uc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Name="_me">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Margin="0 10 0 0"
|
||||
Height="13">
|
||||
<uc:LoadingDataIndicator Visibility="{Binding ElementName=_me, Path=IsDataIncomplete, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Border>
|
||||
|
||||
<Grid x:Name="MainGrid"
|
||||
Margin="0 5 0 0"
|
||||
Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,132 @@
|
||||
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 FasdDesktopUi.Basics.Models;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class CustomizableSection : UserControl
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
#region ContainerCollections
|
||||
|
||||
public List<cContainerCollectionData> ContainerCollections
|
||||
{
|
||||
get { return (List<cContainerCollectionData>)GetValue(ContainerCollectionsProperty); }
|
||||
set { SetValue(ContainerCollectionsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContainerCollectionsProperty =
|
||||
DependencyProperty.Register("ContainerCollections", typeof(List<cContainerCollectionData>), typeof(CustomizableSection), new PropertyMetadata(new List<cContainerCollectionData>(), new PropertyChangedCallback(ContainerCollectionsChanged)));
|
||||
|
||||
private static void ContainerCollectionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is CustomizableSection _me))
|
||||
return;
|
||||
|
||||
_me.DrawContainerCollections();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsDataIncomplete DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty IsDataIncompleteProperty =
|
||||
DependencyProperty.Register("IsDataIncomplete", typeof(bool), typeof(CustomizableSection), new PropertyMetadata(true));
|
||||
|
||||
public bool IsDataIncomplete
|
||||
{
|
||||
get { return (bool)GetValue(IsDataIncompleteProperty); }
|
||||
set { SetValue(IsDataIncompleteProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public CustomizableSection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UpdateContainerCollection(List<cContainerCollectionData> containerCollectionsData)
|
||||
{
|
||||
ContainerCollections = containerCollectionsData;
|
||||
}
|
||||
|
||||
private void DrawContainerCollections()
|
||||
{
|
||||
MainGrid.Children.Clear();
|
||||
foreach (var containerCollection in ContainerCollections)
|
||||
{
|
||||
var containerCollectionToAdd = new DetailsPageStateContainerCollection() { CollectionData = containerCollection };
|
||||
Grid.SetColumnSpan(containerCollectionToAdd, containerCollection.ColumnSpan);
|
||||
SetColumnIndex(containerCollectionToAdd, containerCollection.ColumnSpan);
|
||||
MainGrid.Children.Add(containerCollectionToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetColumnIndex(UIElement element, int columnSpan)
|
||||
{
|
||||
try
|
||||
{
|
||||
int columnCount = MainGrid.ColumnDefinitions.Count;
|
||||
|
||||
if (MainGrid.Children.Count <= 0)
|
||||
{
|
||||
Grid.SetColumn(element, 0);
|
||||
Grid.SetRow(element, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
var lastChild = MainGrid.Children.OfType<FrameworkElement>().Last();
|
||||
|
||||
int lastChildColumnIndex = Grid.GetColumn(lastChild);
|
||||
int lastChildColumnSpan = Grid.GetColumnSpan(lastChild);
|
||||
int lastChildRowIndex = Grid.GetRow(lastChild);
|
||||
|
||||
if (columnCount < lastChildColumnIndex + lastChildColumnSpan + columnSpan)
|
||||
{
|
||||
MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
|
||||
Grid.SetRow(element, lastChildRowIndex + 1);
|
||||
Grid.SetColumn(element, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
Grid.SetRow(element, lastChildRowIndex);
|
||||
Grid.SetColumn(element, lastChildColumnIndex + lastChildColumnSpan);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var child in MainGrid.Children)
|
||||
{
|
||||
if (!(child is DetailsPageStateContainerCollection stateContainerCollection))
|
||||
continue;
|
||||
|
||||
stateContainerCollection.SetEditMode(isActive);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageStateContainer"
|
||||
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: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.DetailsPage.Widget.Value}"
|
||||
CornerRadius="7.5"
|
||||
Padding="10">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="AddButton"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="2"
|
||||
CornerRadius="5"
|
||||
Padding="5 2.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Cursor="Hand"
|
||||
Visibility="Collapsed">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Done }">
|
||||
<TextBlock.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="FontSize"
|
||||
Value="11.5" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Resources>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
|
||||
<StackPanel x:Name="MainStackPanel"
|
||||
Grid.Row="1" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="FullSizeButton"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
Margin="0 -10 -10 0"
|
||||
BorderPadding="7.5"
|
||||
MouseLeftButtonUp="FullSizeButton_MouseLeftButtonUp"
|
||||
TouchDown="FullSizeButton_TouchDown"
|
||||
SelectedMaterialIcon="ic_zoom_out_map" />
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,434 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using MaterialIcons;
|
||||
using FasdDesktopUi.Basics.Helper;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageStateContainer : UserControl
|
||||
{
|
||||
private readonly List<(FrameworkElement ValueControl, FrameworkElement EditControl)> EditableControls = new List<(FrameworkElement ValueControl, FrameworkElement EditControl)>();
|
||||
|
||||
#region Properties
|
||||
|
||||
public cContainerData ContainerData
|
||||
{
|
||||
get { return (cContainerData)GetValue(ContainerDataProperty); }
|
||||
set { SetValue(ContainerDataProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContainerDataProperty =
|
||||
DependencyProperty.Register("ContainerData", typeof(cContainerData), typeof(DetailsPageStateContainer), new PropertyMetadata(null, new PropertyChangedCallback(ContainerDataChanged)));
|
||||
|
||||
private static void ContainerDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageStateContainer _me))
|
||||
return;
|
||||
|
||||
_me.EditableControls.Clear();
|
||||
_me.DrawContainerContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageStateContainer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
private void DrawContainerContent()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ContainerData.IsMaximizable)
|
||||
FullSizeButton.Visibility = Visibility.Visible;
|
||||
else
|
||||
FullSizeButton.Visibility = Visibility.Collapsed;
|
||||
|
||||
if(ContainerData.IsAddable)
|
||||
AddButton.Visibility = Visibility.Visible;
|
||||
else
|
||||
AddButton.Visibility = Visibility.Collapsed;
|
||||
|
||||
foreach (var containerElement in ContainerData)
|
||||
{
|
||||
cUiElementHelper.DrawCustomizableContainerComponent(containerElement, this, out var createdElement, EditableControls.Add);
|
||||
MainStackPanel.Children.Add(createdElement);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetHtmlString(string maximizeValue, double fontSize = 14.0)
|
||||
{
|
||||
var output = maximizeValue;
|
||||
try
|
||||
{
|
||||
var backgroundColor = (SolidColorBrush)TryFindResource("BackgroundColor.DetailsPage.Widget.Title");
|
||||
var backgroundColorString = string.Empty;
|
||||
|
||||
if (backgroundColor != null)
|
||||
backgroundColorString = $"rgb({backgroundColor.Color.R}, {backgroundColor.Color.G}, {backgroundColor.Color.B} )";
|
||||
|
||||
var foreGroundColor = (SolidColorBrush)TryFindResource("FontColor.DetailsPage.Widget");
|
||||
var foreGroundColorString = string.Empty;
|
||||
|
||||
if (foreGroundColor != null)
|
||||
foreGroundColorString = $"rgb({foreGroundColor.Color.R}, {foreGroundColor.Color.G}, {foreGroundColor.Color.B} )";
|
||||
|
||||
string htmlPrefix = $"<html><head><meta charset=\"UTF-8\"></head><body style=\"background-color: {backgroundColorString}; color: {foreGroundColorString}; font-size: {fontSize}px; font-family: Calibri, sans-serif; overflow: auto\"><div>";
|
||||
string htmlSuffix = "</div></body></html>";
|
||||
|
||||
output = htmlPrefix + maximizeValue + htmlSuffix;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private void DrawMaximizedControl(IContainerData containerDataEntry, FrameworkElement parentElement)
|
||||
{
|
||||
try
|
||||
{
|
||||
const double enlargementFactor = 1.5;
|
||||
|
||||
FrameworkElement createdControl = null;
|
||||
switch (containerDataEntry)
|
||||
{
|
||||
case cContainerValue containerValueData:
|
||||
{
|
||||
if (string.IsNullOrEmpty(containerValueData?.MaximizeValue))
|
||||
{
|
||||
createdControl = new TextBlock()
|
||||
{
|
||||
Text = containerValueData.DisplayValue,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
FontSize = containerValueData.FontSize * enlargementFactor,
|
||||
FontWeight = containerValueData.FontWeight,
|
||||
Margin = new Thickness(0, 0, 5, 0),
|
||||
Style = textBlockStyle
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(containerValueData.Description))
|
||||
createdControl.ToolTip = containerValueData.Description;
|
||||
}
|
||||
else
|
||||
{
|
||||
var webBrowser = new WebBrowser() { ClipToBounds = true };
|
||||
webBrowser.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
|
||||
|
||||
string htmlControlString = GetHtmlString(containerValueData.MaximizeValue, containerValueData.FontSize * enlargementFactor);
|
||||
|
||||
webBrowser.NavigateToString(htmlControlString);
|
||||
|
||||
createdControl = new Border() { Child = webBrowser };
|
||||
|
||||
if (createdControl is Border createdBorder)
|
||||
createdBorder.SetResourceReference(BackgroundProperty, "BackgroundColor.DetailsPage.Widget.Title");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case cContainerIcon containerIconData:
|
||||
{
|
||||
enumInternIcons? internIcon = null;
|
||||
enumInternGif? internGif = null;
|
||||
MaterialIconType? materialIcon = null;
|
||||
|
||||
if (Enum.TryParse<enumInternIcons>(containerIconData.IconName, out var tempInternIcon))
|
||||
internIcon = tempInternIcon;
|
||||
|
||||
if (Enum.TryParse<enumInternGif>(containerIconData.IconName, out var tempInternGif))
|
||||
internGif = tempInternGif;
|
||||
|
||||
if (Enum.TryParse<MaterialIconType>(containerIconData.IconName, out var tempMaterialIcon))
|
||||
materialIcon = tempMaterialIcon;
|
||||
|
||||
createdControl = new AdaptableIcon()
|
||||
{
|
||||
SelectedInternIcon = internIcon,
|
||||
SelectedInternGif = internGif,
|
||||
SelectedMaterialIcon = materialIcon,
|
||||
ToolTip = containerIconData.ToolTipText,
|
||||
BorderPadding = new Thickness(0),
|
||||
IconHeight = 14 * enlargementFactor,
|
||||
IconWidth = 14 * enlargementFactor,
|
||||
Margin = new Thickness(0, 0, 5, 0)
|
||||
};
|
||||
|
||||
string iconResourceName = "Color.Menu.Icon";
|
||||
switch (containerIconData.HighlightColor)
|
||||
{
|
||||
case enumHighlightColor.blue:
|
||||
iconResourceName = "Color.Blue";
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
iconResourceName = "Color.Green";
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
iconResourceName = "Color.Orange";
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
iconResourceName = "Color.Red";
|
||||
break;
|
||||
}
|
||||
|
||||
if (createdControl is AdaptableIcon createdAdaptable)
|
||||
createdAdaptable.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, iconResourceName);
|
||||
break;
|
||||
}
|
||||
case cContainerPrimaryContent primaryContentData:
|
||||
{
|
||||
if (parentElement is Grid parentGrid)
|
||||
parentGrid.RowDefinitions.Last().Height = new GridLength(1, GridUnitType.Star);
|
||||
|
||||
createdControl = new Border()
|
||||
{
|
||||
Padding = new Thickness(10),
|
||||
Margin = new Thickness(0, 5, 0, 5),
|
||||
CornerRadius = new CornerRadius(7.5)
|
||||
};
|
||||
|
||||
if (createdControl is Border createdBorder)
|
||||
createdBorder.SetResourceReference(BackgroundProperty, "BackgroundColor.DetailsPage.Widget.Title");
|
||||
|
||||
DrawMaximizedControl(primaryContentData.Value, createdControl);
|
||||
break;
|
||||
}
|
||||
case cContainerStackPanel stackPanelData:
|
||||
{
|
||||
createdControl = new StackPanel() { Orientation = stackPanelData.Orientation };
|
||||
|
||||
foreach (var stackPanelElement in stackPanelData.StackPanelData)
|
||||
{
|
||||
DrawMaximizedControl(stackPanelElement, createdControl);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (createdControl is null)
|
||||
return;
|
||||
|
||||
if (parentElement is Panel parentPanel)
|
||||
{
|
||||
if (parentPanel is Grid parentGrid)
|
||||
Grid.SetRow(createdControl, parentGrid.RowDefinitions.Count - 1);
|
||||
|
||||
parentPanel.Children.Add(createdControl);
|
||||
}
|
||||
else if (parentElement is Decorator parentDecorator)
|
||||
{
|
||||
parentDecorator.Child = createdControl;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private Decorator GetMaximizedContainer()
|
||||
{
|
||||
Decorator output = null;
|
||||
|
||||
try
|
||||
{
|
||||
output = new Border()
|
||||
{
|
||||
CornerRadius = new CornerRadius(10),
|
||||
Padding = new Thickness(22)
|
||||
};
|
||||
output.SetResourceReference(BackgroundProperty, "BackgroundColor.DetailsPage.Widget.Value");
|
||||
|
||||
Grid grid = new Grid();
|
||||
output.Child = grid;
|
||||
|
||||
AdaptableIcon closeIcon = new AdaptableIcon()
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
SelectedInternIcon = enumInternIcons.window_close,
|
||||
IconHeight = 35,
|
||||
IconWidth = 35,
|
||||
Margin = new Thickness(0, -10, 0, 0)
|
||||
};
|
||||
Panel.SetZIndex(closeIcon, 1);
|
||||
closeIcon.SetResourceReference(StyleProperty, "SettingsPage.Close.Icon");
|
||||
closeIcon.MouseLeftButtonUp += CloseIcon_MouseLeftButtonUp;
|
||||
closeIcon.TouchDown += CloseIcon_TouchDown;
|
||||
|
||||
grid.Children.Add(closeIcon);
|
||||
|
||||
foreach (var containerDataEntry in ContainerData)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
|
||||
DrawMaximizedControl(containerDataEntry, grid);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
#region FullSizeButton Click
|
||||
|
||||
private void FullSizeButton_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
var maximizedContainer = GetMaximizedContainer();
|
||||
|
||||
if (maximizedContainer != null)
|
||||
RaiseEvent(new ContainerEventArgs(MaximizeContainerEvent, this, maximizedContainer));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void FullSizeButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
FullSizeButton_Click();
|
||||
}
|
||||
|
||||
private void FullSizeButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
FullSizeButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Styles
|
||||
|
||||
Style textBlockStyle;
|
||||
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
textBlockStyle = (Style)FindResource("DetailsPage.Widget.Title");
|
||||
}
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var editablePair in EditableControls)
|
||||
{
|
||||
editablePair.ValueControl.Visibility = isActive ? Visibility.Collapsed : Visibility.Visible;
|
||||
editablePair.EditControl.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
#region Full Size Events
|
||||
|
||||
public class ContainerEventArgs : RoutedEventArgs
|
||||
{
|
||||
public Decorator MaximizedControl { get; private set; }
|
||||
|
||||
public ContainerEventArgs(RoutedEvent routedEvent, object source, Decorator maximizedControl) : base(routedEvent, source)
|
||||
{
|
||||
MaximizedControl = maximizedControl;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void ContainerEventHandlerDelegate(object sender, ContainerEventArgs args);
|
||||
|
||||
public static readonly RoutedEvent MaximizeContainerEvent = EventManager.RegisterRoutedEvent("MaximizeContainer", RoutingStrategy.Bubble, typeof(ContainerEventHandlerDelegate), typeof(DetailsPageStateContainer));
|
||||
|
||||
public event RoutedEventHandler MaximizeContainer
|
||||
{
|
||||
add { AddHandler(MaximizeContainerEvent, value); }
|
||||
remove { RemoveHandler(MaximizeContainerEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Close Full Size Events
|
||||
|
||||
public static readonly RoutedEvent CloseMaximizedContainerEvent = EventManager.RegisterRoutedEvent("CloseMaximizedContainer", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailsPageStateContainer));
|
||||
|
||||
public event RoutedEventHandler CloseMaximizedContainer
|
||||
{
|
||||
add { AddHandler(CloseMaximizedContainerEvent, value); }
|
||||
remove { RemoveHandler(CloseMaximizedContainerEvent, value); }
|
||||
}
|
||||
|
||||
private void CloseIcon_Click()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
RaiseEvent(new RoutedEventArgs(CloseMaximizedContainerEvent));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseIcon_Click();
|
||||
}
|
||||
|
||||
private void CloseIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseIcon_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageStateContainerCollection"
|
||||
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">
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
Margin="0 0 20 20"
|
||||
Padding="0 0 8 8">
|
||||
<StackPanel x:Name="MainStack" />
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,85 @@
|
||||
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.Media;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageStateContainerCollection : UserControl
|
||||
{
|
||||
#region Properties and Fields
|
||||
|
||||
private List<UIElement> editControls = new List<UIElement>();
|
||||
|
||||
public cContainerCollectionData CollectionData
|
||||
{
|
||||
get { return (cContainerCollectionData)GetValue(CollectionDataProperty); }
|
||||
set { SetValue(CollectionDataProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CollectionDataProperty =
|
||||
DependencyProperty.Register("CollectionData", typeof(cContainerCollectionData), typeof(DetailsPageStateContainerCollection), new PropertyMetadata(null, new PropertyChangedCallback(CollectionDataChanged)));
|
||||
|
||||
private static void CollectionDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageStateContainerCollection _me))
|
||||
return;
|
||||
|
||||
_me.editControls.Clear();
|
||||
_me.DrawStateContainers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageStateContainerCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void DrawStateContainers()
|
||||
{
|
||||
try
|
||||
{
|
||||
MainStack.Children.Clear();
|
||||
|
||||
foreach (var containerData in CollectionData)
|
||||
{
|
||||
var containerToAdd = new DetailsPageStateContainer() { ContainerData = containerData, Margin = new Thickness(0, 0, 0, 10) };
|
||||
MainStack.Children.Add(containerToAdd);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
editControls.ForEach(x => x.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed);
|
||||
|
||||
foreach (var child in MainStack.Children)
|
||||
{
|
||||
if (!(child is DetailsPageStateContainer stateContainer))
|
||||
continue;
|
||||
|
||||
stateContainer.SetEditMode(isActive);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageNavigationHeading"
|
||||
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:buc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
x:Name="NavigationHeadingUc"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource DetailsPage.TitleSection.Icon}">
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="HeadingIcon_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="HeadingIcon_TouchDown" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SwapIconStyleBase"
|
||||
x:Name="SwapIconStyleBase"
|
||||
TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource Menu.MenuBar.PinnedIcon.Base}">
|
||||
<Setter Property="Visibility"
|
||||
Value="Hidden" />
|
||||
<Setter Property="Opacity"
|
||||
Value="0.7" />
|
||||
<Setter Property="Cursor"
|
||||
Value="{x:Null}" />
|
||||
<Setter Property="SelectedInternIcon"
|
||||
Value="misc_chevron_down" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SwapIconStyle"
|
||||
TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource SwapIconStyleBase}">
|
||||
<Setter Property="Opacity"
|
||||
Value="1" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}" />
|
||||
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="SwapIcon_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="SwapIcon_TouchDown" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock"
|
||||
BasedOn="{StaticResource DetailsPage.TitleSection.Header}">
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="HeadingIcon_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="HeadingIcon_TouchDown" />
|
||||
</Style>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<ScrollViewer x:Name="HeadingScroller"
|
||||
x:FieldModifier="private"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
Padding="0 7.5">
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="42" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="0 0 10 0"
|
||||
Background="#01000000"
|
||||
Padding="5 0">
|
||||
<StackPanel x:Name="UserStack"
|
||||
Orientation="Horizontal">
|
||||
|
||||
<Border x:Name="UserStackHighlightBorder"
|
||||
Style="{DynamicResource DetailsPage.TitleSection.Border.NotSelected}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="UserIcon"
|
||||
SelectedInternIcon="misc_user" />
|
||||
<TextBlock x:Name="UserTextBlock" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="UserCopyIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
Background="#01000000"
|
||||
Padding="5 0">
|
||||
<StackPanel x:Name="ComputerStack"
|
||||
Orientation="Horizontal">
|
||||
<Border x:Name="ComputerStackHighlightBorder"
|
||||
Style="{DynamicResource DetailsPage.TitleSection.Border.NotSelected}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="ComputerIcon"
|
||||
SecondaryIconColor="{DynamicResource Color.FunctionMarker}"
|
||||
SelectedInternIcon="misc_computer"
|
||||
Margin="10 0 7.5 0" />
|
||||
<TextBlock x:Name="ComputerTextBlock" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="ComputerSwapIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
Visibility="Visible"
|
||||
BorderBrush="{DynamicResource Color.SoftContrast}"
|
||||
BorderThickness="2 0 0 0"
|
||||
Padding="5 0 0 0" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ComputerCopyIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
Margin="10"
|
||||
CornerRadius="10"
|
||||
Visibility="{Binding ElementName=ComputerSelector, Path=MenuDataList, Converter={StaticResource NullToVisibility}}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="999"
|
||||
MaxWidth="325"
|
||||
HorizontalAlignment="Left">
|
||||
<buc:CustomMenu x:Name="ComputerSelector"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="999"
|
||||
HorizontalAlignment="Left"
|
||||
MaxWidth="325" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Margin="10 0"
|
||||
Background="#01000000"
|
||||
Padding="5 0">
|
||||
<StackPanel x:Name="VirtualSessionStack"
|
||||
Orientation="Horizontal">
|
||||
<Border x:Name="VirtualSessionStackHighlightBorder"
|
||||
Style="{DynamicResource DetailsPage.TitleSection.Border.NotSelected}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="VirtualSessionIcon"
|
||||
SecondaryIconColor="{DynamicResource Color.FunctionMarker}"
|
||||
SelectedInternIcon="misc_computer"
|
||||
Margin="10 0 7.5 0" />
|
||||
<TextBlock x:Name="VirtualSessionTextBlock" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="VirtualSessionSwapIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
Visibility="Visible"
|
||||
BorderBrush="{DynamicResource Color.SoftContrast}"
|
||||
BorderThickness="2 0 0 0"
|
||||
Padding="5 0 0 0" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="VirtualSessionCopyIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
Margin="10"
|
||||
CornerRadius="10"
|
||||
Visibility="{Binding ElementName=VirtualSessionSelector, Path=MenuDataList, Converter={StaticResource NullToVisibility}}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="999"
|
||||
MaxWidth="325"
|
||||
HorizontalAlignment="Left">
|
||||
<buc:CustomMenu x:Name="VirtualSessionSelector"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="999"
|
||||
HorizontalAlignment="Left"
|
||||
MaxWidth="325" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Margin="10 0"
|
||||
Background="#01000000"
|
||||
Padding="5 0">
|
||||
<StackPanel x:Name="MobileDeviceStack"
|
||||
Orientation="Horizontal">
|
||||
<Border x:Name="MobileDeviceStackHighlightBorder"
|
||||
Style="{DynamicResource DetailsPage.TitleSection.Border.NotSelected}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="MobileDeviceIcon"
|
||||
SecondaryIconColor="{DynamicResource Color.FunctionMarker}"
|
||||
SelectedMaterialIcon="ic_smartphone"
|
||||
Margin="10 0 7.5 0" />
|
||||
<TextBlock x:Name="MobileDeviceTextBlock" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="MobileDeviceSwapIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
Visibility="Visible"
|
||||
BorderBrush="{DynamicResource Color.SoftContrast}"
|
||||
BorderThickness="2 0 0 0"
|
||||
Padding="5 0 0 0" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="MobileDeviceCopyIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
Margin="10"
|
||||
CornerRadius="10"
|
||||
Visibility="{Binding ElementName=MobileDeviceSelector, Path=MenuDataList, Converter={StaticResource NullToVisibility}}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Grid.ColumnSpan="999"
|
||||
MaxWidth="325"
|
||||
HorizontalAlignment="Left">
|
||||
<buc:CustomMenu x:Name="MobileDeviceSelector"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="999"
|
||||
HorizontalAlignment="Left"
|
||||
MaxWidth="325" />
|
||||
</Border>
|
||||
<Border Grid.Row="0"
|
||||
Grid.Column="4"
|
||||
Margin="10 0"
|
||||
Background="#01000000"
|
||||
Padding="5 0">
|
||||
<StackPanel x:Name="TicketStack"
|
||||
Orientation="Horizontal">
|
||||
<Border x:Name="TicketStackHighlightBorder"
|
||||
Style="{DynamicResource DetailsPage.TitleSection.Border.NotSelected}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="TicketIcon"
|
||||
IconHeight="25"
|
||||
IconWidth="25"
|
||||
SelectedMaterialIcon="ic_mail"
|
||||
Margin="10 0 7.5 0" />
|
||||
<TextBlock x:Name="TicketTextBlock" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="TicketSwapIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
Visibility="Visible"
|
||||
BorderBrush="{DynamicResource Color.SoftContrast}"
|
||||
BorderThickness="2 0 0 0"
|
||||
Padding="5 0 0 0" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon x:Name="TicketCopyIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
SelectedInternIcon="menuBar_copy" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="EditTicketIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
SelectedMaterialIcon="ic_edit"
|
||||
MouseLeftButtonUp="EditTicketIcon_MouseLeftButtonUp"
|
||||
TouchDown="EditTicketIcon_TouchDown" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="SaveTicketIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
SelectedMaterialIcon="ic_save"
|
||||
Visibility="Collapsed"
|
||||
MouseLeftButtonUp="SaveTicketIcon_MouseLeftButtonUp"
|
||||
TouchDown="SaveTicketIcon_TouchDown" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="UndoTicketIcon"
|
||||
Style="{DynamicResource SwapIconStyle}"
|
||||
SelectedMaterialIcon="ic_undo"
|
||||
Visibility="Collapsed"
|
||||
MouseLeftButtonUp="UndoTicketIcon_MouseLeftButtonUp"
|
||||
TouchDown="UndoTicketIcon_TouchDown" />
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
Margin="10"
|
||||
CornerRadius="10"
|
||||
Visibility="{Binding ElementName=TicketSelector, Path=MenuDataList, Converter={StaticResource NullToVisibility}}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
Grid.ColumnSpan="999"
|
||||
MaxWidth="325"
|
||||
HorizontalAlignment="Left">
|
||||
<buc:CustomMenu x:Name="TicketSelector"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="999"
|
||||
HorizontalAlignment="Left"
|
||||
MaxWidth="325" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,829 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageNavigationHeading : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private cSupportCaseDataProvider dataProvider;
|
||||
|
||||
public cSupportCaseDataProvider DataProvider
|
||||
{
|
||||
get => dataProvider; set
|
||||
{
|
||||
dataProvider = value;
|
||||
if (value != null)
|
||||
{
|
||||
UpdateHeaderHighlights();
|
||||
SetTicketHeadingVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Border> _highlightBorders;
|
||||
|
||||
private void UpdateHeaderHighlights()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var highlightBorder in _highlightBorders)
|
||||
{
|
||||
highlightBorder.ClearValue(BackgroundProperty);
|
||||
|
||||
bool isEmpty = false;
|
||||
|
||||
if (highlightBorder == UserStackHighlightBorder)
|
||||
isEmpty = UserTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Select.User");
|
||||
else if (highlightBorder == ComputerStackHighlightBorder)
|
||||
isEmpty = ComputerTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Select.Computer");
|
||||
else if (highlightBorder == VirtualSessionStackHighlightBorder)
|
||||
isEmpty = VirtualSessionTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Select.VirtualSession");
|
||||
else if (highlightBorder == MobileDeviceStackHighlightBorder)
|
||||
isEmpty = MobileDeviceTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Select.MobileDevice");
|
||||
else if (highlightBorder == TicketStackHighlightBorder)
|
||||
isEmpty = TicketTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Select.Ticket") || TicketTextBlock.Text == cMultiLanguageSupport.GetItem("Header.Create.Ticket");
|
||||
}
|
||||
|
||||
TicketSwapIcon.ClearValue(AdaptableIcon.IconBackgroundColorProperty);
|
||||
ComputerSwapIcon.ClearValue(AdaptableIcon.IconBackgroundColorProperty);
|
||||
|
||||
Border highlightedBorder = null;
|
||||
AdaptableIcon swapIcon = null;
|
||||
|
||||
if (DataProvider?.HealthCardDataHelper.SelectedHealthCard?.InformationClasses is null)
|
||||
return;
|
||||
|
||||
if (DataProvider.HealthCardDataHelper.SelectedHealthCard.InformationClasses.Any(identity => identity is enumFasdInformationClass.Ticket))
|
||||
{
|
||||
highlightedBorder = TicketStackHighlightBorder;
|
||||
swapIcon = TicketSwapIcon;
|
||||
}
|
||||
else if (DataProvider.HealthCardDataHelper.SelectedHealthCard.InformationClasses.Any(identity => identity is enumFasdInformationClass.Computer))
|
||||
{
|
||||
highlightedBorder = ComputerStackHighlightBorder;
|
||||
swapIcon = ComputerSwapIcon;
|
||||
}
|
||||
else if (DataProvider.HealthCardDataHelper.SelectedHealthCard.InformationClasses.Any(identity => identity is enumFasdInformationClass.VirtualSession))
|
||||
{
|
||||
highlightedBorder = VirtualSessionStackHighlightBorder;
|
||||
swapIcon = VirtualSessionSwapIcon;
|
||||
}
|
||||
else if (DataProvider.HealthCardDataHelper.SelectedHealthCard.InformationClasses.Any(identity => identity is enumFasdInformationClass.MobileDevice))
|
||||
{
|
||||
highlightedBorder = MobileDeviceStackHighlightBorder;
|
||||
swapIcon = MobileDeviceSwapIcon;
|
||||
}
|
||||
else if (DataProvider.HealthCardDataHelper.SelectedHealthCard.InformationClasses.Any(identity => identity is enumFasdInformationClass.User))
|
||||
highlightedBorder = UserStackHighlightBorder;
|
||||
|
||||
if (highlightedBorder != null)
|
||||
highlightedBorder.SetResourceReference(BackgroundProperty, "BackgroundColor.Menu.MainCategory");
|
||||
|
||||
if (swapIcon != null)
|
||||
swapIcon.SetResourceReference(AdaptableIcon.IconBackgroundColorProperty, "BackgroundColor.Menu.MainCategory");
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTicketHeadingVisibility()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataProvider is null)
|
||||
return;
|
||||
|
||||
//bool isTicketIntegrationActive = cFasdCockpitCommunicationBase.CockpitUserInfo?.Roles?.Any(role => string.Equals(role, "Cockpit.TicketAgent", StringComparison.OrdinalIgnoreCase)) ?? false;
|
||||
bool isTicketIntegrationActive = cF4SDCockpitXmlConfig.Instance.HealthCardConfig.HealthCards.Values.Any(_e => _e.InformationClasses.Contains(enumFasdInformationClass.Ticket));
|
||||
TicketStack.Visibility = isTicketIntegrationActive ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowsRelations { get; private set; } = false;
|
||||
|
||||
#region HeadingData Dependency Property
|
||||
|
||||
private static void HeadingDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(d is DetailsPageNavigationHeading _me))
|
||||
return;
|
||||
|
||||
if (e.NewValue == null)
|
||||
return;
|
||||
|
||||
_me.ResetControl();
|
||||
_me.SetTicketHeadingVisibility();
|
||||
_me.InitializeHeadings();
|
||||
_me.UpdateHeaderHighlights();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HeadingDataProperty =
|
||||
DependencyProperty.Register("HeadingData", typeof(List<cHeadingDataModel>), typeof(DetailsPageNavigationHeading), new PropertyMetadata(new List<cHeadingDataModel>(), new PropertyChangedCallback(HeadingDataChanged)));
|
||||
|
||||
|
||||
public List<cHeadingDataModel> HeadingData
|
||||
{
|
||||
get { return (List<cHeadingDataModel>)GetValue(HeadingDataProperty); }
|
||||
set { SetValue(HeadingDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HasDirectConnection
|
||||
|
||||
public bool HasDirectConnection
|
||||
{
|
||||
get { return (bool)GetValue(HasDirectConnectionProperty); }
|
||||
set { SetValue(HasDirectConnectionProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HasDirectConnectionProperty =
|
||||
DependencyProperty.Register("HasDirectConnection", typeof(bool), typeof(DetailsPageNavigationHeading), new PropertyMetadata(false, new PropertyChangedCallback(DirectConnectionStatusChanged)));
|
||||
|
||||
private static void DirectConnectionStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DetailsPageNavigationHeading _me))
|
||||
return;
|
||||
|
||||
_me.UpdateDirectConnectionIcon();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly cHeadingDataModel userDataEmpty = new cHeadingDataModel() { IsOnline = false, InformationClass = enumFasdInformationClass.User, HeadingText = "User auswählen" }; //todo: localize
|
||||
private readonly cHeadingDataModel computerDataEmpty = new cHeadingDataModel() { IsOnline = false, InformationClass = enumFasdInformationClass.Computer, HeadingText = cMultiLanguageSupport.GetItem("Header.Select.Computer") };
|
||||
private readonly cHeadingDataModel ticketDataEmpty = new cHeadingDataModel() { IsOnline = false, InformationClass = enumFasdInformationClass.Ticket, HeadingText = cMultiLanguageSupport.GetItem("Header.Select.Ticket") };
|
||||
private readonly cHeadingDataModel virtualSessionDataEmpty = new cHeadingDataModel() { IsOnline = false, InformationClass = enumFasdInformationClass.VirtualSession, HeadingText = cMultiLanguageSupport.GetItem("Header.Select.VirtualSession") };
|
||||
private readonly cHeadingDataModel mobileDeviceDataEmpty = new cHeadingDataModel() { IsOnline = false, InformationClass = enumFasdInformationClass.MobileDevice, HeadingText = cMultiLanguageSupport.GetItem("Header.Select.MobileDevice") };
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageNavigationHeading()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
|
||||
ResetControl();
|
||||
|
||||
_highlightBorders = new List<Border>()
|
||||
{
|
||||
UserStackHighlightBorder,
|
||||
ComputerStackHighlightBorder,
|
||||
TicketStackHighlightBorder,
|
||||
VirtualSessionStackHighlightBorder,
|
||||
MobileDeviceStackHighlightBorder
|
||||
};
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void ResetControl()
|
||||
{
|
||||
try
|
||||
{
|
||||
HeadingScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
|
||||
UserTextBlock.Text = string.Empty;
|
||||
ComputerTextBlock.Text = cMultiLanguageSupport.GetItem("Header.Select.Computer");
|
||||
TicketTextBlock.Text = cMultiLanguageSupport.GetItem("Header.Select.Ticket");
|
||||
VirtualSessionTextBlock.Text = cMultiLanguageSupport.GetItem("Header.Select.VirtualSession");
|
||||
MobileDeviceTextBlock.Text = cMultiLanguageSupport.GetItem("Header.Select.MobileDevice");
|
||||
|
||||
UserIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
ComputerIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
TicketIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
|
||||
UserIcon.Tag = userDataEmpty.InformationClass;
|
||||
ComputerIcon.Tag = computerDataEmpty.InformationClass;
|
||||
TicketIcon.Tag = ticketDataEmpty.InformationClass;
|
||||
VirtualSessionIcon.Tag = virtualSessionDataEmpty.InformationClass;
|
||||
MobileDeviceIcon.Tag = mobileDeviceDataEmpty.InformationClass;
|
||||
|
||||
UserTextBlock.Tag = userDataEmpty.InformationClass;
|
||||
ComputerTextBlock.Tag = computerDataEmpty.InformationClass;
|
||||
TicketTextBlock.Tag = ticketDataEmpty.InformationClass;
|
||||
VirtualSessionTextBlock.Tag = virtualSessionDataEmpty.InformationClass;
|
||||
MobileDeviceTextBlock.Tag = mobileDeviceDataEmpty.InformationClass;
|
||||
|
||||
UserTextBlock.ClearValue(StyleProperty);
|
||||
ComputerTextBlock.ClearValue(StyleProperty);
|
||||
TicketTextBlock.ClearValue(StyleProperty);
|
||||
VirtualSessionTextBlock.ClearValue(StyleProperty);
|
||||
MobileDeviceTextBlock.ClearValue(StyleProperty);
|
||||
|
||||
ComputerSwapIcon.Tag = computerDataEmpty;
|
||||
TicketSwapIcon.Tag = ticketDataEmpty;
|
||||
VirtualSessionSwapIcon.Tag = virtualSessionDataEmpty;
|
||||
MobileDeviceSwapIcon.Tag = mobileDeviceDataEmpty;
|
||||
|
||||
ComputerStackHighlightBorder.Tag = computerDataEmpty;
|
||||
TicketStackHighlightBorder.Tag = ticketDataEmpty;
|
||||
VirtualSessionStackHighlightBorder.Tag = virtualSessionDataEmpty;
|
||||
MobileDeviceStackHighlightBorder.Tag = mobileDeviceDataEmpty;
|
||||
|
||||
ComputerSwapIcon.Style = (Style)FindResource("SwapIconStyle");
|
||||
TicketSwapIcon.Style = (Style)FindResource("SwapIconStyle");
|
||||
VirtualSessionSwapIcon.Style = (Style)FindResource("SwapIconStyle");
|
||||
MobileDeviceSwapIcon.Style = (Style)FindResource("SwapIconStyle");
|
||||
|
||||
ComputerSwapIcon.ClearValue(ToolTipProperty);
|
||||
TicketSwapIcon.ClearValue(ToolTipProperty);
|
||||
VirtualSessionSwapIcon.ClearValue(ToolTipProperty);
|
||||
MobileDeviceSwapIcon.ClearValue(ToolTipProperty);
|
||||
|
||||
SaveTicketIcon.Visibility = Visibility.Collapsed;
|
||||
UndoTicketIcon.Visibility = Visibility.Collapsed;
|
||||
|
||||
UserCopyIcon.ClearValue(VisibilityProperty);
|
||||
ComputerCopyIcon.ClearValue(VisibilityProperty);
|
||||
TicketCopyIcon.ClearValue(VisibilityProperty);
|
||||
VirtualSessionCopyIcon.ClearValue(VisibilityProperty);
|
||||
MobileDeviceCopyIcon.ClearValue(VisibilityProperty);
|
||||
|
||||
ComputerStackHighlightBorder.MouseLeftButtonUp -= SwapIcon_MouseLeftButtonUp;
|
||||
ComputerStackHighlightBorder.TouchDown -= SwapIcon_TouchDown;
|
||||
TicketStackHighlightBorder.MouseLeftButtonUp -= SwapIcon_MouseLeftButtonUp;
|
||||
TicketStackHighlightBorder.TouchDown -= SwapIcon_TouchDown;
|
||||
VirtualSessionStackHighlightBorder.MouseLeftButtonUp -= SwapIcon_MouseLeftButtonUp;
|
||||
VirtualSessionStackHighlightBorder.TouchDown -= SwapIcon_TouchDown;
|
||||
MobileDeviceStackHighlightBorder.MouseLeftButtonUp -= SwapIcon_MouseLeftButtonUp;
|
||||
MobileDeviceStackHighlightBorder.TouchDown -= SwapIcon_TouchDown;
|
||||
|
||||
UserStackHighlightBorder.ClearValue(OpacityProperty);
|
||||
ComputerStackHighlightBorder.ClearValue(OpacityProperty);
|
||||
TicketStackHighlightBorder.ClearValue(OpacityProperty);
|
||||
VirtualSessionStackHighlightBorder.ClearValue(OpacityProperty);
|
||||
MobileDeviceStackHighlightBorder.ClearValue(OpacityProperty);
|
||||
|
||||
SetEditMode(false);
|
||||
|
||||
if (!cFasdCockpitCommunicationBase.Instance.IsDemo())
|
||||
{
|
||||
if (MobileDeviceStack.Parent is UIElement mobileParent)
|
||||
mobileParent.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (VirtualSessionStack.Parent is UIElement virtualParent)
|
||||
virtualParent.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
ResetSelectors();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSelectors()
|
||||
{
|
||||
try
|
||||
{
|
||||
HeadingScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
ShowsRelations = false;
|
||||
ComputerSelector.MenuDataList = null;
|
||||
TicketSelector.MenuDataList = null;
|
||||
VirtualSessionSelector.MenuDataList = null;
|
||||
MobileDeviceSelector.MenuDataList = null;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableElement(FrameworkElement element, string toolTip)
|
||||
{
|
||||
try
|
||||
{
|
||||
element.Style = (Style)FindResource("SwapIconStyleBase");
|
||||
element.ToolTip = toolTip;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeHeadings()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var heading in HeadingData)
|
||||
{
|
||||
bool hasValue = true;
|
||||
AdaptableIcon headingIcon = null;
|
||||
TextBlock headingTextBlock = null;
|
||||
FrameworkElement highlightBoder = null;
|
||||
AdaptableIcon swapIcon = null;
|
||||
AdaptableIcon copyIcon = null;
|
||||
string disableText = null;
|
||||
|
||||
switch (heading.InformationClass)
|
||||
{
|
||||
case enumFasdInformationClass.Computer:
|
||||
headingIcon = ComputerIcon;
|
||||
swapIcon = ComputerSwapIcon;
|
||||
headingTextBlock = ComputerTextBlock;
|
||||
copyIcon = ComputerCopyIcon;
|
||||
highlightBoder = ComputerStackHighlightBorder;
|
||||
hasValue = heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Select.Computer");
|
||||
disableText = cMultiLanguageSupport.GetItem("Header.NotFound.Computers");
|
||||
|
||||
if (!hasValue)
|
||||
{
|
||||
ComputerCopyIcon.Visibility = Visibility.Hidden;
|
||||
ComputerStackHighlightBorder.MouseLeftButtonUp += SwapIcon_MouseLeftButtonUp;
|
||||
ComputerStackHighlightBorder.TouchDown += SwapIcon_TouchDown;
|
||||
}
|
||||
|
||||
break;
|
||||
case enumFasdInformationClass.VirtualSession:
|
||||
headingIcon = VirtualSessionIcon;
|
||||
swapIcon = VirtualSessionSwapIcon;
|
||||
headingTextBlock = VirtualSessionTextBlock;
|
||||
copyIcon = VirtualSessionCopyIcon;
|
||||
highlightBoder = VirtualSessionStackHighlightBorder;
|
||||
hasValue = heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Select.VirtualSession");
|
||||
disableText = cMultiLanguageSupport.GetItem("Header.NotFound.VirtualSession");
|
||||
|
||||
if (!hasValue)
|
||||
{
|
||||
VirtualSessionCopyIcon.Visibility = Visibility.Hidden;
|
||||
VirtualSessionStackHighlightBorder.MouseLeftButtonUp += SwapIcon_MouseLeftButtonUp;
|
||||
VirtualSessionStackHighlightBorder.TouchDown += SwapIcon_TouchDown;
|
||||
}
|
||||
if (heading.IsOnline)
|
||||
VirtualSessionIcon.SelectedMaterialIcon = MaterialIcons.MaterialIconType.ic_cloud_queue;
|
||||
else
|
||||
VirtualSessionIcon.SelectedMaterialIcon = MaterialIcons.MaterialIconType.ic_cloud_off;
|
||||
break;
|
||||
|
||||
case enumFasdInformationClass.MobileDevice:
|
||||
headingIcon = MobileDeviceIcon;
|
||||
swapIcon = MobileDeviceSwapIcon;
|
||||
headingTextBlock = MobileDeviceTextBlock;
|
||||
copyIcon = MobileDeviceCopyIcon;
|
||||
highlightBoder = MobileDeviceStackHighlightBorder;
|
||||
hasValue = heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Select.MobileDevice");
|
||||
disableText = cMultiLanguageSupport.GetItem("Header.NotFound.MobileDevice");
|
||||
|
||||
if (!hasValue)
|
||||
{
|
||||
MobileDeviceCopyIcon.Visibility = Visibility.Hidden;
|
||||
MobileDeviceStackHighlightBorder.MouseLeftButtonUp += SwapIcon_MouseLeftButtonUp;
|
||||
MobileDeviceStackHighlightBorder.TouchDown += SwapIcon_TouchDown;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case enumFasdInformationClass.User:
|
||||
headingIcon = UserIcon;
|
||||
headingTextBlock = UserTextBlock;
|
||||
copyIcon = UserCopyIcon;
|
||||
hasValue = heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Select.User");
|
||||
|
||||
if (!hasValue)
|
||||
UserCopyIcon.Visibility = Visibility.Hidden;
|
||||
|
||||
break;
|
||||
case enumFasdInformationClass.Ticket:
|
||||
headingTextBlock = TicketTextBlock;
|
||||
swapIcon = TicketSwapIcon;
|
||||
|
||||
if (heading.IsOnline)
|
||||
TicketIcon.SelectedMaterialIcon = MaterialIcons.MaterialIconType.ic_drafts;
|
||||
else
|
||||
TicketIcon.SelectedMaterialIcon = MaterialIcons.MaterialIconType.ic_mail;
|
||||
|
||||
copyIcon = TicketCopyIcon;
|
||||
highlightBoder = TicketStackHighlightBorder;
|
||||
hasValue = heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Select.Ticket") && heading.HeadingText != cMultiLanguageSupport.GetItem("Header.Create.Ticket");
|
||||
disableText = cMultiLanguageSupport.GetItem("Header.NotFound.Tickets");
|
||||
|
||||
if (!hasValue)
|
||||
{
|
||||
TicketCopyIcon.Visibility = Visibility.Collapsed;
|
||||
EditTicketIcon.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (DataProvider?.CaseRelations?.TryGetValue(heading.InformationClass, out var storedRelations) ?? false)
|
||||
if (storedRelations != null && storedRelations.Count > 0)
|
||||
break;
|
||||
|
||||
heading.HeadingText = cMultiLanguageSupport.GetItem("Header.Create.Ticket");
|
||||
break;
|
||||
}
|
||||
|
||||
if (headingIcon != null)
|
||||
{
|
||||
if (heading.IsOnline)
|
||||
{
|
||||
headingIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Green");
|
||||
headingIcon.ToolTip = cMultiLanguageSupport.GetItem("Header.IsOnline");
|
||||
}
|
||||
else
|
||||
{
|
||||
headingIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
headingIcon.ToolTip = cMultiLanguageSupport.GetItem("Header.IsOffline");
|
||||
}
|
||||
}
|
||||
|
||||
if (headingTextBlock != null && string.IsNullOrWhiteSpace(heading.HeadingText) is false)
|
||||
{
|
||||
headingTextBlock.Text = heading.HeadingText;
|
||||
}
|
||||
|
||||
if (highlightBoder != null)
|
||||
{
|
||||
highlightBoder.Tag = new cSwapCaseInfo() { SelectedCaseInformationClass = heading.InformationClass, HeadingDatas = HeadingData };
|
||||
}
|
||||
|
||||
if (copyIcon != null)
|
||||
{
|
||||
copyIcon.Tag = heading.HeadingText;
|
||||
|
||||
if (!hasValue)
|
||||
copyIcon.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
if (swapIcon != null)
|
||||
{
|
||||
swapIcon.Tag = new cSwapCaseInfo() { SelectedCaseInformationClass = heading.InformationClass, HeadingDatas = HeadingData };
|
||||
|
||||
if (DataProvider?.CaseRelations is null || DataProvider.CaseRelations.TryGetValue(heading.InformationClass, out var storedRelations) is false
|
||||
|| storedRelations is null || storedRelations.Count == 0)
|
||||
{
|
||||
DisableElement(swapIcon, disableText);
|
||||
headingTextBlock.SetResourceReference(StyleProperty, "DetailsPage.TitleSection.Header.Base");
|
||||
highlightBoder.Opacity = 0.7;
|
||||
|
||||
highlightBoder.MouseLeftButtonUp -= SwapIcon_MouseLeftButtonUp;
|
||||
highlightBoder.TouchDown -= SwapIcon_TouchDown;
|
||||
}
|
||||
else if (!hasValue)
|
||||
{
|
||||
highlightBoder.MouseLeftButtonUp += SwapIcon_MouseLeftButtonUp;
|
||||
highlightBoder.TouchDown += SwapIcon_TouchDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDirectConnectionIcon()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HasDirectConnection)
|
||||
{
|
||||
ComputerIcon.SelectedInternIcon = enumInternIcons.misc_directConnection;
|
||||
ComputerIcon.IconHeight = 35;
|
||||
ComputerIcon.IconWidth = 35;
|
||||
}
|
||||
else
|
||||
{
|
||||
ComputerIcon.SelectedInternIcon = enumInternIcons.misc_computer;
|
||||
ComputerIcon.ClearValue(AdaptableIcon.IconHeightProperty);
|
||||
ComputerIcon.ClearValue(AdaptableIcon.IconWidthProperty);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
EditTicketIcon.Visibility = Visibility.Collapsed;
|
||||
SaveTicketIcon.Visibility = Visibility.Collapsed;
|
||||
UndoTicketIcon.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region HeadingIcon Click
|
||||
|
||||
public event EventHandler HeadingIconClickedEvent;
|
||||
|
||||
private void HeadingIcon_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataProvider.HealthCardDataHelper.IsInEditMode)
|
||||
{
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show("Do you want to save changes and continue?", "Open changes", enumHealthCardStateLevel.Warning, Window.GetWindow(this), true);
|
||||
|
||||
if (dialogResult == false)
|
||||
return;
|
||||
else
|
||||
DataProvider.HealthCardDataHelper.IsInEditMode = false;
|
||||
}
|
||||
|
||||
HeadingIconClickedEvent.Invoke(sender, new EventArgs());
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HeadingIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
HeadingIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void HeadingIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
HeadingIcon_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SwapIcon Click
|
||||
|
||||
private void SwapIcon_Click(object sender)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (!(senderElement.Tag is cSwapCaseInfo swapCaseData))
|
||||
return;
|
||||
|
||||
CustomMenu location = null;
|
||||
ResetSelectors();
|
||||
|
||||
switch (swapCaseData.SelectedCaseInformationClass)
|
||||
{
|
||||
case enumFasdInformationClass.Computer:
|
||||
location = ComputerSelector;
|
||||
break;
|
||||
case enumFasdInformationClass.Ticket:
|
||||
location = TicketSelector;
|
||||
break;
|
||||
case enumFasdInformationClass.VirtualSession:
|
||||
location = VirtualSessionSelector;
|
||||
break;
|
||||
case enumFasdInformationClass.MobileDevice:
|
||||
location = MobileDeviceSelector;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
var action = new cShowHeadingSelectionMenuAction();
|
||||
ShowsRelations = true;
|
||||
cUiActionBase.RaiseEvent(new cShowHeadingSelectionMenuAction(), this, sender);
|
||||
DoShowRelations(swapCaseData, location);
|
||||
//Dispatcher.Invoke(async () => await action.RunUiActionAsync(sender, location, false, DataProvider));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DoShowRelations(cSwapCaseInfo swapCaseData, CustomMenu customMenu)
|
||||
{
|
||||
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var selectedHeadingData = swapCaseData.HeadingDatas.FirstOrDefault(data => data.InformationClass == swapCaseData.SelectedCaseInformationClass);
|
||||
|
||||
if (selectedHeadingData is null)
|
||||
return;
|
||||
|
||||
HeadingScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
|
||||
|
||||
customMenu.Visibility = Visibility.Visible;
|
||||
|
||||
List<cMenuDataBase> quickActionList = new List<cMenuDataBase>();
|
||||
|
||||
if (dataProvider.CaseRelations != null && dataProvider.CaseRelations.TryGetValue(swapCaseData.SelectedCaseInformationClass, out var storedRelations))
|
||||
{
|
||||
foreach (var storedRelation in storedRelations)
|
||||
{
|
||||
bool isMatchingRelation = IsMatchingRelation(storedRelation, swapCaseData.HeadingDatas);
|
||||
quickActionList.Add(new cMenuDataSearchRelation(storedRelation)
|
||||
{
|
||||
IsMatchingRelation = isMatchingRelation,
|
||||
IsUsedForCaseEnrichment = true,
|
||||
UiAction = new cChangeHealthCardAction(storedRelation)
|
||||
});
|
||||
}
|
||||
}
|
||||
if (quickActionList.Count > 0)
|
||||
customMenu.MenuDataList = quickActionList;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMatchingRelation(cF4sdApiSearchResultRelation relationData, List<cHeadingDataModel> headingData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (relationData.Type is enumF4sdSearchResultClass.Ticket)
|
||||
if (relationData.Infos.TryGetValue("Asset", out string assetName))
|
||||
return headingData.Any(heading => !string.IsNullOrWhiteSpace(heading.HeadingText) && heading.HeadingText.Equals(assetName));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SwapIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SwapIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void SwapIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SwapIcon_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyIcon Click
|
||||
|
||||
private async Task CopyIcon_ClickAsync(object sender)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (!(sender is AdaptableIcon senderIcon))
|
||||
return;
|
||||
|
||||
if (senderIcon.Tag is null)
|
||||
return;
|
||||
|
||||
System.Windows.Forms.Clipboard.SetText(senderIcon.Tag.ToString());
|
||||
|
||||
await cUtility.ChangeIconToCheckAsync(senderIcon);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private async void CopyIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) => await CopyIcon_ClickAsync(sender);
|
||||
private async void CopyIcon_TouchDown(object sender, TouchEventArgs e) => await CopyIcon_ClickAsync(sender);
|
||||
|
||||
#endregion
|
||||
|
||||
#region EditTicket Click
|
||||
|
||||
private void EditTicketIcon_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
dataProvider.HealthCardDataHelper.IsInEditMode = true;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void EditTicketIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EditTicketIcon_Click();
|
||||
}
|
||||
|
||||
private void EditTicketIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
EditTicketIcon_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SaveTicket Click
|
||||
|
||||
private void SaveTicketIcon_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
dataProvider.HealthCardDataHelper.IsInEditMode = false;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveTicketIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SaveTicketIcon_Click();
|
||||
}
|
||||
|
||||
private void SaveTicketIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SaveTicketIcon_Click();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UndoTicket Click
|
||||
|
||||
private void UndoTicketIcon_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show("Do you really want to undo changes?\nAll changes will get lost.", "Undo changes", enumHealthCardStateLevel.Error, Window.GetWindow(this), true);
|
||||
|
||||
if (dialogResult is true)
|
||||
dataProvider.HealthCardDataHelper.IsInEditMode = false;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UndoTicketIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UndoTicketIcon_Click();
|
||||
}
|
||||
|
||||
private void UndoTicketIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
UndoTicketIcon_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageRefreshControl"
|
||||
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:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:uc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
x:Name="RefreshControl"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel x:Name="RefreshStackPanel"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.RefreshNow}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ControlBar.Action}"
|
||||
MouseUp="RefreshDetailsButton_MouseUp"
|
||||
TouchDown="RefreshDetailsButton_TouchDown" />
|
||||
|
||||
<TextBlock x:Name="LastDataRequestTextBlock"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.ControlBar.Text}"
|
||||
Margin="5 0" />
|
||||
|
||||
<uc:LoadingDataIndicator x:Name="LoadingDataIndicatorUc"
|
||||
Visibility="{Binding ElementName=RefreshControl, Path=IsDataIncomplete, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,127 @@
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics;
|
||||
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 System.Windows.Threading;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageRefreshControl : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private DispatcherTimer timer;
|
||||
|
||||
public cSupportCaseDataProvider DataProvider { get; set; }
|
||||
|
||||
#region IsDataIncomplete DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty IsDataIncompleteProperty =
|
||||
DependencyProperty.Register("IsDataIncomplete", typeof(bool), typeof(DetailsPageRefreshControl), new PropertyMetadata(true));
|
||||
|
||||
public bool IsDataIncomplete
|
||||
{
|
||||
get { return (bool)GetValue(IsDataIncompleteProperty); }
|
||||
set { SetValue(IsDataIncompleteProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler RefreshButtonClicked;
|
||||
|
||||
public DetailsPageRefreshControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
~DetailsPageRefreshControl()
|
||||
{
|
||||
timer.Stop();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
|
||||
timer = new DispatcherTimer(TimeSpan.FromSeconds(15), DispatcherPriority.Loaded, new EventHandler((s, args) =>
|
||||
{
|
||||
try { UpdateLastDataRequestTime(); } catch { }
|
||||
}), Dispatcher.CurrentDispatcher);
|
||||
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public void UpdateLastDataRequestTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
string newText = string.Empty;
|
||||
if (DataProvider?.HealthCardDataHelper?.LastDataRequest is null)
|
||||
{
|
||||
LastDataRequestTextBlock.Text = newText;
|
||||
return;
|
||||
}
|
||||
|
||||
string dateAddtionFormat = cMultiLanguageSupport.GetItem("DetailsPage.LastRefresh");
|
||||
string timeText = string.Empty;
|
||||
|
||||
var from = DataProvider?.HealthCardDataHelper?.LastDataRequest;
|
||||
if (from == null)
|
||||
return;
|
||||
|
||||
TimeSpan timeSpan = DateTime.Now - from.Value;
|
||||
|
||||
if (timeSpan.TotalHours < 1)
|
||||
timeText = $"< {Math.Ceiling(timeSpan.TotalMinutes)} min";
|
||||
else
|
||||
timeText = $"< {Math.Ceiling(timeSpan.TotalHours)} h";
|
||||
|
||||
newText = string.Format(dateAddtionFormat, timeText);
|
||||
|
||||
LastDataRequestTextBlock.Text = newText;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region RefreshDetails
|
||||
|
||||
private void RefreshDetails_Click()
|
||||
{
|
||||
LoadingDataIndicatorUc.LoadingText = cMultiLanguageSupport.GetItem("DetailsPage.Refresh");
|
||||
RefreshButtonClicked?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void RefreshDetailsButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
RefreshDetails_Click();
|
||||
}
|
||||
|
||||
private void RefreshDetailsButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
RefreshDetails_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageSettings"
|
||||
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="270"
|
||||
d:DesignWidth="400"
|
||||
x:Name="SettingsUserControl"
|
||||
MinHeight="250"
|
||||
MinWidth="400"
|
||||
Initialized="UserControl_Initialized">
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius"
|
||||
Value="7.5" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
<Setter Property="Margin"
|
||||
Value="5" />
|
||||
<Setter Property="Padding"
|
||||
Value="10,5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Margin"
|
||||
Value="0, 0, 20, 0" />
|
||||
<Setter Property="FontSize"
|
||||
Value="14" />
|
||||
<Setter Property="FontFamily"
|
||||
Value="Calibri" />
|
||||
<Setter Property="FontWeight"
|
||||
Value="Bold" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<Border>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Color Mode:" />
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="BorderPadding"
|
||||
Value="0" />
|
||||
<Setter Property="Margin"
|
||||
Value="0, 5, 10, 0" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="20" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="20" />
|
||||
|
||||
<EventSetter Event="MouseUp"
|
||||
Handler="ColorModeIcon_MouseUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="ColorModeIcon_TouchDown" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<ico:AdaptableIcon x:Name="LightModeIcon"
|
||||
Tag="LightMode"
|
||||
IconHeight="25"
|
||||
IconWidth="25"
|
||||
SelectedInternIcon="style_sunFilled" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="DarkModeIcon"
|
||||
Tag="DarkMode"
|
||||
SelectedInternIcon="style_moonFilled" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock>Zoom:</TextBlock>
|
||||
<TextBox x:Name="ScaleValueTextBox"
|
||||
Text="{Binding Path=ScaleValue, StringFormat=N2, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
|
||||
BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Padding="2" />
|
||||
</StackPanel>
|
||||
|
||||
<Slider x:Name="SizeSlider"
|
||||
Orientation="Horizontal"
|
||||
Minimum="0"
|
||||
Maximum="2.50"
|
||||
Value="{Binding Path=ScaleValue, Mode=TwoWay}"
|
||||
Margin="0,3"
|
||||
TickFrequency="0.01" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border>
|
||||
<StackPanel>
|
||||
|
||||
<TextBlock Text="Hightlight Colors:" />
|
||||
|
||||
<StackPanel x:Name="HighlightColorStack"
|
||||
Orientation="Horizontal"
|
||||
Margin="-5,0,0,0">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="5" />
|
||||
<Setter Property="Height"
|
||||
Value="25" />
|
||||
<Setter Property="Width"
|
||||
Value="25" />
|
||||
<Setter Property="Margin"
|
||||
Value="5" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="2.5" />
|
||||
|
||||
<EventSetter Event="MouseEnter"
|
||||
Handler="HightlightColorBorder_MouseEnter" />
|
||||
<EventSetter Event="MouseLeave"
|
||||
Handler="HightlightColorBorder_MouseLeave" />
|
||||
<EventSetter Event="MouseUp"
|
||||
Handler="HighlightColorBorder_MouseUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="HighlightColorBorder_TouchDown" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Height"
|
||||
Value="30" />
|
||||
<Setter Property="Width"
|
||||
Value="30" />
|
||||
<Setter Property="Margin"
|
||||
Value="2.5" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<Border x:Name="HighlightBlue"
|
||||
Background="{DynamicResource Color.Blue}"
|
||||
BorderBrush="{DynamicResource Color.Menu.Icon}"
|
||||
Tag="Blue" />
|
||||
<Border x:Name="HighlightGreen"
|
||||
Background="{DynamicResource Color.Green}"
|
||||
BorderBrush="{DynamicResource Color.Menu.Icon}"
|
||||
Tag="Green" />
|
||||
<Border x:Name="HighlightOrange"
|
||||
Background="{DynamicResource Color.Orange}"
|
||||
BorderBrush="{DynamicResource Color.Menu.Icon}"
|
||||
Tag="Orange" />
|
||||
<Border x:Name="HighlightRed"
|
||||
Background="{DynamicResource Color.Red}"
|
||||
BorderBrush="{DynamicResource Color.Menu.Icon}"
|
||||
Tag="Red" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,379 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
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 FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageSettings : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private Dictionary<enumHighlightColor, bool> highlightColorActivationStatus;
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageSettings()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetUpSettingsControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
enumAppColorMode selectedAppColorMode = cFasdCockpitConfig.Instance.DetailsPageColorMode;
|
||||
SelectAppColorMode(selectedAppColorMode);
|
||||
|
||||
foreach (Border highlightBorder in HighlightColorStack.Children)
|
||||
{
|
||||
HighlightColorBorder_Click(highlightBorder);
|
||||
HighlightColorBorder_Click(highlightBorder);
|
||||
}
|
||||
|
||||
SizeSlider.Value = cFasdCockpitConfig.Instance.DetailsPageZoom / 100.0;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
private void UserControl_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
highlightColorActivationStatus = !string.IsNullOrEmpty(cFasdCockpitConfig.Instance.HighlightColorVisibility) ?
|
||||
JsonConvert.DeserializeObject<Dictionary<enumHighlightColor, bool>>(cFasdCockpitConfig.Instance.HighlightColorVisibility) :
|
||||
new Dictionary<enumHighlightColor, bool>()
|
||||
{
|
||||
{ enumHighlightColor.blue, true},
|
||||
{ enumHighlightColor.green, true},
|
||||
{ enumHighlightColor.orange, true},
|
||||
{ enumHighlightColor.red, true}
|
||||
};
|
||||
|
||||
if (DesignerProperties.GetIsInDesignMode(this))
|
||||
return;
|
||||
|
||||
SetUpSettingsControls();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region CloseButton
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
SettingsUserControl.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectColorMode
|
||||
|
||||
private void SelectAppColorMode(enumAppColorMode appColorMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
string src = "";
|
||||
|
||||
switch (appColorMode)
|
||||
{
|
||||
case enumAppColorMode.DarkMode:
|
||||
LightModeIcon.SelectedInternIcon = enumInternIcons.style_sun;
|
||||
LightModeIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
DarkModeIcon.SelectedInternIcon = enumInternIcons.style_moonFilled;
|
||||
DarkModeIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon.Hover");
|
||||
|
||||
src = @"ResourceDictionaries\DarkModeResources.xaml";
|
||||
break;
|
||||
case enumAppColorMode.LightMode:
|
||||
LightModeIcon.SelectedInternIcon = enumInternIcons.style_sunFilled;
|
||||
LightModeIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon.Hover");
|
||||
DarkModeIcon.SelectedInternIcon = enumInternIcons.style_moon;
|
||||
DarkModeIcon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
|
||||
src = @"ResourceDictionaries\LightModeResources.xaml";
|
||||
break;
|
||||
default:
|
||||
LightModeIcon.SelectedInternIcon = enumInternIcons.style_sunFilled;
|
||||
DarkModeIcon.SelectedInternIcon = enumInternIcons.style_moon;
|
||||
LightModeIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon.Hover");
|
||||
break;
|
||||
}
|
||||
|
||||
cFasdCockpitConfig.Instance.DetailsPageColorMode = appColorMode;
|
||||
cFasdCockpitConfig.Instance.Save("DetailsPageColorMode");
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Insert(0, new ResourceDictionary { Source = new Uri(src, UriKind.Relative) });
|
||||
Application.Current.Resources.MergedDictionaries.Remove(Application.Current.Resources.MergedDictionaries[1]);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorModeIcon_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is FrameworkElement senderFrameworkElement)
|
||||
{
|
||||
string senderTag = senderFrameworkElement.Tag.ToString().ToLower();
|
||||
|
||||
switch (senderTag)
|
||||
{
|
||||
case "darkmode":
|
||||
SelectAppColorMode(enumAppColorMode.DarkMode);
|
||||
break;
|
||||
case "lightmode":
|
||||
SelectAppColorMode(enumAppColorMode.LightMode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorModeIcon_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ColorModeIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void ColorModeIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ColorModeIcon_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectHighlightColor
|
||||
|
||||
private void SetHighlightColor(enumHighlightColor selectedColor, bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
Border selectedBorder = new Border();
|
||||
string colorReference = "";
|
||||
|
||||
switch (selectedColor)
|
||||
{
|
||||
case enumHighlightColor.blue:
|
||||
selectedBorder = HighlightBlue;
|
||||
colorReference = "Color.Blue";
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
selectedBorder = HighlightGreen;
|
||||
colorReference = "Color.Green";
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
selectedBorder = HighlightOrange;
|
||||
colorReference = "Color.Orange";
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
selectedBorder = HighlightRed;
|
||||
colorReference = "Color.Red";
|
||||
break;
|
||||
}
|
||||
|
||||
selectedBorder.ClearValue(BorderBrushProperty);
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
selectedBorder.SetResourceReference(BorderBrushProperty, "Color.Menu.Icon");
|
||||
selectedBorder.SetResourceReference(BackgroundProperty, colorReference);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedBorder.SetResourceReference(BorderBrushProperty, colorReference);
|
||||
selectedBorder.Background = Brushes.Transparent;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HightlightColorBorder_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is FrameworkElement senderFrameworkElement)
|
||||
{
|
||||
string tagValue = senderFrameworkElement.Tag.ToString().ToLower();
|
||||
|
||||
switch (tagValue)
|
||||
{
|
||||
case "blue":
|
||||
SetHighlightColor(enumHighlightColor.blue, !highlightColorActivationStatus[enumHighlightColor.blue]);
|
||||
break;
|
||||
case "green":
|
||||
SetHighlightColor(enumHighlightColor.green, !highlightColorActivationStatus[enumHighlightColor.green]);
|
||||
break;
|
||||
case "orange":
|
||||
SetHighlightColor(enumHighlightColor.orange, !highlightColorActivationStatus[enumHighlightColor.orange]);
|
||||
break;
|
||||
case "red":
|
||||
SetHighlightColor(enumHighlightColor.red, !highlightColorActivationStatus[enumHighlightColor.red]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HightlightColorBorder_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is FrameworkElement senderFrameworkElement)
|
||||
{
|
||||
string tagValue = senderFrameworkElement.Tag.ToString().ToLower();
|
||||
|
||||
switch (tagValue)
|
||||
{
|
||||
case "blue":
|
||||
SetHighlightColor(enumHighlightColor.blue, highlightColorActivationStatus[enumHighlightColor.blue]);
|
||||
break;
|
||||
case "green":
|
||||
SetHighlightColor(enumHighlightColor.green, highlightColorActivationStatus[enumHighlightColor.green]);
|
||||
break;
|
||||
case "orange":
|
||||
SetHighlightColor(enumHighlightColor.orange, highlightColorActivationStatus[enumHighlightColor.orange]);
|
||||
break;
|
||||
case "red":
|
||||
SetHighlightColor(enumHighlightColor.red, highlightColorActivationStatus[enumHighlightColor.red]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HighlightColorBorder_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
enumHighlightColor clickedHighlightColor = enumHighlightColor.none;
|
||||
|
||||
if (sender is FrameworkElement senderFrameworkElement)
|
||||
{
|
||||
switch (senderFrameworkElement.Tag.ToString().ToLower())
|
||||
{
|
||||
case "blue":
|
||||
clickedHighlightColor = enumHighlightColor.blue;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Blue"] = Brushes.Transparent;
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Blue"] = FindResource("Color.Blue");
|
||||
break;
|
||||
case "green":
|
||||
clickedHighlightColor = enumHighlightColor.green;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Green"] = Brushes.Transparent;
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Green"] = FindResource("Color.Green");
|
||||
break;
|
||||
case "orange":
|
||||
clickedHighlightColor = enumHighlightColor.orange;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Orange"] = Brushes.Transparent;
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Orange"] = FindResource("Color.Orange");
|
||||
break;
|
||||
case "red":
|
||||
clickedHighlightColor = enumHighlightColor.red;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Red"] = Brushes.Transparent;
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Red"] = FindResource("Color.Red");
|
||||
break;
|
||||
}
|
||||
|
||||
highlightColorActivationStatus[clickedHighlightColor] = !highlightColorActivationStatus[clickedHighlightColor];
|
||||
|
||||
string jsonText = JsonConvert.SerializeObject(highlightColorActivationStatus, Formatting.Indented);
|
||||
cFasdCockpitConfig.Instance.HighlightColorVisibility = jsonText;
|
||||
cFasdCockpitConfig.Instance.Save("HighlightColorVisibility");
|
||||
|
||||
SetHighlightColor(clickedHighlightColor, highlightColorActivationStatus[clickedHighlightColor]);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void HighlightColorBorder_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
HighlightColorBorder_Click(sender);
|
||||
}
|
||||
|
||||
private void HighlightColorBorder_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
HighlightColorBorder_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageWidget"
|
||||
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="300"
|
||||
d:DesignWidth="455"
|
||||
Name="_this"
|
||||
Initialized="UserControl_Initialized">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource BackgroundColor.Menu.SubCategory.Hover}" />
|
||||
<Setter Property="Padding"
|
||||
Value="7.5 5" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<Style.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius"
|
||||
Value="7.5" />
|
||||
</Style>
|
||||
</Style.Resources>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="WidgetGrid"
|
||||
MinHeight="{DynamicResource DetailsPage.Widget.MinHeight}"
|
||||
Height="{Binding ElementName=_this, Path=WidgetHeight}">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MinWidth="{DynamicResource DetailsPage.Widget.Title.MinWidth}" />
|
||||
<ColumnDefinition MinWidth="{DynamicResource DetailsPage.Widget.Value.MinWidth}"
|
||||
MaxWidth="{DynamicResource DetailsPage.Widget.Value.MaxWidth}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border x:Name="WidgetTitleBorder" x:FieldModifier="private"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="100"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
|
||||
CornerRadius="10,0,0,10" />
|
||||
|
||||
<Border x:Name="WidgetDetailsBorder" x:FieldModifier="private"
|
||||
Grid.Column="1"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="100"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Value}"
|
||||
CornerRadius="0,10,10,0" />
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,645 @@
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageWidget : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region WidgetGeometry DependencyProperty
|
||||
|
||||
private static bool DidGeometryDataChange(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
bool didGeometryChange = false;
|
||||
|
||||
if (e.OldValue != null && e.NewValue != null)
|
||||
{
|
||||
var oldGeometry = e.OldValue as DetailsPageWidgetGeometryModel;
|
||||
var newGeometry = e.NewValue as DetailsPageWidgetGeometryModel;
|
||||
|
||||
didGeometryChange = newGeometry.WidgetTitleCount != oldGeometry.WidgetTitleCount || didGeometryChange;
|
||||
didGeometryChange = newGeometry.WidgetDetailCount != oldGeometry.WidgetDetailCount || didGeometryChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
|
||||
return didGeometryChange;
|
||||
}
|
||||
|
||||
private static void GeometryChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DidGeometryDataChange(e) is false)
|
||||
return;
|
||||
|
||||
var _me = d as DetailsPageWidget;
|
||||
_me.ClearControls();
|
||||
_me.InitializeWidgetGeometry();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty WidgetGeometryProperty =
|
||||
DependencyProperty.Register("WidgetGeometry", typeof(DetailsPageWidgetGeometryModel), typeof(DetailsPageWidget), new PropertyMetadata(new DetailsPageWidgetGeometryModel(), new PropertyChangedCallback(GeometryChangedCallback)));
|
||||
|
||||
public DetailsPageWidgetGeometryModel WidgetGeometry
|
||||
{
|
||||
get { return (DetailsPageWidgetGeometryModel)GetValue(WidgetGeometryProperty); }
|
||||
set { SetValue(WidgetGeometryProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WidgetData DependencyProperty
|
||||
|
||||
private static void RefreshDataCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailsPageWidget _me)
|
||||
{
|
||||
_me.UpdateWidgetControls();
|
||||
_me.RefreshData();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty WidgetDataProperty =
|
||||
DependencyProperty.Register("WidgetData", typeof(List<cWidgetValueModel>), typeof(DetailsPageWidget), new PropertyMetadata(new List<cWidgetValueModel>(), new PropertyChangedCallback(RefreshDataCallback)));
|
||||
|
||||
public List<cWidgetValueModel> WidgetData
|
||||
{
|
||||
get { return (List<cWidgetValueModel>)GetValue(WidgetDataProperty); }
|
||||
set { SetValue(WidgetDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WidgetHeight DependencyProperty
|
||||
|
||||
public static readonly DependencyProperty WidgetHeightProperty =
|
||||
DependencyProperty.Register("WidgetHeight", typeof(double), typeof(DetailsPageWidget), new PropertyMetadata(50.0, new PropertyChangedCallback(RefreshWidgetHeightCallback)));
|
||||
|
||||
public double WidgetHeight
|
||||
{
|
||||
get { return (double)GetValue(WidgetHeightProperty); }
|
||||
set { SetValue(WidgetHeightProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageWidget()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region SetUpControls
|
||||
|
||||
#region Control Lists
|
||||
|
||||
private readonly List<FrameworkElement> TitleControls = new List<FrameworkElement>();
|
||||
private readonly List<FunctionMarker> TitleFunctionMarkerControls = new List<FunctionMarker>();
|
||||
private readonly List<FrameworkElement> ValueControls = new List<FrameworkElement>();
|
||||
private readonly List<FunctionMarker> ValueFunctionMarkerControls = new List<FunctionMarker>();
|
||||
private readonly List<EditWidgetValueControl> EditControls = new List<EditWidgetValueControl>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear Controls and ControlLists
|
||||
|
||||
private void ClearControls()
|
||||
{
|
||||
TitleControls.Clear();
|
||||
TitleFunctionMarkerControls.Clear();
|
||||
ValueControls.Clear();
|
||||
ValueFunctionMarkerControls.Clear();
|
||||
EditControls.Clear();
|
||||
WidgetGrid.RowDefinitions.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetUp Functions
|
||||
|
||||
private void InitializeWidgetGeometry()
|
||||
{
|
||||
try
|
||||
{
|
||||
SetUpTitleRows(WidgetGeometry.WidgetTitleCount);
|
||||
SetUpValueRows(WidgetGeometry.WidgetDetailCount);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpTitleRows(int rowsToAdd)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TitleControls.Count == 0)
|
||||
WidgetGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
|
||||
|
||||
for (int i = 0; i < rowsToAdd; i++)
|
||||
{
|
||||
WidgetGrid.RowDefinitions.Insert(TitleControls.Count, new RowDefinition { Height = GridLength.Auto });
|
||||
|
||||
StackPanel titleStackPanel = new StackPanel() { Orientation = Orientation.Horizontal };
|
||||
|
||||
TitleFunctionMarkerControls.Add(FunctionMarker.SetUpFunctionMarker(titleStackPanel, new FunctionMarker.FunctionMarkerClick(WidgetDetailsTitleFunctionMarker_Click)));
|
||||
|
||||
TextBlock title = new TextBlock() { Style = widgetTitleStyle };
|
||||
title.Margin = new Thickness(0, 0, 0, 0);
|
||||
titleStackPanel.Children.Add(title);
|
||||
TitleControls.Add(title);
|
||||
|
||||
Grid.SetRow(titleStackPanel, TitleControls.Count - 1);
|
||||
Grid.SetColumn(titleStackPanel, 0);
|
||||
|
||||
WidgetGrid.Children.Add(titleStackPanel);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpValueRows(int rowsToAdd)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < rowsToAdd; i++)
|
||||
{
|
||||
StackPanel valueDockPanel = new StackPanel() { Orientation = Orientation.Horizontal };
|
||||
|
||||
var valueFunctionMarker = FunctionMarker.SetUpFunctionMarker(valueDockPanel, new FunctionMarker.FunctionMarkerClick(WidgetDetailsValueFunctionMarker_Click));
|
||||
ValueFunctionMarkerControls.Add(valueFunctionMarker);
|
||||
valueFunctionMarker.Margin = new Thickness(-8, 0, -15, 0);
|
||||
|
||||
TextBlock valueTextBlock = new TextBlock() { Style = widgetValueStyle };
|
||||
ValueControls.Add(valueTextBlock);
|
||||
valueDockPanel.Children.Add(valueTextBlock);
|
||||
|
||||
Grid.SetRow(valueDockPanel, ValueControls.Count - 1);
|
||||
Grid.SetColumn(valueDockPanel, 1);
|
||||
|
||||
WidgetGrid.Children.Add(valueDockPanel);
|
||||
|
||||
EditWidgetValueControl editControl = new EditWidgetValueControl() { Visibility = Visibility.Collapsed, Margin = new Thickness(10, 0, 10, 0), ParentElement = WidgetGrid };
|
||||
var maxWidthValue = FindResource("DetailsPage.Widget.Value.MaxWidth");
|
||||
|
||||
if (maxWidthValue != null && maxWidthValue is double maxWidth)
|
||||
editControl.MaxWidth = maxWidth - 7.5 - 7.5;
|
||||
|
||||
EditControls.Add(editControl);
|
||||
|
||||
Grid.SetRow(editControl, EditControls.Count - 1);
|
||||
Grid.SetColumn(editControl, 1);
|
||||
|
||||
WidgetGrid.Children.Add(editControl);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Controls Functions
|
||||
|
||||
private void UpdateWidgetControls()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (WidgetData == null)
|
||||
return;
|
||||
|
||||
UpdateWidgetTitleControls();
|
||||
UpdateWidgetValueControls();
|
||||
UpdateEditControls();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWidgetTitleControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TitleControls.Count < WidgetData.Count)
|
||||
{
|
||||
SetUpTitleRows(WidgetData.Count - TitleControls.Count);
|
||||
}
|
||||
|
||||
foreach (var titleControl in TitleControls)
|
||||
{
|
||||
if (titleControl.Parent is FrameworkElement titleControlParent)
|
||||
{
|
||||
titleControlParent.Margin = new Thickness(0, 0, 10, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (TitleControls.First().Parent is FrameworkElement firstTitleControlParent)
|
||||
{
|
||||
firstTitleControlParent.Margin = new Thickness(0, 15, 10, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWidgetValueControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ValueControls.Count < WidgetData.Count)
|
||||
{
|
||||
SetUpValueRows(WidgetData.Count - ValueControls.Count);
|
||||
}
|
||||
|
||||
if (ValueControls.First().Parent is FrameworkElement firstControlParent)
|
||||
{
|
||||
firstControlParent.Margin = new Thickness(0, 15, 10, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEditControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < EditControls.Count; i++)
|
||||
{
|
||||
var currentEditControl = EditControls[i];
|
||||
|
||||
if (WidgetData.Count <= i)
|
||||
continue;
|
||||
|
||||
if (i == 0)
|
||||
currentEditControl.Margin = new Thickness(10, 15, 10, 0);
|
||||
else
|
||||
currentEditControl.Margin = new Thickness(10, 0, 10, 0);
|
||||
|
||||
var currentWidgetData = WidgetData[i];
|
||||
currentEditControl.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (currentWidgetData.EditValueInformation is null)
|
||||
continue;
|
||||
|
||||
currentEditControl.EditableValueInformation = currentWidgetData.EditValueInformation;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh Data
|
||||
|
||||
private delegate void RefreshDelegate();
|
||||
|
||||
private void RefreshData()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (WidgetData == null)
|
||||
return;
|
||||
|
||||
RefreshWidgetTitles();
|
||||
RefreshWidgetTitleFunctionMarkers();
|
||||
RefreshWidgetValues();
|
||||
RefreshWidgetValueFunctionMarkers();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWidgetTitles()
|
||||
{
|
||||
try
|
||||
{
|
||||
var widgetTitleEnumerator = WidgetData.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < TitleControls.Count; i++)
|
||||
{
|
||||
if (widgetTitleEnumerator.MoveNext())
|
||||
{
|
||||
var Data = widgetTitleEnumerator.Current;
|
||||
if (TitleControls[i] is TextBlock titleEntry)
|
||||
{
|
||||
titleEntry.Text = Data.Title;
|
||||
titleEntry.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TitleControls[i] is TextBlock titleEntry)
|
||||
{
|
||||
titleEntry.Text = null;
|
||||
titleEntry.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWidgetTitleFunctionMarkers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var titleFunctionMarkerEnumerator = WidgetData.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < TitleFunctionMarkerControls.Count; i++)
|
||||
{
|
||||
if (titleFunctionMarkerEnumerator.MoveNext())
|
||||
{
|
||||
var Data = titleFunctionMarkerEnumerator.Current;
|
||||
var functionMarkerEntry = TitleFunctionMarkerControls[i];
|
||||
|
||||
if (Data.UiActionTitle != null && Data.UiActionTitle.DisplayType == enumActionDisplayType.enabled)
|
||||
{
|
||||
functionMarkerEntry.Tag = Data;
|
||||
var tempToolTip = Data.UiActionTitle.Name;
|
||||
if (!string.IsNullOrEmpty(Data.UiActionTitle.Description))
|
||||
tempToolTip += ": \n" + Data.UiActionTitle.Description;
|
||||
|
||||
functionMarkerEntry.ToolTip = tempToolTip;
|
||||
functionMarkerEntry.Visibility = Visibility.Visible;
|
||||
|
||||
if (Data.UiActionTitle is cShowDetailedDataAction)
|
||||
functionMarkerEntry.SelectedIcon = enumInternIcons.misc_dot;
|
||||
else if (Data.UiActionTitle is cUiQuickAction || Data.UiActionTitle is cSubMenuAction)
|
||||
functionMarkerEntry.SelectedIcon = enumInternIcons.misc_functionBolt;
|
||||
}
|
||||
else
|
||||
{
|
||||
functionMarkerEntry.Tag = null;
|
||||
functionMarkerEntry.ToolTip = null;
|
||||
functionMarkerEntry.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var functionMarkerEntry = TitleFunctionMarkerControls[i];
|
||||
functionMarkerEntry.Tag = null;
|
||||
functionMarkerEntry.ToolTip = null;
|
||||
functionMarkerEntry.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWidgetValueFunctionMarkers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var valueFunctionMarkerEnumerator = WidgetData.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < ValueFunctionMarkerControls.Count; i++)
|
||||
{
|
||||
if (valueFunctionMarkerEnumerator.MoveNext())
|
||||
{
|
||||
var Data = valueFunctionMarkerEnumerator.Current;
|
||||
var functionMarkerEntry = ValueFunctionMarkerControls[i];
|
||||
|
||||
if (Data.UiActionValue != null && Data.UiActionValue.DisplayType == enumActionDisplayType.enabled && !string.IsNullOrEmpty(Data.Value))
|
||||
{
|
||||
functionMarkerEntry.Visibility = Visibility.Visible;
|
||||
functionMarkerEntry.Tag = Data;
|
||||
var tempToolTip = Data.UiActionValue.Name;
|
||||
if (!string.IsNullOrEmpty(Data.UiActionValue.Description))
|
||||
tempToolTip += ": \n" + Data.UiActionValue.Description;
|
||||
|
||||
functionMarkerEntry.ToolTip = tempToolTip;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
functionMarkerEntry.Tag = null;
|
||||
functionMarkerEntry.ToolTip = null;
|
||||
functionMarkerEntry.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var functionMarkerEntry = ValueFunctionMarkerControls[i];
|
||||
functionMarkerEntry.Tag = null;
|
||||
functionMarkerEntry.ToolTip = null;
|
||||
functionMarkerEntry.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWidgetValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
var widgetDataEnumerator = WidgetData.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < ValueControls.Count; i++)
|
||||
{
|
||||
if (widgetDataEnumerator.MoveNext())
|
||||
{
|
||||
var Data = widgetDataEnumerator.Current;
|
||||
if (ValueControls[i] is TextBlock valueEntry)
|
||||
{
|
||||
valueEntry.Text = Data.IsLoading ? "..." : Data.Value;
|
||||
valueEntry.Visibility = Visibility.Visible;
|
||||
valueEntry.IsHitTestVisible = !string.IsNullOrWhiteSpace(Data.Value);
|
||||
|
||||
switch (Data.HighlightIn)
|
||||
{
|
||||
case enumHighlightColor.none:
|
||||
valueEntry.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
case enumHighlightColor.blue:
|
||||
valueEntry.Foreground = (SolidColorBrush)FindResource("Color.Blue");
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
valueEntry.Foreground = (SolidColorBrush)FindResource("Color.Green");
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
valueEntry.Foreground = (SolidColorBrush)FindResource("Color.Orange");
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
valueEntry.Foreground = (SolidColorBrush)FindResource("Color.Red");
|
||||
break;
|
||||
default:
|
||||
valueEntry.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ValueControls[i] is TextBlock valueEntry)
|
||||
{
|
||||
valueEntry.Text = null;
|
||||
valueEntry.Visibility = Visibility.Collapsed;
|
||||
valueEntry.Foreground = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh Widget Height
|
||||
|
||||
static void RefreshWidgetHeightCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailsPageWidget _me)
|
||||
_me.WidgetHeight = (double)e.NewValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style Definitions
|
||||
|
||||
private Style widgetTitleStyle;
|
||||
private Style widgetValueStyle;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
widgetTitleStyle = (Style)FindResource("DetailsPage.Widget.Title");
|
||||
widgetValueStyle = (Style)FindResource("DetailsPage.Widget.Value");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Methods
|
||||
|
||||
#region UserControl
|
||||
|
||||
private void UserControl_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FunctionMarker
|
||||
|
||||
private void WidgetDetailsTitleFunctionMarker_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
if (!(FE.Tag is cWidgetValueModel widgetData))
|
||||
return;
|
||||
|
||||
if (widgetData.UiActionTitle == null)
|
||||
return;
|
||||
|
||||
cUiActionBase.RaiseEvent(widgetData.UiActionTitle, this, this);
|
||||
}
|
||||
|
||||
private void WidgetDetailsValueFunctionMarker_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
if (!(FE.Tag is cWidgetValueModel widgetData))
|
||||
return;
|
||||
|
||||
if (widgetData.UiActionValue == null)
|
||||
return;
|
||||
|
||||
cUiActionBase.RaiseEvent(widgetData.UiActionValue, this, this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (WidgetData is null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < WidgetData.Count; i++)
|
||||
{
|
||||
var currentWidgetData = WidgetData[i];
|
||||
|
||||
if (currentWidgetData.EditValueInformation is null)
|
||||
continue;
|
||||
|
||||
if (EditControls.Count > i)
|
||||
EditControls[i].Visibility = isActive ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
if (ValueControls.Count > i)
|
||||
ValueControls[i].Visibility = isActive ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageWidgetCollection"
|
||||
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:uc="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"
|
||||
x:Name="_this"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Initialized="DetailsPageWidgetCollection_Initialized">
|
||||
|
||||
<Grid>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Disabled"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Padding="0,0,0,8"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"
|
||||
PreviewKeyDown="ScrollViewer_PreviewKeyDown">
|
||||
|
||||
<StackPanel x:Name="WidgetSectionStackPanel"
|
||||
Orientation="Horizontal"
|
||||
MouseLeftButtonUp="WidgetSectionStackPanel_MouseLeftButtonUp"
|
||||
TouchDown="WidgetSectionStackPanel_TouchDown" />
|
||||
|
||||
</ScrollViewer>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,441 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageWidgetCollection : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private bool isNewCase = true;
|
||||
|
||||
#region WidgetGeometryList DependencyProperty
|
||||
|
||||
private static bool DidGeometryDataChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
bool didGeometryChange = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (e.NewValue != null && e.OldValue != null)
|
||||
{
|
||||
var oldValueEnumerator = (e.OldValue as List<DetailsPageWidgetGeometryModel>).GetEnumerator();
|
||||
var newValues = e.NewValue as List<DetailsPageWidgetGeometryModel>;
|
||||
|
||||
foreach (var value in newValues)
|
||||
{
|
||||
if (oldValueEnumerator.MoveNext())
|
||||
{
|
||||
didGeometryChange = value.WidgetTitleCount != oldValueEnumerator.Current.WidgetTitleCount || didGeometryChange;
|
||||
didGeometryChange = value.WidgetDetailCount != oldValueEnumerator.Current.WidgetDetailCount || didGeometryChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
didGeometryChange = true;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return didGeometryChange;
|
||||
}
|
||||
|
||||
private static void GeometryChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DidGeometryDataChanged(e) is false)
|
||||
return;
|
||||
|
||||
var _me = d as DetailsPageWidgetCollection;
|
||||
_me.InitializeCollectionGeometry();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty WidgetGeometryListProperty =
|
||||
DependencyProperty.Register("WidgetGeometryList", typeof(List<DetailsPageWidgetGeometryModel>), typeof(DetailsPageWidgetCollection), new PropertyMetadata(new List<DetailsPageWidgetGeometryModel>(), new PropertyChangedCallback(GeometryChangedCallback)));
|
||||
|
||||
public List<DetailsPageWidgetGeometryModel> WidgetGeometryList
|
||||
{
|
||||
get { return (List<DetailsPageWidgetGeometryModel>)GetValue(WidgetGeometryListProperty); }
|
||||
set { SetValue(WidgetGeometryListProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WidgetDataList DependencyProperty
|
||||
|
||||
static void RefreshDataCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DetailsPageWidgetCollection _me)
|
||||
{
|
||||
_me.UpdateWidgetBar();
|
||||
_me.RefreshData();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty WidgetDataListProperty =
|
||||
DependencyProperty.Register("WidgetDataList", typeof(List<List<cWidgetValueModel>>), typeof(DetailsPageWidgetCollection), new PropertyMetadata(new List<List<cWidgetValueModel>>(), new PropertyChangedCallback(RefreshDataCallback)));
|
||||
|
||||
public List<List<cWidgetValueModel>> WidgetDataList
|
||||
{
|
||||
get { return (List<List<cWidgetValueModel>>)GetValue(WidgetDataListProperty); }
|
||||
set { SetValue(WidgetDataListProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public DetailsPageWidgetCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
cSupportCaseDataProvider.CaseChanged += (sender, args) => isNewCase = true;
|
||||
}
|
||||
|
||||
|
||||
#region SetUp Controls
|
||||
|
||||
#region Control Lists
|
||||
|
||||
private readonly List<DetailsPageWidget> WidgetControls = new List<DetailsPageWidget>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetUpFunctions
|
||||
|
||||
private void InitializeCollectionGeometry()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this) || WidgetGeometryList == null)
|
||||
return;
|
||||
|
||||
WidgetControls.Clear();
|
||||
WidgetSectionStackPanel.Children.RemoveRange(0, WidgetSectionStackPanel.Children.Count - 1);
|
||||
|
||||
for (int i = 0; i < WidgetGeometryList.Count; i++)
|
||||
{
|
||||
Border widgetBorder = new Border() { Background = Brushes.Transparent, AllowDrop = true, Padding = new Thickness(0, 0, 25, 0), Tag = "WidgetDataBorder" };
|
||||
|
||||
DetailsPageWidget widgetToCreate = new DetailsPageWidget() { WidgetGeometry = WidgetGeometryList[i] };
|
||||
|
||||
widgetBorder.Child = widgetToCreate;
|
||||
WidgetSectionStackPanel.Children.Add(widgetBorder);
|
||||
WidgetControls.Add(widgetToCreate);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Controls Function
|
||||
|
||||
private void UpdateWidgetBar()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (WidgetDataList == null)
|
||||
return;
|
||||
|
||||
if (WidgetDataList.Count > WidgetControls.Count)
|
||||
{
|
||||
int missingWidgetData = WidgetDataList.Count - WidgetControls.Count;
|
||||
LogEntry($"WidgetCollection - {missingWidgetData} widgets were missing and had to be added."); //todo: remove
|
||||
|
||||
for (int i = 0; i < missingWidgetData; i++)
|
||||
{
|
||||
Border widgetBorder = new Border() { Background = Brushes.Transparent, AllowDrop = true, Padding = new Thickness(0, 0, 25, 0), Tag = "WidgetDataBorder" };
|
||||
|
||||
DetailsPageWidget widgetToCreate = new DetailsPageWidget();
|
||||
|
||||
widgetBorder.Child = widgetToCreate;
|
||||
WidgetSectionStackPanel.Children.Add(widgetBorder);
|
||||
WidgetControls.Add(widgetToCreate);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh Data
|
||||
|
||||
private void RefreshData()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (WidgetDataList == null)
|
||||
return;
|
||||
|
||||
var WidgetDataEnumerator = WidgetDataList.GetEnumerator();
|
||||
|
||||
foreach (var widgetControl in WidgetControls)
|
||||
{
|
||||
if (WidgetDataEnumerator.MoveNext())
|
||||
{
|
||||
var widgetData = WidgetDataEnumerator.Current;
|
||||
|
||||
widgetControl.WidgetHeight = GetWidgetHeight();
|
||||
widgetControl.Visibility = widgetData?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
widgetControl.WidgetData = widgetData;
|
||||
}
|
||||
else
|
||||
{
|
||||
widgetControl.WidgetData = null;
|
||||
widgetControl.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Update Data
|
||||
|
||||
public void UpdateWidgetData(List<List<cWidgetValueModel>> widgetData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (WidgetDataList is null || WidgetDataList.Count == 0)
|
||||
return;
|
||||
|
||||
var widgetDataEnumerator = WidgetDataList.GetEnumerator();
|
||||
|
||||
for (int i = 0; i < widgetData.Count; i++)
|
||||
{
|
||||
var widgetCategory = widgetData[i];
|
||||
|
||||
widgetDataEnumerator.MoveNext();
|
||||
|
||||
var currentHistoryData = widgetDataEnumerator.Current;
|
||||
|
||||
var didWidgetCategoryChange = isNewCase || DidWidgetCategoryChange(currentHistoryData, widgetCategory);
|
||||
LogEntry($"WidgetCollection - WidgetData for Widget {i} did {(didWidgetCategoryChange ? "" : "NOT")} change."); //todo: remove
|
||||
|
||||
if (didWidgetCategoryChange && WidgetControls[i] != null)
|
||||
WidgetControls[i].WidgetData = widgetCategory;
|
||||
}
|
||||
|
||||
WidgetDataList = widgetData;
|
||||
isNewCase = false;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private bool DidWidgetCategoryChange(List<cWidgetValueModel> oldValue, List<cWidgetValueModel> newValue)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (oldValue is null || newValue is null)
|
||||
return true;
|
||||
|
||||
if (oldValue.Count != newValue.Count)
|
||||
return true;
|
||||
|
||||
var newValueRowEnumeator = newValue.GetEnumerator();
|
||||
|
||||
foreach (var oldValueRow in oldValue)
|
||||
{
|
||||
if (!newValueRowEnumeator.MoveNext())
|
||||
continue;
|
||||
|
||||
var currentNewValueRow = newValueRowEnumeator.Current;
|
||||
|
||||
if (oldValueRow?.Value != currentNewValueRow?.Value)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style Definitions
|
||||
|
||||
private Style widgetTitleStyle;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
widgetTitleStyle = (Style)FindResource("DetailsPage.Widget.Title");
|
||||
}
|
||||
|
||||
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 GetWidgetHeight()
|
||||
{
|
||||
double widgetHeight = 150;
|
||||
|
||||
foreach (var widgetData in WidgetDataList)
|
||||
{
|
||||
double tempWidgetHeight = 0;
|
||||
foreach (var widget in widgetData)
|
||||
{
|
||||
if (widget.Title == null)
|
||||
continue;
|
||||
|
||||
tempWidgetHeight += MeasureStringSize(widget.Title, new Control { Style = widgetTitleStyle }).Height + 14; // 14 = FunctionMarkerBorderHeight - FontSize
|
||||
}
|
||||
|
||||
tempWidgetHeight += 4;
|
||||
|
||||
if (tempWidgetHeight > widgetHeight)
|
||||
widgetHeight = tempWidgetHeight;
|
||||
}
|
||||
|
||||
return widgetHeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Methods
|
||||
|
||||
private void DetailsPageWidgetCollection_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (!(sender is ScrollViewer scrollViewer))
|
||||
return;
|
||||
|
||||
var destination = scrollViewer.HorizontalOffset - e.Delta;
|
||||
scrollViewer.ScrollToHorizontalOffset(destination);
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
#region Click Events
|
||||
|
||||
private void WidgetSectionStackPanel_Click(object originalSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(originalSource is TextBlock clickedTextBlock))
|
||||
return;
|
||||
|
||||
System.Windows.Forms.Clipboard.SetText(clickedTextBlock.Text);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void WidgetSectionStackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
WidgetSectionStackPanel_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
private void WidgetSectionStackPanel_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
WidgetSectionStackPanel_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetEditMode(bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var child in WidgetSectionStackPanel.Children)
|
||||
{
|
||||
if (!(child is Border widgetBorder && widgetBorder.Child is DetailsPageWidget widget))
|
||||
continue;
|
||||
|
||||
widget.SetEditMode(isActive);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageWindowStateBar"
|
||||
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:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
d:Background="White"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Height="40"
|
||||
Padding="0,15,15,0">
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Height="25"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True">
|
||||
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="Margin"
|
||||
Value="7.5 0" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="0" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="25" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="25" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<ico:AdaptableIcon x:Name="SlimPageButton"
|
||||
MouseLeftButtonUp="SlimPageButton_MouseLeftButtonUp"
|
||||
TouchDown="SlimPageButton_TouchDown"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.ToSlim}"
|
||||
SelectedInternIcon="window_toSlim"
|
||||
Margin="0"/>
|
||||
|
||||
<ico:AdaptableIcon x:Name="MinimizeButton"
|
||||
BorderPadding="0 10 0 0"
|
||||
VerticalAlignment="Bottom"
|
||||
MouseUp="MinimizeButton_MouseUp"
|
||||
TouchDown="MinimizeButton_TouchDown"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.Minimize}"
|
||||
SelectedInternIcon="window_minimize" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="WindowSizeButton"
|
||||
MouseUp="WindowSizeButton_MouseUp"
|
||||
TouchDown="WindowSizeButton_TouchDown">
|
||||
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource {x:Type ico:AdaptableIcon}}">
|
||||
|
||||
<Setter Property="SelectedInternIcon"
|
||||
Value="window_fullscreen" />
|
||||
<Setter Property="ToolTip"
|
||||
Value="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.Maximize}" />
|
||||
<Style.Triggers>
|
||||
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=WindowState}"
|
||||
Value="Normal">
|
||||
<Setter Property="SelectedInternIcon"
|
||||
Value="window_fullscreen" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=WindowState}"
|
||||
Value="Maximized">
|
||||
<Setter Property="SelectedInternIcon"
|
||||
Value="window_fullscreenExit" />
|
||||
<Setter Property="ToolTip"
|
||||
Value="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.UnMaximize}" />
|
||||
</DataTrigger>
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
MouseUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
Margin="7.5 0 0 0"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.Close}"
|
||||
SelectedInternIcon="window_close" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,101 @@
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
using FasdDesktopUi.Pages.SlimPage;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.DetailsPage.UserControls
|
||||
{
|
||||
public partial class DetailsPageWindowStateBar : UserControl
|
||||
{
|
||||
public DetailsPageWindowStateBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region MinimizeButton
|
||||
|
||||
private void Minimize_Click(object sender)
|
||||
{
|
||||
if (sender is UIElement senderVisual)
|
||||
Window.GetWindow(senderVisual).WindowState = WindowState.Minimized;
|
||||
}
|
||||
|
||||
private void MinimizeButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Minimize_Click(sender);
|
||||
}
|
||||
|
||||
private void MinimizeButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Minimize_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WindowSizeButton
|
||||
|
||||
private void WindowSize_Click(object sender)
|
||||
{
|
||||
if (sender is UIElement senderVisual)
|
||||
Window.GetWindow(senderVisual).WindowState = Window.GetWindow(senderVisual).WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
}
|
||||
|
||||
private void WindowSizeButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
WindowSize_Click(sender);
|
||||
}
|
||||
|
||||
private void WindowSizeButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
WindowSize_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CloseButton
|
||||
|
||||
private void CloseButton_Click(object sender)
|
||||
{
|
||||
if (sender is UIElement senderVisual)
|
||||
Window.GetWindow(senderVisual).Close();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click(sender);
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SlimPageButton
|
||||
|
||||
private void SlimPageButton_Click()
|
||||
{
|
||||
App.HideAllSettingViews();
|
||||
Window.GetWindow(this).Hide();
|
||||
cSupportCaseDataProvider.slimPage?.Show();
|
||||
}
|
||||
private void SlimPageButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SlimPageButton_Click();
|
||||
}
|
||||
|
||||
private void SlimPageButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SlimPageButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user