This commit is contained in:
Meik
2025-11-11 11:03:42 +01:00
commit dc3e8a2e4c
582 changed files with 191465 additions and 0 deletions

View File

@@ -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
}
}