inital
This commit is contained in:
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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user