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,78 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media;
using C4IT.Logging;
namespace FasdDesktopUi.Basics.Converter
{
public class BoolOrToVisibilityConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
foreach (var value in values)
{
if (value is bool boolValue && boolValue)
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class BooleanToBrushConverter : MarkupExtension, IValueConverter
{
public Object TrueValue { get; set; } = new SolidColorBrush(Colors.LightGray);
public Object FalseValue { get; set; } = new SolidColorBrush(Colors.Blue);
public object Convert(
object value, Type targetType, object parameter,
CultureInfo culture)
{
if (!(value is bool))
return FalseValue;
return (bool)value ? TrueValue :
FalseValue;
}
public object ConvertBack(
object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new NotImplementedException();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
public class WebView2PathConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var _webViewConfigPath = cLogManagerFile.GetDefaultPath(false, SubFolder: "WebViewData");
_webViewConfigPath = System.IO.Path.GetDirectoryName(_webViewConfigPath);
return _webViewConfigPath;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,53 @@
using FasdDesktopUi.Basics.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
[ValueConversion(typeof(cDataCanvasDataModel), typeof(bool))]
public class DataCanvasIsCloseButtonVisibileConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is cDataCanvasDataModel data) || !(parameter is enumDataCanvasTypes dataCanvasType))
return null;
bool output = false;
switch (dataCanvasType)
{
case enumDataCanvasTypes.recommendation:
if (data.QuickActionStatusMonitorData == null && data.DetailedData == null)
output = true;
break;
case enumDataCanvasTypes.detailedData:
if (data.QuickActionStatusMonitorData == null)
output = true;
break;
case enumDataCanvasTypes.quickActionStatusMonitor:
output = true;
break;
}
return output;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public enum enumDataCanvasTypes
{
recommendation = 0,
detailedData,
quickActionStatusMonitor
}
}

View File

@@ -0,0 +1,79 @@
using C4IT.FASD.Base;
using F4SD_AdaptableIcon;
using F4SD_AdaptableIcon.Enums;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
/// <summary>
/// Manages conversion between <see cref="cFasdIcon"/> and <see cref="IconData"/>
/// </summary>
internal class IconDataConverter : IValueConverter
{
/// <summary>
/// Converts <see cref="cFasdIcon"/> to <see cref="IconData"/>
/// </summary>
/// <returns>The icon data of type <see cref="IconData"/></returns>
internal static IconData Convert(cFasdIcon iconConfig)
{
switch (iconConfig.IconType)
{
case enumIconType.intern:
if (Enum.TryParse(iconConfig.Name, out enumInternIcons intern))
return new IconData(intern);
break;
case enumIconType.material:
if (Enum.TryParse(iconConfig.Name, out MaterialIcons.MaterialIconType material))
return new IconData(material);
break;
case enumIconType.gif:
if (Enum.TryParse(iconConfig.Name, out enumInternGif gif))
return new IconData(gif);
break;
}
return new IconData(enumInternIcons.none);
}
/// <summary>
/// Converts <see cref="cFasdIcon"/> to <see cref="IconData"/>
/// </summary>
/// <returns>The icon data of type <see cref="IconData"/></returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(IconData))
return null;
if (!(value is cFasdIcon iconConfig))
return new IconData(enumInternIcons.none);
return Convert(iconConfig);
}
/// <summary>
/// Converts <see cref="IconData"/> to <see cref="cFasdIcon"/>
/// </summary>
/// <returns>The configuration of type <see cref="cFasdIcon"/></returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is IconData iconData))
return null;
if (iconData.Intern != null)
return new cFasdIcon() { IconType = enumIconType.intern, Name = iconData.Intern.ToString(), IsValid = true };
else if (iconData.Material != null)
return new cFasdIcon(iconData.Material.Value);
else if (iconData.Gif != null)
return new cFasdIcon() { IconType = enumIconType.gif, Name = iconData.Gif.ToString(), IsValid = true };
return null;
}
}
}

View File

@@ -0,0 +1,47 @@
using C4IT.FASD.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace FasdDesktopUi.Basics.Converter
{
public class InternalEnumConverter
{
public static HorizontalAlignment GetHorizontalAlignment(enumF4sdHorizontalAlignment intern)
{
switch (intern)
{
case enumF4sdHorizontalAlignment.Default:
return HorizontalAlignment.Left;
case enumF4sdHorizontalAlignment.Right:
return HorizontalAlignment.Right;
case enumF4sdHorizontalAlignment.Center:
return HorizontalAlignment.Center;
case enumF4sdHorizontalAlignment.Left:
return HorizontalAlignment.Left;
default:
throw new NotImplementedException();
}
}
public static enumF4sdHorizontalAlignment GetHorizontalAlignment(HorizontalAlignment alignment)
{
switch (alignment)
{
case HorizontalAlignment.Left:
return enumF4sdHorizontalAlignment.Left;
case HorizontalAlignment.Center:
return enumF4sdHorizontalAlignment.Center;
case HorizontalAlignment.Right:
return enumF4sdHorizontalAlignment.Right;
case HorizontalAlignment.Stretch:
return enumF4sdHorizontalAlignment.Left;
default:
throw new NotImplementedException();
}
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InvertBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
return !(bool)value;
}
}
}

View File

@@ -0,0 +1,51 @@
using C4IT.Logging;
using C4IT.MultiLanguage;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using static C4IT.Logging.cLogManager;
namespace FasdDesktopUi.Basics.Converter
{
public class LanguageDefinitionsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
if (!(parameter is string techFieldDescriptor))
return "N/A";
string fieldDescription = cMultiLanguageSupport.GetItem(techFieldDescriptor, techFieldDescriptor);
if (value is object[] valueArray)
return string.Format(fieldDescription, valueArray);
if (value is List<object> valueList)
return string.Format(fieldDescription, valueList.ToArray());
if (value is object valueString)
return string.Format(fieldDescription, valueString);
return fieldDescription;
}
catch (Exception E)
{
LogException(E);
LogEntry($"An Error occured while setting the value ({value}) to field: {parameter}");
}
return "N/A";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
public class NullValueToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Visibility.Collapsed;
else if (value is string valueString)
if (string.IsNullOrWhiteSpace(valueString))
return Visibility.Collapsed;
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
public class PercentToDecimalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int percent)
return percent / 100.0;
else
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double doubleValue)
return doubleValue * 100;
else
return null;
}
}
}

View File

@@ -0,0 +1,52 @@
using C4IT.FASD.Base;
using F4SD_AdaptableIcon.Enums;
using FasdCockpitBase.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FasdDesktopUi.Basics.Converter
{
public class RevisionStatusToAdaptableIconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is enumQuickActionRevisionStatus revisionStatus))
return null;
switch (revisionStatus)
{
case enumQuickActionRevisionStatus.unknown:
if (targetType == typeof(enumInternIcons?))
return enumInternIcons.none;
break;
case enumQuickActionRevisionStatus.inProgress:
if (targetType == typeof(enumInternGif?))
return enumInternGif.loadingSpinner;
break;
case enumQuickActionRevisionStatus.finishedSuccessfull:
if (targetType == typeof(enumInternIcons?))
return enumInternIcons.status_good;
break;
case enumQuickActionRevisionStatus.canceled:
case enumQuickActionRevisionStatus.finishedWithError:
if(targetType == typeof(enumInternIcons?))
return enumInternIcons.status_bad;
break;
default:
return null;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}