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,9 @@
namespace DTS.Common.Interface.DASFactory
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "DAS is an acronym")]
public interface IDASReconfigure
{
int GetMaxModuleCount();
void SetMaxModuleCount(int count);
}
}

View File

@@ -0,0 +1,14 @@
namespace DTS.Common.Interface.Tags
{
/// <summary>
/// defines the interface tag aware classes must implement
/// </summary>
public interface ITagAware
{
void SetTags(string[] tagsText);
string[] GetTagsArray();
int[] GetTagIDs();
void RemoveTags(string[] tagsText);
bool ContainsAnyTag(int[] tags);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -0,0 +1,13 @@
using Prism.Events;
namespace DTS.Common.Events.Groups.GroupList
{
/// <summary>
/// The GroupTemplateListGroupTemplateSelectedEvent event.
/// </summary>
///
/// <remarks>called when a template is selected.</remarks>
///
public class GroupListGroupSelectedEvent : PubSubEvent<int[]> { }
}

View File

@@ -0,0 +1,7 @@
namespace DTS.Common.Interface.DASFactory.Config
{
public interface IAlignUDPToPPSAware
{
bool AlignUDPToPPS { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using Prism.Events;
namespace DTS.Common.Events
{
public class NavigateFromTSRAIRGoToDataPROEvent : PubSubEvent<NavigateFromTSRAIRGoToDataPROArg> { }
public class NavigateFromTSRAIRGoToDataPROArg
{
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.ComponentModel;
using DTS.Common.Converters;
using DTS.Common.Utils;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
// ReSharper disable CheckNamespace
namespace DTS.Common.Enums.Viewer
{
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum YRangeScaleEnum
{
[Description("Auto Range")]
AutoRange = 0,
[Description("% Full Scale")]
FullScale = 1,
[Description("Fixed")]
Fixed = 2,
[Description("Manual")]
Manual = 3
}
public class YRangeScaleItemSource : IItemsSource
{
public ItemCollection GetValues()
{
return EnumUtil.GetValuesList<YRangeScaleEnum>();
}
}
}

View File

@@ -0,0 +1,9 @@
using DTS.Common.Base;
namespace DTS.Common.Interface.TestSetups.Imports.TTS
{
public interface ITOMChannelsViewModel : IBaseViewModel
{
ITOMChannelsView View { get; set; }
}
}

View File

@@ -0,0 +1,392 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using DTS.Common.Converters;
using DTS.Common.Enums.Sensors;
using DTS.Common.Interface.Sensors;
namespace DTS.Common.Classes.Sensors
{
/// <summary>
/// InitialOffset is the replacement for InitialEU
/// it encompasses the old InitialOffset specified in EU with a offset of specifying it in mV @EU
/// Initial EU is a post data collection adjustment to engineering units recorded
/// </summary>
public class InitialOffset : Base.BasePropertyChanged
{
/// <summary>
/// copy constructor
/// </summary>
/// <param name="copy"></param>
public InitialOffset(InitialOffset copy)
{
if (null == copy) { return; }
EU = copy.EU;
MV = copy.MV;
Form = copy.Form;
}
/// <summary>
/// default constructor
/// </summary>
public InitialOffset()
{
Form = InitialOffsetTypes.None;
EU = 0D;
MV = 0D;
}
/// <summary>
/// constructor for the old format Initial EU (a single double representing offset in EU)
/// </summary>
/// <param name="d"></param>
public InitialOffset(double d)
{
Form = InitialOffsetTypes.EU;
EU = d;
MV = 0D;
}
/// <summary>
/// constructor for string from db
/// </summary>
/// <param name="s"></param>
public InitialOffset(string s)
{
FromDbSerializeString(s);
}
public override string ToString()
{
var converter = new EnumDescriptionTypeConverter(typeof(InitialOffsetTypes));
return converter.ConvertToString(Form);
}
/// <summary>
/// serializes to a db safe string
/// </summary>
/// <returns></returns>
public string ToDbSerializeString()
{
var s = new List<string>
{
Form.ToString(),
EU.ToString(System.Globalization.CultureInfo.InvariantCulture),
MV.ToString(System.Globalization.CultureInfo.InvariantCulture)
};
return string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, s.ToArray());
}
/// <summary>
/// deserializes from a string suitable for db storage
/// </summary>
/// <param name="input"></param>
public void FromDbSerializeString(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
Form = InitialOffsetTypes.None;
EU = 0;
MV = 0;
return;
}
if (input == "EU")
{
Form = InitialOffsetTypes.EU;
EU = 0;
return;
}
if (input.Contains(InitialOffsets.MySeparator))
{
//we got an InputOffsets input. just take the first one
input = input.Split(new[] { InitialOffsets.MySeparator }, StringSplitOptions.RemoveEmptyEntries)[0];
}
var tokens = input.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
if (Enum.TryParse(tokens[0], out InitialOffsetTypes form))
{
Form = form;
if (tokens.Length < 3)
{
throw new System.IO.InvalidDataException($"Invalid InitialOffset number of parameters: {input}");
}
else
{
if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var d))
{
EU = d;
}
else { throw new FormatException($"Invalid InitialOffset EU format: {tokens[1]}"); }
if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
{
MV = d;
}
else { throw new FormatException($"Invalid InitialOffset MV format: {tokens[2]}"); }
}
}
else { throw new System.IO.InvalidDataException("Invalid InitialOffset form: " + tokens[0]); }
}
private InitialOffsetTypes _form;
/// <summary>
/// the format this intial offset instance is in
/// </summary>
public InitialOffsetTypes Form
{
get => _form;
set => SetProperty(ref _form, value, Fields.Form.ToString());
}
//FB18158 Don't allow removal of None option
public System.Windows.Visibility InitialOffsetVisibility
{
get => Form != InitialOffsetTypes.None ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
}
private double _eu = 0D;
/// <summary>
/// EU value. In the case of Form == EU, this is the offset in EU
/// In. the form of EU@mV, this is the EU@mV value, and offset in EU still needs to be calculated
/// GetInitialEUValue calculates the offset in eu
/// this value is not used for InitialOffset format None
/// </summary>
public double EU
{
get => _eu;
set => SetProperty(ref _eu, value, Fields.EU.ToString());
}
private double _mv = 0D;
/// <summary>
/// mV value, only applies for the format EU@mV
/// this is the value in mV that The value in EU is observed at by a calibrated instrument
/// </summary>
public double MV
{
get => _mv;
set => SetProperty(ref _mv, value, Fields.MV.ToString());
}
private enum Fields
{
Form,
EU,
MV
}
/// <summary>
/// Displays initial offset structure to string
/// created for FB5429
/// </summary>
/// <param name="NONEFormatString">string resource similar to "None"</param>
/// <param name="EUFormatString">string resource similar to "EU"</param>
/// <param name="mVFormatString">string resource similar to "mV"</param>
/// <returns></returns>
public string ToDisplayString(string NONEFormatString, string EUFormatString, string mVFormatString)
{
var sb = new StringBuilder();
switch (Form)
{
case InitialOffsetTypes.EU:
case InitialOffsetTypes.LHS:
case InitialOffsetTypes.RHS:
case InitialOffsetTypes.FRONTAL:
sb.AppendFormat("{0} {1}", EU, EUFormatString);
break;
case InitialOffsetTypes.EUAtMV:
sb.AppendFormat("{0} {1} @ {2} {3}", EU, EUFormatString, MV, mVFormatString);
break;
case InitialOffsetTypes.None:
sb.AppendFormat("{0}", NONEFormatString);
break;
default:
break;
}
return sb.ToString();
}
/// <summary>
/// Compares attributes to another InitialOffset object
/// created for FB5429
/// </summary>
/// <param name="obj">an InitialOffset object</param>
/// <returns>if contents are equal</returns>
public override bool Equals(object obj)
{
if (obj is InitialOffset io)
{
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
foreach (var field in fields)
{
switch (field)
{
case Fields.Form: if (io.Form != Form) { return false; } break;
case Fields.EU: if (io.EU != EU) { return false; } break;
case Fields.MV: if (io.MV != MV) { return false; } break;
default:
throw new NotSupportedException("InitialOffset::Equals Unknown field " + field);
}
}
return true;
}
return base.Equals(obj);
}
}
public class InitialOffsets : IInitialOffsets
{
public InitialOffset[] Offsets { get; set; } = new InitialOffset[] { };
//FB18158 Always add None option to InitialOffsets
private void SeedNoneInInitialOffsets()
{
if (Offsets.Any(p => p.Form == InitialOffsetTypes.None))
{
return;
}
List<InitialOffset> initialOffsets = new List<InitialOffset>();
initialOffsets.Add(new InitialOffset());
foreach (var io in Offsets)
{
initialOffsets.Add(io);
}
Offsets = initialOffsets.ToArray();
}
public InitialOffset DefaultOffset
{
get
{
//30442 Don't default InitialOffset to None if other options exist
if (null != Offsets && Offsets.Any())
{
if ((Offsets.Count() > 1) && (Offsets[0].Form == InitialOffsetTypes.None))
{
return Offsets[1];
}
else
{
return Offsets[0];
}
}
else
{
return new InitialOffset();
}
}
}
public InitialOffsets(InitialOffsets copy)
{
InitialOffset[] offsets = new InitialOffset[copy.Offsets.Length];
for (int i = 0; i < copy.Offsets.Length; i++)
{
offsets[i] = new InitialOffset(copy.Offsets[i]);
}
Offsets = offsets;
SeedNoneInInitialOffsets();
}
/// <summary>
/// This produces an instance of the class based on an existing instance,
/// but without the first Initial Offset, only additional Initial Offsets
/// </summary>
/// <param name="copy"></param>
/// <param name="numAdditionalInitialOffsets"></param>
public InitialOffsets(InitialOffsets copy, int numAdditionalInitialOffsets)
{
InitialOffset[] offsets = new InitialOffset[numAdditionalInitialOffsets];
for (int i = 0; i < numAdditionalInitialOffsets; i++)
{
offsets[i] = new InitialOffset(copy.Offsets[i + 1]);
}
Offsets = offsets;
SeedNoneInInitialOffsets();
}
public InitialOffsets()
{
Offsets = new InitialOffset[] { new InitialOffset() };
SeedNoneInInitialOffsets();
}
public InitialOffsets(string offsets)
{
FromSerializedString(offsets);
SeedNoneInInitialOffsets();
}
public InitialOffsets(InitialOffset startingOffset)
{
Offsets = new InitialOffset[] { startingOffset };
SeedNoneInInitialOffsets();
}
public override bool Equals(object obj)
{
if (obj is InitialOffsets r)
{
if (r.Offsets.Length != Offsets.Length) { return false; }
for (var i = 0; i < r.Offsets.Length; i++)
{
if (!r.Offsets[i].Equals(Offsets[i])) { return false; }
}
return true;
}
return base.Equals(obj);
}
public void FromSerializedString(string s)
{
var tokens = s.Split(new string[] { MySeparator }, StringSplitOptions.None);
for (var i = 0; i < tokens.Length; i++) { tokens[i] = tokens[i].Replace(MySeparatorBackup, MySeparator); }
var offsets = new List<InitialOffset>();
foreach (string token in tokens)
{
offsets.Add(new InitialOffset(token));
}
Offsets = offsets.ToArray();
SeedNoneInInitialOffsets();
}
internal const string MySeparator = "__x__";
internal const string MySeparatorBackup = "___xx___";
public string ToSerializedString()
{
var offsets = new List<string>();
foreach (var r in Offsets) { offsets.Add(r.ToDbSerializeString()); }
for (int i = 0; i < offsets.Count; i++)
{
Trace.Assert(!offsets[i].Contains(MySeparatorBackup));
offsets[i] = offsets[i].Replace(MySeparator, MySeparatorBackup);
}
return string.Join(MySeparator, offsets.ToArray());
}
public string ToDisplayString(string averageOverTimeFormatString, string diagnosticLevelFormatString, string absoluteZeroFormatString)
{
var sb = new StringBuilder();
for (var i = 0; i < Offsets.Length; i++)
{
if (i > 0) { sb.AppendLine(); }
var s = Offsets[i].ToDisplayString(averageOverTimeFormatString, diagnosticLevelFormatString, absoluteZeroFormatString);
if (!string.IsNullOrEmpty(s))
{
sb.Append(s);
}
}
return sb.ToString();
}
public override string ToString()
{
return ToDisplayString(Strings.Strings.SensorFields_InitialOffset_AverageOverTimeFormat, Strings.Strings.SensorFields_InitialOffset_DiagnosticLevelFormat,
Strings.Strings.SensorFields_InitialOffset_AbsoluteZeroFormat);
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Common.Enums
{
/// <summary>
/// Specifies constants defining which information to display.
/// </summary>
public enum PopupWindowImage
{
// The popup window contains a symbol consisting of an exclamation point in a triangle with a yellow background.
Warning = 0,
// The popup window contains a symbol consisting of white X in a circle with a red background.
Error = 1,
// The popup window contains a symbol consisting of a question mark in a circle.
Question = 2,
// The popup window contains a symbol consisting of a lowercase letter i in a circle.
Information = 3
}
}

View File

@@ -0,0 +1,400 @@
using System;
using System.Windows;
using DTS.Common.Enums;
using Prism.Regions;
using DTS.Common.Events;
using DTS.Common.Interactivity;
using Microsoft.Xaml.Behaviors;
namespace DTS.Common.Dialogs
{
/// <summary>
/// Shows a popup window in response to an <see cref="DTS.Common.Interactivity.InteractionRequest.Confirmation"/> being raised.
/// </summary>
public class PopupWindowAction : TriggerAction<FrameworkElement>
{
private Window _openedNotificationWindow;
#region DependecyProperties
public enum WindowPositions
{
CenterOwner,
CenterScreen
}
//public enum ResultEnum
//{
// Ok = MessageBoxResult.OK,
// Yes = MessageBoxResult.Yes,
// No = MessageBoxResult.No,
// Cancel = MessageBoxResult.Cancel
//}
/// <summary>
/// The content of the child window to display as part of the popup.
/// </summary>
public static readonly DependencyProperty WindowContentProperty =
DependencyProperty.Register("WindowContent", typeof(FrameworkElement), typeof(PopupWindowAction), new PropertyMetadata(null));
/// <summary>
/// The <see cref="DataTemplate"/> to apply to the popup content.
/// </summary>
public static readonly DependencyProperty ContentTemplateProperty =
DependencyProperty.Register("ContentTemplate", typeof(DataTemplate), typeof(PopupWindowAction), new PropertyMetadata(null));
/// <summary>
/// Determines if the content should be shown in a modal window or not.
/// </summary>
public static readonly DependencyProperty IsModalProperty =
DependencyProperty.Register("IsModal", typeof(bool), typeof(PopupWindowAction), new PropertyMetadata(null));
/// <summary>
/// Determines whether the window is shown centered over associated object or entire screen.
/// </summary>
public static readonly DependencyProperty StartupPositionProperty =
DependencyProperty.Register("StartupPosition", typeof(WindowPositions), typeof(PopupWindowAction), new PropertyMetadata(WindowPositions.CenterScreen));
/// <summary>
/// Determines if the content should be initially shown centered over the View that raised the interaction request or not.
/// </summary>
public static readonly DependencyProperty CenterOverAssociatedObjectProperty =
DependencyProperty.Register("CenterOverAssociatedObject", typeof(bool), typeof(PopupWindowAction), new PropertyMetadata(null));
/// <summary>
/// Determines whether the multiple Notification Windows should be allowed.
/// </summary>
public static readonly DependencyProperty AllowMultipleNotificationWindowsProperty =
DependencyProperty.Register("AllowMultipleNotificationWindows", typeof(bool), typeof(PopupWindowAction), new PropertyMetadata(null));
///// <summary>
///// Determines timeout interval in milliseconds (0 = no timeout).
///// </summary>
//public static readonly DependencyProperty TimeoutIntervalProperty =
// DependencyProperty.Register("AutoCancelInterval", typeof(int), typeof(PopupWindowAction), new PropertyMetadata(0));
///// <summary>
///// Determines result if timeout occurs.
///// </summary>
//public static readonly ResultEnum TimeoutResultProperty =
// DependencyProperty.Register("TimeoutResult", typeof(ResultEnum), typeof(PopupWindowAction), new PropertyMetadata(ResultEnum.Cancel));
#endregion
#region Getters and Setters
/// <summary>
/// Gets or sets the content of the window.
/// </summary>
public FrameworkElement WindowContent
{
get => (FrameworkElement)GetValue(WindowContentProperty);
set => SetValue(WindowContentProperty, value);
}
/// <summary>
/// Gets or sets the content template for the window.
/// </summary>
public DataTemplate ContentTemplate
{
get => (DataTemplate)GetValue(ContentTemplateProperty);
set => SetValue(ContentTemplateProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether the window will be modal or not.
/// </summary>
public bool IsModal
{
get => (bool)GetValue(IsModalProperty);
set => SetValue(IsModalProperty, value);
}
/// <summary>
/// Gets or sets a value whether the window is shown centered over associated object, the screen or WindowsDefault.
/// </summary>
public WindowPositions StartupPosition
{
get => (WindowPositions)GetValue(StartupPositionProperty);
set => SetValue(StartupPositionProperty, value);
}
/// <summary>
/// Gets or sets a value whether the multiple Notification Windows should be allowed.
/// This property can be used for the popup window of type <see cref="NotificationWindow"/> only.
/// </summary>
public bool AllowMultipleNotificationWindows
{
get => (bool)GetValue(AllowMultipleNotificationWindowsProperty);
set => SetValue(AllowMultipleNotificationWindowsProperty, value);
}
///// <summary>
///// Gets or sets a value indicating number of milliseconds before dialog times out (0 = no timeout).
///// </summary>
//public int TimeoutInterval
//{
// get { return (int)GetValue(TimeoutIntervalProperty); }
// set { SetValue(TimeoutIntervalProperty, value); }
//}
///// <summary>
///// Gets or sets a value indicating number of milliseconds before dialog times out (0 = no timeout).
///// </summary>
//public ResultEnum TimeoutResult
//{
// get { return (ResultEnum)GetValue(TimeoutResultProperty); }
// set { SetValue(TimeoutResultProperty, value); }
//}
#endregion
#region PopupWindowAction logic
/// <summary>
/// Displays the child window and collects results for <see cref="IInteractionRequest"/>.
/// </summary>
/// <param name="parameter">The parameter to the action. If the action does not require a parameter, the parameter may be set to a null reference.</param>
protected override void Invoke(object parameter)
{
var args = parameter as InteractionRequestedEventArgs;
if (args == null)
return;
// If the WindowContent shouldn't be part of another visual tree.
if (WindowContent != null && WindowContent.Parent != null)
return;
var wrapperWindow = GetWindow((Notification)args.Context);
if (wrapperWindow == null)
return;
var callback = args.Callback;
EventHandler handler = null;
handler =
(o, e) =>
{
wrapperWindow.Closed -= handler;
wrapperWindow.Content = null;
if (_openedNotificationWindow != null && wrapperWindow is NotificationWindow)
_openedNotificationWindow = null;
callback();
};
wrapperWindow.Closed += handler;
// New way, using StartupPosition enumeration:
//
if (StartupPosition == WindowPositions.CenterOwner || StartupPosition == WindowPositions.CenterScreen)
{
SizeChangedEventHandler sizeHandler = null;
sizeHandler =
(o, e) =>
{
wrapperWindow.SizeChanged -= sizeHandler;
if (StartupPosition == WindowPositions.CenterOwner)
{
var invoker = AssociatedObject;
var position = invoker.PointToScreen(new Point(0, 0));
wrapperWindow.Top = position.Y + ((invoker.ActualHeight - wrapperWindow.ActualHeight) / 2);
wrapperWindow.Left = position.X + ((invoker.ActualWidth - wrapperWindow.ActualWidth) / 2);
}
else
{
wrapperWindow.Top = ((SystemParameters.WorkArea.Height - wrapperWindow.ActualHeight) / 2);
wrapperWindow.Left = ((SystemParameters.WorkArea.Width - wrapperWindow.ActualWidth) / 2);
}
};
wrapperWindow.SizeChanged += sizeHandler;
}
// Old way, using CenterOverAssociatedObject property:
//
//if (CenterOverAssociatedObject)
//{
// SizeChangedEventHandler sizeHandler = null;
// sizeHandler =
// (o, e) =>
// {
// wrapperWindow.SizeChanged -= sizeHandler;
// FrameworkElement invoker = AssociatedObject;
// Point position = invoker.PointToScreen(new Point(0, 0));
// wrapperWindow.Top = position.Y + ((invoker.ActualHeight - wrapperWindow.ActualHeight) / 2);
// wrapperWindow.Left = position.X + ((invoker.ActualWidth - wrapperWindow.ActualWidth) / 2);
// };
// wrapperWindow.SizeChanged += sizeHandler;
//}
if (AllowMultipleNotificationWindows == false && wrapperWindow is NotificationWindow)
_openedNotificationWindow = wrapperWindow;
if (IsModal)
{
wrapperWindow.ShowDialog();
}
else
{
wrapperWindow.Show();
}
}
/// <summary>
/// Checks if the WindowContent or its DataContext implements IPopupWindowActionAware and IRegionManagerAware.
/// If so, it sets the corresponding values.
/// Also, if WindowContent does not have a RegionManager attached, it creates a new scoped RegionManager for it.
/// </summary>
/// <param name="notification">The notification to be set as a DataContext in the HostWindow.</param>
/// <param name="wrapperWindow">The HostWindow</param>
protected void PrepareContentForWindow(Notification notification, Window wrapperWindow)
{
if (WindowContent == null)
return;
// We set the WindowContent as the content of the window.
wrapperWindow.Content = WindowContent;
var regionManager = WindowContent.GetValue(RegionManager.RegionManagerProperty) as IRegionManager;
// If the WindowContent does not have a RegionManager attached we create a new scoped RegionManager for it in order to support regions.
if (regionManager == null)
{
regionManager = new RegionManager();
WindowContent.SetValue(RegionManager.RegionManagerProperty, regionManager);
}
// If the WindowContent implements IRegionManagerAware we set the new scoped manager as the RegionManager.
var regionManagerAwareContent = WindowContent as IRegionManagerAware;
if (regionManagerAwareContent != null)
{
regionManagerAwareContent.RegionManager = regionManager;
}
// If the WindowContent's DataContext implements IRegionManagerAware we set the new scoped manager as the RegionManager.
var regionManagerAwareDataContext = WindowContent.DataContext as IRegionManagerAware;
if (regionManagerAwareDataContext != null)
{
regionManagerAwareDataContext.RegionManager = regionManager;
}
// If the WindowContent implements IPopupWindowActionAware, we set the corresponding values.
var popupAwareContent = WindowContent as IPopupWindowActionAware;
if (popupAwareContent != null)
{
popupAwareContent.HostWindow = wrapperWindow;
popupAwareContent.HostNotification = notification;
}
// If the WindowContent's DataContext implements IPopupWindowActionAware, we set the corresponding values.
var popupAwareDataContext = WindowContent.DataContext as IPopupWindowActionAware;
if (popupAwareDataContext != null)
{
popupAwareDataContext.HostWindow = wrapperWindow;
popupAwareDataContext.HostNotification = notification;
}
}
#endregion
#region Window creation methods
/// <summary>
/// Returns the window to display as part of the trigger action.
/// </summary>
/// <param name="notification">The notification to be set as a DataContext in the window.</param>
/// <returns></returns>
protected Window GetWindow(Notification notification)
{
Window wrapperWindow;
if (WindowContent != null)
{
wrapperWindow = new Window();
// If the WindowContent does not have its own DataContext, it will inherit this one.
wrapperWindow.DataContext = notification;
wrapperWindow.Title = notification.Title;
PrepareContentForWindow(notification, wrapperWindow);
}
else
{
wrapperWindow = CreateWindow(notification);
}
return wrapperWindow;
}
/// <summary>
/// When no WindowContent is sent this method is used to create a Notification/Confirmation window to show
/// the corresponding <see cref="Notification"/> or <see cref="Confirmation"/>.
/// </summary>
/// <param name="notification">The Notification or Confirmation parameter to show.</param>
/// <returns></returns>
protected Window CreateWindow(Notification notification)
{
Window window = null;
if (notification is Confirmation)
{
window = new ConfirmationWindow { ConfirmationTemplate = ContentTemplate };
}
else
{
var content = notification.Content as NotificationContentEventArgs;
if (content == null)
return null;
var imageUri = GetImageUri(content.Image);
window = new NotificationWindow { NotificationTemplate = ContentTemplate, ImageUri = imageUri };
}
window.DataContext = notification;
return window;
}
/// <summary>
/// Gets the <see cref="Uri"/> for the notification image.
/// </summary>
/// <param name="windowImage">The popup window's symbol.</param>
private Uri GetImageUri(PopupWindowImage windowImage)
{
string image;
switch (windowImage)
{
case PopupWindowImage.Error:
image = "error_48.png";
break;
case PopupWindowImage.Question:
image = "question_48.png";
break;
case PopupWindowImage.Warning:
image = "warning_48.png";
break;
case PopupWindowImage.Information:
image = "information_48.png";
break;
default:
image = "warning_48.png";
break;
}
return new Uri("pack://application:,,,/" + System.Reflection.Assembly.GetExecutingAssembly() + ";component/Images/" + image, UriKind.RelativeOrAbsolute);
}
#endregion
}
}

View File

@@ -0,0 +1,15 @@
using DTS.Common.Interface.DASFactory.Diagnostics.HardwareList;
using Prism.Events;
using System;
namespace DTS.Common.Events.Hardware.HardwareList
{
/// <summary>
/// The HardwareReplaceEvent event.
/// </summary>
///
/// <remarks>This event is used to indicate hardware replacement was requested
/// </remarks>
public class HardwareReplaceEvent : PubSubEvent<Tuple<IHardware, IHardware>> { }
}