This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
namespace DTS.Common.Interface.DASFactory.Config
{
public interface IEID
{
string ID { get; set; }
byte[] Blob { get; set; }
bool IsValid();
}
}

View File

@@ -0,0 +1,187 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Threading;
using DTS.Common.Base;
using DTS.Common.Events;
using Prism.Commands;
using Prism.Events;
using Unity;
using Prism.Regions;
using DTS.Common.Interactivity;
namespace DTS.Common.RibbonControl
{
public class RibbonViewModel<TModel> : BasePropertyChanged, IRibbonViewModel
where TModel : class
{
protected IEventAggregator Aggregator { get; }
protected IUnityContainer Container { get; }
protected IRegionManager RegionManager { get; }
public TModel Model { get; set; }
public IRibbonView View { get; }
protected RibbonViewModel(IRibbonView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
{
View = view;
Aggregator = eventAggregator;
Container = unityContainer;
RegionManager = regionManager;
CreateCommands();
}
protected virtual void CreateCommands()
{
ConfirmationRequest = new InteractionRequest<Confirmation>();
CloseCommand = new DelegateCommand<object>(CloseMethod);
}
#region Commands
/// <summary>
/// The interaction request to display the confirmation.
/// </summary>
public InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }
/// <summary>
/// The delegate command to close object.
/// </summary>
public DelegateCommand<object> CloseCommand { get; private set; }
/// <summary>
/// This is an execute method for the <see cref="CloseCommand">CloseCommand</see>.
/// </summary>
/// <param name="parameter">The parameter to pass to the <see cref="CloseCommand">CloseCommand</see>.</param>
protected virtual void CloseMethod(object parameter)
{
CleanupAtClose();
}
private void CleanupAtClose()
{
Cleanup();
}
#endregion Commands
#region Bases Methods
/// <summary>
/// Executes after the viewmodel activated.
/// </summary>
public virtual void Activated()
{
}
/// <summary>
/// Publishes the <see cref="ShowStatus">ShowStatus</see> during the viewmodel initialization.
/// </summary>
public virtual void Initialize()
{
Aggregator.GetEvent<ShowStatus>()
.Publish(new StatusInfo(StatusInfo.StatusState.Busy, Strings.Strings.Loading));
}
/// <summary>
/// Publishes the <see cref="ShowStatus">ShowStatus</see> during the viewmodel initialization.
/// </summary>
/// <param name="parameter">The parameter to be used initialize viewmodel.</param>
public virtual void Initialize(object parameter)
{
Aggregator.GetEvent<ShowStatus>()
.Publish(new StatusInfo(StatusInfo.StatusState.Busy, Strings.Strings.Loading));
}
public void Initialize(object parameter, object model)
{
}
/// <summary>
/// Publishes the <see cref="ShowStatus">ShowStatus</see> during the viewmodel initialization.
/// </summary>
public virtual async Task InitializeAsync()
{
await Dispatcher.CurrentDispatcher.InvokeAsync(() =>
{
Aggregator.GetEvent<ShowStatus>()
.Publish(new StatusInfo(StatusInfo.StatusState.Busy, Strings.Strings.Loading));
});
}
/// <summary>
/// Publishes the <see cref="ShowStatus">ShowStatus</see> during the viewmodel initialization.
/// </summary>
/// <param name="parameter">The parameter to be used initialize viewmodel.</param>
public virtual async Task InitializeAsync(object parameter)
{
await Dispatcher.CurrentDispatcher.InvokeAsync(() =>
{
Aggregator.GetEvent<ShowStatus>()
.Publish(new StatusInfo(StatusInfo.StatusState.Busy, Strings.Strings.Loading));
});
}
#endregion Bases Methods
#region Methods
#region PropertyChanged
///<summary>
///Occurs when a property value changes.
///</summary>
public new event PropertyChangedEventHandler PropertyChanged;
private new void OnPropertyChanged(string propertyName)
{
var eventHandler = PropertyChanged;
if (eventHandler != null)
{
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion PropertyChanged
#endregion Methods
#region Properties
private bool _isMenuIncluded = true;
public bool IsMenuIncluded
{
get => _isMenuIncluded;
set
{
_isMenuIncluded = value;
OnPropertyChanged("IsMenuIncluded");
}
}
private bool _isNavigationIncluded = false;
public bool IsNavigationIncluded
{
get => _isNavigationIncluded;
set
{
_isNavigationIncluded = value;
OnPropertyChanged("IsNavigationIncluded");
}
}
public int Percentage { get; set; }
public string IsBusyMessage { get; set; }
public bool IsBusy { get; set; }
public bool IsDirty { get; set; }
#endregion Properties
/// <summary>
/// Sets the Model to null.
/// </summary>
public virtual void Cleanup()
{
Model = default(TModel);
}
public Task CleanupAsync()
{
return Task.CompletedTask;
}
}
}

View File

@@ -0,0 +1,32 @@
using System.Windows;
using Prism.Events;
using System.Windows.Media;
using System.Windows.Controls;
namespace DTS.Common.Events
{
/// <summary>
/// Progress bar event
/// </summary>
/// <remarks>
/// notification event for progress bars
/// </remarks>
public class HelpTextEvent : PubSubEvent<HelpTextEventArg> { }
public class HelpTextEventArg
{
public object Sender { get; set; }
public ToolTipEventArgs E { get; set; }
public HelpTextEventArg(object sender, ToolTipEventArgs e)
{
Sender = sender;
E = e;
}
public HelpTextEventArg()
{
}
}
}

View File

@@ -0,0 +1,160 @@
using DTS.Common.Enums;
using DTS.Common.Utilities.Logging;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Xaml.Behaviors;
namespace DTS.Common.Behaviors
{
public class MultiSelectionBehavior : Behavior<ListBox>
{
protected override void OnAttached()
{
base.OnAttached();
if (SelectedItems != null)
{
AssociatedObject.SelectedItems.Clear();
foreach (var item in SelectedItems)
{
AssociatedObject.SelectedItems.Add(item);
}
}
}
public IList SelectedItems
{
get => (IList)GetValue(SelectedItemsProperty);
set => SetValue(SelectedItemsProperty, value);
}
public static readonly DependencyProperty SelectedItemsProperty =
DependencyProperty.Register("SelectedItems", typeof(IList), typeof(MultiSelectionBehavior), new UIPropertyMetadata(null, SelectedItemsChanged));
private static void SelectedItemsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var behavior = o as MultiSelectionBehavior;
if (behavior == null)
return;
if (e.OldValue is INotifyCollectionChanged oldValue)
{
oldValue.CollectionChanged -= behavior.SourceCollectionChanged;
behavior.AssociatedObject.SelectionChanged -= behavior.ListBoxSelectionChanged;
}
if (e.NewValue is INotifyCollectionChanged newValue)
{
behavior.AssociatedObject.SelectedItems.Clear();
foreach (var item in (IEnumerable)newValue)
{
behavior.AssociatedObject.SelectedItems.Add(item);
}
behavior.AssociatedObject.SelectionChanged += behavior.ListBoxSelectionChanged;
newValue.CollectionChanged += behavior.SourceCollectionChanged;
}
}
private bool _isUpdatingTarget;
private bool _isUpdatingSource;
private void SourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (_isUpdatingSource)
return;
try
{
_isUpdatingTarget = true;
if (e.OldItems != null)
{
foreach (var item in e.OldItems)
{
AssociatedObject.SelectedItems.Remove(item);
}
}
if (e.NewItems != null)
{
foreach (var item in e.NewItems)
{
AssociatedObject.SelectedItems.Add(item);
}
}
if (e.Action == NotifyCollectionChangedAction.Reset)
{
AssociatedObject.SelectedItems.Clear();
}
}
finally
{
_isUpdatingTarget = false;
}
}
private void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (_isUpdatingTarget)
return;
var selectedItems = SelectedItems;
if (selectedItems == null)
return;
//this could be a bulk operation, turn off notifications if consumer is paying attention
SelectedItemsStatus.SetUpdating(SelectedItems, true);
try
{
_isUpdatingSource = true;
foreach (var item in e.RemovedItems)
{
selectedItems.Remove(item);
}
var itemsToAdd = new List<object>();
foreach (var item in e.AddedItems)
{
if (!selectedItems.Contains(item))
{
itemsToAdd.Add(item);
}
}
var type = selectedItems.GetType().GenericTypeArguments[0];
foreach (var item in itemsToAdd)
{
if (item == itemsToAdd.Last())
{
//if this is the last item, turn notifications back on
SelectedItemsStatus.SetUpdating(SelectedItems, false);
}
try
{
if (type.IsAssignableFrom(item.GetType()))
{
selectedItems.Add(item);
}
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
finally
{
_isUpdatingSource = false;
}
}
}
}