inital
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.AdvancedSearchPage.AdvancedSearchPage"
|
||||
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.AdvancedSearchPage"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
Name="AdvancedSearchPageWindow"
|
||||
Title="AdvancedSearchPage"
|
||||
Height="450"
|
||||
Width="800"
|
||||
WindowState="Maximized"
|
||||
Background="Transparent"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True">
|
||||
|
||||
<Window.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<Grid x:Name="BodyStack">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<buc:SearchBar x:Name="SearchBarUc"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="0"
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Center"
|
||||
Width="450"
|
||||
Margin="0 200 0 0"
|
||||
SearchButtonSize="30"
|
||||
CloseButtonSize="30" />
|
||||
|
||||
<buc:SearchFilterBar x:Name="SearchFilterBar"
|
||||
x:FieldModifier="private"
|
||||
Margin="0 -5 0 -5"
|
||||
Grid.Row="1"
|
||||
FontSize="{Binding ElementName=SearchBarUc, Path=FontSize}"
|
||||
HorizontalAlignment="Center"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
FilterChanged="SearchFilterBar_FilterChanged"
|
||||
InformationClassesToFilter="{Binding ElementName=AdvancedSearchPageWindow, Path=FilterInformationClasses}" />
|
||||
|
||||
<Border x:Name="SearchResultBorder"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="2"
|
||||
MaxHeight="350"
|
||||
Padding="10"
|
||||
Margin="0 10 0 0"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="10"
|
||||
Visibility="Collapsed">
|
||||
|
||||
<buc:CustomSearchResultCollection x:Name="ResultMenu"
|
||||
x:FieldModifier="private"
|
||||
FontSize="14" />
|
||||
</Border>
|
||||
|
||||
<Border x:Name="SearchHistoryBorder"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="1"
|
||||
Padding="10"
|
||||
Margin="0 100 0 0"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="10"
|
||||
Visibility="Collapsed">
|
||||
|
||||
<buc:CustomSearchResultCollection x:Name="SearchHistory"
|
||||
x:FieldModifier="private" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,563 @@
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.CustomEvents;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Helper;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using FasdDesktopUi.Basics.Services.SupportCaseSearchService;
|
||||
using FasdDesktopUi.Basics.Services.RelationService;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static FasdDesktopUi.Basics.UserControls.SearchBar;
|
||||
|
||||
|
||||
namespace FasdDesktopUi.Pages.AdvancedSearchPage
|
||||
{
|
||||
public partial class AdvancedSearchPage : Window, ISearchUiProvider, INotifyPropertyChanged
|
||||
{
|
||||
public SupportCaseSearchService SearchService { get; } = new SupportCaseSearchService(new RelationService());
|
||||
// New Advanced-Search-Page IN PROGRESS
|
||||
// Next steps:
|
||||
// 1. Open F4SD Cockpit when user is clicked
|
||||
// 2. Display filter name next to filter icon when filter is selected
|
||||
// 3. When F4SD Tray-Icon is clicked, open the new advanced search page
|
||||
|
||||
|
||||
SearchBar.ChangedSearchValueDelegate ChangedSearchValue { get; set; }
|
||||
private cF4sdApiSearchResultRelation preSelectedRelation = null;
|
||||
|
||||
private static readonly object _currentSearchTaskLock = new object();
|
||||
private static Guid? CurrentSearchTaskId = null;
|
||||
private static CancellationTokenSource CurrentSearchTaskToken = null;
|
||||
|
||||
private readonly DispatcherTimer _searchTimer = new DispatcherTimer();
|
||||
private string searchValue = null;
|
||||
|
||||
public static AdvancedSearchPage advancedSearchPage;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
||||
|
||||
// Mapping zwischen den Enum-Classes, da Integer-Values nicht alle identisch sind. Evtl. im nachgang anpassen, aber vorher alle Abhängigkeiten prüfen
|
||||
private enumFasdInformationClass MapSearchResultClassToInformationClass(enumF4sdSearchResultClass searchResultClass)
|
||||
{
|
||||
switch (searchResultClass)
|
||||
{
|
||||
case enumF4sdSearchResultClass.Computer: return enumFasdInformationClass.Computer;
|
||||
case enumF4sdSearchResultClass.User: return enumFasdInformationClass.User;
|
||||
case enumF4sdSearchResultClass.Ticket: return enumFasdInformationClass.Ticket;
|
||||
case enumF4sdSearchResultClass.VirtualSession: return enumFasdInformationClass.VirtualSession;
|
||||
case enumF4sdSearchResultClass.MobileDevice: return enumFasdInformationClass.MobileDevice;
|
||||
default: return enumFasdInformationClass.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
// Alle Suchergebnisse (ungefilterte Sammlung)
|
||||
public cFasdApiSearchResultCollection SearchResults { get; set; }
|
||||
|
||||
// Gefilterte Suchergebnisse (für die Anzeige in der UI)
|
||||
private cFasdApiSearchResultCollection _filteredSearchResults;
|
||||
public cFasdApiSearchResultCollection FilteredSearchResults
|
||||
{
|
||||
get => _filteredSearchResults;
|
||||
set
|
||||
{
|
||||
if (_filteredSearchResults != value)
|
||||
{
|
||||
_filteredSearchResults = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aktuell gesetzte Filterklassen
|
||||
public HashSet<enumFasdInformationClass> StoredFilterInformationClasses { get; set; }
|
||||
|
||||
public static readonly DependencyProperty FilterInformationClassesProperty =
|
||||
DependencyProperty.Register("FilterInformationClasses", typeof(HashSet<enumFasdInformationClass>), typeof(AdvancedSearchPage), new PropertyMetadata(new HashSet<enumFasdInformationClass>()));
|
||||
|
||||
// Ermittelte Filter bei der Suche
|
||||
public HashSet<enumFasdInformationClass> FilterInformationClasses
|
||||
{
|
||||
get { return (HashSet<enumFasdInformationClass>)GetValue(FilterInformationClassesProperty); }
|
||||
set { SetValue(FilterInformationClassesProperty, value); }
|
||||
}
|
||||
|
||||
public eSearchStatus searchStatus { get; private set; } = eSearchStatus.message;
|
||||
|
||||
public AdvancedSearchPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
AddCustomEventHandlers();
|
||||
SearchBarUc.ActivateManualSearch();
|
||||
|
||||
advancedSearchPage = this;
|
||||
}
|
||||
|
||||
private void AddCustomEventHandlers()
|
||||
{
|
||||
AddHandler(cUiActionBase.UiActionClickedEvent, new cUiActionBase.UiActionEventHandlerDelegate(UiActionWasTriggered));
|
||||
SearchBarUc.ChangedSearchValue = ChangedSearchValueActionAsync;
|
||||
SearchBarUc.CancledSearchAction = CancledSearchAction;
|
||||
}
|
||||
|
||||
|
||||
private Task ChangedSearchValueActionAsync(cFilteredResults filteredResults)
|
||||
{
|
||||
this.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (filteredResults?.Results is null)
|
||||
{
|
||||
SetSearchResultVisibility(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Speichern der Kompletten Suchergebnisse
|
||||
SearchResults = filteredResults.Results;
|
||||
|
||||
// Verfügbare FilterIcons dynamisch ermitteln
|
||||
UpdateFilterInformationClasses();
|
||||
|
||||
// Filter anwenden
|
||||
ApplyFilters();
|
||||
|
||||
// Menü mit den gefilterten Ergebnissen anzeigen
|
||||
string menuHeaderText = filteredResults?.PreSelectedRelation?.DisplayName;
|
||||
ResultMenu.ShowSearchResults(filteredResults, menuHeaderText, this);
|
||||
|
||||
preSelectedRelation = filteredResults.PreSelectedRelation;
|
||||
SetSearchResultVisibility(true);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void UpdateFilterInformationClasses()
|
||||
{
|
||||
if (SearchResults == null)
|
||||
{
|
||||
FilterInformationClasses = new HashSet<enumFasdInformationClass>();
|
||||
return;
|
||||
}
|
||||
|
||||
var filter = new HashSet<enumFasdInformationClass>();
|
||||
|
||||
foreach (var group in SearchResults)
|
||||
{
|
||||
foreach (var entry in group.Value)
|
||||
{
|
||||
var mappedClass = MapSearchResultClassToInformationClass(entry.Type);
|
||||
filter.Add(mappedClass);
|
||||
}
|
||||
}
|
||||
FilterInformationClasses = filter;
|
||||
}
|
||||
|
||||
private void SearchFilterBar_FilterChanged(object sender, SearchFilterChangedEventArgs e)
|
||||
{
|
||||
// Filter speichern
|
||||
StoredFilterInformationClasses = new HashSet<enumFasdInformationClass>(e.InformationClassesToShow);
|
||||
|
||||
// Filter anwenden
|
||||
ApplyFilters();
|
||||
|
||||
// cFilteredResults erzeugen
|
||||
var filteredResultWrapper = new cFilteredResults()
|
||||
{
|
||||
Results = FilteredSearchResults,
|
||||
PreSelectedRelation = preSelectedRelation
|
||||
};
|
||||
|
||||
// Ergebnisse im Menü neu anzeigen
|
||||
string menuHeaderText = preSelectedRelation?.DisplayName;
|
||||
ResultMenu.ShowSearchResults(filteredResultWrapper, menuHeaderText, this);
|
||||
}
|
||||
|
||||
private void ApplyFilters()
|
||||
{
|
||||
if (SearchResults == null)
|
||||
return;
|
||||
|
||||
// Wenn keine Filter ausgewählt wurden, alles übernehmen
|
||||
if (StoredFilterInformationClasses == null || StoredFilterInformationClasses.Count == 0)
|
||||
{
|
||||
FilteredSearchResults = SearchResults;
|
||||
return;
|
||||
}
|
||||
|
||||
// Wenn ein oder mehrere Filter gesetzt, dann Ergebnisse entsprechend gefiltert anzeigen
|
||||
cFasdApiSearchResultCollection filtered = new cFasdApiSearchResultCollection();
|
||||
|
||||
foreach (var group in SearchResults)
|
||||
{
|
||||
var filteredEntries = group.Value
|
||||
.Where(entry =>
|
||||
StoredFilterInformationClasses.Contains(MapSearchResultClassToInformationClass(entry.Type))
|
||||
)
|
||||
.ToList();
|
||||
|
||||
if (filteredEntries.Any())
|
||||
{
|
||||
filtered.Add(group.Key, filteredEntries);
|
||||
}
|
||||
}
|
||||
|
||||
FilteredSearchResults = filtered;
|
||||
}
|
||||
|
||||
public void ShowSearchRelations(cSearchHistorySearchResultEntry searchHistoryEntry, IRelationService relationService, ISearchUiProvider searchUiProvider)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultMenu.SetHeaderText(searchHistoryEntry.HeaderText, hideDetailsCheckbox: false);
|
||||
|
||||
cSearchManager.ResolveRelations(searchHistoryEntry.Relations);
|
||||
|
||||
ILookup<enumFasdInformationClass, cMenuDataBase> relationsLookup = searchHistoryEntry.Relations
|
||||
.OrderBy(r => r.UsingLevel)
|
||||
.ThenBy(r => r.LastUsed)
|
||||
.ToLookup(GetInformationClass, GetMenuData);
|
||||
|
||||
ResultMenu.UpdateSearchRelations(relationsLookup);
|
||||
ResultMenu.SetHeaderText(searchHistoryEntry.HeaderText, hideDetailsCheckbox: false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
|
||||
cMenuDataBase GetMenuData(cF4sdApiSearchResultRelation relation)
|
||||
{
|
||||
var requiredInformationClasses = new List<enumFasdInformationClass>() { cF4sdIdentityEntry.GetFromSearchResult(relation.Type) };
|
||||
bool isEnabled = cHealthCardDataHelper.HasAvailableHealthCard(requiredInformationClasses);
|
||||
string disabledReason = null;
|
||||
|
||||
if (!isEnabled)
|
||||
{
|
||||
disabledReason = cMultiLanguageSupport.GetItem("Searchbar.NoValidHealthcard") ?? string.Empty;
|
||||
}
|
||||
|
||||
string trailingText = null;
|
||||
|
||||
return new cMenuDataSearchRelation(relation)
|
||||
{
|
||||
MenuText = relation.DisplayName,
|
||||
TrailingText = trailingText,
|
||||
UiAction = new cUiProcessSearchRelationAction(searchHistoryEntry, relation, relationService, searchUiProvider)
|
||||
{
|
||||
DisplayType = isEnabled ? enumActionDisplayType.enabled : enumActionDisplayType.disabled,
|
||||
Description = isEnabled ? string.Empty : disabledReason,
|
||||
AlternativeDescription = isEnabled ? string.Empty : disabledReason
|
||||
}
|
||||
};
|
||||
}
|
||||
enumFasdInformationClass GetInformationClass(cF4sdApiSearchResultRelation relation) => cF4sdIdentityEntry.GetFromSearchResult(relation.Type);
|
||||
|
||||
}
|
||||
|
||||
public void SetPendingInformationClasses(HashSet<enumFasdInformationClass> informationClasses) => ResultMenu.SetPendingInformationClasses(informationClasses);
|
||||
|
||||
public void UpdatePendingInformationClasses(HashSet<enumFasdInformationClass> informationClasses) => ResultMenu.UpdatePendingInformationClasses(informationClasses);
|
||||
|
||||
private async void UiActionWasTriggered(object sender, UiActionEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.UiAction == null)
|
||||
return;
|
||||
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
|
||||
switch (e.UiAction)
|
||||
{
|
||||
case cUiProcessSearchResultAction searchResultAction:
|
||||
searchResultAction.PreSelectedSearchRelation = preSelectedRelation;
|
||||
break;
|
||||
case cUiProcessSearchRelationAction _:
|
||||
case cUiProcessSearchHistoryEntry _:
|
||||
break;
|
||||
default:
|
||||
var _t = e.UiAction?.GetType().Name;
|
||||
Debug.Assert(true, $"The UI action '{_t}' is not supported in detailed page");
|
||||
CancledSearchAction();
|
||||
return;
|
||||
}
|
||||
|
||||
SetSearchResultVisibility(true);
|
||||
if (!await e.UiAction.RunUiActionAsync(sender, null, false, null))
|
||||
CancledSearchAction();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSearchResultVisibility(bool isVisible)
|
||||
{
|
||||
SearchResultBorder.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
BodyStack.Visibility = (isVisible || SearchResultBorder.IsVisible) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void CancledSearchAction()
|
||||
{
|
||||
SearchBarUc.Clear();
|
||||
ResultMenu.ShowSearchResults(new cFilteredResults(), null, this);
|
||||
SetSearchResultVisibility(false);
|
||||
SetSearchHistoryVisibility(false);
|
||||
Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region Cleanup when implementing search
|
||||
|
||||
public void SetSearchHistoryVisibility(bool isVisible)
|
||||
{
|
||||
SearchHistoryBorder.Visibility = isVisible && !SearchHistory.IsEmpty() ? Visibility.Visible : Visibility.Collapsed;
|
||||
BodyStack.Visibility = (isVisible || SearchResultBorder.IsVisible) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ComputerDomainSearch(cComputerDomainSearchParameters searchInfo)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var _h = Task.Run(async () =>
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var _result = await cFasdCockpitCommunicationBase.Instance.GetComputerSearchResults(searchInfo.name, searchInfo.domain);
|
||||
var strInfo = string.Format(cMultiLanguageSupport.GetItem("Searchbar.ComputerSearch.Info"), searchInfo.name);
|
||||
ShowExternalSearchInfo(strInfo, _result, enumF4sdSearchResultClass.Computer);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ShowExternalSearchInfo(string strInfo, cFasdApiSearchResultCollection resultEntry, enumF4sdSearchResultClass Class)
|
||||
{
|
||||
var filteredResults = new cFilteredResults(resultEntry) { AutoContinue = true };
|
||||
var _t = ShowExternalSearchInfoAsync(strInfo, filteredResults, Class);
|
||||
}
|
||||
|
||||
private async Task ShowExternalSearchInfoAsync(string strInfo, cFilteredResults result, enumF4sdSearchResultClass Class)
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await SearchBarUc.SetFixedSearchResultAsync(Class, strInfo, result);
|
||||
|
||||
if (result.AutoContinue && result.Results?.Count == 1)
|
||||
{
|
||||
ResultMenu.IndexOfSelectedResultItem = 0;
|
||||
ResultMenu.SelectCurrentResultItem();
|
||||
}
|
||||
|
||||
Show();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchValue
|
||||
{
|
||||
get => searchValue;
|
||||
set
|
||||
{
|
||||
if (value != searchValue)
|
||||
{
|
||||
searchValue = value;
|
||||
if (searchStatus == eSearchStatus.active)
|
||||
UpdateSearchResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateSearchResultsAsync(string searchValue, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchValue))
|
||||
{
|
||||
await ChangedSearchValue.Invoke(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
cFasdApiSearchResultCollection filteredResultDictionary = null;
|
||||
|
||||
try
|
||||
{
|
||||
var taskId = await cFasdCockpitCommunicationBase.Instance.GetSearchResultsStart(searchValue, CancellationToken.None);
|
||||
lock (_currentSearchTaskLock)
|
||||
{
|
||||
CurrentSearchTaskId = taskId;
|
||||
}
|
||||
var _canceled = false;
|
||||
if (!cancellationToken.IsCancellationRequested && taskId != null)
|
||||
try
|
||||
{
|
||||
filteredResultDictionary = await cFasdCockpitCommunicationBase.Instance.GetSearchResultsResult((Guid)taskId, cancellationToken);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
_canceled = true;
|
||||
LogEntry("UpdateSearchResultsAsync was cancelled by token (4).", LogLevels.Debug);
|
||||
}
|
||||
_canceled |= cancellationToken.IsCancellationRequested;
|
||||
taskId = null;
|
||||
if (_canceled)
|
||||
lock (_currentSearchTaskLock)
|
||||
{
|
||||
taskId = CurrentSearchTaskId;
|
||||
CurrentSearchTaskId = null;
|
||||
}
|
||||
if (taskId != null)
|
||||
await cFasdCockpitCommunicationBase.Instance.GetSearchResultsStop((Guid)taskId, CancellationToken.None);
|
||||
}
|
||||
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
LogEntry("UpdateSearchResultsAsync was cancelled by token (3).", LogLevels.Debug);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
LogEntry("UpdateSearchResultsAsync was cancelled by token (2).", LogLevels.Debug);
|
||||
return;
|
||||
}
|
||||
|
||||
cFilteredResults filteredResult = new cFilteredResults(filteredResultDictionary);
|
||||
await ChangedSearchValue.Invoke(filteredResult);
|
||||
}
|
||||
LogEntry("UpdateSearchResultsAsync finished successful.", LogLevels.Warning);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
LogEntry("UpdateSearchResultsAsync was cancelled by token (1).", LogLevels.Warning);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSearchResults()
|
||||
{
|
||||
MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); }
|
||||
|
||||
try
|
||||
{
|
||||
if (ChangedSearchValue == null)
|
||||
return;
|
||||
|
||||
if (_searchTimer.IsEnabled)
|
||||
_searchTimer.Stop();
|
||||
|
||||
_searchTimer.Start();
|
||||
|
||||
var stopTask = Task.Run(() =>
|
||||
{
|
||||
CancelRunningSearchTaskAsync();
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (CM != null) LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CancelRunningSearchTaskAsync()
|
||||
{
|
||||
// cancel the search task, in case of a running search task
|
||||
lock (_currentSearchTaskLock)
|
||||
{
|
||||
if (CurrentSearchTaskToken != null)
|
||||
{
|
||||
LogEntry("Canceling current running search...");
|
||||
CurrentSearchTaskToken.Cancel(true);
|
||||
CurrentSearchTaskToken = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ShowLoadingTextItem(string itemText)
|
||||
{
|
||||
SetSearchHistoryVisibility(false);
|
||||
ResultMenu.ShowLoadingTextItem(itemText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
122
FasdDesktopUi/Pages/CustomMessageBox/CustomMessageBox.xaml
Normal file
122
FasdDesktopUi/Pages/CustomMessageBox/CustomMessageBox.xaml
Normal file
@@ -0,0 +1,122 @@
|
||||
<p:CustomPopupBase x:Class="FasdDesktopUi.Pages.CustomMessageBox.CustomMessageBox"
|
||||
xmlns:p="clr-namespace:FasdDesktopUi.Pages"
|
||||
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.CustomMessageBox"
|
||||
xmlns:uc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
x:Name="CustomMessageBoxView"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
MaxWidth="475"
|
||||
Background="Transparent"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
PreviewKeyDown="CustomMessageBox_PreviewKeyDown"
|
||||
IsVisibleChanged="BlurInvoker_IsActiveChanged"
|
||||
>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<p:CustomPopupBase.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<vc:BoolOrToVisibilityConverter x:Key="BoolOrToVisibilityConverter" />
|
||||
</p:CustomPopupBase.Resources>
|
||||
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="7.5"
|
||||
Padding="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas Grid.RowSpan="999"
|
||||
Panel.ZIndex="5"
|
||||
Margin="-10 -10">
|
||||
<Border x:Name="FocusBorder"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Grid.RowSpan="999"
|
||||
Opacity="0.4"
|
||||
Visibility="Collapsed"
|
||||
Panel.ZIndex="-1"
|
||||
Width="{Binding ElementName=CustomMessageBoxView, Path=ActualWidth}"
|
||||
Height="{Binding ElementName=CustomMessageBoxView, Path=ActualHeight}" />
|
||||
<Decorator x:Name="FocusDecorator" />
|
||||
|
||||
</Canvas>
|
||||
|
||||
<DockPanel Grid.Row="0"
|
||||
Margin="0 0 0 10"
|
||||
>
|
||||
<ico:AdaptableIcon DockPanel.Dock="Right"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseLeftButtonUp="Close_MouseLeftButtonUp"
|
||||
TouchDown="Close_TouchDown"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="StatusIcon"
|
||||
DockPanel.Dock="Left"
|
||||
SecondaryIconColor="{DynamicResource Color.AppBackground}"
|
||||
HorizontalAlignment="Right"
|
||||
BorderPadding="0 7.5 7.5 7.5"
|
||||
Visibility="Collapsed">
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<TextBlock Text="{Binding Caption}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
FontSize="18"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}"
|
||||
Visibility="{Binding Caption, Converter={StaticResource NullToVisibility}}"/>
|
||||
</DockPanel>
|
||||
|
||||
<Border Grid.Row="1" Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
CornerRadius="7.5"
|
||||
Padding="10"
|
||||
Visibility="{Binding Message, Converter={StaticResource NullToVisibility}}">
|
||||
<TextBlock Text="{Binding Message}"
|
||||
FontSize="16"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding Message, Converter={StaticResource NullToVisibility}}"
|
||||
Style="{DynamicResource SlimPage.Widget.Title}" />
|
||||
</Border>
|
||||
|
||||
<uc:YesNoButton x:Name="YesNoButtonControl" x:FieldModifier="private"
|
||||
Grid.Row="2"
|
||||
HasYesNoButtons="{Binding ElementName=CustomMessageBoxView, Path=HasYesNoButtons}"
|
||||
HasYesNoText="{Binding ElementName=CustomMessageBoxView, Path=HasYesNoText}"
|
||||
ButtonHasBeenClicked="YesNoButton_ButtonHasBeenClicked"
|
||||
>
|
||||
<uc:YesNoButton.Visibility>
|
||||
<MultiBinding Converter="{StaticResource BoolOrToVisibilityConverter}">
|
||||
<Binding Path="HasYesNoButtons" ElementName="CustomMessageBoxView"/>
|
||||
<Binding Path="HasYesNoText" ElementName="CustomMessageBoxView"/>
|
||||
</MultiBinding>
|
||||
</uc:YesNoButton.Visibility>
|
||||
</uc:YesNoButton>
|
||||
<uc:MultiButton HorizontalAlignment="Center"
|
||||
x:Name="MultiButtons"
|
||||
Grid.Row="2"
|
||||
Visibility="Collapsed" ResultChanged="MultiButtons_ResultChanged"
|
||||
Margin="0,10,0,0"
|
||||
>
|
||||
</uc:MultiButton>
|
||||
</Grid>
|
||||
</Border>
|
||||
</p:CustomPopupBase>
|
||||
343
FasdDesktopUi/Pages/CustomMessageBox/CustomMessageBox.xaml.cs
Normal file
343
FasdDesktopUi/Pages/CustomMessageBox/CustomMessageBox.xaml.cs
Normal file
@@ -0,0 +1,343 @@
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.CustomEvents;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.CustomMessageBox
|
||||
{
|
||||
public partial class CustomMessageBox : CustomPopupBase, IBlurInvoker, INotifyPropertyChanged
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private bool isCanceled = false;
|
||||
|
||||
#region Caption
|
||||
|
||||
private string _Caption = null;
|
||||
public string Caption
|
||||
{
|
||||
get { return _Caption; }
|
||||
set { if (value != _Caption) { _Caption = value; OnPropertyChanged("Caption"); } }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Message
|
||||
|
||||
private string _Message = null;
|
||||
public string Message
|
||||
{
|
||||
get { return _Message; }
|
||||
set { if (value != _Message) { _Message = value; OnPropertyChanged("Message"); } }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CenterText
|
||||
|
||||
private bool _CenterText = false;
|
||||
public bool CenterText
|
||||
{
|
||||
get { return _CenterText; }
|
||||
set { if (value != _CenterText) { _CenterText = value; OnPropertyChanged("CenterText"); } }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HasYesNoButtons
|
||||
|
||||
|
||||
private bool _HasYesNoButtons = false;
|
||||
|
||||
public bool HasYesNoButtons
|
||||
{
|
||||
get { return _HasYesNoButtons; }
|
||||
set { if (value != _HasYesNoButtons) { _HasYesNoButtons = value; OnPropertyChanged("HasYesNoButtons"); } }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region HasYesNoText
|
||||
|
||||
|
||||
private bool _HasYesNoText = false;
|
||||
public bool HasYesNoText
|
||||
{
|
||||
get { return _HasYesNoText; }
|
||||
set { if (value != _HasYesNoText) { _HasYesNoText = value; OnPropertyChanged("HasYesNoText"); } }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public int ResultIndex { get; private set; } = -1;
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CustomMessageBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
|
||||
cFocusInvoker.GotFocus += ElementGotFocus;
|
||||
cFocusInvoker.LostFocus += ElementLostFocus;
|
||||
}
|
||||
|
||||
private void SetLevel(enumHealthCardStateLevel level)
|
||||
{
|
||||
StatusIcon.Visibility = Visibility.Visible;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case enumHealthCardStateLevel.None:
|
||||
StatusIcon.Visibility = Visibility.Collapsed;
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.none;
|
||||
break;
|
||||
case enumHealthCardStateLevel.Ok:
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.status_good;
|
||||
StatusIcon.PrimaryIconColor = (SolidColorBrush)Application.Current.FindResource("Color.Green");
|
||||
break;
|
||||
case enumHealthCardStateLevel.Warning:
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.status_danger;
|
||||
StatusIcon.PrimaryIconColor = (SolidColorBrush)Application.Current.FindResource("Color.Orange");
|
||||
break;
|
||||
case enumHealthCardStateLevel.Error:
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.status_bad;
|
||||
StatusIcon.PrimaryIconColor = (SolidColorBrush)Application.Current.FindResource("Color.Red");
|
||||
break;
|
||||
case enumHealthCardStateLevel.Info:
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.status_info;
|
||||
StatusIcon.PrimaryIconColor = (SolidColorBrush)Application.Current.FindResource("Color.Blue");
|
||||
break;
|
||||
default:
|
||||
StatusIcon.SelectedInternIcon = enumInternIcons.f4sd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static CustomMessageBox InitializeMessageBox(string Message, string Caption, enumHealthCardStateLevel Level, Window Owner, bool HasYesNoButtons, bool HasYesNoText, List<string> MultiButtonText, bool TopMost, bool CenterScreen)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Owner != null)
|
||||
cUtility.BringWindowToFront(Owner);
|
||||
|
||||
var existingMessageBox = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is CustomMessageBox);
|
||||
if (existingMessageBox != null)
|
||||
{
|
||||
existingMessageBox.Show();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
CustomMessageBox messageBox = new CustomMessageBox();
|
||||
|
||||
if (MultiButtonText != null)
|
||||
{
|
||||
HasYesNoButtons = false;
|
||||
HasYesNoText = false;
|
||||
messageBox.MultiButtons.Visibility = Visibility.Visible;
|
||||
messageBox.MultiButtons.SetButtonText(MultiButtonText);
|
||||
}
|
||||
|
||||
messageBox.Message = Message;
|
||||
messageBox.Caption = Caption;
|
||||
messageBox.SetLevel(Level);
|
||||
messageBox.HasYesNoButtons = HasYesNoButtons;
|
||||
messageBox.HasYesNoText = HasYesNoText;
|
||||
messageBox.Topmost = TopMost;
|
||||
|
||||
try
|
||||
{
|
||||
messageBox.Owner = Owner;
|
||||
}
|
||||
catch { }
|
||||
if (!CenterScreen && Owner != null && Owner.Visibility == Visibility.Visible)
|
||||
messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
else
|
||||
messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
return messageBox;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int Show(string Message, List<string> MultiButtonText, string Caption = null, enumHealthCardStateLevel Level = enumHealthCardStateLevel.None, Window Owner = null, bool TopMost = false, bool CenterScreen = false, int MaxWidth = -1)
|
||||
{
|
||||
var messageBox = InitializeMessageBox(Message, Caption, Level, Owner, false, false, MultiButtonText, TopMost, CenterScreen);
|
||||
if (MaxWidth > 0)
|
||||
messageBox.MaxWidth = MaxWidth;
|
||||
if (messageBox == null)
|
||||
return -1;
|
||||
messageBox.ShowDialog();
|
||||
return messageBox.ResultIndex;
|
||||
}
|
||||
|
||||
public static bool? Show(string Message, string Caption = null, enumHealthCardStateLevel Level = enumHealthCardStateLevel.None, Window Owner = null, bool HasYesNoButtons = false, bool HasYesNoText = false, bool TopMost = false, bool CenterScreen = false)
|
||||
{
|
||||
var messageBox = InitializeMessageBox(Message, Caption, Level, Owner, HasYesNoButtons, HasYesNoText, null, TopMost, CenterScreen);
|
||||
if (messageBox == null)
|
||||
return null;
|
||||
|
||||
var dialogResult = messageBox.ShowDialog();
|
||||
return messageBox.isCanceled ? null : dialogResult;
|
||||
}
|
||||
|
||||
#region Close_Click
|
||||
|
||||
private void Close_Click()
|
||||
{
|
||||
DialogResult = null;
|
||||
isCanceled = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Close_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close_Click();
|
||||
}
|
||||
|
||||
private void Close_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Close_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Focus Events
|
||||
|
||||
private void ElementGotFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
FocusBorder.Visibility = Visibility.Visible;
|
||||
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (FocusBorder.IsVisible is false)
|
||||
return;
|
||||
|
||||
var desiredHeight = senderElement.ActualHeight;
|
||||
var desiredWidth = senderElement.ActualWidth;
|
||||
|
||||
FrameworkElement placeHolderElement = new FrameworkElement() { Height = desiredHeight, Width = desiredWidth, Margin = senderElement.Margin };
|
||||
FocusDecorator.Height = desiredHeight + senderElement.Margin.Top + senderElement.Margin.Bottom;
|
||||
FocusDecorator.Width = desiredWidth + senderElement.Margin.Left + senderElement.Margin.Right;
|
||||
|
||||
Point relativePoint = senderElement.TransformToAncestor(this)
|
||||
.Transform(new Point(0, 0));
|
||||
|
||||
if (senderElement.Parent is Decorator actualParentDecorator)
|
||||
actualParentDecorator.Child = placeHolderElement;
|
||||
else if (senderElement.Parent is Panel actualParentPanel)
|
||||
{
|
||||
if (actualParentPanel is Grid)
|
||||
{
|
||||
Grid.SetColumn(placeHolderElement, Grid.GetColumn(senderElement));
|
||||
Grid.SetRow(placeHolderElement, Grid.GetRow(senderElement));
|
||||
}
|
||||
|
||||
actualParentPanel.Children.Insert(actualParentPanel.Children.IndexOf(senderElement), placeHolderElement);
|
||||
actualParentPanel.Children.Remove(senderElement);
|
||||
}
|
||||
|
||||
Canvas.SetLeft(FocusDecorator, relativePoint.X - (senderElement.Margin.Left));
|
||||
Canvas.SetTop(FocusDecorator, relativePoint.Y - senderElement.Margin.Top);
|
||||
|
||||
FocusDecorator.Child = senderElement;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ElementLostFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
FocusBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void CustomMessageBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
Close_Click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DoCloseAction(bool IsClose)
|
||||
{
|
||||
DialogResult = IsClose;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
private void YesNoButton_ButtonHasBeenClicked(object sender, BooleanEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoCloseAction(e.BooleanArg);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void MultiButtons_ResultChanged(object sender, MultiButtonEventArgs e)
|
||||
{
|
||||
ResultIndex = e.ResultIndex;
|
||||
Close();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
FasdDesktopUi/Pages/CustomPopupBase.cs
Normal file
55
FasdDesktopUi/Pages/CustomPopupBase.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace FasdDesktopUi.Pages
|
||||
{
|
||||
public class CustomPopupBase : Window, IDisposable, IBlurInvoker
|
||||
{
|
||||
public CustomPopupBase()
|
||||
{
|
||||
this.IsVisibleChanged += SettingsPageBase_IsVisibleChanged;
|
||||
}
|
||||
|
||||
private void SettingsPageBase_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is CustomPopupBase senderPage))
|
||||
return;
|
||||
|
||||
if (senderPage.Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
foreach (var window in Application.Current.Windows.OfType<CustomPopupBase>().Where(w => w.IsVisible && w != sender).ToArray())
|
||||
{
|
||||
window.Hide();
|
||||
window.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
cLogManager.LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void BlurInvoker_IsActiveChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlurInvoker.InvokeVisibilityChanged(this, new EventArgs());
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
cLogManager.LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public bool BlurInvoker_IsActive => IsVisible;
|
||||
|
||||
public virtual void Dispose() { }
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.M42AuthenticationPage.F4sdM42FormsAuthentication"
|
||||
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:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:local="clr-namespace:FasdDesktopUi.Pages.M42AuthenticationPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:WebView="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
mc:Ignorable="d"
|
||||
Title="M42FomsAuthetication"
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="800"
|
||||
MinWidth="800"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:Name="F4sdM42FormsAuth"
|
||||
>
|
||||
<Window.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</Window.Resources>
|
||||
<Border
|
||||
CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="TextHeader" x:FieldModifier="private" Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.FormsAuthentication.Header}" FontSize="18" VerticalAlignment="Center" Margin="10 0 0 0" FontWeight="Bold"/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="butRefresh"
|
||||
Grid.Column="1"
|
||||
SelectedInternIcon="menuBar_refresh"
|
||||
Padding="0" Margin="4 2"
|
||||
IconHeight="30" IconWidth="30"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Background="#01000000"
|
||||
MouseLeftButtonUp="butRefresh_MouseLeftButtonUp"
|
||||
Cursor="Hand"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.Header.RefreshForm}"
|
||||
/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="butClearCookies"
|
||||
Grid.Column="2"
|
||||
SelectedMaterialIcon="ic_delete_forever"
|
||||
Padding="0" Margin="4 2"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
IconHeight="30" IconWidth="30"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Background="#01000000"
|
||||
MouseLeftButtonUp="butClearCookies_MouseLeftButtonUp"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.Header.ClearCookies}"
|
||||
/>
|
||||
<ico:AdaptableIcon Grid.Column="3"
|
||||
SelectedInternIcon="window_close"
|
||||
Padding="0" Margin="4 2"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
IconHeight="30"
|
||||
IconWidth="30"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Background="#01000000"
|
||||
MouseLeftButtonUp="CloseIcon_MouseLeftButtonUp"
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="249*"/>
|
||||
<ColumnDefinition Width="11*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<WebView:WebView2
|
||||
x:Name="WebLogon" x:FieldModifier="private"
|
||||
Loaded="WebLogon_Loaded"
|
||||
NavigationStarting="WebLogon_NavigationStarting"
|
||||
Margin="10,10,10,10"
|
||||
Grid.ColumnSpan="2"
|
||||
/>
|
||||
<Border
|
||||
x:Name="NoAccessTokenMessage" x:FieldModifier="private"
|
||||
Margin="197,0,0,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="7.5"
|
||||
>
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
Foreground="Red"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Margin="10"
|
||||
Text="Could not get a valid authorisation token."
|
||||
/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
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.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Logging;
|
||||
using C4IT.Matrix42.WebClient;
|
||||
using C4IT.MultiLanguage;
|
||||
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.Wpf;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.M42AuthenticationPage
|
||||
{
|
||||
public partial class F4sdM42FormsAuthentication : Window
|
||||
{
|
||||
private string _M42Server = null;
|
||||
private Uri _logonUrl = null;
|
||||
private bool regainToken = false;
|
||||
private cM42UserInfoResult userInfoM42 = null;
|
||||
private bool Reauthenticate = false;
|
||||
|
||||
public cF4SdUserInfoChange UserInfoChange { get; private set; } = null;
|
||||
|
||||
public F4sdM42FormsAuthentication(bool Reauthenticate)
|
||||
{
|
||||
InitializeComponent();
|
||||
NoAccessTokenMessage.Visibility = Visibility.Collapsed;
|
||||
this.Reauthenticate = Reauthenticate;
|
||||
}
|
||||
|
||||
private void CloseIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void StartForm()
|
||||
{
|
||||
_logonUrl = new Uri($"https://{_M42Server}/m42Services/api/sts/authorize?client_id=ServiceStore.NewUX&scope=urn:matrix42NewUX&response_type=token&autoLogin=true");
|
||||
WebLogon.Source = _logonUrl;
|
||||
}
|
||||
|
||||
private async void WebLogon_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
// set the data path for the WebView2 component
|
||||
var _webViewConfigPath = cLogManagerFile.GetDefaultPath(false, SubFolder: "WebViewData");
|
||||
_webViewConfigPath = System.IO.Path.GetDirectoryName(_webViewConfigPath);
|
||||
CultureInfo culture = new CultureInfo(cMultiLanguageSupport.CurrentLanguage);
|
||||
var webEnv = await CoreWebView2Environment.CreateAsync(userDataFolder: _webViewConfigPath, options: new CoreWebView2EnvironmentOptions() { Language = culture.TextInfo.CultureName, AllowSingleSignOnUsingOSPrimaryAccount = true });
|
||||
var _co = webEnv.CreateCoreWebView2ControllerOptions();
|
||||
await WebLogon.EnsureCoreWebView2Async(webEnv, _co);
|
||||
|
||||
// modify the header text
|
||||
if (Reauthenticate)
|
||||
{
|
||||
TextHeader.Text = cMultiLanguageSupport.GetItem("M42Settings.FormsAuthentication.HeaderResign");
|
||||
this.ShowInTaskbar = true;
|
||||
}
|
||||
|
||||
// check if we have a correct M42 config
|
||||
_M42Server = cCockpitConfiguration.Instance?.m42ServerConfiguration?.Server;
|
||||
if (string.IsNullOrEmpty(_M42Server) || cFasdCockpitCommunicationBase.CockpitUserInfo == null)
|
||||
{
|
||||
Close();
|
||||
return; ;
|
||||
}
|
||||
|
||||
// start the logon page
|
||||
StartForm();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async void WebLogon_NavigationStarting(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var _u = e.Uri;
|
||||
Debug.WriteLine($"nav.start: {_u}");
|
||||
|
||||
var _uri = new Uri(_u);
|
||||
var _host = _uri.Host.ToLowerInvariant();
|
||||
var _path = _uri.LocalPath.ToLowerInvariant();
|
||||
var _frag = _uri.Fragment;
|
||||
var _query = _uri.Query;
|
||||
string M42Code = null;
|
||||
string M42State = null;
|
||||
if (_frag == null)
|
||||
_frag = "";
|
||||
|
||||
if (_host == _M42Server.ToLowerInvariant() && _path == "/wm/" && _query.Contains("code="))
|
||||
{
|
||||
var _tmpQuery = _query;
|
||||
if (_tmpQuery.StartsWith("?"))
|
||||
_tmpQuery = _tmpQuery.Remove(0, 1);
|
||||
var _arrItems = _tmpQuery.Split('&');
|
||||
foreach (var item in _arrItems)
|
||||
{
|
||||
var _props = item.Split('=');
|
||||
if (_props.Length == 2)
|
||||
{
|
||||
switch (_props[0])
|
||||
{
|
||||
case "code":
|
||||
M42Code = _props[1];
|
||||
break;
|
||||
case "state":
|
||||
M42State = _props[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
WebLogon.Stop();
|
||||
WebLogon.CoreWebView2.Navigate(_logonUrl.AbsoluteUri);
|
||||
}
|
||||
|
||||
if (_host == _M42Server.ToLowerInvariant() && _path == "/wm/" && _frag.Contains("#access_token="))
|
||||
{
|
||||
if (regainToken)
|
||||
{
|
||||
regainToken = false;
|
||||
return;
|
||||
}
|
||||
|
||||
WebLogon.Stop();
|
||||
WebLogon.Visibility = Visibility.Collapsed;
|
||||
var _token = await ProcessAccessTokenAsync(_frag);
|
||||
if (_token is null)
|
||||
NoAccessTokenMessage.Visibility = Visibility.Visible;
|
||||
else
|
||||
{
|
||||
cF4sdUserInfo userInfo;
|
||||
lock (cFasdCockpitCommunicationBase.CockpitUserInfoLock)
|
||||
{
|
||||
userInfo = cFasdCockpitCommunicationBase.CockpitUserInfo;
|
||||
}
|
||||
var _TokenRegistration = new cF4SDTokenRegistration()
|
||||
{
|
||||
UserId = userInfo.Id,
|
||||
TokenType = cF4SDTokenRegistration.enumTokenType.M42Bearer,
|
||||
Secret = _token,
|
||||
AutoCreatePermanent = true
|
||||
};
|
||||
|
||||
var _userInfoChange = await cFasdCockpitCommunicationBase.Instance.RegisterExternalTokenAsync(_TokenRegistration);
|
||||
|
||||
if (_userInfoChange is null)
|
||||
{
|
||||
NoAccessTokenMessage.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserInfoChange = _userInfoChange;
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> ProcessAccessTokenAsync(string Fragment)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var _arrParameters = Fragment.Split('&');
|
||||
string _AccessToken = null;
|
||||
foreach (var _arrParam in _arrParameters)
|
||||
{
|
||||
var _items = _arrParam.Split('=');
|
||||
if (_items.Length == 2 && _items[0] == "#access_token")
|
||||
_AccessToken = _items[1];
|
||||
}
|
||||
|
||||
var _AccessPayload = cM42TokenPayload.GetAccessPayload(_AccessToken);
|
||||
|
||||
if (_AccessPayload != null && _AccessPayload.UserObjectId != Guid.Empty)
|
||||
{
|
||||
|
||||
var M42WebClient = new cM42WebClient(_M42Server);
|
||||
M42WebClient.SetBearerToken(_AccessToken);
|
||||
var _res = await M42WebClient.Open();
|
||||
if (_res == cM42WebClient.eReason.ok)
|
||||
{
|
||||
userInfoM42 = await M42WebClient.GetUserInfoAsync();
|
||||
if (userInfoM42.Reason == cM42WebClient.eReason.ok)
|
||||
{
|
||||
return _AccessToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static cF4SdUserInfoChange M42FormBasedAuthenticationDelegate()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var logonPage = new F4sdM42FormsAuthentication(Reauthenticate: true);
|
||||
var _ret = logonPage.ShowDialog();
|
||||
|
||||
if (_ret == true)
|
||||
return logonPage.UserInfoChange;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void butRefresh_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
WebLogon.Stop();
|
||||
WebLogon.Source = new Uri("about:blank");
|
||||
_logonUrl = new Uri($"https://{_M42Server}/m42Services/api/sts/authorize?client_id=ServiceStore.NewUX&scope=urn:matrix42NewUX&response_type=token&autoLogin=true");
|
||||
WebLogon.Source = _logonUrl;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void butClearCookies_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (WebLogon?.CoreWebView2?.CookieManager != null)
|
||||
WebLogon.CoreWebView2.CookieManager.DeleteAllCookies();
|
||||
butRefresh_MouseLeftButtonUp(sender, null);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class cM42UserInfo
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public Guid ObjectId { get; set; }
|
||||
}
|
||||
}
|
||||
179
FasdDesktopUi/Pages/SearchPage/SearchPageView.xaml
Normal file
179
FasdDesktopUi/Pages/SearchPage/SearchPageView.xaml
Normal file
@@ -0,0 +1,179 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.SearchPage.SearchPageView"
|
||||
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.SearchPage"
|
||||
xmlns:buc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:suc="clr-namespace:FasdDesktopUi.Pages.SlimPage.UserControls"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
PreviewKeyDown="Window_PreviewKeyDown"
|
||||
Title="SearchPageView"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
Background="Transparent"
|
||||
VerticalAlignment="Bottom"
|
||||
ResizeMode="NoResize"
|
||||
WindowState="Maximized"
|
||||
Topmost="True"
|
||||
ShowInTaskbar="False">
|
||||
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<Border x:Name="MainBorder"
|
||||
x:FieldModifier="private"
|
||||
Background="#01000000"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom">
|
||||
<Grid VerticalAlignment="Bottom">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--Grid Row 0: Close Button-->
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<suc:SlimPageWindowStateBar Visibility="{Binding ElementName=MainBorder, Path=IsMouseOver, Converter={StaticResource BoolToVisibility}}"
|
||||
Grid.Row="0"
|
||||
Margin="0 -13 0 9"
|
||||
ClickedClose="SlimPageWindowStateBar_ClickedClose" />
|
||||
</Grid>
|
||||
|
||||
<!--Grid Row 1: TicketOverview-->
|
||||
<Grid Grid.Row="1"
|
||||
x:Name="BodyStack_TicketOverview"
|
||||
x:FieldModifier="private"
|
||||
Background="#01000000"
|
||||
Visibility="Collapsed"
|
||||
Margin="0 -2 0 -1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="TicketOverviewBorder"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="0"
|
||||
Padding="10"
|
||||
Margin="0 0 0 12"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="10"
|
||||
Visibility="Visible">
|
||||
<buc:TicketOverview x:Name="TicketOverviewUc"
|
||||
x:FieldModifier="private" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0">
|
||||
<CheckBox x:Name="FilterCheckbox"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
Margin="0 7 50 129"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Cursor="Hand"
|
||||
Visibility="Visible">
|
||||
</CheckBox>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0">
|
||||
<Label x:Name="RoleLabel"
|
||||
Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Role}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
Margin="280 0 0 0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="Bold"
|
||||
Visibility="Visible" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0">
|
||||
<Label x:Name="OwnTicketsLabel"
|
||||
Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.MyTickets}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
Margin="200 0 0 0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="Bold"
|
||||
Visibility="Visible" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="0">
|
||||
<Label x:Name="TicketOverviewLabel"
|
||||
Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Header}"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
Margin="9 0 0 0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="Bold"
|
||||
Visibility="Visible" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!--Grid Row 2 SearchResult + SearchHistory-->
|
||||
<Grid Grid.Row="2"
|
||||
x:Name="BodyStack_SearchResults"
|
||||
Background="#01000000"
|
||||
Visibility="Collapsed"
|
||||
Margin="0 -2 0 2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="SearchHistoryBorder"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="0"
|
||||
Padding="10"
|
||||
Margin="0 0 0 10"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="10"
|
||||
VerticalAlignment="Bottom"
|
||||
Visibility="Collapsed">
|
||||
<buc:CustomSearchResultCollection x:Name="SearchHistory"
|
||||
x:FieldModifier="private" />
|
||||
</Border>
|
||||
|
||||
<Border x:Name="SearchResultBorder"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="1"
|
||||
Padding="10"
|
||||
Margin="0 -2 0 9"
|
||||
Width="{Binding ElementName=SearchBarUc, Path=ActualWidth}"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="10"
|
||||
VerticalAlignment="Bottom"
|
||||
Visibility="Collapsed">
|
||||
<buc:CustomSearchResultCollection x:Name="ResultMenu"
|
||||
x:FieldModifier="private" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!--Grid Row 3: SearchBar-->
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<buc:SearchBar x:Name="SearchBarUc"
|
||||
x:FieldModifier="private"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="330" />
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Window>
|
||||
1413
FasdDesktopUi/Pages/SearchPage/SearchPageView.xaml.cs
Normal file
1413
FasdDesktopUi/Pages/SearchPage/SearchPageView.xaml.cs
Normal file
File diff suppressed because it is too large
Load Diff
691
FasdDesktopUi/Pages/SettingsPage/M42SettingsPageView.xaml
Normal file
691
FasdDesktopUi/Pages/SettingsPage/M42SettingsPageView.xaml
Normal file
@@ -0,0 +1,691 @@
|
||||
<settingspagebase:SettingsPageBase
|
||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.SettingsPage.M42SettingsPageView"
|
||||
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:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="PhoneSettingsPage"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="50"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
x:Name="M42SettingsWindows"
|
||||
Loaded="M42SettingsWindows_Loaded" Closed="M42SettingsWindows_Closed" IsVisibleChanged="M42SettingsWindows_IsVisibleChanged">
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<settingspagebase:SettingsPageBase.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<BlurEffect x:Key="BlurEffecStyle" Radius="4" KernelType="Gaussian"/>
|
||||
<Style x:Key="BlurableBorder" TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=M42SettingsWindows, Path=IsMethodBlurred}" Value="True">
|
||||
<Setter Property="Effect" Value="{StaticResource BlurEffecStyle}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="BlurMaskBoarder" TargetType="Border">
|
||||
<Setter Property="Background" Value="{DynamicResource Color.BlurBorder}"/>
|
||||
<Setter Property="Opacity" Value="0.2"/>
|
||||
<Setter Property="CornerRadius" Value="7.5"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Margin" Value="-10 -5"/>
|
||||
<Setter Property="Visibility" Value="{Binding ElementName=M42SettingsWindows, Path=IsMethodBlurred, Converter={StaticResource BoolToVisibility}}"/>
|
||||
<Setter Property="Grid.RowSpan" Value="999"/>
|
||||
<Setter Property="Grid.ColumnSpan" Value="999"/>
|
||||
</Style>
|
||||
<Style x:Key="BlurMaskBoarderAuto" TargetType="Border" BasedOn="{StaticResource BlurableBorder}">
|
||||
<Setter Property="Visibility" Value="{Binding ElementName=M42SettingsWindows, Path=IsMethodAuto, Converter={StaticResource BoolToVisibility}}"/>
|
||||
</Style>
|
||||
<Style x:Key="DefaultText" TargetType="TextBlock">
|
||||
<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" />
|
||||
<Setter Property="Margin"
|
||||
Value="0 0 0 0" />
|
||||
</Style>
|
||||
<Style x:Key="BlurableText" TargetType="TextBlock" BasedOn="{StaticResource DefaultText}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=M42SettingsWindows, Path=IsMethodAuto}" Value="True">
|
||||
<Setter Property="Effect" Value="{StaticResource BlurEffecStyle}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="BlurableRadioButton" TargetType="RadioButton" BasedOn="{StaticResource RadioButtonStyle}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=M42SettingsWindows, Path=IsMethodAuto}" Value="True">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<Setter Property="Effect" Value="{StaticResource BlurEffecStyle}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource Menu.MenuBar.PinnedIcon.Pinned}">
|
||||
<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>
|
||||
</settingspagebase:SettingsPageBase.Resources>
|
||||
|
||||
<Border
|
||||
CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.SystemTray}"
|
||||
x:Name="txtHeader"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
FontSize="18"
|
||||
Margin="15,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}"
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="3"
|
||||
/>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
SelectedInternIcon="window_close" Grid.Column="2" Margin="335,0,0,0" />
|
||||
|
||||
<Border Grid.Row="1"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5"
|
||||
SizeChanged="borderLogon_SizeChanged"
|
||||
Grid.ColumnSpan="3"
|
||||
>
|
||||
<TextBlock Text="You are not currently logged in to Matrix42 WPM."
|
||||
x:Name="txtCurrentUser"
|
||||
Margin="0,0,0,0"
|
||||
FontStyle="Italic"
|
||||
FontWeight="Normal"
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="2"
|
||||
x:Name="borderLogonActive"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5"
|
||||
SizeChanged="borderLogon_SizeChanged"
|
||||
Grid.ColumnSpan="3"
|
||||
>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonActive.Header}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonActive.No}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonActive.Always}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonActive.Auto}"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<RadioButton x:Name="radioButtonLogonActiveNo"
|
||||
Style="{DynamicResource RadioButtonStyle}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="4 5" Checked="radioButtonLogonActive_Checked"
|
||||
/>
|
||||
|
||||
<RadioButton x:Name="radioButtonLogonActiveYes"
|
||||
Style="{DynamicResource RadioButtonStyle}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="4 5" Checked="radioButtonLogonActive_Checked"
|
||||
/>
|
||||
<RadioButton x:Name="radioButtonLogonActiveAuto"
|
||||
Style="{DynamicResource RadioButtonStyle}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="4 5" Checked="radioButtonLogonActive_Checked"
|
||||
/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="3"
|
||||
x:Name="borderLogonMethod"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5"
|
||||
SizeChanged="borderLogon_SizeChanged" Grid.ColumnSpan="3"
|
||||
Style="{StaticResource BlurableBorder}"
|
||||
IsEnabled="{Binding ElementName=M42SettingsWindows, Path=IsNotMethodBlurred}"
|
||||
>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.AuthenticationMethod}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Name="labelPassthough"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Passthough}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Basic}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource BlurableText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Token}"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource BlurableText}"
|
||||
/>
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.WebForm}"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Margin="8 0 0 0"
|
||||
Style="{StaticResource BlurableText}"
|
||||
/>
|
||||
<RadioButton x:Name="radioButtonLogonMethodPassthrough"
|
||||
Style="{DynamicResource RadioButtonStyle}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="4 5"
|
||||
Checked="radioButtonLogonMethod_Checked"
|
||||
/>
|
||||
|
||||
<RadioButton x:Name="radioButtonLogonMethodBasic"
|
||||
Style="{StaticResource BlurableRadioButton}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="4 5"
|
||||
Checked="radioButtonLogonMethod_Checked"
|
||||
/>
|
||||
|
||||
<RadioButton x:Name="radioButtonLogonMethodToken"
|
||||
Style="{StaticResource BlurableRadioButton}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="4 5"
|
||||
Checked="radioButtonLogonMethod_Checked"
|
||||
/>
|
||||
<RadioButton x:Name="radioButtonLogonMethodForms"
|
||||
Style="{StaticResource BlurableRadioButton}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
Margin="4 5"
|
||||
Checked="radioButtonLogonMethod_Checked"
|
||||
/>
|
||||
<Border Style="{StaticResource BlurMaskBoarder}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="additionalBlockLogonMethodBasic"
|
||||
Grid.Row="4"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5" Grid.ColumnSpan="3"
|
||||
Style="{StaticResource BlurableBorder}"
|
||||
IsEnabled="{Binding ElementName=M42SettingsWindows, Path=IsNotMethodBlurred}"
|
||||
>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Basic.Header}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Basic.Username}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="4 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Basic.Password}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="4 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="8 5"
|
||||
CornerRadius="2"
|
||||
BorderThickness="0.5"
|
||||
BorderBrush="Gray"
|
||||
VerticalAlignment="Center"
|
||||
Padding="3 2"
|
||||
>
|
||||
<TextBox
|
||||
x:Name="BasicUserName"
|
||||
BorderThickness="0"
|
||||
BorderBrush="Transparent"
|
||||
VerticalAlignment="Center"
|
||||
Text="imagoverum\vvogel"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="8 5"
|
||||
CornerRadius="2"
|
||||
BorderThickness="0.5"
|
||||
BorderBrush="Gray"
|
||||
VerticalAlignment="Center"
|
||||
Height="21"
|
||||
Padding="3 2"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<PasswordBox Grid.Column="0"
|
||||
x:Name="pwBoxPasswordBasicShow"
|
||||
BorderThickness="0"
|
||||
BorderBrush="Transparent"
|
||||
VerticalAlignment="Center"
|
||||
Password="Matrix42"
|
||||
PasswordChanged="pwBoxPasswordBasicShow_PasswordChanged"
|
||||
/>
|
||||
<TextBox Grid.Column="0"
|
||||
x:Name="txtBoxPasswordBasicShow"
|
||||
BorderThickness="0"
|
||||
BorderBrush="Transparent"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
TextChanged="txtBoxPasswordBasicShow_TextChanged"
|
||||
/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="iconPasswordBasicShow"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_visibility"
|
||||
BorderPadding="0"
|
||||
IconWidth="17" IconHeight="17"
|
||||
Tag="PwBasicOn"
|
||||
MouseLeftButtonDown="iconPasswordShow_MouseLeftButtonDown"
|
||||
/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="iconPasswordBasicHide"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_visibility_off"
|
||||
Visibility="Collapsed"
|
||||
BorderPadding="0"
|
||||
IconWidth="17" IconHeight="17"
|
||||
Tag="PwBasicOff"
|
||||
MouseLeftButtonDown="iconPasswordShow_MouseLeftButtonDown"
|
||||
/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Style="{StaticResource BlurMaskBoarder}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="additionalBlockLogonMethodToken"
|
||||
Grid.Row="5"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5" Grid.ColumnSpan="3"
|
||||
Style="{StaticResource BlurableBorder}"
|
||||
IsEnabled="{Binding ElementName=M42SettingsWindows, Path=IsNotMethodBlurred}"
|
||||
>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Token.Header}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Token.Token}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="4 0 0 0"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="8 5"
|
||||
CornerRadius="2"
|
||||
BorderThickness="0.5"
|
||||
BorderBrush="Gray"
|
||||
VerticalAlignment="Center"
|
||||
Padding="3 2"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<PasswordBox Grid.Column="0"
|
||||
x:Name="pwBoxPasswordTokenShow"
|
||||
BorderThickness="0"
|
||||
BorderBrush="Transparent"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 3 0"
|
||||
Password="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1"
|
||||
PasswordChanged="pwBoxPasswordTokenShow_PasswordChanged"
|
||||
/>
|
||||
<TextBox Grid.Column="0"
|
||||
x:Name="txtBoxPasswordTokenShow"
|
||||
BorderThickness="0"
|
||||
BorderBrush="Transparent"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
Margin="0 0 3 0"
|
||||
TextChanged="pwBoxPasswordTokenHide_TextChanged"
|
||||
/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="iconTokenShow"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_visibility"
|
||||
BorderPadding="0"
|
||||
IconWidth="17" IconHeight="17"
|
||||
Tag="TokenOn"
|
||||
MouseLeftButtonDown="iconPasswordShow_MouseLeftButtonDown"
|
||||
/>
|
||||
<ico:AdaptableIcon
|
||||
x:Name="iconTokenHide"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_visibility_off"
|
||||
Visibility="Collapsed"
|
||||
BorderPadding="0"
|
||||
IconWidth="17" IconHeight="17"
|
||||
Tag="TokenOff"
|
||||
MouseLeftButtonDown="iconPasswordShow_MouseLeftButtonDown"
|
||||
/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Style="{StaticResource BlurMaskBoarder}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="additionalBlockLogonMethodForms"
|
||||
Grid.Row="6"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5,5,5,5"
|
||||
Padding="10 5" Grid.ColumnSpan="3"
|
||||
Style="{StaticResource BlurableBorder}"
|
||||
IsEnabled="{Binding ElementName=M42SettingsWindows, Path=IsNotMethodBlurred}"
|
||||
>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Forms.Header}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="8 5"
|
||||
CornerRadius="2"
|
||||
BorderThickness="0.5"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Height="21"
|
||||
Padding="4 2" MouseLeftButtonDown="DoFormsAuthentication_MouseLeftButtonDown"
|
||||
>
|
||||
<Border.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource Background.Menu.Icon.Hover}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="Gray" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FFD8E6FF" />
|
||||
<Setter Property="BorderBrush" Value="#FF5593FF" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=M42Settings.LogonMethod.Forms.Logon}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="8 0 8 0"
|
||||
IsHitTestVisible="False"
|
||||
Style="{StaticResource DefaultText}"
|
||||
/>
|
||||
</Border>
|
||||
<Border Style="{StaticResource BlurMaskBoarder}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<TextBlock Grid.Row="7" Grid.ColumnSpan="3"
|
||||
x:Name="txtAuthenticationError"
|
||||
Text="Sie konnten nicht angemeldet werden. Bitte ändern Sie ihre Angaben für eine gültige Anmeldung."
|
||||
Grid.Column="0"
|
||||
Margin="10 3 0 3"
|
||||
Foreground="Red"
|
||||
/>
|
||||
|
||||
<Grid Grid.Row="8" Grid.ColumnSpan="3">
|
||||
|
||||
<Grid.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="Margin"
|
||||
Value="0 10 0 0" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="125" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="2.5" />
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="7*" />
|
||||
<ColumnDefinition Width="31*"/>
|
||||
<ColumnDefinition Width="38*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ConfirmButton"
|
||||
Grid.Column="0"
|
||||
SelectedMaterialIcon="ic_check" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="32,10,0,0" MouseDown="ConfirmButton_MouseDown" TouchDown="ConfirmButton_TouchDown">
|
||||
<ico:AdaptableIcon.Tag>
|
||||
<sys:Boolean>True</sys:Boolean>
|
||||
</ico:AdaptableIcon.Tag>
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource {x:Type ico:AdaptableIcon}}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Green}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CancelButton"
|
||||
Grid.Column="2"
|
||||
SelectedMaterialIcon="ic_close" Margin="0,10,0,0" MouseLeftButtonUp="CloseButton_MouseLeftButtonUp" TouchDown="CloseButton_TouchDown">
|
||||
<ico:AdaptableIcon.Tag>
|
||||
<sys:Boolean>False</sys:Boolean>
|
||||
</ico:AdaptableIcon.Tag>
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource {x:Type ico:AdaptableIcon}}">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Red}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</settingspagebase:SettingsPageBase>
|
||||
588
FasdDesktopUi/Pages/SettingsPage/M42SettingsPageView.xaml.cs
Normal file
588
FasdDesktopUi/Pages/SettingsPage/M42SettingsPageView.xaml.cs
Normal file
@@ -0,0 +1,588 @@
|
||||
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.Shapes;
|
||||
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Pages.M42AuthenticationPage;
|
||||
using FasdDesktopUi.Pages.DetailsPage;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SettingsPage
|
||||
{
|
||||
public partial class M42SettingsPageView : SettingsPageBase
|
||||
{
|
||||
private static M42SettingsPageView _Instance = null;
|
||||
|
||||
public static M42SettingsPageView Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Instance ?? (_Instance = new M42SettingsPageView());
|
||||
}
|
||||
}
|
||||
|
||||
private double borderWidth = double.MaxValue;
|
||||
|
||||
private enumM42AuthenticationMethod authenticationMethod;
|
||||
|
||||
private enumM42AuthenticationControl authenticationControl;
|
||||
|
||||
private bool formsAuthenticated = false;
|
||||
|
||||
private bool IsTemporaryDisabled = false;
|
||||
|
||||
private bool _isMethodBlurred = false;
|
||||
public bool IsNotMethodBlurred
|
||||
{
|
||||
get { return !_isMethodBlurred; }
|
||||
}
|
||||
public bool IsMethodBlurred
|
||||
{
|
||||
get { return _isMethodBlurred; }
|
||||
set
|
||||
{
|
||||
if (value != _isMethodBlurred)
|
||||
{
|
||||
_isMethodBlurred = value;
|
||||
OnPropertyChanged(nameof(IsMethodBlurred));
|
||||
OnPropertyChanged(nameof(IsNotMethodBlurred));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isMethodAuto = false;
|
||||
public bool IsNotMethodAuto { get { return !_isMethodAuto; } }
|
||||
public bool IsMethodAuto
|
||||
{
|
||||
get { return _isMethodAuto; }
|
||||
set
|
||||
{
|
||||
if (value != _isMethodAuto)
|
||||
{
|
||||
_isMethodAuto = value;
|
||||
OnPropertyChanged(nameof(IsMethodAuto));
|
||||
OnPropertyChanged(nameof(IsNotMethodAuto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private M42SettingsPageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void M42SettingsWindows_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.NewValue is bool isVisible)
|
||||
{
|
||||
if (isVisible && !IsTemporaryDisabled)
|
||||
{
|
||||
App.HideAllSettingViews();
|
||||
|
||||
if (this.IsLoaded)
|
||||
InitializeControlValues();
|
||||
}
|
||||
}
|
||||
|
||||
BlurInvoker_IsActiveChanged(sender, e);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region DialogButton_Click
|
||||
|
||||
public void DialogButton_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (!(senderElement.Tag is bool tagValue))
|
||||
return;
|
||||
|
||||
if (tagValue)
|
||||
{
|
||||
}
|
||||
|
||||
Close();
|
||||
|
||||
if (tagValue)
|
||||
{
|
||||
var _h = Dispatcher.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(300);
|
||||
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show(cMultiLanguageSupport.GetItem("M42Settings.ChangedInfoDialog.Text"), cMultiLanguageSupport.GetItem("M42Settings.RestartDialog.Caption"), enumHealthCardStateLevel.Info, null, true);
|
||||
|
||||
if (dialogResult == true)
|
||||
{
|
||||
System.Windows.Forms.Application.Restart();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CloseButton_Click
|
||||
|
||||
private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async void M42SettingsWindows_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
// initialize the window title
|
||||
var _ServerDisplayName = cCockpitConfiguration.Instance?.m42ServerConfiguration?.DisplayName;
|
||||
if (!string.IsNullOrEmpty(_ServerDisplayName))
|
||||
{
|
||||
var _strTitle = cMultiLanguageSupport.GetItem("M42Settings.Header");
|
||||
_strTitle = string.Format(_strTitle, _ServerDisplayName);
|
||||
txtHeader.Text = _strTitle;
|
||||
}
|
||||
|
||||
// get the current logon user info
|
||||
var _currUserInfo = await cFasdCockpitCommunicationBase.Instance.GetAdditionalUserInfo(enumAdditionalAuthentication.M42WinLogon);
|
||||
if (_currUserInfo != null)
|
||||
{
|
||||
var _txt = cMultiLanguageSupport.GetItem("M42Settings.LogonMethod.CurrentUserValid");
|
||||
var _ci = new CultureInfo(cMultiLanguageSupport.CurrentLanguage);
|
||||
var _dt = _currUserInfo.ValidUntil.ToLocalTime().ToString(_ci);
|
||||
_txt = string.Format(_txt, _currUserInfo.Name, _dt);
|
||||
txtCurrentUser.Text = _txt;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtCurrentUser.Text = cMultiLanguageSupport.GetItem("M42Settings.LogonMethod.CurrentUserInvalid");
|
||||
}
|
||||
|
||||
// get user name for passthrough label
|
||||
string userName;
|
||||
string userAccount;
|
||||
lock (cFasdCockpitCommunicationBase.CockpitUserInfoLock)
|
||||
{
|
||||
userName = cFasdCockpitCommunicationBase.CockpitUserInfo?.Name;
|
||||
userAccount = cFasdCockpitCommunicationBase.CockpitUserInfo?.AdAccount;
|
||||
}
|
||||
string str = null;
|
||||
if (string.IsNullOrEmpty(userName))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(userAccount))
|
||||
str = userAccount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(userAccount))
|
||||
str = userName;
|
||||
else
|
||||
str = $"{userName}({userAccount})";
|
||||
}
|
||||
|
||||
|
||||
if (str != null)
|
||||
{
|
||||
var s = cMultiLanguageSupport.GetItem("M42Settings.LogonMethod.PassthoughUser");
|
||||
str = string.Format(s, str);
|
||||
labelPassthough.Text = str;
|
||||
}
|
||||
|
||||
txtAuthenticationError.Visibility = Visibility.Hidden;
|
||||
|
||||
InitializeControlValues();
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void InitializeControlValues()
|
||||
{
|
||||
// set the initial input control values
|
||||
BasicUserName.Text = cFasdCockpitConfig.Instance?.M42Config?.BasicUser ?? "";
|
||||
|
||||
var _pw = PrivateSecurePassword.Instance.Decode(cFasdCockpitConfig.Instance?.M42Config.BasicPassword) ?? "";
|
||||
pwBoxPasswordBasicShow.Password = _pw;
|
||||
|
||||
_pw = PrivateSecurePassword.Instance.Decode(cFasdCockpitConfig.Instance?.M42Config.ApiToken) ?? "";
|
||||
pwBoxPasswordTokenShow.Password = _pw;
|
||||
|
||||
txtBoxPasswordBasicShow.Text = pwBoxPasswordBasicShow?.Password;
|
||||
txtBoxPasswordTokenShow.Text = pwBoxPasswordTokenShow?.Password;
|
||||
|
||||
// set the initial radio button values
|
||||
switch (cFasdCockpitConfig.Instance?.M42Config?.Control)
|
||||
{
|
||||
case enumM42AuthenticationControl.always:
|
||||
radioButtonLogonActiveYes.IsChecked = true;
|
||||
break;
|
||||
case enumM42AuthenticationControl.never:
|
||||
radioButtonLogonActiveNo.IsChecked = true;
|
||||
break;
|
||||
default:
|
||||
radioButtonLogonActiveAuto.IsChecked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
authenticationMethod = cFasdCockpitConfig.Instance?.M42Config?.Method ?? enumM42AuthenticationMethod.passthrough;
|
||||
switch (cFasdCockpitConfig.Instance?.M42Config?.Method)
|
||||
{
|
||||
case enumM42AuthenticationMethod.basic:
|
||||
radioButtonLogonMethodBasic.IsChecked = true;
|
||||
break;
|
||||
case enumM42AuthenticationMethod.token:
|
||||
radioButtonLogonMethodToken.IsChecked = true;
|
||||
break;
|
||||
case enumM42AuthenticationMethod.forms:
|
||||
radioButtonLogonMethodForms.IsChecked = true;
|
||||
break;
|
||||
default:
|
||||
radioButtonLogonMethodPassthrough.IsChecked = true;
|
||||
break;
|
||||
}
|
||||
LogonActiveChanged();
|
||||
}
|
||||
|
||||
private void logonMethodChanged()
|
||||
{
|
||||
if (radioButtonLogonMethodBasic.IsChecked == true)
|
||||
{
|
||||
authenticationMethod = enumM42AuthenticationMethod.basic;
|
||||
additionalBlockLogonMethodBasic.Visibility = Visibility.Visible;
|
||||
additionalBlockLogonMethodToken.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodForms.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (radioButtonLogonMethodToken.IsChecked == true)
|
||||
{
|
||||
authenticationMethod = enumM42AuthenticationMethod.token;
|
||||
additionalBlockLogonMethodBasic.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodToken.Visibility = Visibility.Visible;
|
||||
additionalBlockLogonMethodForms.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (radioButtonLogonMethodForms.IsChecked == true)
|
||||
{
|
||||
authenticationMethod = enumM42AuthenticationMethod.forms;
|
||||
additionalBlockLogonMethodBasic.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodToken.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodForms.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
authenticationMethod = enumM42AuthenticationMethod.passthrough;
|
||||
additionalBlockLogonMethodBasic.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodToken.Visibility = Visibility.Collapsed;
|
||||
additionalBlockLogonMethodForms.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void radioButtonLogonMethod_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
logonMethodChanged();
|
||||
}
|
||||
|
||||
private void LogonActiveChanged()
|
||||
{
|
||||
if (radioButtonLogonActiveNo.IsChecked == true)
|
||||
{
|
||||
authenticationControl = enumM42AuthenticationControl.never;
|
||||
IsMethodBlurred = true;
|
||||
IsMethodAuto = false;
|
||||
}
|
||||
else if (radioButtonLogonActiveYes.IsChecked == true)
|
||||
{
|
||||
authenticationControl = enumM42AuthenticationControl.always;
|
||||
IsMethodBlurred = false;
|
||||
IsMethodAuto = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
authenticationControl = enumM42AuthenticationControl.auto;
|
||||
IsMethodBlurred = false;
|
||||
IsMethodAuto = true;
|
||||
radioButtonLogonMethodPassthrough.IsChecked = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void radioButtonLogonActive_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LogonActiveChanged();
|
||||
}
|
||||
|
||||
private void borderLogon_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
var _w = e.NewSize.Width;
|
||||
if (_w < borderWidth)
|
||||
{
|
||||
borderWidth = _w;
|
||||
additionalBlockLogonMethodBasic.MaxWidth = _w;
|
||||
additionalBlockLogonMethodForms.MaxWidth = _w;
|
||||
additionalBlockLogonMethodToken.MaxWidth = _w;
|
||||
}
|
||||
}
|
||||
|
||||
private void pwBoxPasswordBasicShow_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (txtBoxPasswordBasicShow != null && txtBoxPasswordBasicShow.Visibility != Visibility.Visible)
|
||||
txtBoxPasswordBasicShow.Text = pwBoxPasswordBasicShow?.Password;
|
||||
}
|
||||
|
||||
private void txtBoxPasswordBasicShow_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (pwBoxPasswordBasicShow != null && pwBoxPasswordBasicShow.Visibility != Visibility.Visible)
|
||||
pwBoxPasswordBasicShow.Password = txtBoxPasswordBasicShow?.Text;
|
||||
}
|
||||
|
||||
private void pwBoxPasswordTokenShow_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (txtBoxPasswordTokenShow != null && txtBoxPasswordTokenShow.Visibility != Visibility.Visible)
|
||||
txtBoxPasswordTokenShow.Text = pwBoxPasswordTokenShow?.Password;
|
||||
}
|
||||
|
||||
private void pwBoxPasswordTokenHide_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (pwBoxPasswordTokenShow != null && pwBoxPasswordTokenShow.Visibility != Visibility.Visible)
|
||||
pwBoxPasswordTokenShow.Password = txtBoxPasswordBasicShow?.Text;
|
||||
}
|
||||
|
||||
private void iconPasswordShow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!(sender is FrameworkElement _fr))
|
||||
return;
|
||||
|
||||
switch (_fr.Tag.ToString())
|
||||
{
|
||||
case "PwBasicOn":
|
||||
iconPasswordBasicHide.Visibility = Visibility.Visible;
|
||||
iconPasswordBasicShow.Visibility = Visibility.Collapsed;
|
||||
txtBoxPasswordBasicShow.Visibility = Visibility.Visible;
|
||||
pwBoxPasswordBasicShow.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
case "PwBasicOff":
|
||||
iconPasswordBasicShow.Visibility = Visibility.Visible;
|
||||
iconPasswordBasicHide.Visibility = Visibility.Collapsed;
|
||||
pwBoxPasswordBasicShow.Visibility = Visibility.Visible;
|
||||
txtBoxPasswordBasicShow.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
case "TokenOn":
|
||||
iconTokenHide.Visibility = Visibility.Visible;
|
||||
iconTokenShow.Visibility = Visibility.Collapsed;
|
||||
txtBoxPasswordTokenShow.Visibility = Visibility.Visible;
|
||||
pwBoxPasswordTokenShow.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
case "TokenOff":
|
||||
iconTokenShow.Visibility = Visibility.Visible;
|
||||
iconTokenHide.Visibility = Visibility.Collapsed;
|
||||
pwBoxPasswordTokenShow.Visibility = Visibility.Visible;
|
||||
txtBoxPasswordTokenShow.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfirmButton_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ConfirmButton_Click(sender);
|
||||
}
|
||||
|
||||
private void ConfirmButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ConfirmButton_Click(sender);
|
||||
}
|
||||
|
||||
private async void ConfirmButton_Click(object sender)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
|
||||
cFasdCockpitConfig.Instance.M42Config.Control = authenticationControl;
|
||||
cFasdCockpitConfig.Instance.Save("M42Config\\Control");
|
||||
|
||||
if (authenticationControl == enumM42AuthenticationControl.never)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
bool isAuthenticated = false;
|
||||
cF4sdCockpitM42BearerTokenInfo TokenInfo = null;
|
||||
bool HasChanged = false;
|
||||
HasChanged |= authenticationMethod != cFasdCockpitConfig.Instance.M42Config.Method;
|
||||
switch (authenticationMethod)
|
||||
{
|
||||
case enumM42AuthenticationMethod.passthrough:
|
||||
TokenInfo = await cFasdCockpitCommunicationBase.Instance.M42.ValidateLogonPassthrough();
|
||||
if (TokenInfo?.Token != null)
|
||||
isAuthenticated = true;
|
||||
break;
|
||||
case enumM42AuthenticationMethod.basic:
|
||||
var _user = BasicUserName.Text;
|
||||
var _pw = pwBoxPasswordBasicShow.Password;
|
||||
HasChanged |= _user != cFasdCockpitConfig.Instance.M42Config.BasicUser;
|
||||
HasChanged |= PrivateSecurePassword.Instance.Decode(cFasdCockpitConfig.Instance.M42Config.BasicPassword) != _pw;
|
||||
TokenInfo = await cFasdCockpitCommunicationBase.Instance.M42.ValidateLogonBasic(_user, _pw);
|
||||
if (TokenInfo?.Token != null)
|
||||
{
|
||||
isAuthenticated = true;
|
||||
if (HasChanged)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.M42Config.BasicUser = _user;
|
||||
cFasdCockpitConfig.Instance.M42Config.BasicPassword = PrivateSecurePassword.Instance.Encode(_pw);
|
||||
cFasdCockpitConfig.Instance.Save("M42Config\\BasicUser");
|
||||
cFasdCockpitConfig.Instance.Save("M42Config\\BasicPassword");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case enumM42AuthenticationMethod.token:
|
||||
var _token = pwBoxPasswordTokenShow.Password;
|
||||
HasChanged |= PrivateSecurePassword.Instance.Decode(cFasdCockpitConfig.Instance.M42Config.ApiToken) != _token;
|
||||
TokenInfo = await cFasdCockpitCommunicationBase.Instance.M42.ValidateLogonToken(_token);
|
||||
if (TokenInfo?.Token != null)
|
||||
{
|
||||
isAuthenticated = true;
|
||||
if (HasChanged)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.M42Config.ApiToken = PrivateSecurePassword.Instance.Encode(_token);
|
||||
cFasdCockpitConfig.Instance.Save("M42Config\\ApiToken");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case enumM42AuthenticationMethod.forms:
|
||||
if (formsAuthenticated)
|
||||
isAuthenticated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isAuthenticated)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.M42Config.Method = authenticationMethod;
|
||||
cFasdCockpitConfig.Instance.Save("M42Config\\Method");
|
||||
|
||||
txtAuthenticationError.Visibility = Visibility.Hidden;
|
||||
if (HasChanged)
|
||||
{
|
||||
var _tsk = Dispatcher.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(100);
|
||||
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show(cMultiLanguageSupport.GetItem("M42Settings.ChangedInfoDialog.Text"), cMultiLanguageSupport.GetItem("M42Settings.RestartDialog.Caption"), enumHealthCardStateLevel.Info, null, true);
|
||||
|
||||
if (dialogResult == true)
|
||||
{
|
||||
System.Windows.Forms.Application.Restart();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
txtAuthenticationError.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Mouse.OverrideCursor = null; ;
|
||||
this.IsEnabled = true;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DoFormsAuthentication_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
if (cFasdCockpitCommunicationBase.CockpitUserInfo == null)
|
||||
return;
|
||||
|
||||
IsTemporaryDisabled = true;
|
||||
this.IsEnabled = false;
|
||||
|
||||
var logonPage = new F4sdM42FormsAuthentication(Reauthenticate: false);
|
||||
var _ret = logonPage.ShowDialog();
|
||||
logonPage = null;
|
||||
|
||||
if (_ret == true)
|
||||
{
|
||||
formsAuthenticated = true;
|
||||
txtAuthenticationError.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.IsEnabled = true;
|
||||
IsTemporaryDisabled = false;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
private void M42SettingsWindows_Closed(object sender, EventArgs e)
|
||||
{
|
||||
_Instance = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
313
FasdDesktopUi/Pages/SettingsPage/PhoneSettingsPage.xaml
Normal file
313
FasdDesktopUi/Pages/SettingsPage/PhoneSettingsPage.xaml
Normal file
@@ -0,0 +1,313 @@
|
||||
<settingspagebase:SettingsPageBase
|
||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.PhoneSettingsPage.PhoneSettingsPage"
|
||||
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.PhoneSettingsPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="PhoneSettingsPage"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="100"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
x:Name="PhoneSettingsWindow"
|
||||
Closed="PhoneSettingsWindow_Closed" IsVisibleChanged="PhoneSettingsWindow_IsVisibleChanged"
|
||||
>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<settingspagebase:SettingsPageBase.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
|
||||
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
|
||||
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
|
||||
<Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="10">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Right" Width="58"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
|
||||
<Condition Property="IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</settingspagebase:SettingsPageBase.Resources>
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.SystemTray}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
FontSize="18"
|
||||
Margin="30 0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<Border Grid.Row="1"
|
||||
CornerRadius="7.5"
|
||||
Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
|
||||
Margin="5"
|
||||
Padding="10 5">
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.Resources>
|
||||
<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" />
|
||||
<Setter Property="Margin"
|
||||
Value="0 7.5 15 7.5" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
<RowDefinition SharedSizeGroup="RowsHeight" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.PhoneSupport.Disable}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0" />
|
||||
<CheckBox x:Name="PhoneSupportCheck"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=IsPhoneSupportDisabled}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 7.5" />
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.SwyxIt.PreferNative}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0" />
|
||||
<CheckBox x:Name="SwyxNativeCheck"
|
||||
IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=IsNativeSwyxItPreferred}"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 7.5"
|
||||
ToolTipService.ShowOnDisabled="True" />
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.PreferredLine}"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0" />
|
||||
|
||||
<ComboBox x:Name="PreferredTapiLineComboBox"
|
||||
MinWidth="150"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
ToolTipService.ShowOnDisabled="True"
|
||||
Margin="0 5" />
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.BitMode32}"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0" />
|
||||
<CheckBox x:Name="UseTapi32BitCheck"
|
||||
IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=UseTapi32Bit}"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 7.5"
|
||||
ToolTipService.ShowOnDisabled="True" />
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.SignalOutgoingCalls}"
|
||||
Grid.Row="4"
|
||||
Grid.Column="0" />
|
||||
<CheckBox x:Name="SignalOutgoingCalls"
|
||||
IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=boolSignalOutgoingCalls}"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 7.5"
|
||||
ToolTipService.ShowOnDisabled="True" />
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.ShowUnresolvedPhoneNumbers}"
|
||||
Grid.Row="5"
|
||||
Grid.Column="0" />
|
||||
<CheckBox x:Name="ShowUnresolvedPhoneNumbers"
|
||||
IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=boolShowUnresolvedPhoneNumbers}"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 7.5"
|
||||
ToolTipService.ShowOnDisabled="True" />
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.ExternalCallPrefix}"
|
||||
Grid.Row="6"
|
||||
Grid.Column="0" />
|
||||
<TextBox x:Name="ExternalCallPrefix"
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
Style="{DynamicResource TextBoxStyle1}"
|
||||
Text="{Binding ElementName=PhoneSettingsWindow, Path=strExternalCallPrefix, Mode=TwoWay}"
|
||||
MaxLength="4"
|
||||
FontSize="14"
|
||||
Width="60"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 5"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
|
||||
<Grid.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="Margin"
|
||||
Value="0 10 0 0" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="125" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="2.5" />
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="DialogButton_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="DialogButton_TouchDown" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ConfirmButton"
|
||||
Grid.Column="0"
|
||||
SelectedMaterialIcon="ic_check">
|
||||
<ico:AdaptableIcon.Tag>
|
||||
<sys:Boolean>True</sys:Boolean>
|
||||
</ico:AdaptableIcon.Tag>
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource {x:Type ico:AdaptableIcon}}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Green}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CancelButton"
|
||||
Grid.Column="1"
|
||||
SelectedMaterialIcon="ic_close">
|
||||
<ico:AdaptableIcon.Tag>
|
||||
<sys:Boolean>False</sys:Boolean>
|
||||
</ico:AdaptableIcon.Tag>
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource {x:Type ico:AdaptableIcon}}">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Red}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</settingspagebase:SettingsPageBase>
|
||||
348
FasdDesktopUi/Pages/SettingsPage/PhoneSettingsPage.xaml.cs
Normal file
348
FasdDesktopUi/Pages/SettingsPage/PhoneSettingsPage.xaml.cs
Normal file
@@ -0,0 +1,348 @@
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.F4SD.TAPI;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.CustomMessageBox;
|
||||
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.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
|
||||
namespace FasdDesktopUi.Pages.PhoneSettingsPage
|
||||
{
|
||||
public partial class PhoneSettingsPage : SettingsPageBase
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private static PhoneSettingsPage _Instance = null;
|
||||
|
||||
public static PhoneSettingsPage Instance { get
|
||||
{
|
||||
return _Instance ?? (_Instance = new PhoneSettingsPage());
|
||||
}
|
||||
}
|
||||
|
||||
#region IsPhoneSupportDisabled
|
||||
private bool _IsPhoneSupportDisabled = false;
|
||||
|
||||
public bool IsPhoneSupportDisabled
|
||||
{
|
||||
get { return _IsPhoneSupportDisabled; }
|
||||
set
|
||||
{
|
||||
if (_IsPhoneSupportDisabled != value)
|
||||
{
|
||||
_IsPhoneSupportDisabled = value;
|
||||
OnPropertyChanged(nameof(IsPhoneSupportDisabled));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsNativeSwyxItPreferred
|
||||
private bool _IsNativeSwyxItPreferred = false;
|
||||
|
||||
public bool IsNativeSwyxItPreferred
|
||||
{
|
||||
get { return _IsNativeSwyxItPreferred; }
|
||||
set
|
||||
{
|
||||
if (_IsNativeSwyxItPreferred != value)
|
||||
{
|
||||
_IsNativeSwyxItPreferred = value;
|
||||
OnPropertyChanged(nameof(IsNativeSwyxItPreferred));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsBitMode32
|
||||
private bool _UseTapi32Bit = false;
|
||||
|
||||
public bool UseTapi32Bit
|
||||
{
|
||||
get { return _UseTapi32Bit; }
|
||||
set
|
||||
{
|
||||
if (_UseTapi32Bit != value)
|
||||
{
|
||||
_UseTapi32Bit = value;
|
||||
OnPropertyChanged(nameof(UseTapi32Bit));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SignalOutgoingCalls
|
||||
private bool _boolSignalOutgoingCalls = false;
|
||||
|
||||
public bool boolSignalOutgoingCalls
|
||||
{
|
||||
get { return _boolSignalOutgoingCalls; }
|
||||
set
|
||||
{
|
||||
if (_boolSignalOutgoingCalls != value)
|
||||
{
|
||||
_boolSignalOutgoingCalls = value;
|
||||
OnPropertyChanged(nameof(boolSignalOutgoingCalls));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowUnresolvedPhoneNumbers
|
||||
private bool _boolShowUnresolvedPhoneNumbers = false;
|
||||
|
||||
public bool boolShowUnresolvedPhoneNumbers
|
||||
{
|
||||
get { return _boolShowUnresolvedPhoneNumbers; }
|
||||
set
|
||||
{
|
||||
if (_boolShowUnresolvedPhoneNumbers != value)
|
||||
{
|
||||
_boolShowUnresolvedPhoneNumbers = value;
|
||||
OnPropertyChanged(nameof(boolShowUnresolvedPhoneNumbers));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExternalCallPrefix
|
||||
private string _strExternalCallPrefix = string.Empty;
|
||||
|
||||
public string strExternalCallPrefix
|
||||
{
|
||||
get { return _strExternalCallPrefix; }
|
||||
set
|
||||
{
|
||||
if (_strExternalCallPrefix != value)
|
||||
{
|
||||
_strExternalCallPrefix = value;
|
||||
OnPropertyChanged(nameof(strExternalCallPrefix));
|
||||
UpdateEnableStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private PhoneSettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
IsPhoneSupportDisabled = cFasdCockpitConfig.Instance.PhoneSupport.DisablePhoneSupport;
|
||||
IsNativeSwyxItPreferred = cFasdCockpitConfig.Instance.PhoneSupport.PreferSwyxitNative;
|
||||
UseTapi32Bit = cFasdCockpitConfig.Instance.PhoneSupport.UseTapi32Bit;
|
||||
boolSignalOutgoingCalls = cFasdCockpitConfig.Instance.PhoneSupport.SignalOutgoingCalls;
|
||||
strExternalCallPrefix = cFasdCockpitConfig.Instance.PhoneSupport.ExternalCallPrefix;
|
||||
boolShowUnresolvedPhoneNumbers = cFasdCockpitConfig.Instance.PhoneSupport.ShowUnresolvedPhoneNumbers;
|
||||
|
||||
UpdateTapiLines();
|
||||
UpdateEnableStatus();
|
||||
|
||||
base.OnInitialized(e);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void PhoneSettingsWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
UpdateEnableStatus();
|
||||
BlurInvoker_IsActiveChanged(sender, e);
|
||||
}
|
||||
|
||||
private void UpdateTapiLines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (PreferredTapiLineComboBox.Items?.Count > 0)
|
||||
return;
|
||||
|
||||
var tapiLines = C4TapiHelper.Lines;
|
||||
|
||||
if (tapiLines?.Count > 0)
|
||||
{
|
||||
foreach (var line in tapiLines)
|
||||
{
|
||||
var comboBoxItem = new ComboBoxItem() { Content = line };
|
||||
|
||||
if (tapiLines?.First() == line && tapiLines?.Last() == line)
|
||||
comboBoxItem.SetResourceReference(StyleProperty, "ComboBoxSingleItem");
|
||||
else if (tapiLines?.First() == line)
|
||||
comboBoxItem.SetResourceReference(StyleProperty, "ComboBoxFirstItem");
|
||||
else if (tapiLines?.Last() == line)
|
||||
comboBoxItem.SetResourceReference(StyleProperty, "ComboBoxLastItem");
|
||||
|
||||
PreferredTapiLineComboBox.Items.Add(comboBoxItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PreferredTapiLineComboBox.IsEnabled = false;
|
||||
}
|
||||
|
||||
var currentLineIndex = tapiLines.IndexOf(cFasdCockpitConfig.Instance.PhoneSupport.PreferedTapiLine);
|
||||
PreferredTapiLineComboBox.SelectedIndex = currentLineIndex;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnableStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
UpdateTapiLines();
|
||||
|
||||
SwyxNativeCheck.ClearValue(ToolTipProperty);
|
||||
UseTapi32BitCheck.ClearValue(ToolTipProperty);
|
||||
PreferredTapiLineComboBox.ClearValue(ToolTipProperty);
|
||||
|
||||
|
||||
SwyxNativeCheck.IsEnabled = true;
|
||||
|
||||
PreferredTapiLineComboBox.IsEnabled = !IsNativeSwyxItPreferred;
|
||||
|
||||
if (IsNativeSwyxItPreferred)
|
||||
PreferredTapiLineComboBox.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.SwyxItNativeEnabled");
|
||||
|
||||
if (IsPhoneSupportDisabled)
|
||||
{
|
||||
SwyxNativeCheck.IsEnabled = false;
|
||||
SwyxNativeCheck.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.PhoneSupportDisabled");
|
||||
|
||||
UseTapi32BitCheck.IsEnabled = false;
|
||||
PreferredTapiLineComboBox.IsEnabled = false;
|
||||
PreferredTapiLineComboBox.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.PhoneSupportDisabled");
|
||||
UseTapi32BitCheck.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.PhoneSupportDisabled");
|
||||
}
|
||||
|
||||
if (C4TapiHelper.Lines?.Count <= 0)
|
||||
{
|
||||
UseTapi32BitCheck.IsEnabled = false;
|
||||
PreferredTapiLineComboBox.IsEnabled = false;
|
||||
PreferredTapiLineComboBox.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.NoLine");
|
||||
UseTapi32BitCheck.ToolTip = cMultiLanguageSupport.GetItem("PhoneSettings.Tapi.Disabled.NoLine");
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region DialogButton_Click
|
||||
|
||||
public void DialogButton_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (!(senderElement.Tag is bool tagValue))
|
||||
return;
|
||||
|
||||
if (tagValue)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.DisablePhoneSupport = IsPhoneSupportDisabled;
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.PreferSwyxitNative = IsNativeSwyxItPreferred;
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.UseTapi32Bit = UseTapi32Bit;
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.SignalOutgoingCalls = boolSignalOutgoingCalls;
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.ExternalCallPrefix = ExternalCallPrefix.Text;
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.ShowUnresolvedPhoneNumbers = boolShowUnresolvedPhoneNumbers;
|
||||
|
||||
if (PreferredTapiLineComboBox.SelectedItem is ComboBoxItem selectedItem)
|
||||
cFasdCockpitConfig.Instance.PhoneSupport.PreferedTapiLine = selectedItem.Content?.ToString();
|
||||
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\DisablePhoneSupport");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\PreferSwyxitNative");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\UseTapi32Bit");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\PreferedTapiLine");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\SignalOutgoingCalls");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\ExternalCallPrefix");
|
||||
cFasdCockpitConfig.Instance.Save("PhoneSupport\\ShowUnresolvedPhoneNumbers");
|
||||
}
|
||||
|
||||
Close();
|
||||
|
||||
if (tagValue)
|
||||
{
|
||||
var _h = Dispatcher.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(300);
|
||||
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show(cMultiLanguageSupport.GetItem("PhoneSettings.RestartDialog.Text"), cMultiLanguageSupport.GetItem("PhoneSettings.RestartDialog.Caption"), enumHealthCardStateLevel.Info, null, true);
|
||||
|
||||
if (dialogResult == true)
|
||||
{
|
||||
System.Windows.Forms.Application.Restart();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void DialogButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DialogButton_Click(sender);
|
||||
}
|
||||
|
||||
private void DialogButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
DialogButton_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CloseButton_Click
|
||||
|
||||
private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void PhoneSettingsWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
_Instance = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
15
FasdDesktopUi/Pages/SettingsPage/SettingsPageBase.cs
Normal file
15
FasdDesktopUi/Pages/SettingsPage/SettingsPageBase.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SettingsPage
|
||||
{
|
||||
public class SettingsPageBase : CustomPopupBase, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
475
FasdDesktopUi/Pages/SettingsPage/SettingsPageView.xaml
Normal file
475
FasdDesktopUi/Pages/SettingsPage/SettingsPageView.xaml
Normal file
@@ -0,0 +1,475 @@
|
||||
<settingspagebase:SettingsPageBase
|
||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
|
||||
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.SettingsPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="SettingsPageView"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="100"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Initialized="Window_Initialized"
|
||||
x:Name="SettingsWindow"
|
||||
KeyDown="SettingsWindow_KeyDown" Closed="SettingsWindow_Closed" IsVisibleChanged="SettingsWindow_IsVisibleChanged">
|
||||
|
||||
<settingspagebase:SettingsPageBase.Resources>
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
x:Key="ApplyButton"
|
||||
BasedOn="{StaticResource SettingsPage.Close.Icon}">
|
||||
<Setter Property="Margin"
|
||||
Value="0 -7.5" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="22.5" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="0 0 0 5" />
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="ApplyZoomButton_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="ApplyZoomButton_TouchDown" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Green}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</settingspagebase:SettingsPageBase.Resources>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<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}"
|
||||
MouseLeftButtonUp="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>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global}" />
|
||||
<Border>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme}" />
|
||||
|
||||
<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"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme.LightMode}"
|
||||
SelectedInternIcon="style_sunFilled" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="DarkModeIcon"
|
||||
Tag="DarkMode"
|
||||
ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme.DarkMode}"
|
||||
SelectedInternIcon="style_moonFilled" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.SelectLanguage}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="Margin"
|
||||
Value="5 0" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="2.5" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="22.5" />
|
||||
<Setter Property="IconWidth"
|
||||
Value="22.5" />
|
||||
<EventSetter Event="MouseLeftButtonUp"
|
||||
Handler="Flag_MouseLeftButtonUp" />
|
||||
<EventSetter Event="TouchDown"
|
||||
Handler="Flag_TouchDown" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<ico:AdaptableIcon IconBackgroundColor="Transparent"
|
||||
IconWidth="30"
|
||||
IconHeight="30"
|
||||
Margin="-2.5 0 5 0"
|
||||
SelectedMaterialIcon="ic_language" />
|
||||
|
||||
<ico:AdaptableIcon Tag="DE"
|
||||
SelectedCountryCode="DE" />
|
||||
|
||||
<ico:AdaptableIcon Tag="US"
|
||||
SelectedCountryCode="GB" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="ShouldSkipSlimViewLabel" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.ShouldSkipSlimView}" />
|
||||
<ico:AdaptableIcon x:Name="ShouldSkipSlimViewPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox x:Name="ShouldSkipSlimViewCheckBox"
|
||||
Style="{DynamicResource ToggleSwitch}"
|
||||
IsChecked="{Binding ElementName=SettingsWindow, Path=ShouldSkipSlimView}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0,3,0,10"
|
||||
>
|
||||
</CheckBox>
|
||||
|
||||
<StackPanel x:Name="PositionOfSmallViewsLabel" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfSmallViews}" />
|
||||
<ico:AdaptableIcon x:Name="PositionOfSmallViewsPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="PositionOfSmallViewsInput" Grid.IsSharedSizeScope="True"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"
|
||||
SharedSizeGroup="Label" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto"
|
||||
SharedSizeGroup="Label" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock x:Name="SmallViewLeftTextBlock"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Left}"
|
||||
Grid.Column="0"
|
||||
FontWeight="Regular"
|
||||
Cursor="Hand"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="2.5 -0 2.5 0"
|
||||
Tag="0"
|
||||
TouchDown="SmallViewTextBlock_TouchDown"
|
||||
MouseLeftButtonUp="SmallViewTextBlock_MouseLeftButtonUp" />
|
||||
|
||||
<Border Grid.Column="1"
|
||||
Padding="5 0">
|
||||
<Slider x:Name="SmallViewPositionSlider"
|
||||
Minimum="0"
|
||||
Maximum="2"
|
||||
MinWidth="75"
|
||||
IsSnapToTickEnabled="True"
|
||||
Ticks="0 2"
|
||||
TickPlacement="TopLeft"
|
||||
TickFrequency="2"
|
||||
Value="{Binding ElementName=SettingsWindow, Path=PositionOfSmallViews}" />
|
||||
|
||||
</Border>
|
||||
|
||||
<TextBlock x:Name="SmallViewRightTextBlock"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Right}"
|
||||
Grid.Column="2"
|
||||
FontWeight="Regular"
|
||||
Cursor="Hand"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="2.5 -0 2.5 0"
|
||||
Tag="2"
|
||||
TouchDown="SmallViewTextBlock_TouchDown"
|
||||
MouseLeftButtonUp="SmallViewTextBlock_MouseLeftButtonUp" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel x:Name="PositionOfFavouriteBarLabel" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfFavouriteBar}" />
|
||||
<ico:AdaptableIcon x:Name="PositionOfFavouriteBarPolicy" SelectedInternIcon="lock_closed" Margin="-25,-5,0,0" IconWidth="23" IconHeight="23" Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="PositionOfFavouriteBarInput" Grid.IsSharedSizeScope="True"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"
|
||||
SharedSizeGroup="Label" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto"
|
||||
SharedSizeGroup="Label" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock x:Name="FavouritePositionLeftTextBlock"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Left}"
|
||||
Grid.Column="0"
|
||||
FontWeight="Regular"
|
||||
Cursor="Hand"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="2.5 -0 2.5 0"
|
||||
Tag="0"
|
||||
TouchDown="FavouritePositionTextBlock_TouchDown"
|
||||
MouseLeftButtonUp="FavouritePositionTextBlock_MouseLeftButtonUp" />
|
||||
|
||||
<Border Grid.Column="1"
|
||||
Padding="5 0">
|
||||
<Slider x:Name="FavouritePositionSlider"
|
||||
Minimum="0"
|
||||
Maximum="2"
|
||||
MinWidth="75"
|
||||
IsSnapToTickEnabled="True"
|
||||
Ticks="0 1 2"
|
||||
TickPlacement="TopLeft"
|
||||
TickFrequency="1"
|
||||
Value="{Binding ElementName=SettingsWindow, Path=PositionOfFavouriteBar}" />
|
||||
|
||||
</Border>
|
||||
|
||||
<TextBlock x:Name="FavouritePositionRightTextBlock"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Right}"
|
||||
Grid.Column="2"
|
||||
FontWeight="Regular"
|
||||
Cursor="Hand"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="2.5 -0 2.5 0"
|
||||
Tag="2"
|
||||
TouchDown="FavouritePositionTextBlock_TouchDown"
|
||||
MouseLeftButtonUp="FavouritePositionTextBlock_MouseLeftButtonUp" />
|
||||
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel x:Name="SlimPageSection"
|
||||
Visibility="{Binding ElementName=SettingsWindow, Path=IsSlimPageVisibile, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.SlimPage}" />
|
||||
<Border>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.ZoomFactor}" />
|
||||
<TextBox x:Name="SlimPageScaleValueTextBox"
|
||||
Tag="SlimPageZoom"
|
||||
Text="{Binding ElementName=SettingsWindow, Path=ZoomSlimPageInPercent, Mode=TwoWay, UpdateSourceTrigger=LostFocus, TargetNullValue={x:Static sys:String.Empty}}"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
|
||||
BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Width="28"
|
||||
TextChanged="ScaleValueTextBox_TextChanged">
|
||||
<TextBox.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius"
|
||||
Value="2.5" />
|
||||
</Style>
|
||||
</TextBox.Resources>
|
||||
</TextBox>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ApplySlimPageZoomButton"
|
||||
Style="{DynamicResource ApplyButton}"
|
||||
Tag="SlimPageZoom"
|
||||
SelectedInternIcon="misc_check" />
|
||||
</StackPanel>
|
||||
|
||||
<Slider x:Name="SizeSliderSlimPage"
|
||||
Orientation="Horizontal"
|
||||
Minimum="50"
|
||||
Maximum="250"
|
||||
Value="{Binding ElementName=SettingsWindow, Path=ZoomSlimPageInPercent, Mode=TwoWay}"
|
||||
Margin="0,3"
|
||||
TickFrequency="1" />
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="DetailsPageSection"
|
||||
Visibility="{Binding ElementName=SettingsWindow, Path=IsDetailsPageVisibile, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.DetailPage}" />
|
||||
<Border>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.ZoomFactor}" />
|
||||
<TextBox x:Name="ScaleValueTextBox"
|
||||
Tag="DetailsPageZoom"
|
||||
Text="{Binding ElementName=SettingsWindow, Path=ZoomDetailsPageInPecent, Mode=TwoWay, UpdateSourceTrigger=LostFocus, TargetNullValue={x:Static sys:String.Empty}}"
|
||||
Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
|
||||
BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
|
||||
Width="28"
|
||||
TextChanged="ScaleValueTextBox_TextChanged">
|
||||
<TextBox.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius"
|
||||
Value="2.5" />
|
||||
</Style>
|
||||
</TextBox.Resources>
|
||||
</TextBox>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ApplyDetailsPageZoomButton"
|
||||
Style="{DynamicResource ApplyButton}"
|
||||
Tag="DetailsPageZoom"
|
||||
SelectedInternIcon="misc_check" />
|
||||
</StackPanel>
|
||||
|
||||
<Slider x:Name="SizeSlider"
|
||||
Orientation="Horizontal"
|
||||
Minimum="50"
|
||||
Maximum="250"
|
||||
Value="{Binding ElementName=SettingsWindow, Path=ZoomDetailsPageInPecent, Mode=TwoWay}"
|
||||
Margin="0,3"
|
||||
TickFrequency="1" />
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.DetailPage.HighlightColors}" />
|
||||
|
||||
<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>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</settingspagebase:SettingsPageBase>
|
||||
886
FasdDesktopUi/Pages/SettingsPage/SettingsPageView.xaml.cs
Normal file
886
FasdDesktopUi/Pages/SettingsPage/SettingsPageView.xaml.cs
Normal file
@@ -0,0 +1,886 @@
|
||||
using C4IT.MultiLanguage;
|
||||
using C4IT.FASD.Base;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
|
||||
using FasdDesktopUi.Pages.DetailsPage;
|
||||
using FasdDesktopUi.Pages.SlimPage;
|
||||
using Newtonsoft.Json;
|
||||
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 System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using System.Reflection;
|
||||
using C4IT.Logging;
|
||||
using System.Windows.Navigation;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using FasdDesktopUi.Basics;
|
||||
using System.Diagnostics;
|
||||
using C4IT.Configuration;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SettingsPage
|
||||
{
|
||||
public partial class SettingsPageView : SettingsPageBase
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private static SettingsPageView _Instance = null;
|
||||
public static SettingsPageView Instance { get
|
||||
{
|
||||
return _Instance ?? (_Instance = new SettingsPageView());
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<enumHighlightColor, bool> highlightColorActivationStatus;
|
||||
|
||||
#region ZoomInPercent
|
||||
|
||||
public int ZoomDetailsPageInPecent
|
||||
{
|
||||
get { return cFasdCockpitConfig.Instance.DetailsPageZoom; }
|
||||
set
|
||||
{
|
||||
if (value < 50)
|
||||
value = 50;
|
||||
else if (value > 250)
|
||||
value = 250;
|
||||
|
||||
cFasdCockpitConfig.Instance.SetDetailsPageZoom(value);
|
||||
OnPropertyChanged(nameof(ZoomDetailsPageInPecent));
|
||||
}
|
||||
}
|
||||
public int ZoomSlimPageInPercent
|
||||
{
|
||||
get { return cFasdCockpitConfig.Instance.SlimPageZoom; }
|
||||
set
|
||||
{
|
||||
if (value < 50)
|
||||
value = 50;
|
||||
else if (value > 250)
|
||||
value = 250;
|
||||
|
||||
cFasdCockpitConfig.Instance.SetSlimPageZoom(value);
|
||||
OnPropertyChanged(nameof(ZoomSlimPageInPercent));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SlimPageVisibility
|
||||
|
||||
public bool IsSlimPageVisibile
|
||||
{
|
||||
get
|
||||
{
|
||||
return cSupportCaseDataProvider.slimPage?.Visibility == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsDetailsPageVisible
|
||||
|
||||
public bool IsDetailsPageVisibile
|
||||
{
|
||||
get
|
||||
{
|
||||
return cSupportCaseDataProvider.detailsPage?.Visibility == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public int PositionOfSmallViews
|
||||
{
|
||||
get {
|
||||
return cF4sdGlobalConfig.ConvertHorizontalAlignmentToPosition(cFasdCockpitConfig.Instance.Global.SmallViewAlignment, 0);
|
||||
}
|
||||
set
|
||||
{
|
||||
var _algn = cF4sdGlobalConfig.ConvertPositionToHorizontalAlignment(value, enumF4sdHorizontalAlignment.Right);
|
||||
UpdatePositionOfSmallViewTextBlock(value);
|
||||
if (_algn != cFasdCockpitConfig.Instance.Global.SmallViewAlignment)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.Global.SmallViewAlignment = _algn;
|
||||
cFasdCockpitConfig.Instance.Global.Save("SmallViewAlignment");
|
||||
cFasdCockpitConfig.Instance.OnUiSettingsChanged();
|
||||
}
|
||||
OnPropertyChanged(nameof(PositionOfSmallViews));
|
||||
}
|
||||
}
|
||||
|
||||
public int PositionOfFavouriteBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return cF4sdGlobalConfig.ConvertHorizontalAlignmentToPosition(cFasdCockpitConfig.Instance.Global.FavouriteBarAlignment, 0);
|
||||
}
|
||||
set
|
||||
{
|
||||
var _algn = cF4sdGlobalConfig.ConvertPositionToHorizontalAlignment(value, enumF4sdHorizontalAlignment.Right);
|
||||
UpdatePositionOfFavouriteBarTextBlock(value);
|
||||
if (cFasdCockpitConfig.Instance.Global.FavouriteBarAlignment != _algn)
|
||||
{
|
||||
cFasdCockpitConfig.Instance.Global.FavouriteBarAlignment = _algn;
|
||||
cFasdCockpitConfig.Instance.Global.Save("FavouriteBarAlignment");
|
||||
cFasdCockpitConfig.Instance.OnUiSettingsChanged();
|
||||
}
|
||||
OnPropertyChanged(nameof(PositionOfFavouriteBar));
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldSkipSlimView
|
||||
{
|
||||
get => cFasdCockpitConfig.Instance.Global.ShouldSkipSlimView;
|
||||
set
|
||||
{
|
||||
cFasdCockpitConfig.Instance.Global.ShouldSkipSlimView = value;
|
||||
cFasdCockpitConfig.Instance.Global.Save("ShouldSkipSlimView");
|
||||
OnPropertyChanged(nameof(ShouldSkipSlimView));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static SettingsPageView Create()
|
||||
{
|
||||
if (Instance == null)
|
||||
return new SettingsPageView();
|
||||
return Instance;
|
||||
}
|
||||
|
||||
private SettingsPageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
UpdatePositionOfSmallViewTextBlock(PositionOfSmallViews);
|
||||
UpdatePositionOfFavouriteBarTextBlock(PositionOfFavouriteBar);
|
||||
cFasdCockpitConfig.Instance.UiSettingsChanged += CockpitConfig_UiSettingsChanged;
|
||||
}
|
||||
|
||||
private void UpdatePositionOfFavouriteBarTextBlock(int positionIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
FavouritePositionSlider.ClearValue(BackgroundProperty);
|
||||
|
||||
switch (positionIndex)
|
||||
{
|
||||
case 1:
|
||||
FavouritePositionLeftTextBlock.ClearValue(ForegroundProperty);
|
||||
FavouritePositionRightTextBlock.ClearValue(ForegroundProperty);
|
||||
FavouritePositionSlider.SetResourceReference(BackgroundProperty, "Color.FunctionMarker");
|
||||
break;
|
||||
case 2:
|
||||
FavouritePositionRightTextBlock.SetResourceReference(ForegroundProperty, "Color.FunctionMarker");
|
||||
FavouritePositionLeftTextBlock.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
default:
|
||||
FavouritePositionLeftTextBlock.SetResourceReference(ForegroundProperty, "Color.FunctionMarker");
|
||||
FavouritePositionRightTextBlock.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePositionOfSmallViewTextBlock(int positionIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
switch (positionIndex)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
SmallViewRightTextBlock.SetResourceReference(ForegroundProperty, "Color.FunctionMarker");
|
||||
SmallViewLeftTextBlock.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
default:
|
||||
SmallViewLeftTextBlock.SetResourceReference(ForegroundProperty, "Color.FunctionMarker");
|
||||
SmallViewRightTextBlock.ClearValue(ForegroundProperty);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void CockpitConfig_UiSettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
ZoomDetailsPageInPecent = cFasdCockpitConfig.Instance.DetailsPageZoom;
|
||||
ZoomSlimPageInPercent = cFasdCockpitConfig.Instance.SlimPageZoom;
|
||||
|
||||
// hide or deactivate ShouldSkipSlimView options due to the policies
|
||||
var _policy = cFasdCockpitConfig.Instance.Global.GetPropertyPolicy("ShouldSkipSlimView");
|
||||
if (_policy == enumConfigPolicy.Hidden)
|
||||
{
|
||||
ShouldSkipSlimViewLabel.Visibility = Visibility.Collapsed;
|
||||
ShouldSkipSlimViewCheckBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShouldSkipSlimViewLabel.Visibility = Visibility.Visible;
|
||||
ShouldSkipSlimViewCheckBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (_policy == enumConfigPolicy.Default)
|
||||
{
|
||||
ShouldSkipSlimViewCheckBox.IsEnabled = true;
|
||||
ShouldSkipSlimViewPolicy.Visibility = Visibility.Collapsed;
|
||||
ShouldSkipSlimViewCheckBox.ToolTip = null;
|
||||
ShouldSkipSlimViewPolicy.ToolTip = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShouldSkipSlimViewCheckBox.IsEnabled = false;
|
||||
ShouldSkipSlimViewPolicy.Visibility = Visibility.Visible;
|
||||
ShouldSkipSlimViewCheckBox.ToolTip = cMultiLanguageSupport.GetItem("Settings.Global.PolicyTooltip");
|
||||
ShouldSkipSlimViewPolicy.ToolTip = cMultiLanguageSupport.GetItem("Settings.Global.PolicyTooltip");
|
||||
}
|
||||
OnPropertyChanged(nameof(ShouldSkipSlimView));
|
||||
|
||||
// hide or deactivate SmallViewAlignment options due to the policies
|
||||
_policy = cFasdCockpitConfig.Instance.Global.GetPropertyPolicy("SmallViewAlignment");
|
||||
if (_policy == enumConfigPolicy.Hidden)
|
||||
{
|
||||
PositionOfSmallViewsLabel.Visibility = Visibility.Collapsed;
|
||||
PositionOfSmallViewsInput.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
PositionOfSmallViewsLabel.Visibility = Visibility.Visible;
|
||||
PositionOfSmallViewsInput.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (_policy == enumConfigPolicy.Default)
|
||||
{
|
||||
PositionOfSmallViewsInput.IsEnabled = true;
|
||||
PositionOfSmallViewsPolicy.Visibility = Visibility.Collapsed;
|
||||
PositionOfSmallViewsPolicy.ToolTip = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
PositionOfSmallViewsInput.IsEnabled = false;
|
||||
PositionOfSmallViewsPolicy.Visibility = Visibility.Visible;
|
||||
PositionOfSmallViewsPolicy.ToolTip = cMultiLanguageSupport.GetItem("Settings.Global.PolicyTooltip");
|
||||
}
|
||||
OnPropertyChanged(nameof(PositionOfSmallViews));
|
||||
|
||||
// hide or deactivate FavouriteBarAlignment options due to the policies
|
||||
_policy = cFasdCockpitConfig.Instance.Global.GetPropertyPolicy("FavouriteBarAlignment");
|
||||
if (_policy == enumConfigPolicy.Hidden)
|
||||
{
|
||||
PositionOfFavouriteBarLabel.Visibility = Visibility.Collapsed;
|
||||
PositionOfFavouriteBarInput.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
PositionOfFavouriteBarLabel.Visibility = Visibility.Visible;
|
||||
PositionOfFavouriteBarInput.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (_policy == enumConfigPolicy.Default)
|
||||
{
|
||||
PositionOfFavouriteBarInput.IsEnabled = true;
|
||||
PositionOfFavouriteBarPolicy.Visibility = Visibility.Collapsed;
|
||||
PositionOfFavouriteBarPolicy.ToolTip = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
PositionOfFavouriteBarInput.IsEnabled = false;
|
||||
PositionOfFavouriteBarPolicy.Visibility = Visibility.Visible;
|
||||
PositionOfFavouriteBarPolicy.ToolTip = cMultiLanguageSupport.GetItem("Settings.Global.PolicyTooltip");
|
||||
}
|
||||
OnPropertyChanged(nameof(PositionOfFavouriteBar));
|
||||
|
||||
}
|
||||
|
||||
public void SetUpSettingsControls()
|
||||
{
|
||||
try
|
||||
{
|
||||
enumAppColorMode selectedAppColorMode = cFasdCockpitConfig.Instance.DetailsPageColorMode;
|
||||
SelectAppColorMode(selectedAppColorMode);
|
||||
|
||||
foreach (Border highlightBorder in HighlightColorStack.Children)
|
||||
{
|
||||
HighlightColorBorder_Click(highlightBorder);
|
||||
HighlightColorBorder_Click(highlightBorder);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region Window Events
|
||||
|
||||
private void Window_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);
|
||||
}
|
||||
}
|
||||
|
||||
private async void SettingsWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnPropertyChanged(nameof(IsSlimPageVisibile));
|
||||
OnPropertyChanged(nameof(IsDetailsPageVisibile));
|
||||
|
||||
BlurInvoker_IsActiveChanged(sender, e);
|
||||
|
||||
if (e.NewValue is bool b && b is false)
|
||||
if (cSupportCaseDataProvider.detailsPage?.Visibility == Visibility.Visible)
|
||||
await cSupportCaseDataProvider.detailsPage.AdjustWindowSizeAsync();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CloseButton
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetLanguage
|
||||
|
||||
private void Flag_Click(object sender)
|
||||
{
|
||||
if (!(sender is FrameworkElement FE))
|
||||
return;
|
||||
|
||||
var NewLanguage = FE.Tag?.ToString();
|
||||
var OldLanguage = cMultiLanguageSupport.CurrentLanguage;
|
||||
|
||||
|
||||
cMultiLanguageSupport.CurrentLanguage = NewLanguage;
|
||||
|
||||
cFasdCockpitConfig.Instance.SelectedLanguage = NewLanguage;
|
||||
cFasdCockpitConfig.Instance.Save("SelectedLanguage");
|
||||
|
||||
if (OldLanguage == NewLanguage)
|
||||
return;
|
||||
|
||||
var dialogResult = CustomMessageBox.CustomMessageBox.Show(cMultiLanguageSupport.GetItem("Menu.SelectLanguage.RestartDialog.Text"), cMultiLanguageSupport.GetItem("Menu.SelectLanguage.RestartDialog.Caption"), enumHealthCardStateLevel.Info, null, true);
|
||||
|
||||
if (dialogResult == true)
|
||||
{
|
||||
System.Windows.Forms.Application.Restart();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void Flag_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Flag_Click(sender);
|
||||
}
|
||||
|
||||
private void Flag_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Flag_Click(sender);
|
||||
}
|
||||
|
||||
#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
|
||||
{
|
||||
string senderTag = (sender as FrameworkElement).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
|
||||
{
|
||||
string tagValue = (sender as FrameworkElement).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
|
||||
{
|
||||
string tagValue = (sender as FrameworkElement).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;
|
||||
|
||||
switch ((sender as Border).Tag.ToString().ToLower())
|
||||
{
|
||||
case "blue":
|
||||
clickedHighlightColor = enumHighlightColor.blue;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Blue"] = FindResource("Transparent.Custom");
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Blue"] = FindResource("Color.Blue");
|
||||
break;
|
||||
case "green":
|
||||
clickedHighlightColor = enumHighlightColor.green;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Green"] = FindResource("Transparent.Custom");
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Green"] = FindResource("Color.Green");
|
||||
break;
|
||||
case "orange":
|
||||
clickedHighlightColor = enumHighlightColor.orange;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Orange"] = FindResource("Transparent.Custom");
|
||||
else
|
||||
Application.Current.Resources["HighlightColor.Orange"] = FindResource("Color.Orange");
|
||||
break;
|
||||
case "red":
|
||||
clickedHighlightColor = enumHighlightColor.red;
|
||||
if (highlightColorActivationStatus[clickedHighlightColor])
|
||||
Application.Current.Resources["HighlightColor.Red"] = FindResource("Transparent.Custom");
|
||||
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
|
||||
|
||||
#region SmallViewTextBlockClick
|
||||
|
||||
private void SmallViewTextBlock_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is FrameworkElement senderElement)
|
||||
if (int.TryParse(senderElement.Tag.ToString(), out int positionIndex))
|
||||
PositionOfSmallViews = positionIndex;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SmallViewTextBlock_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SmallViewTextBlock_Click(sender);
|
||||
}
|
||||
|
||||
private void SmallViewTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
SmallViewTextBlock_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FavouritePositionTextBlock_Click
|
||||
|
||||
private void FavouritePositionTextBlock_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is FrameworkElement senderElement)
|
||||
if (int.TryParse(senderElement.Tag.ToString(), out int positionIndex))
|
||||
PositionOfFavouriteBar = positionIndex;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void FavouritePositionTextBlock_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
FavouritePositionTextBlock_Click(sender);
|
||||
}
|
||||
|
||||
private void FavouritePositionTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
FavouritePositionTextBlock_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyZoomButton_Click
|
||||
|
||||
private void ScaleValueTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (!senderElement.IsFocused)
|
||||
return;
|
||||
|
||||
UpdateApplyButtonVisibility();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateApplyButtonVisibility()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ApplySlimPageZoomButton != null)
|
||||
{
|
||||
bool isSlimPageButtonVisible = false;
|
||||
if (int.TryParse(SlimPageScaleValueTextBox.Text, out var slimPageZoom))
|
||||
if (slimPageZoom >= 50 && slimPageZoom <= 250)
|
||||
isSlimPageButtonVisible = slimPageZoom != ZoomSlimPageInPercent;
|
||||
|
||||
ApplySlimPageZoomButton.Visibility = isSlimPageButtonVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
if (ApplyDetailsPageZoomButton != null)
|
||||
{
|
||||
bool isDetailsPageButtonVisible = false;
|
||||
if (int.TryParse(ScaleValueTextBox.Text, out var detailsPageZoom))
|
||||
if (detailsPageZoom >= 50 && detailsPageZoom <= 250)
|
||||
isDetailsPageButtonVisible = detailsPageZoom != ZoomDetailsPageInPecent;
|
||||
|
||||
ApplyDetailsPageZoomButton.Visibility = isDetailsPageButtonVisible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyZoomButton_Click(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
switch (senderElement.Tag)
|
||||
{
|
||||
case "SlimPageZoom":
|
||||
if (int.TryParse(SlimPageScaleValueTextBox.Text, out var slimPageZoom))
|
||||
ZoomSlimPageInPercent = slimPageZoom;
|
||||
break;
|
||||
case "DetailsPageZoom":
|
||||
if (int.TryParse(ScaleValueTextBox.Text, out var detailsPageZoom))
|
||||
ZoomDetailsPageInPecent = detailsPageZoom;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateApplyButtonVisibility();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyZoomButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ApplyZoomButton_Click(sender);
|
||||
}
|
||||
|
||||
private void ApplyZoomButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
ApplyZoomButton_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SettingsWindow_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
if (int.TryParse(ScaleValueTextBox.Text, out var detailsPageZoom))
|
||||
ZoomDetailsPageInPecent = detailsPageZoom;
|
||||
|
||||
if (int.TryParse(SlimPageScaleValueTextBox.Text, out var slimPageZoom))
|
||||
ZoomSlimPageInPercent = slimPageZoom;
|
||||
|
||||
UpdateApplyButtonVisibility();
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private async void SettingsWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_Instance = null;
|
||||
if (cSupportCaseDataProvider.detailsPage?.Visibility == Visibility.Visible)
|
||||
await cSupportCaseDataProvider.detailsPage.AdjustWindowSizeAsync();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
102
FasdDesktopUi/Pages/SettingsPage/ShortCutPageView.xaml
Normal file
102
FasdDesktopUi/Pages/SettingsPage/ShortCutPageView.xaml
Normal file
@@ -0,0 +1,102 @@
|
||||
<settingspagebase:SettingsPageBase
|
||||
xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
|
||||
x:Class="FasdDesktopUi.Pages.ShortCutPage.ShortCutPageView"
|
||||
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.ShortCutPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
mc:Ignorable="d"
|
||||
Title="ShortCutPageView"
|
||||
IsVisibleChanged="BlurInvoker_IsActiveChanged"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MinHeight="100"
|
||||
MinWidth="400"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
UseLayoutRounding="True">
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Border CornerRadius="10"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
Padding="10"
|
||||
Style="{x:Null}">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseLeftButtonUp="CloseButton_MouseUp"
|
||||
TouchDown="CloseButton_TouchDown"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<StackPanel x:Name="ContentPanel"
|
||||
Grid.Row="1">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="BorderBrush"
|
||||
Value="#DBDBDB" />
|
||||
<Setter Property="Background"
|
||||
Value="#F7FAFA" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1.5" />
|
||||
<Setter Property="Padding"
|
||||
Value="6 2.5" />
|
||||
<Setter Property="MaxHeight"
|
||||
Value="30" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="5" />
|
||||
<Setter Property="Margin"
|
||||
Value="0 7.5" />
|
||||
<Setter Property="Effect">
|
||||
<Setter.Value>
|
||||
<DropShadowEffect Color="{DynamicResource ShadowColor.Menu.KeyBoardShortcut}"
|
||||
Direction="290"
|
||||
ShadowDepth="2.5"
|
||||
BlurRadius="7.5" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</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" />
|
||||
<Setter Property="TextWrapping"
|
||||
Value="Wrap" />
|
||||
<Setter Property="MaxWidth"
|
||||
Value="250" />
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Left" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</settingspagebase:SettingsPageBase>
|
||||
302
FasdDesktopUi/Pages/SettingsPage/ShortCutPageView.xaml.cs
Normal file
302
FasdDesktopUi/Pages/SettingsPage/ShortCutPageView.xaml.cs
Normal file
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.SettingsPage;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.ShortCutPage
|
||||
{
|
||||
public partial class ShortCutPageView : SettingsPageBase
|
||||
{
|
||||
private static ShortCutPageView _Instance = null;
|
||||
|
||||
public static ShortCutPageView Instance
|
||||
{
|
||||
get { return _Instance = _Instance ?? new ShortCutPageView(); }
|
||||
}
|
||||
|
||||
private ShortCutPageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
InitializeHotKeyInformation();
|
||||
}
|
||||
|
||||
private void InitializeHotKeyInformation()
|
||||
{
|
||||
try
|
||||
{
|
||||
var hotKeyCategories = new List<cHotKeyCategoryInformation>();
|
||||
|
||||
var initialSearchCategory = new cHotKeyCategoryInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Initial search",
|
||||
["DE"] = "Initiale Suche"
|
||||
},
|
||||
HotKeyInformation = new List<cHotKeyInformation>()
|
||||
{
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Start new empty search",
|
||||
["DE"] = "Neue leere Suche starten"
|
||||
},
|
||||
Modifiers = new List<ModifierKeys>() { ModifierKeys.Control },
|
||||
HotKey = Key.F3
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Start new search with highlighted text",
|
||||
["DE"] = "Neue Suche nach markiertem Text starten"
|
||||
},
|
||||
Modifiers = new List<ModifierKeys>() { ModifierKeys.Control, ModifierKeys.Alt },
|
||||
HotKey = Key.F3
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Select previous/next result",
|
||||
["DE"] = "Vorheriges/Nächstes Ergebnis auwählen"
|
||||
},
|
||||
HotKey = Key.Up,
|
||||
AlternativeKey = Key.Down
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Confirm selection",
|
||||
["DE"] = "Auswahl bestätigen"
|
||||
},
|
||||
HotKey = Key.Enter
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Cancel search",
|
||||
["DE"] = "Suche abbrechen"
|
||||
},
|
||||
HotKey = Key.Escape
|
||||
}
|
||||
}
|
||||
};
|
||||
hotKeyCategories.Add(initialSearchCategory);
|
||||
|
||||
var slimViewCategory = new cHotKeyCategoryInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Slim View",
|
||||
["DE"] = "Slim View"
|
||||
},
|
||||
HotKeyInformation = new List<cHotKeyInformation>()
|
||||
{
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Open Details Page",
|
||||
["DE"] = "Details Page öffnen"
|
||||
},
|
||||
HotKey = Key.Enter
|
||||
}
|
||||
}
|
||||
};
|
||||
hotKeyCategories.Add(slimViewCategory);
|
||||
|
||||
var detailsPageCategory = new cHotKeyCategoryInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Details Page",
|
||||
["DE"] = "Details Page"
|
||||
},
|
||||
HotKeyInformation = new List<cHotKeyInformation>()
|
||||
{
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Open previous/next category",
|
||||
["DE"] = "Vorherige/nächste Kategorie öffnen"
|
||||
},
|
||||
HotKey = Key.Up,
|
||||
AlternativeKey = Key.Down
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Fold in/out history",
|
||||
["DE"] = "Historie ein-/ausklappen"
|
||||
},
|
||||
HotKey = Key.Left,
|
||||
AlternativeKey = Key.Right
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Opens/closes all categories at once",
|
||||
["DE"] = "Alle Kateogrien auf einmal öffnen/schließen"
|
||||
},
|
||||
HotKey = Key.OemPlus,
|
||||
AlternativeKey = Key.OemMinus
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new C4IT.MultiLanguage.cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Open Quick Action menu",
|
||||
["DE"] = "Quick Action Menü öffnen"
|
||||
},
|
||||
HotKey = Key.Q,
|
||||
},
|
||||
new cHotKeyInformation()
|
||||
{
|
||||
Names = new cMultiLanguageDictionary()
|
||||
{
|
||||
["EN"] = "Reset zoom",
|
||||
["DE"] = "Zoom zurücksetzen"
|
||||
},
|
||||
HotKey = Key.NumPad0,
|
||||
Modifiers = new List<ModifierKeys>() { ModifierKeys.Control }
|
||||
}
|
||||
}
|
||||
};
|
||||
hotKeyCategories.Add(detailsPageCategory);
|
||||
|
||||
DrawHotKeyCategories(hotKeyCategories);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHotKeyCategories(List<cHotKeyCategoryInformation> HotKeyCategories)
|
||||
{
|
||||
try
|
||||
{
|
||||
const int keyFontSize = 11;
|
||||
ContentPanel.Children.Clear();
|
||||
|
||||
if (HotKeyCategories is null)
|
||||
return;
|
||||
|
||||
foreach (var category in HotKeyCategories)
|
||||
{
|
||||
TextBlock titleTextBlock = new TextBlock() { Text = category.Names.GetValue() };
|
||||
ContentPanel.Children.Add(titleTextBlock);
|
||||
|
||||
Border categoryBorder = new Border() { CornerRadius = new CornerRadius(7.5), Margin = new Thickness(5), Padding = new Thickness(10, 5, 10, 5), Style = null };
|
||||
categoryBorder.SetResourceReference(BackgroundProperty, "BackgroundColor.Menu.MainCategory");
|
||||
|
||||
|
||||
Grid hotKeyGrid = new Grid();
|
||||
hotKeyGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(250) });
|
||||
hotKeyGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
|
||||
|
||||
for (int i = 0; i < category.HotKeyInformation.Count; i++)
|
||||
{
|
||||
var hotKeyInfo = category.HotKeyInformation[i];
|
||||
|
||||
hotKeyGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
|
||||
|
||||
TextBlock hotKeyNameTextBlock = new TextBlock() { Text = hotKeyInfo.Names.GetValue(), FontWeight = FontWeights.Regular };
|
||||
hotKeyNameTextBlock.SetResourceReference(ForegroundProperty, "FontColor.Menu.Categories");
|
||||
Grid.SetColumn(hotKeyNameTextBlock, 0);
|
||||
Grid.SetRow(hotKeyNameTextBlock, i);
|
||||
hotKeyGrid.Children.Add(hotKeyNameTextBlock);
|
||||
|
||||
StackPanel hotKeyPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };
|
||||
|
||||
foreach (var modifier in hotKeyInfo.Modifiers)
|
||||
{
|
||||
Border modifierKeyBorder = new Border();
|
||||
string modifierText = modifier.Equals(ModifierKeys.Control) ? cMultiLanguageSupport.GetItem("Global.KeyBoard.Ctrl") : modifier.ToString();
|
||||
|
||||
modifierKeyBorder.Child = new TextBlock() { Text = modifierText, TextAlignment = TextAlignment.Center, FontSize = keyFontSize, Margin = new Thickness(0), TextWrapping = TextWrapping.NoWrap, Foreground = (SolidColorBrush)new BrushConverter().ConvertFrom("#3D3C3C") };
|
||||
hotKeyPanel.Children.Add(modifierKeyBorder);
|
||||
|
||||
TextBlock plusTextBlock = new TextBlock() { Text = "+", Margin = new Thickness(10, 0, 10, 0), FontWeight = FontWeights.Regular };
|
||||
hotKeyPanel.Children.Add(plusTextBlock);
|
||||
}
|
||||
|
||||
Border keyBorder = new Border();
|
||||
keyBorder.Child = new TextBlock() { Text = hotKeyInfo.GetKeyDisplayString(hotKeyInfo.HotKey), TextAlignment = TextAlignment.Center, FontSize = keyFontSize, Margin = new Thickness(0), TextWrapping = TextWrapping.NoWrap, Foreground = (SolidColorBrush)new BrushConverter().ConvertFrom("#3D3C3C") };
|
||||
hotKeyPanel.Children.Add(keyBorder);
|
||||
|
||||
if (hotKeyInfo.AlternativeKey != null)
|
||||
{
|
||||
TextBlock alternativeTextBlock = new TextBlock() { Text = "/", Margin = new Thickness(10, 0, 10, 0), FontWeight = FontWeights.Regular };
|
||||
hotKeyPanel.Children.Add(alternativeTextBlock);
|
||||
|
||||
Border alternativeKeyBorder = new Border();
|
||||
alternativeKeyBorder.Child = new TextBlock() { Text = hotKeyInfo.GetKeyDisplayString(hotKeyInfo.AlternativeKey.Value), FontSize = keyFontSize, TextAlignment = TextAlignment.Center, Margin = new Thickness(0), TextWrapping = TextWrapping.NoWrap, Foreground = (SolidColorBrush)new BrushConverter().ConvertFrom("#3D3C3C") };
|
||||
hotKeyPanel.Children.Add(alternativeKeyBorder);
|
||||
}
|
||||
|
||||
Grid.SetColumn(hotKeyPanel, 1);
|
||||
Grid.SetRow(hotKeyPanel, i);
|
||||
hotKeyGrid.Children.Add(hotKeyPanel);
|
||||
}
|
||||
|
||||
categoryBorder.Child = hotKeyGrid;
|
||||
|
||||
ContentPanel.Children.Add(categoryBorder);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region CloseButton
|
||||
|
||||
private void CloseButton_Click()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
30
FasdDesktopUi/Pages/SlimPage/Models/SlimPageBase.cs
Normal file
30
FasdDesktopUi/Pages/SlimPage/Models/SlimPageBase.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.Models
|
||||
{
|
||||
public class cSlimPageData
|
||||
{
|
||||
public cSupportCaseDataProvider DataProvider { get; set; }
|
||||
|
||||
//Header
|
||||
public List<cHeadingDataModel> HeadingData { get; set; }
|
||||
|
||||
//Widget
|
||||
public List<List<cWidgetValueModel>> WidgetData { get; set; }
|
||||
|
||||
//Details
|
||||
public List<cSlimPageDataHistoryModel> DataHistoryList { get; set; }
|
||||
|
||||
//Menu
|
||||
public List<cMenuDataBase> MenuBarData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage.Models
|
||||
{
|
||||
public class cSlimPageDataHistoryModel : cDataHistoryValueModel
|
||||
{
|
||||
public List<cDataHistoryValueModel> ValueColumns { get; set; } = new List<cDataHistoryValueModel>();
|
||||
}
|
||||
}
|
||||
114
FasdDesktopUi/Pages/SlimPage/SlimPageView.xaml
Normal file
114
FasdDesktopUi/Pages/SlimPage/SlimPageView.xaml
Normal file
@@ -0,0 +1,114 @@
|
||||
<detailspagebase:SupportCasePageBase
|
||||
xmlns:detailspagebase="clr-namespace:FasdDesktopUi.Pages"
|
||||
x:Class="FasdDesktopUi.Pages.SlimPage.SlimPageView"
|
||||
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.SlimPage"
|
||||
xmlns:uc="clr-namespace:FasdDesktopUi.Pages.SlimPage.UserControls"
|
||||
xmlns:buc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
Title="FASD Slim"
|
||||
x:Name="SlimPage"
|
||||
PreviewKeyDown="Window_PreviewKeyDown"
|
||||
Closing="Window_Closing"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
Background="Transparent"
|
||||
VerticalAlignment="Bottom"
|
||||
ResizeMode="CanMinimize"
|
||||
WindowState="Maximized"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True" Loaded="SlimPage_Loaded">
|
||||
<Window.DataContext>
|
||||
<local:SlimPageViewModel />
|
||||
</Window.DataContext>
|
||||
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<vc:PercentToDecimalConverter x:Key="PercentToDecimal" />
|
||||
</Window.Resources>
|
||||
|
||||
<Border x:Name="MainBorder"
|
||||
Background="#01000000"
|
||||
MinWidth="360"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom">
|
||||
<Border.LayoutTransform>
|
||||
<ScaleTransform ScaleX="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
|
||||
ScaleY="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
|
||||
CenterX="0"
|
||||
CenterY="0" />
|
||||
</Border.LayoutTransform>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="Header"
|
||||
Grid.Row="0">
|
||||
<uc:SlimPageWindowStateBar ClickedClose="WindowStateBarUc_ClickedClose"
|
||||
ClickedMaximize="WindowStateBarUc_ClickedMaximize"
|
||||
ShowFullStateBar="True"
|
||||
Visibility="{Binding ElementName=MainBorder, Path=IsMouseOver, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Border>
|
||||
|
||||
<Border x:Name="Body"
|
||||
Grid.Row="1">
|
||||
<Grid x:Name="BodyGrid">
|
||||
|
||||
<Border x:Name="StaticBodyParts"
|
||||
VerticalAlignment="Bottom"
|
||||
Panel.ZIndex="0">
|
||||
<StackPanel>
|
||||
<uc:SlimPageDataHistoryCollection x:Name="DataHistoryCollectionUc" />
|
||||
<uc:SlimPageWidgetCollection x:Name="WidgetCollectionUc"
|
||||
HeadingData="{Binding HeadingData}"
|
||||
WidgetData="{Binding WidgetData}"
|
||||
Width="{Binding ElementName=BodyGrid, Path=ActualWidth}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="BlurBorderBody"
|
||||
Background="Transparent"
|
||||
Panel.ZIndex="1"
|
||||
Visibility="{Binding ElementName=SlimPage, Path=IsBlurred, Converter={StaticResource BoolToVisibility}}"
|
||||
MouseUp="BlurBorder_MouseUp"
|
||||
TouchDown="BlurBorder_TouchDown" />
|
||||
|
||||
<Border x:Name="DynamicBodyParts" x:FieldModifier="private"
|
||||
Width="{Binding ElementName=StaticBodyParts, Path=ActualWidth}"
|
||||
Panel.ZIndex="2"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="0 2.5 0 0"
|
||||
CornerRadius="10 10 0 0"
|
||||
Background="{DynamicResource BackgroundColor.Menu.Categories}" />
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="Footer" x:FieldModifier="private"
|
||||
Grid.Row="2"
|
||||
Background="{DynamicResource BackgroundColor.SlimPage.MenuBar}"
|
||||
CornerRadius="0 0 7.5 7.5"
|
||||
Padding="10">
|
||||
<Grid>
|
||||
<buc:MenuBar x:Name="MenuBarUc" x:FieldModifier="private" />
|
||||
<buc:SearchBar x:Name="SearchBarUserControl" x:FieldModifier="private"
|
||||
Visibility="Collapsed"
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</detailspagebase:SupportCasePageBase>
|
||||
580
FasdDesktopUi/Pages/SlimPage/SlimPageView.xaml.cs
Normal file
580
FasdDesktopUi/Pages/SlimPage/SlimPageView.xaml.cs
Normal file
@@ -0,0 +1,580 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Pages.SlimPage.Models;
|
||||
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage
|
||||
{
|
||||
public partial class SlimPageView : SupportCasePageBase, IBlurrable
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private bool shouldReRunDataChangedEvent = false;
|
||||
|
||||
private const int MaxItemCountMenuBar = 5;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Blurring
|
||||
|
||||
internal override void DoBlurredChanged(bool isBlured)
|
||||
{
|
||||
DataHistoryCollectionUc.IsBlurred = isBlured;
|
||||
WidgetCollectionUc.IsBlurred = isBlured;
|
||||
}
|
||||
|
||||
internal override bool CheckBlurInvoker(IBlurInvoker invoker)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (invoker)
|
||||
{
|
||||
case SearchBar searchBar:
|
||||
if (!searchBar.IsVisible || searchBar.SearchStatus != SearchBar.eSearchStatus.message)
|
||||
return true;
|
||||
break;
|
||||
case QuickActionSelector _:
|
||||
case QuickActionStatusMonitor _:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public SlimPageView()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
AddCustomHandlers();
|
||||
|
||||
SourceInitialized += (s, e) =>
|
||||
{
|
||||
IntPtr handle = new WindowInteropHelper(this).Handle;
|
||||
HwndSource.FromHwnd(handle).AddHook(new HwndSourceHook(cUtility.WindowProc));
|
||||
};
|
||||
|
||||
UiSettingsChanged(null, null);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void SlimPage_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MenuBarUc.SetSlimPage();
|
||||
}
|
||||
|
||||
private void AddCustomHandlers()
|
||||
{
|
||||
try
|
||||
{
|
||||
AddHandler(cUiActionBase.UiActionClickedEvent, new cUiActionBase.UiActionEventHandlerDelegate(UiActionWasTriggered));
|
||||
AddHandler(DataCanvas.DataCanvasWasClosedEvent, new RoutedEventHandler(DataCanvasWasClosed));
|
||||
|
||||
BlurInvoker.BlurInvokerVisibilityChanged += (obj, e) => UpdateBlurStatus(obj);
|
||||
|
||||
MenuBarUc.SearchButtonClickedAction = SearchButtonClickedAction;
|
||||
MenuBarUc.MoreButtonClickedAction = MoreButtonClickedAction;
|
||||
|
||||
SearchBarUserControl.ChangedSearchValue = EnteredSearchValueAsync;
|
||||
SearchBarUserControl.CancledSearchAction = BlurBorder_Click;
|
||||
|
||||
cFasdCockpitConfig.Instance.UiSettingsChanged += UiSettingsChanged;
|
||||
cConnectionStatusHelper.ApiConnectionStatusChanged += ApiConnectionStatusChanged;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void UiSettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var positionAlignement = cFasdCockpitConfig.Instance.Global.SmallViewAlignment;
|
||||
|
||||
switch (positionAlignement)
|
||||
{
|
||||
case enumF4sdHorizontalAlignment.Center:
|
||||
MainBorder.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
break;
|
||||
case enumF4sdHorizontalAlignment.Right:
|
||||
MainBorder.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
break;
|
||||
default:
|
||||
MainBorder.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApiConnectionStatusChanged(cConnectionStatusHelper.enumOnlineStatus? Status)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (Status == cConnectionStatusHelper.enumOnlineStatus.online)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Footer.ClearValue(IsHitTestVisibleProperty);
|
||||
Footer.ClearValue(OpacityProperty);
|
||||
DynamicBodyParts.ClearValue(IsHitTestVisibleProperty);
|
||||
DynamicBodyParts.ClearValue(OpacityProperty);
|
||||
if (MenuBarUc.Visibility != Visibility.Visible)
|
||||
{
|
||||
SearchBarUserControl.Visibility = Visibility.Collapsed;
|
||||
MenuBarUc.Visibility = Visibility.Visible;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Footer.IsHitTestVisible = false;
|
||||
DynamicBodyParts.IsHitTestVisible = false;
|
||||
DynamicBodyParts.Opacity = 0.6;
|
||||
if (SearchBarUserControl.Visibility != Visibility.Visible)
|
||||
{
|
||||
MenuBarUc.Visibility = Visibility.Collapsed;
|
||||
SearchBarUserControl.Visibility = Visibility.Visible;
|
||||
}
|
||||
SearchBarUserControl.SetApiStatus();
|
||||
|
||||
IsBlurred = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Delegate Actions
|
||||
|
||||
private void SearchButtonClickedAction()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
MenuBarUc.MenuBarUc.Visibility = Visibility.Collapsed;
|
||||
SearchBarUserControl.Visibility = Visibility.Visible;
|
||||
SearchBarUserControl.ActivateManualSearch();
|
||||
|
||||
DynamicBodyParts.Child = null;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EnteredSearchValueAsync(cFilteredResults filteredResults)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
//try
|
||||
//{
|
||||
// if (filteredResults?.Results == null)
|
||||
// {
|
||||
// DynamicBodyParts.Child = null;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (DynamicBodyParts.Child is CustomSearchResultCollection customSearchResultCollection)
|
||||
// {
|
||||
// customSearchResultCollection.ShowSearchResults(filteredResults,null);
|
||||
// customSearchResultCollection.IndexOfSelectedResultItem = filteredResults?.Results?.Count - 1 ?? -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var _searchResultCollection = new CustomSearchResultCollection(true) { IndexOfSelectedResultItem = filteredResults?.Results?.Count - 1 ?? -1 };
|
||||
// _searchResultCollection.ShowSearchResults(filteredResults,null);
|
||||
// DynamicBodyParts.Child = _searchResultCollection;
|
||||
// }
|
||||
//}
|
||||
//catch (Exception E)
|
||||
//{
|
||||
// LogException(E);
|
||||
//}
|
||||
}
|
||||
|
||||
private void MoreButtonClickedAction()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(DataContext is SlimPageViewModel viewModel))
|
||||
return;
|
||||
|
||||
var tempMoreQuickActionList = viewModel.MenuDrawerData;
|
||||
|
||||
if (cF4SDCockpitXmlConfig.Instance?.CopyTemplateConfig?.CopyTemplates != null)
|
||||
{
|
||||
var tempSubMenuList = new List<cMenuDataBase>();
|
||||
|
||||
foreach (var copyTemplate in cF4SDCockpitXmlConfig.Instance?.CopyTemplateConfig?.CopyTemplates.CopyTemplates)
|
||||
{
|
||||
tempSubMenuList.Add(new cMenuDataBase(copyTemplate.Value));
|
||||
}
|
||||
|
||||
tempMoreQuickActionList.Insert(0, new cMenuDataContainer() { MenuText = cMultiLanguageSupport.GetItem("QuickAction.CopyContent"), MenuIcon = new F4SD_AdaptableIcon.IconData(enumInternIcons.menuBar_copy), UiAction = new cSubMenuAction(true) { Name = cMultiLanguageSupport.GetItem("QuickAction.CopyContent"), SubMenuData = tempSubMenuList }, SubMenuData = tempSubMenuList });
|
||||
}
|
||||
|
||||
var quickActionSelector = new QuickActionSelector()
|
||||
{
|
||||
Visibility = Visibility.Visible,
|
||||
QuickActionList = tempMoreQuickActionList,
|
||||
QuickActionSelectorHeading = "Quick Actions",
|
||||
TempQuickActionList = null,
|
||||
CloseButtonClickedAction = BlurBorder_Click
|
||||
};
|
||||
|
||||
quickActionSelector.LockButton.Visibility = Visibility.Collapsed;
|
||||
DynamicBodyParts.Child = quickActionSelector;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetPropertyValues(cSlimPageData slimPageData)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlurBorder_Click();
|
||||
|
||||
if (DataContext is SlimPageViewModel viewModel)
|
||||
viewModel.InitializeProperties(slimPageData);
|
||||
|
||||
//todo: replace binding with following schema due to performance issues:
|
||||
WidgetCollectionUc.HeadingData = slimPageData.HeadingData;
|
||||
WidgetCollectionUc.WidgetData = slimPageData.WidgetData;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region Update Data
|
||||
|
||||
internal override async void DataProvider_DataChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isDataChangedEventRunning)
|
||||
{
|
||||
shouldReRunDataChangedEvent = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await _supportCase?.SupportCaseDataProviderArtifact.HealthCardDataHelper.GetSlimPageDataAsync();
|
||||
//todo: check if there is a more performant way solving this
|
||||
Dispatcher.Invoke(() => WidgetCollectionUc.HeadingData = data.HeadingData);
|
||||
Dispatcher.Invoke(() => WidgetCollectionUc.WidgetData = data.WidgetData);
|
||||
Dispatcher.Invoke(() => MenuBarUc.MenuBarItemData = GetSlimpageMenuBarData(data.MenuBarData));
|
||||
Dispatcher.Invoke(() => DataHistoryCollectionUc.UpdateHistory(data.DataHistoryList));
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (DataContext is SlimPageViewModel viewModel)
|
||||
viewModel.InitializeProperties(data);
|
||||
});
|
||||
|
||||
if (shouldReRunDataChangedEvent)
|
||||
{
|
||||
shouldReRunDataChangedEvent = false;
|
||||
DataProvider_DataChanged(sender, e);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
internal override async void DataProvider_DataFullyLoaded(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _supportCase?.SupportCaseDataProviderArtifact.HealthCardDataHelper.GetSlimPageDataAsync();
|
||||
//todo: check if there is a more performant way solving this
|
||||
Dispatcher.Invoke(() => WidgetCollectionUc.HeadingData = data.HeadingData);
|
||||
Dispatcher.Invoke(() => WidgetCollectionUc.WidgetData = data.WidgetData);
|
||||
Dispatcher.Invoke(() => MenuBarUc.MenuBarItemData = GetSlimpageMenuBarData(data.MenuBarData));
|
||||
Dispatcher.Invoke(() => DataHistoryCollectionUc.UpdateHistory(data.DataHistoryList));
|
||||
|
||||
if (_supportCase != null)
|
||||
{
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataChanged -= DataProvider_DataChanged;
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataFullyLoaded -= DataProvider_DataFullyLoaded;
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void DirectConnectionHelper_DirectConnectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
bool hasDirectConnection = _supportCase?.SupportCaseDataProviderArtifact?.DirectConnectionHelper?.IsDirectConnectionActive ?? false;
|
||||
WidgetCollectionUc.HasDirectConnection = hasDirectConnection;
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private List<cMenuDataBase> GetSlimpageMenuBarData(List<cMenuDataBase> list)
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Where(data => data.IconPositionIndex > -1)
|
||||
.OrderBy(data => data.IconPositionIndex)
|
||||
.Skip(MaxItemCountMenuBar)
|
||||
.ToList()
|
||||
.ForEach(data => data.IconPositionIndex = -1);
|
||||
return list;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
return new List<cMenuDataBase>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BlurBorder_Click
|
||||
|
||||
private void BlurBorder_Click()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(DataContext is SlimPageViewModel viewModel))
|
||||
return;
|
||||
|
||||
if (SearchBarUserControl.SearchStatus != SearchBar.eSearchStatus.message)
|
||||
{
|
||||
SearchBarUserControl.Visibility = Visibility.Collapsed;
|
||||
MenuBarUc.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
IsBlurred = false;
|
||||
|
||||
DynamicBodyParts.Child = null;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void BlurBorder_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
}
|
||||
|
||||
private void BlurBorder_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Search Events
|
||||
|
||||
private void SearchBar_DidSearch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
}
|
||||
|
||||
private void SearchBar_CancledSearch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WindowStateBar Events
|
||||
|
||||
private void WindowStateBarUc_ClickedClose(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void WindowStateBarUc_ClickedMaximize(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
|
||||
if (detailsPage != null)
|
||||
{
|
||||
Hide();
|
||||
App.HideAllSettingViews();
|
||||
detailsPage.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async void UiActionWasTriggered(object sender, UiActionEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// define drawing area
|
||||
UIElement drawingArea = null;
|
||||
|
||||
switch (e.UiAction)
|
||||
{
|
||||
case cUiQuickAction _:
|
||||
drawingArea = DynamicBodyParts.Child is Decorator decorator ? decorator : new Decorator();
|
||||
if (!(DynamicBodyParts.Child is Decorator))
|
||||
DynamicBodyParts.Child = drawingArea;
|
||||
break;
|
||||
case cSubMenuAction _:
|
||||
drawingArea = DynamicBodyParts.Child is QuickActionSelector quickActionSelector ? quickActionSelector : new QuickActionSelector();
|
||||
if (!(DynamicBodyParts.Child is QuickActionSelector))
|
||||
DynamicBodyParts.Child = drawingArea;
|
||||
break;
|
||||
}
|
||||
|
||||
await e.UiAction?.RunUiActionAsync(e.OriginalSource, drawingArea, false, _supportCase?.SupportCaseDataProviderArtifact);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataCanvasWasClosed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BlurBorder_Click();
|
||||
}
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SearchBarUserControl.Visibility == Visibility.Visible && DynamicBodyParts.Child is CustomSearchResultCollection resultMenu)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
if (resultMenu.IndexOfSelectedResultItem > 0)
|
||||
resultMenu.IndexOfSelectedResultItem--;
|
||||
break;
|
||||
case Key.Down:
|
||||
resultMenu.IndexOfSelectedResultItem++;
|
||||
break;
|
||||
case Key.Enter:
|
||||
resultMenu.SelectCurrentResultItem();
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Key.Escape:
|
||||
BlurBorder_Click();
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Enter:
|
||||
if (SearchBarUserControl.Visibility == Visibility.Visible)
|
||||
break;
|
||||
|
||||
var detailsPage = cSupportCaseDataProvider.detailsPage;
|
||||
if (detailsPage != null)
|
||||
{
|
||||
Hide();
|
||||
App.HideAllSettingViews();
|
||||
detailsPage.Show();
|
||||
}
|
||||
break;
|
||||
case Key.F3:
|
||||
if (Keyboard.Modifiers == ModifierKeys.Control)
|
||||
SearchButtonClickedAction();
|
||||
break;
|
||||
}
|
||||
} //todo: add QuickAction Navigation
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetZoomValue(int zoomInPercent)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataContext is SlimPageViewModel viewModel)
|
||||
viewModel.ZoomInPercent = zoomInPercent;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
152
FasdDesktopUi/Pages/SlimPage/SlimPageViewModel.cs
Normal file
152
FasdDesktopUi/Pages/SlimPage/SlimPageViewModel.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FasdDesktopUi.Pages.SlimPage.Models;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SlimPage
|
||||
{
|
||||
public class SlimPageViewModel : BaseViewModel
|
||||
{
|
||||
#region Properties
|
||||
|
||||
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.SetSlimPageZoom(value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cockpit Properties
|
||||
|
||||
#region HeadingData Property
|
||||
|
||||
private List<cHeadingDataModel> headingData;
|
||||
|
||||
public List<cHeadingDataModel> HeadingData
|
||||
{
|
||||
get { return headingData; }
|
||||
set
|
||||
{
|
||||
headingData = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Widget Property
|
||||
|
||||
private List<List<cWidgetValueModel>> widgetData;
|
||||
|
||||
public List<List<cWidgetValueModel>> WidgetData
|
||||
{
|
||||
get { return widgetData; }
|
||||
set
|
||||
{
|
||||
widgetData = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#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
|
||||
|
||||
#region DataHistory Properties
|
||||
|
||||
private List<cSlimPageDataHistoryModel> dataHistoryList;
|
||||
|
||||
public List<cSlimPageDataHistoryModel> DataHistoryList
|
||||
{
|
||||
get { return dataHistoryList; }
|
||||
set
|
||||
{
|
||||
dataHistoryList = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
public SlimPageViewModel()
|
||||
{
|
||||
cFasdCockpitConfig.Instance.UiSettingsChanged += CockpitConfig_UiSettingsChanged;
|
||||
}
|
||||
|
||||
private void CockpitConfig_UiSettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
ZoomInPercent = cFasdCockpitConfig.Instance.SlimPageZoom;
|
||||
}
|
||||
|
||||
public void InitializeProperties(cSlimPageData slimPageData)
|
||||
{
|
||||
DataProvider = slimPageData.DataProvider;
|
||||
HeadingData = slimPageData.HeadingData;
|
||||
WidgetData = slimPageData.WidgetData;
|
||||
DataHistoryList = slimPageData.DataHistoryList;
|
||||
MenuBarData = slimPageData.MenuBarData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
FasdDesktopUi/Pages/SplashScreenView/IntroView.xaml
Normal file
23
FasdDesktopUi/Pages/SplashScreenView/IntroView.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.SplashScreenView.IntroView"
|
||||
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.SplashScreenView"
|
||||
mc:Ignorable="d"
|
||||
Title="IntroView"
|
||||
Height="450"
|
||||
Width="800"
|
||||
WindowState="Maximized"
|
||||
WindowStyle="None"
|
||||
Background="#426199"
|
||||
PreviewKeyDown="Window_PreviewKeyDown"
|
||||
IsVisibleChanged="Window_IsVisibleChanged">
|
||||
<Grid>
|
||||
<MediaElement x:Name="VideoPlayer"
|
||||
x:FieldModifier="private"
|
||||
Stretch="Fill"
|
||||
MediaEnded="videoPlayer_MediaEnded"
|
||||
LoadedBehavior="Manual"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
66
FasdDesktopUi/Pages/SplashScreenView/IntroView.xaml.cs
Normal file
66
FasdDesktopUi/Pages/SplashScreenView/IntroView.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
using C4IT.Logging;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
|
||||
using FasdCockpitCommunication;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SplashScreenView
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for IntroView.xaml
|
||||
/// </summary>
|
||||
public partial class IntroView : Window
|
||||
{
|
||||
public const string IntroPath = "MediaContent/F4SD-Intro-001.mov";
|
||||
|
||||
public IntroView()
|
||||
{
|
||||
MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); }
|
||||
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var _mediaUri = cFasdCockpitCommunicationBase.Instance.GetMediaContentUri(IntroPath);
|
||||
if (_mediaUri != null)
|
||||
VideoPlayer.Source = _mediaUri;
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (CM != null) LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void videoPlayer_MediaEnded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
VideoPlayer.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
98
FasdDesktopUi/Pages/SplashScreenView/SplashScreenView.xaml
Normal file
98
FasdDesktopUi/Pages/SplashScreenView/SplashScreenView.xaml
Normal file
@@ -0,0 +1,98 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.SplashScreenView.SplashScreenView"
|
||||
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.SplashScreenView"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
mc:Ignorable="d"
|
||||
Title="First Aid Service Desk"
|
||||
Height="240"
|
||||
Width="430"
|
||||
ResizeMode="NoResize"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
IsVisibleChanged="Window_IsVisibleChanged">
|
||||
|
||||
<Border Padding="12.5 7.5"
|
||||
Background="#234B92">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ico:AdaptableIcon x:Name="MinimizeButton"
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
PrimaryIconColor="White"
|
||||
HorizontalAlignment="Right"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonUp="MinimizeButton_MouseLeftButtonUp"
|
||||
TouchDown="MinimizeButton_TouchDown">
|
||||
<ico:AdaptableIcon.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="Opacity"
|
||||
Value="1" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.6" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ico:AdaptableIcon.Resources>
|
||||
<ico:AdaptableIcon.SelectedInternIcon>
|
||||
window_minimize
|
||||
</ico:AdaptableIcon.SelectedInternIcon>
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<ico:AdaptableIcon Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
PrimaryIconColor="White"
|
||||
IconHeight="220"
|
||||
IconWidth="330"
|
||||
SelectedInternIcon="f4sd_product_logo"
|
||||
MouseLeftButtonDown="F4SDLogo_MouseLeftButtonDown"/>
|
||||
|
||||
<Image Source="pack://application:,,,/Resources/Consulting4ITWhite.png"
|
||||
Width="90"
|
||||
Grid.Row="2"
|
||||
Grid.Column="2" />
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Bottom">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground"
|
||||
Value="White" />
|
||||
<Setter Property="FontFamily"
|
||||
Value="Calibri" />
|
||||
<Setter Property="Opacity"
|
||||
Value="0.8" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<TextBlock x:Name="StatusTextBlock" />
|
||||
<TextBlock x:Name="LoadingDotBlock" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
|
||||
141
FasdDesktopUi/Pages/SplashScreenView/SplashScreenView.xaml.cs
Normal file
141
FasdDesktopUi/Pages/SplashScreenView/SplashScreenView.xaml.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Graphics;
|
||||
using C4IT.Logging;
|
||||
using FasdCockpitCommunication;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SplashScreenView
|
||||
{
|
||||
public partial class SplashScreenView : Window
|
||||
{
|
||||
private DispatcherTimer timer;
|
||||
private readonly IntroView _introView = new IntroView();
|
||||
|
||||
public SplashScreenView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetStatusText(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.Invoke(() => StatusTextBlock.Text = text);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
timer = new DispatcherTimer(TimeSpan.FromSeconds(0.5), DispatcherPriority.Loaded, new EventHandler((sender, args) => UpdateLoadingDots()), Dispatcher.CurrentDispatcher);
|
||||
}
|
||||
|
||||
private void UpdateLoadingDots()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(LoadingDotBlock.Text))
|
||||
LoadingDotBlock.Text = ".";
|
||||
else if (LoadingDotBlock.Text == ".")
|
||||
LoadingDotBlock.Text = "..";
|
||||
else if (LoadingDotBlock.Text == "..")
|
||||
LoadingDotBlock.Text = "...";
|
||||
else
|
||||
LoadingDotBlock.Text = string.Empty;
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(e.NewValue is bool isVisible))
|
||||
return;
|
||||
|
||||
if (isVisible)
|
||||
timer?.Start();
|
||||
else
|
||||
timer?.Stop();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#region MinimizeButton_Click
|
||||
|
||||
private void MinimizeButton_Click()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
(App.Current as App).notifyIcon.Visible = true;
|
||||
Close();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void MinimizeButton_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
MinimizeButton_Click();
|
||||
}
|
||||
|
||||
private void MinimizeButton_TouchDown(object sender, System.Windows.Input.TouchEventArgs e)
|
||||
{
|
||||
MinimizeButton_Click();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void F4SDLogo_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
var serverUrl = cFasdCockpitMachineConfiguration.Instance?.ServerUrl;
|
||||
|
||||
if (communication?.IsDemo() == true || string.IsNullOrWhiteSpace(serverUrl) || !Uri.TryCreate(serverUrl, UriKind.Absolute, out var baseUri))
|
||||
{
|
||||
_introView.Show();
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
using (HttpClient http = new HttpClient() { BaseAddress = baseUri })
|
||||
{
|
||||
if (!http.GetAsync(IntroView.IntroPath).Result.IsSuccessStatusCode)
|
||||
return;
|
||||
}
|
||||
|
||||
_introView.Show();
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
FasdDesktopUi/Pages/SuccessPage/SuccessPage.xaml
Normal file
43
FasdDesktopUi/Pages/SuccessPage/SuccessPage.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.SuccessPage.SuccessPage"
|
||||
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.SuccessPage"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
mc:Ignorable="d"
|
||||
d:Height="300"
|
||||
d:Width="300"
|
||||
Background="Transparent"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="none"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
IsVisibleChanged="BlurInvoker_IsActiveChanged">
|
||||
|
||||
<Border x:Name="MainBorder"
|
||||
CornerRadius="20"
|
||||
Background="{DynamicResource Color.AppBackground}"
|
||||
Height="250"
|
||||
Width="250">
|
||||
<Grid>
|
||||
<ico:AdaptableIcon x:Name="SuccessIcon"
|
||||
IconWidth="250"
|
||||
IconHeight="250"
|
||||
SelectedInternGif="partyPopper"
|
||||
BorderPadding="45 0 0 45" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseButton"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
SelectedInternIcon="window_close"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="7.5 2.5"
|
||||
MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
|
||||
TouchDown="CloseButton_TouchDown" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Window>
|
||||
68
FasdDesktopUi/Pages/SuccessPage/SuccessPage.xaml.cs
Normal file
68
FasdDesktopUi/Pages/SuccessPage/SuccessPage.xaml.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.SuccessPage
|
||||
{
|
||||
public partial class SuccessPage : Window, IBlurInvoker
|
||||
{
|
||||
public SuccessPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CloseButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CloseButton_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public async void BlurInvoker_IsActiveChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlurInvoker.InvokeVisibilityChanged(this, new EventArgs());
|
||||
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
const int delayInMilliSeconds = 750;
|
||||
const int animationDurationInMilliSeconds = 750;
|
||||
|
||||
await Task.Delay(delayInMilliSeconds);
|
||||
DoubleAnimation opacityAnimation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(animationDurationInMilliSeconds));
|
||||
MainBorder.BeginAnimation(OpacityProperty, opacityAnimation);
|
||||
await Task.Delay(animationDurationInMilliSeconds);
|
||||
Close();
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool BlurInvoker_IsActive => IsVisible;
|
||||
|
||||
}
|
||||
}
|
||||
118
FasdDesktopUi/Pages/SupportCasePageBase/SupportCasePageBase.cs
Normal file
118
FasdDesktopUi/Pages/SupportCasePageBase/SupportCasePageBase.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages
|
||||
{
|
||||
public class SupportCasePageBase : Window, IBlurrable
|
||||
{
|
||||
protected ISupportCase _supportCase;
|
||||
|
||||
internal bool isDataChangedEventRunning = false;
|
||||
|
||||
public virtual void SetSupportCase(ISupportCase supportCase)
|
||||
{
|
||||
if (_supportCase != null)
|
||||
{
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataChanged -= DataProvider_DataChanged;
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataFullyLoaded -= DataProvider_DataFullyLoaded;
|
||||
_supportCase.SupportCaseDataProviderArtifact.DirectConnectionHelper.DirectConnectionChanged -= DirectConnectionHelper_DirectConnectionChanged;
|
||||
}
|
||||
|
||||
_supportCase = supportCase;
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataChanged += DataProvider_DataChanged;
|
||||
_supportCase.SupportCaseDataProviderArtifact.HealthCardDataHelper.DataFullyLoaded += DataProvider_DataFullyLoaded;
|
||||
_supportCase.SupportCaseDataProviderArtifact.DirectConnectionHelper.DirectConnectionChanged += DirectConnectionHelper_DirectConnectionChanged;
|
||||
}
|
||||
|
||||
internal async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e != null)
|
||||
e.Cancel = true;
|
||||
|
||||
var dialogResult = await cSupportCaseDataProvider.CloseSupportCaseAsync();
|
||||
if (dialogResult)
|
||||
Hide();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual void DataProvider_DataChanged(object sender, EventArgs e) { throw new NotImplementedException(); }
|
||||
internal virtual void DataProvider_DataFullyLoaded(object sender, EventArgs e) { throw new NotImplementedException(); }
|
||||
internal virtual void DirectConnectionHelper_DirectConnectionChanged(object sender, EventArgs e) { throw new NotImplementedException(); }
|
||||
|
||||
#region IsBlurred
|
||||
|
||||
private static void IsBlurredChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is SupportCasePageBase _me))
|
||||
return;
|
||||
|
||||
if (!(e.NewValue is bool isBlurred))
|
||||
return;
|
||||
|
||||
_me.DoBlurredChanged(isBlurred);
|
||||
}
|
||||
|
||||
internal virtual void DoBlurredChanged(bool isBlured) { throw new NotImplementedException(); }
|
||||
|
||||
public static readonly DependencyProperty IsBlurredProperty =
|
||||
DependencyProperty.Register("IsBlurred", typeof(bool), typeof(SupportCasePageBase), new PropertyMetadata(false, new PropertyChangedCallback(IsBlurredChanged)));
|
||||
|
||||
|
||||
public bool IsBlurred
|
||||
{
|
||||
get { return (bool)GetValue(IsBlurredProperty); }
|
||||
set
|
||||
{
|
||||
SetValue(IsBlurredProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public List<IBlurInvoker> BlurInvokers { get; set; } = new List<IBlurInvoker>();
|
||||
|
||||
|
||||
public void UpdateBlurStatus(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(sender is IBlurInvoker invoker))
|
||||
return;
|
||||
|
||||
if (CheckBlurInvoker(invoker))
|
||||
{
|
||||
if (invoker.BlurInvoker_IsActive)
|
||||
{
|
||||
if (BlurInvokers?.Contains(invoker) is false)
|
||||
BlurInvokers?.Add(invoker);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BlurInvokers?.Contains(invoker) is true)
|
||||
BlurInvokers?.Remove(invoker);
|
||||
}
|
||||
}
|
||||
|
||||
IsBlurred = BlurInvokers?.Count > 0;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual bool CheckBlurInvoker(IBlurInvoker invoker) { return false; }
|
||||
}
|
||||
}
|
||||
228
FasdDesktopUi/Pages/TicketCompletion/TicketCompletion.xaml
Normal file
228
FasdDesktopUi/Pages/TicketCompletion/TicketCompletion.xaml
Normal file
@@ -0,0 +1,228 @@
|
||||
<Window x:Class="FasdDesktopUi.Pages.TicketCompletion.TicketCompletion"
|
||||
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.CustomMessageBox"
|
||||
xmlns:uc="clr-namespace:FasdDesktopUi.Basics.UserControls"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
|
||||
xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
|
||||
mc:Ignorable="d"
|
||||
x:Name="TicketCompletionView"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
MaxWidth="475"
|
||||
Background="Transparent"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
PreviewKeyDown="CustomMessageBox_PreviewKeyDown"
|
||||
IsVisibleChanged="BlurInvoker_IsActiveChanged">
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="40" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Window.Resources>
|
||||
<BlurEffect x:Key="BlurEffecStyle"
|
||||
Radius="4"
|
||||
KernelType="Gaussian" />
|
||||
<Style x:Key="BlurablePanel"
|
||||
TargetType="Panel">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=TicketCompletionView, Path=WaitForClosing}"
|
||||
Value="True">
|
||||
<Setter Property="Effect"
|
||||
Value="{StaticResource BlurEffecStyle}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
|
||||
<vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
|
||||
<vc:BoolOrToVisibilityConverter x:Key="BoolOrToVisibilityConverter" />
|
||||
<vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
|
||||
CornerRadius="7.5"
|
||||
Padding="10">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas Grid.RowSpan="999"
|
||||
Panel.ZIndex="5"
|
||||
Margin="-10 -10">
|
||||
<Border x:Name="FocusBorder"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
Grid.RowSpan="999"
|
||||
Opacity="0.4"
|
||||
Visibility="Collapsed"
|
||||
Panel.ZIndex="-1"
|
||||
Width="{Binding ElementName=TicketCompletionView, Path=ActualWidth}"
|
||||
Height="{Binding ElementName=TicketCompletionView, Path=ActualHeight}" />
|
||||
<Decorator x:Name="FocusDecorator" />
|
||||
|
||||
</Canvas>
|
||||
|
||||
<DockPanel Grid.Row="0"
|
||||
Margin="0 0 0 10"
|
||||
Style="{StaticResource BlurablePanel}">
|
||||
<ico:AdaptableIcon DockPanel.Dock="Right"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
MouseLeftButtonUp="CloseButton_Click"
|
||||
TouchDown="CloseButton_Click"
|
||||
SelectedInternIcon="window_close" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="StatusIcon"
|
||||
DockPanel.Dock="Left"
|
||||
SecondaryIconColor="{DynamicResource Color.AppBackground}"
|
||||
HorizontalAlignment="Right"
|
||||
BorderPadding="0 7.5 7.5 7.5"
|
||||
SelectedInternIcon="misc_ticket">
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Title}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
FontSize="18"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Calibri"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}" />
|
||||
</DockPanel>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Style="{StaticResource BlurablePanel}">
|
||||
|
||||
<uc:CloseCaseDialogWithTicket x:Name="CloseCaseDialogUc" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Border x:Name="BlurOverlayBoarder"
|
||||
x:FieldModifier="private"
|
||||
Grid.RowSpan="2"
|
||||
Background="{DynamicResource Color.BlurBorder}"
|
||||
CornerRadius="7.5"
|
||||
Opacity="0.4"
|
||||
Visibility="{Binding ElementName=TicketCompletionView, Path=WaitForClosing, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
<Grid x:Name="GridPanel"
|
||||
Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="40 10 0 0"
|
||||
Padding="10 0 10 0"
|
||||
HorizontalAlignment="Right"
|
||||
Height="Auto">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="5" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<TextBlock x:Name="SafeText"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Safe}"
|
||||
Grid.Column="0"
|
||||
Padding="10 10 10 10"
|
||||
FontWeight="Bold"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonUp="SafeText_Click"
|
||||
TouchDown="SafeText_Click">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource Color.Green}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="False">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="170 10 0 0"
|
||||
Padding="10 0 10 0"
|
||||
HorizontalAlignment="Right"
|
||||
Height="Auto">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
|
||||
<Setter Property="CornerRadius"
|
||||
Value="5" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<TextBlock x:Name="AbortText"
|
||||
Grid.Column="1"
|
||||
Padding="10 10 10 10"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Abort}"
|
||||
FontWeight="Bold"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonUp="AbortText_Click"
|
||||
TouchDown="AbortText_Click">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource Color.Red}" />
|
||||
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="False">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource FontColor.Menu.Categories}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
|
||||
<ico:AdaptableIcon Grid.ColumnSpan="999"
|
||||
BorderPadding="0"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
IconHeight="20"
|
||||
IconWidth="20"
|
||||
SelectedInternGif="loadingSpinner"
|
||||
Margin="50 10 0 0"
|
||||
Visibility="{Binding Path=IsClosingBusy, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
|
||||
278
FasdDesktopUi/Pages/TicketCompletion/TicketCompletion.xaml.cs
Normal file
278
FasdDesktopUi/Pages/TicketCompletion/TicketCompletion.xaml.cs
Normal file
@@ -0,0 +1,278 @@
|
||||
using C4IT.FASD.Base;
|
||||
using FasdDesktopUi.Basics;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Pages.TicketCompletion
|
||||
{
|
||||
public partial class TicketCompletion : Window, IBlurInvoker, INotifyPropertyChanged
|
||||
{
|
||||
private bool isCanceled = false;
|
||||
|
||||
private bool _WaitForClosing = false;
|
||||
public bool WaitForClosing
|
||||
{
|
||||
get { return _WaitForClosing; }
|
||||
set
|
||||
{
|
||||
if (value != _WaitForClosing)
|
||||
{
|
||||
_WaitForClosing = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("WaitForClosing"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly cSupportCaseDataProvider _dataProvider;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private TicketCompletion(cSupportCaseDataProvider dataProvider)
|
||||
{
|
||||
InitializeComponent();
|
||||
_dataProvider = dataProvider;
|
||||
CloseCaseDialogUc.DataProvider = _dataProvider;
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
|
||||
cFocusInvoker.GotFocus += ElementGotFocus;
|
||||
cFocusInvoker.LostFocus += ElementLostFocus;
|
||||
}
|
||||
|
||||
#region ClosingBusy
|
||||
|
||||
public bool IsClosingBusy
|
||||
{
|
||||
get { return (bool)GetValue(IsClosingBusyProperty); }
|
||||
set { SetValue(IsClosingBusyProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsClosingBusyProperty =
|
||||
DependencyProperty.Register("IsClosingBusy", typeof(bool), typeof(TicketCompletion), new PropertyMetadata(false));
|
||||
|
||||
#endregion
|
||||
|
||||
public static bool? Show(cSupportCaseDataProvider DataProvider, Window Owner)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existingMessageBox = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is TicketCompletion);
|
||||
if (existingMessageBox != null)
|
||||
{
|
||||
existingMessageBox.Show();
|
||||
return null;
|
||||
}
|
||||
|
||||
TicketCompletion ticketCompletion = new TicketCompletion(DataProvider);
|
||||
|
||||
if (Owner != null)
|
||||
ticketCompletion.Owner = Owner;
|
||||
else
|
||||
ticketCompletion.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
bool? dialogResult = null;
|
||||
try
|
||||
{
|
||||
dialogResult = ticketCompletion.ShowDialog();
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return ticketCompletion.isCanceled ? null : dialogResult;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#region Close_Click
|
||||
|
||||
private void Close_Click()
|
||||
{
|
||||
DialogResult = null;
|
||||
isCanceled = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CloseButton_Click(object sender, InputEventArgs e) => Close_Click();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Focus Events
|
||||
|
||||
private void ElementGotFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
FocusBorder.Visibility = Visibility.Visible;
|
||||
|
||||
if (!(sender is FrameworkElement senderElement))
|
||||
return;
|
||||
|
||||
if (FocusBorder.IsVisible is false)
|
||||
return;
|
||||
|
||||
var desiredHeight = senderElement.ActualHeight;
|
||||
var desiredWidth = senderElement.ActualWidth;
|
||||
|
||||
FrameworkElement placeHolderElement = new FrameworkElement() { Height = desiredHeight, Width = desiredWidth, Margin = senderElement.Margin };
|
||||
FocusDecorator.Height = desiredHeight + senderElement.Margin.Top + senderElement.Margin.Bottom;
|
||||
FocusDecorator.Width = desiredWidth + senderElement.Margin.Left + senderElement.Margin.Right;
|
||||
|
||||
Point relativePoint = senderElement.TransformToAncestor(this)
|
||||
.Transform(new Point(0, 0));
|
||||
|
||||
if (senderElement.Parent is Decorator actualParentDecorator)
|
||||
actualParentDecorator.Child = placeHolderElement;
|
||||
else if (senderElement.Parent is Panel actualParentPanel)
|
||||
{
|
||||
if (actualParentPanel is Grid)
|
||||
{
|
||||
Grid.SetColumn(placeHolderElement, Grid.GetColumn(senderElement));
|
||||
Grid.SetRow(placeHolderElement, Grid.GetRow(senderElement));
|
||||
}
|
||||
|
||||
actualParentPanel.Children.Insert(actualParentPanel.Children.IndexOf(senderElement), placeHolderElement);
|
||||
actualParentPanel.Children.Remove(senderElement);
|
||||
}
|
||||
|
||||
Canvas.SetLeft(FocusDecorator, relativePoint.X - (senderElement.Margin.Left));
|
||||
Canvas.SetTop(FocusDecorator, relativePoint.Y - senderElement.Margin.Top);
|
||||
|
||||
FocusDecorator.Child = senderElement;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void ElementLostFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
FocusBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void CustomMessageBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
Close_Click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoCloseActionAsync()
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
WaitForClosing = true;
|
||||
SafeText.IsEnabled = false;
|
||||
AbortText.IsEnabled = false;
|
||||
IsClosingBusy = true;
|
||||
|
||||
bool closedSuccessfull = await CloseCaseDialogUc.CloseCaseAsync(_dataProvider.Identities.FirstOrDefault(identity => identity.Class == enumFasdInformationClass.User).Id);
|
||||
|
||||
if (closedSuccessfull)
|
||||
{
|
||||
SuccessPage.SuccessPage successPage = new SuccessPage.SuccessPage();
|
||||
successPage.Show();
|
||||
await _dataProvider?.CloseCaseAsync();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WaitForClosing = false;
|
||||
SafeText.IsEnabled = true;
|
||||
AbortText.IsEnabled = true;
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
}
|
||||
|
||||
public void BlurInvoker_IsActiveChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
BlurInvoker.InvokeVisibilityChanged(this, new EventArgs());
|
||||
}
|
||||
|
||||
public bool BlurInvoker_IsActive => IsVisible;
|
||||
|
||||
public void SetButtonStateYes(bool Enabled, string MouseOverMessage)
|
||||
{
|
||||
var _h = this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolTip tip = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(MouseOverMessage))
|
||||
tip = new ToolTip { Content = MouseOverMessage };
|
||||
|
||||
SafeText.IsEnabled = Enabled;
|
||||
GridPanel.ToolTip = tip;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void SetButtonStateNo(bool Enabled, string MouseOverMessage)
|
||||
{
|
||||
_ = this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolTip tip = null;
|
||||
if (!string.IsNullOrEmpty(MouseOverMessage))
|
||||
tip = new ToolTip { Content = MouseOverMessage };
|
||||
|
||||
AbortText.IsEnabled = Enabled;
|
||||
AbortText.ToolTip = tip;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private async void SafeText_Click(object sender, InputEventArgs e) => await DoCloseActionAsync();
|
||||
|
||||
private void AbortText_Click(object sender, InputEventArgs e) => Close_Click();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user