inital
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.SlimPage.UserControls.SlimPageDataHistory"
|
||||
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.SlimPage.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
mc:Ignorable="d"
|
||||
Name="DataHistoryUc"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Cursor="Hand">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Border x:Name="ValueBorder"
|
||||
CornerRadius="7.5"
|
||||
Padding="10">
|
||||
<Border.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.SlimPage.DataHistory}" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMouseOver}"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.SlimPage.DataHistory.Hover}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding ElementName=DataHistoryUc, Path=HistoryData.Content}"
|
||||
Style="{DynamicResource SlimPage.DataHistory.OverviewTitle}" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="LoadingIcon"
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
BorderPadding="2.5"
|
||||
Margin="10 0"
|
||||
SelectedInternGif="loadingSpinner" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="MainStack"
|
||||
Orientation="Horizontal"
|
||||
Margin="-7.5 0"
|
||||
Height="Auto"
|
||||
Width="Auto">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock"
|
||||
BasedOn="{StaticResource SlimPage.DataHistory.ColumnHeader}">
|
||||
<Setter Property="Height"
|
||||
Value="15" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="StackPanel">
|
||||
|
||||
<Setter Property="Height"
|
||||
Value="45" />
|
||||
<Setter Property="Width"
|
||||
Value="35" />
|
||||
<Setter Property="Margin"
|
||||
Value="2.5" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="BorderPadding"
|
||||
Value="2.5" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="30" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="30" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IconName}"
|
||||
Value="status_empty">
|
||||
<Setter Property="BorderPadding"
|
||||
Value="8" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
<Border x:Name="BlurBorder"
|
||||
Opacity="0.7"
|
||||
Visibility="{Binding IsBlurred, ElementName=DataHistoryUc, Converter={StaticResource BoolToVisibility}}"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Height="{Binding ActualHeight, ElementName=ValueBorder}"
|
||||
Width="{Binding ActualWidth, ElementName=ValueBorder}" />
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Effects;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using FasdDesktopUi.Pages.SlimPage.Models;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.UserControls
|
||||
{
|
||||
public partial class SlimPageDataHistory : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region IsBlurred
|
||||
|
||||
private static void IsBlurredChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlimPageDataHistory _me && e.NewValue is bool isBlurred)
|
||||
_me.ValueBorder.Child.Effect = isBlurred ? new BlurEffect() { Radius = 5, KernelType = KernelType.Gaussian } : null;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsBlurredProperty =
|
||||
DependencyProperty.Register("IsBlurred", typeof(bool), typeof(SlimPageDataHistory), new PropertyMetadata(false, new PropertyChangedCallback(IsBlurredChangedCallback)));
|
||||
|
||||
public bool IsBlurred
|
||||
{
|
||||
get { return (bool)GetValue(IsBlurredProperty); }
|
||||
set { SetValue(IsBlurredProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HistoryData Dependeny Property
|
||||
|
||||
private static void HistoryDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlimPageDataHistory slimPageDataHistory)
|
||||
slimPageDataHistory.InitializeHistoryData();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HistoryDataProperty =
|
||||
DependencyProperty.Register("HistoryData", typeof(cSlimPageDataHistoryModel), typeof(SlimPageDataHistory), new PropertyMetadata(new cSlimPageDataHistoryModel(), new PropertyChangedCallback(HistoryDataChangedCallback)));
|
||||
|
||||
public cSlimPageDataHistoryModel HistoryData
|
||||
{
|
||||
get { return (cSlimPageDataHistoryModel)GetValue(HistoryDataProperty); }
|
||||
set { SetValue(HistoryDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public SlimPageDataHistory()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeHistoryData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HistoryData == null)
|
||||
return;
|
||||
|
||||
MainStack.Children.Clear();
|
||||
|
||||
var tempHistoryDataColumns = HistoryData.ValueColumns.Take(7);
|
||||
|
||||
foreach (var historyColumn in tempHistoryDataColumns)
|
||||
{
|
||||
StackPanel stackPanel = new StackPanel();
|
||||
stackPanel.Children.Add(new TextBlock() { TextAlignment = TextAlignment.Center, Text = historyColumn.Content });
|
||||
AdaptableIcon adaptableIcon = new AdaptableIcon();
|
||||
|
||||
switch (historyColumn.HighlightColor)
|
||||
{
|
||||
case enumHighlightColor.none:
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.status_empty;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.SoftContrast");
|
||||
break;
|
||||
case enumHighlightColor.blue:
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.status_info;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Blue");
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.status_good;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Green");
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.status_danger;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Orange");
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.status_bad;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Red");
|
||||
break;
|
||||
}
|
||||
|
||||
if (historyColumn.IsLoading && historyColumn.HighlightColor != enumHighlightColor.red)
|
||||
{
|
||||
//todo: replace loading icon
|
||||
adaptableIcon.SelectedInternIcon = enumInternIcons.menuBar_more;
|
||||
adaptableIcon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Menu.Icon");
|
||||
}
|
||||
|
||||
stackPanel.Children.Add(adaptableIcon);
|
||||
MainStack.Children.Add(stackPanel);
|
||||
}
|
||||
|
||||
if (tempHistoryDataColumns.Any(data => data.IsLoading))
|
||||
LoadingIcon.Visibility = Visibility.Visible;
|
||||
else
|
||||
LoadingIcon.Visibility = Visibility.Collapsed;
|
||||
|
||||
(MainStack.Children[0] as FrameworkElement).Margin = new Thickness(5, 2.5, 2.5, 2.5);
|
||||
(MainStack.Children[MainStack.Children.Count - 1] as FrameworkElement).Width = 75;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal void UpdateHistoryData(cSlimPageDataHistoryModel newHistoryData)
|
||||
{
|
||||
HistoryData = newHistoryData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.SlimPage.UserControls.SlimPageDataHistoryCollection"
|
||||
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.SlimPage.UserControls"
|
||||
mc:Ignorable="d"
|
||||
Name="DataHistoryCollectionUc"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer.Resources>
|
||||
<Style TargetType="ScrollViewer">
|
||||
<Setter Property="Padding"
|
||||
Value="0 0 0 2.5" />
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=ComputedVerticalScrollBarVisibility}"
|
||||
Value="Visible">
|
||||
<Setter Property="Padding"
|
||||
Value="0 0 5 5" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ScrollViewer.Resources>
|
||||
|
||||
<StackPanel x:Name="MainStack"
|
||||
VerticalAlignment="Bottom">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="local:SlimPageDataHistory">
|
||||
<EventSetter Event="MouseUp"
|
||||
Handler="DataHistoryUc_MouseUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="DataHistoryUc_TouchDown" />
|
||||
</Style>
|
||||
|
||||
</StackPanel.Resources>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,192 @@
|
||||
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 FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Pages.DetailsPage;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
using FasdDesktopUi.Pages.SlimPage.Models;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.UserControls
|
||||
{
|
||||
public partial class SlimPageDataHistoryCollection : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region IsBlurred
|
||||
|
||||
private bool isBlurred;
|
||||
|
||||
public bool IsBlurred
|
||||
{
|
||||
get { return isBlurred; }
|
||||
set
|
||||
{
|
||||
isBlurred = value;
|
||||
foreach (var child in MainStack.Children)
|
||||
{
|
||||
if (child is SlimPageDataHistory dataHistory)
|
||||
{
|
||||
dataHistory.IsBlurred = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HistoryDataList Dependency Property
|
||||
|
||||
private static void HistoryDataCollectionChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlimPageDataHistoryCollection _me)
|
||||
_me.InitializeDataHistoryCollection();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HistoryDataListProperty =
|
||||
DependencyProperty.Register("HistoryDataList", typeof(List<cSlimPageDataHistoryModel>), typeof(SlimPageDataHistoryCollection), new PropertyMetadata(new List<cSlimPageDataHistoryModel>(), new PropertyChangedCallback(HistoryDataCollectionChangedCallback)));
|
||||
|
||||
public List<cSlimPageDataHistoryModel> HistoryDataList
|
||||
{
|
||||
get { return (List<cSlimPageDataHistoryModel>)GetValue(HistoryDataListProperty); }
|
||||
set { SetValue(HistoryDataListProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public SlimPageDataHistoryCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region DataHistoryClicked
|
||||
|
||||
private void DataHistoryUc_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
if (detailsPage != null)
|
||||
{
|
||||
detailsPage.OpenDataHistory(MainStack.Children.IndexOf(sender as FrameworkElement));
|
||||
Window.GetWindow(this).Hide();
|
||||
|
||||
App.HideAllSettingViews();
|
||||
detailsPage.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataHistoryUc_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DataHistoryUc_Click(sender);
|
||||
}
|
||||
|
||||
private void DataHistoryUc_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
DataHistoryUc_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitializeDataHistoryCollection()
|
||||
{
|
||||
if (HistoryDataList == null)
|
||||
return;
|
||||
|
||||
MainStack.Children.Clear();
|
||||
|
||||
foreach (var historyData in HistoryDataList)
|
||||
{
|
||||
MainStack.Children.Add(new SlimPageDataHistory() { Margin = new Thickness(0, 2.5, 0, 2.5), HistoryData = historyData });
|
||||
}
|
||||
}
|
||||
|
||||
private bool DidHistoryCategoryChange(cSlimPageDataHistoryModel oldValue, cSlimPageDataHistoryModel newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (oldValue.IsLoading != newValue.IsLoading)
|
||||
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;
|
||||
|
||||
if (oldValueColumn.HighlightColor != currentNewValueColumn.HighlightColor)
|
||||
return true;
|
||||
|
||||
if (oldValueColumn.IsLoading != currentNewValueColumn.IsLoading)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void UpdateHistory(List<cSlimPageDataHistoryModel> historyData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HistoryDataList is null)
|
||||
return;
|
||||
|
||||
var historyDataEnumerator = HistoryDataList.GetEnumerator();
|
||||
foreach (var historyCategory in historyData)
|
||||
{
|
||||
if (!historyDataEnumerator.MoveNext())
|
||||
continue;
|
||||
|
||||
var currentHistoryData = historyDataEnumerator.Current;
|
||||
|
||||
if (DidHistoryCategoryChange(currentHistoryData, historyCategory))
|
||||
{
|
||||
var indexOfCurrentHistoryData = HistoryDataList.IndexOf(currentHistoryData);
|
||||
|
||||
if (MainStack.Children[indexOfCurrentHistoryData] is SlimPageDataHistory dataHistoryControl)
|
||||
dataHistoryControl.UpdateHistoryData(historyCategory);
|
||||
}
|
||||
}
|
||||
|
||||
HistoryDataList = historyData;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.SlimPage.UserControls.SlimPageWidgetCollection"
|
||||
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.SlimPage.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
x:Name="WidgetCollection"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Initialized="WidgetCollection_Initialized"
|
||||
Loaded="WidgetCollection_Loaded"
|
||||
MouseUp="WidgetCollection_MouseUp"
|
||||
TouchDown="WidgetCollection_TouchDown">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
|
||||
<Border x:Name="ValueBorder"
|
||||
CornerRadius="7.5 7.5 0 0"
|
||||
Background="{DynamicResource BackgroundColor.SlimPage.WidgetCollection}"
|
||||
Padding="10"
|
||||
Cursor="Hand">
|
||||
|
||||
<StackPanel>
|
||||
<Grid x:Name="HeaderGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel x:Name="UserStack"
|
||||
Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="UserIcon"
|
||||
Style="{DynamicResource SlimPage.Widget.Header.Icon}"
|
||||
SelectedInternIcon="misc_user" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="ComputerStack"
|
||||
Orientation="Horizontal"
|
||||
Grid.Column="1">
|
||||
<ico:AdaptableIcon x:Name="ComputerIcon"
|
||||
Style="{DynamicResource SlimPage.Widget.Header.Icon}"
|
||||
SecondaryIconColor="{DynamicResource Color.FunctionMarker}"
|
||||
SelectedInternIcon="misc_computer" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="WidgetGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" />
|
||||
<StackPanel Grid.Column="1" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="BlurBorder"
|
||||
CornerRadius="7.5 7.5 0 0"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Opacity="0.7"
|
||||
Height="{Binding ActualHeight, ElementName=ValueBorder}"
|
||||
Width="{Binding ActualWidth, ElementName=ValueBorder}"
|
||||
Visibility="{Binding IsBlurred, ElementName=WidgetCollection, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,393 @@
|
||||
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.Input;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics;
|
||||
using System.Reflection;
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
using FasdDesktopUi.Pages.DetailsPage.UserControls;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.UserControls
|
||||
{
|
||||
public partial class SlimPageWidgetCollection : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
#region IsBlurred
|
||||
|
||||
private static void IsBlurredChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlimPageWidgetCollection _me && e.NewValue is bool isBlurred)
|
||||
_me.ValueBorder.Child.Effect = isBlurred ? new BlurEffect() { Radius = 5, KernelType = KernelType.Gaussian } : null;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsBlurredProperty =
|
||||
DependencyProperty.Register("IsBlurred", typeof(bool), typeof(SlimPageWidgetCollection), new PropertyMetadata(false, new PropertyChangedCallback(IsBlurredChangedCallback)));
|
||||
|
||||
public bool IsBlurred
|
||||
{
|
||||
get { return (bool)GetValue(IsBlurredProperty); }
|
||||
set { SetValue(IsBlurredProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public bool HasDirectConnection
|
||||
{
|
||||
get { return (bool)GetValue(HasDirectConnectionProperty); }
|
||||
set { SetValue(HasDirectConnectionProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HasDirectConnectionProperty =
|
||||
DependencyProperty.Register("HasDirectConnection", typeof(bool), typeof(SlimPageWidgetCollection), new PropertyMetadata(false, new PropertyChangedCallback(DirectConnectionStatusChanged)));
|
||||
|
||||
private static void DirectConnectionStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is SlimPageWidgetCollection _me))
|
||||
return;
|
||||
|
||||
_me.UpdateDirectConnectionIcon();
|
||||
}
|
||||
|
||||
#region HeadingData DependencyProperty
|
||||
private static void HeadingDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is SlimPageWidgetCollection _me))
|
||||
return;
|
||||
|
||||
if (!(e.NewValue is List<cHeadingDataModel> data))
|
||||
return;
|
||||
|
||||
_me.UserStack.Children.RemoveRange(1, int.MaxValue);
|
||||
_me.ComputerStack.Children.RemoveRange(1, int.MaxValue);
|
||||
|
||||
data = data.Where(heading =>
|
||||
heading.InformationClass is enumFasdInformationClass.User || heading.InformationClass is enumFasdInformationClass.Computer)
|
||||
.ToList();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var currentData = data[i];
|
||||
|
||||
StackPanel stackPanel = null;
|
||||
AdaptableIcon icon = null;
|
||||
|
||||
switch (currentData.InformationClass)
|
||||
{
|
||||
case enumFasdInformationClass.Computer:
|
||||
stackPanel = _me.ComputerStack;
|
||||
icon = _me.ComputerIcon;
|
||||
break;
|
||||
case enumFasdInformationClass.User:
|
||||
stackPanel = _me.UserStack;
|
||||
icon = _me.UserIcon;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentData.IsOnline)
|
||||
{
|
||||
icon.SetResourceReference(AdaptableIcon.PrimaryIconColorProperty, "Color.Green");
|
||||
icon.ToolTip = cMultiLanguageSupport.GetItem("Header.IsOnline");
|
||||
}
|
||||
else
|
||||
{
|
||||
icon.ClearValue(AdaptableIcon.PrimaryIconColorProperty);
|
||||
icon.ToolTip = cMultiLanguageSupport.GetItem("Header.IsOffline");
|
||||
}
|
||||
|
||||
TextBlock textBlock = new TextBlock();
|
||||
textBlock.SetResourceReference(StyleProperty, "SlimPage.Widget.Header");
|
||||
textBlock.Text = currentData.HeadingText;
|
||||
textBlock.MouseLeftButtonUp += _me.Heading_MouseLeftButtonUp;
|
||||
textBlock.TouchDown += _me.Heading_TouchDown;
|
||||
|
||||
stackPanel.Children.Add(textBlock);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void Heading_Click(object originalSource) //todo: bring in separate function? same procedure in widget values and in DetailsPage
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(originalSource is TextBlock clickedTextBlock))
|
||||
return;
|
||||
|
||||
System.Windows.Forms.Clipboard.SetText(clickedTextBlock.Text);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void Heading_TouchDown(object sender, System.Windows.Input.TouchEventArgs e)
|
||||
{
|
||||
Heading_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
private void Heading_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
Heading_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HeadingDataProperty =
|
||||
DependencyProperty.Register("HeadingData", typeof(List<cHeadingDataModel>), typeof(SlimPageWidgetCollection), new PropertyMetadata(new List<cHeadingDataModel>() {
|
||||
new cHeadingDataModel() { HeadingText = "UserName", InformationClass = enumFasdInformationClass.User },
|
||||
new cHeadingDataModel() { HeadingText = "ComputerName", InformationClass = enumFasdInformationClass.Computer }
|
||||
}, new PropertyChangedCallback(HeadingDataChanged)));
|
||||
|
||||
|
||||
public List<cHeadingDataModel> HeadingData
|
||||
{
|
||||
get { return (List<cHeadingDataModel>)GetValue(HeadingDataProperty); }
|
||||
set { SetValue(HeadingDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WidgetData DependencyProperty
|
||||
|
||||
private static void WidgetDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is SlimPageWidgetCollection _me)
|
||||
_me.InitializeWidgetData();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty WidgetDataProperty =
|
||||
DependencyProperty.Register("WidgetData", typeof(List<List<cWidgetValueModel>>), typeof(SlimPageWidgetCollection), new PropertyMetadata(new List<List<cWidgetValueModel>>(), new PropertyChangedCallback(WidgetDataChangedCallback)));
|
||||
|
||||
public List<List<cWidgetValueModel>> WidgetData
|
||||
{
|
||||
get { return (List<List<cWidgetValueModel>>)GetValue(WidgetDataProperty); }
|
||||
set { SetValue(WidgetDataProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public SlimPageWidgetCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region InitializeWidgetData
|
||||
|
||||
private void InitializeWidgetData()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (WidgetData == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (WidgetGrid.Children.Count <= i)
|
||||
continue;
|
||||
|
||||
if (WidgetGrid.Children[i] is Panel widgetPanel)
|
||||
{
|
||||
widgetPanel.Children.Clear();
|
||||
WidgetGrid.ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Auto);
|
||||
|
||||
if (WidgetData.Count <= i)
|
||||
continue;
|
||||
|
||||
WidgetGrid.ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Star);
|
||||
|
||||
foreach (var widgetValue in WidgetData[i].OrderBy(x => x.ValueIndex))
|
||||
{
|
||||
if (string.IsNullOrEmpty(widgetValue.Title))
|
||||
{
|
||||
Border noTitleValueBorder = new Border() { ClipToBounds = true };
|
||||
var noTitleValueTextBlock = new TextBlock() { Text = widgetValue.Value, Style = widgetNoTitleValueStyle };
|
||||
noTitleValueTextBlock.MouseEnter += WidgetValue_MouseEnter;
|
||||
noTitleValueTextBlock.MouseLeave += WidgetValue_MouseLeave;
|
||||
|
||||
noTitleValueBorder.Child = noTitleValueTextBlock;
|
||||
|
||||
widgetPanel.Children.Add(noTitleValueBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
//todo: add ticker text animation to values with title
|
||||
StackPanel valueStackPanel = new StackPanel() { Orientation = Orientation.Horizontal };
|
||||
valueStackPanel.Children.Add(new TextBlock() { Text = String.Format("{0}: ", widgetValue.Title), Style = widgetTitleStyle });
|
||||
|
||||
TextBlock valueTextBlock = new TextBlock() { Text = widgetValue.Value, Style = widgetValueStyle };
|
||||
|
||||
switch (widgetValue.HighlightIn)
|
||||
{
|
||||
case enumHighlightColor.none:
|
||||
break;
|
||||
case enumHighlightColor.blue:
|
||||
valueTextBlock.SetResourceReference(ForegroundProperty, "Color.Blue");
|
||||
break;
|
||||
case enumHighlightColor.green:
|
||||
valueTextBlock.SetResourceReference(ForegroundProperty, "Color.Green");
|
||||
break;
|
||||
case enumHighlightColor.orange:
|
||||
valueTextBlock.SetResourceReference(ForegroundProperty, "Color.Orange");
|
||||
break;
|
||||
case enumHighlightColor.red:
|
||||
valueTextBlock.SetResourceReference(ForegroundProperty, "Color.Red");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
valueStackPanel.Children.Add(valueTextBlock);
|
||||
widgetPanel.Children.Add(valueStackPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
private void WidgetValue_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (!(senderElement.Parent is FrameworkElement senderParent))
|
||||
return;
|
||||
|
||||
cUtility.SetTickerTextAnimation(senderElement, senderParent);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void WidgetValue_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
senderElement.BeginAnimation(MarginProperty, null);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private void UpdateDirectConnectionIcon()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HasDirectConnection)
|
||||
{
|
||||
ComputerIcon.SelectedInternIcon = enumInternIcons.misc_directConnection;
|
||||
ComputerIcon.BorderPadding = new Thickness(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ComputerIcon.SelectedInternIcon = enumInternIcons.misc_computer;
|
||||
ComputerIcon.ClearValue(AdaptableIcon.BorderPaddingProperty);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Styles
|
||||
|
||||
private Style widgetNoTitleValueStyle;
|
||||
private Style widgetTitleStyle;
|
||||
private Style widgetValueStyle;
|
||||
|
||||
private void SetStyles()
|
||||
{
|
||||
widgetNoTitleValueStyle = (Style)FindResource("SlimPage.Widget.NoTitleValue");
|
||||
widgetTitleStyle = (Style)FindResource("SlimPage.Widget.Title");
|
||||
widgetValueStyle = (Style)FindResource("SlimPage.Widget.Value");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void WidgetCollection_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
SetStyles();
|
||||
}
|
||||
|
||||
private void WidgetCollection_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InitializeWidgetData();
|
||||
}
|
||||
|
||||
#region WidgetCollection_Click
|
||||
|
||||
private void WidgetCollection_Click(object originalSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (originalSource is TextBlock clickedTextBlock)
|
||||
{
|
||||
System.Windows.Forms.Clipboard.SetText(clickedTextBlock.Text);
|
||||
return;
|
||||
}
|
||||
else if (originalSource == ValueBorder)
|
||||
{
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
if (detailsPage != null)
|
||||
{
|
||||
Window.GetWindow(this).Hide();
|
||||
App.HideAllSettingViews();
|
||||
detailsPage.Show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void WidgetCollection_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
WidgetCollection_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
private void WidgetCollection_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
WidgetCollection_Click(e.OriginalSource);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<UserControl x:Class="FasdDesktopUi.Pages.SlimPage.UserControls.SlimPageWindowStateBar"
|
||||
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.SlimPage.UserControls"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
x:Name="WindowStateBarUc"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="30"
|
||||
d:DesignWidth="300">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource SettingsPage.Close.Icon}">
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.SlimPage.WidgetCollection}" />
|
||||
<Setter Property="IconCornerRadius"
|
||||
Value="15" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="30" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="30" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="10" />
|
||||
<Setter Property="Margin"
|
||||
Value="7.5 0 0 0" />
|
||||
</Style>
|
||||
|
||||
</StackPanel.Resources>
|
||||
|
||||
<ico:AdaptableIcon MouseUp="WindowButton_MouseUp"
|
||||
TouchDown="WindowButton_TouchDown"
|
||||
Tag="maximize"
|
||||
Visibility="{Binding ElementName=WindowStateBarUc, Path=ShowFullStateBar, Converter={StaticResource BoolToVisibility}}"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.Maximize}"
|
||||
SelectedInternIcon="window_fullscreen" />
|
||||
|
||||
<ico:AdaptableIcon MouseUp="WindowButton_MouseUp"
|
||||
TouchDown="WindowButton_TouchDown"
|
||||
Tag="close"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.NavBar.Close}"
|
||||
SelectedInternIcon="window_close" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,99 @@
|
||||
using C4IT.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.UserControls
|
||||
{
|
||||
public partial class SlimPageWindowStateBar : UserControl
|
||||
{
|
||||
public bool ShowFullStateBar
|
||||
{
|
||||
get { return (bool)GetValue(ShowFullStateBarProperty); }
|
||||
set { SetValue(ShowFullStateBarProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowFullStateBarProperty =
|
||||
DependencyProperty.Register("ShowFullStateBar", typeof(bool), typeof(SlimPageWindowStateBar), new PropertyMetadata(false));
|
||||
|
||||
public SlimPageWindowStateBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region ClickedMaximize Event
|
||||
|
||||
public static readonly RoutedEvent ClickedMaximizeEvent = EventManager.RegisterRoutedEvent("ClickedMaximize", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SlimPageWindowStateBar));
|
||||
|
||||
public event RoutedEventHandler ClickedMaximize
|
||||
{
|
||||
add { AddHandler(ClickedMaximizeEvent, value); }
|
||||
remove { RemoveHandler(ClickedMaximizeEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClickedClose Event
|
||||
|
||||
public static readonly RoutedEvent ClickedCloseEvent = EventManager.RegisterRoutedEvent("ClickedClose", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SlimPageWindowStateBar));
|
||||
|
||||
public event RoutedEventHandler ClickedClose
|
||||
{
|
||||
add { AddHandler(ClickedCloseEvent, value); }
|
||||
remove { RemoveHandler(ClickedCloseEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void WindowButton_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
RoutedEventArgs newEventArgs = null;
|
||||
switch (senderElement.Tag)
|
||||
{
|
||||
case "maximize":
|
||||
newEventArgs = new RoutedEventArgs(ClickedMaximizeEvent);
|
||||
break;
|
||||
case "close":
|
||||
newEventArgs = new RoutedEventArgs(ClickedCloseEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newEventArgs != null)
|
||||
RaiseEvent(newEventArgs);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void WindowButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
WindowButton_Click(sender);
|
||||
}
|
||||
|
||||
private void WindowButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
WindowButton_Click(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user