Push Changes from Techcrafters Repo

This commit is contained in:
2026-03-05 14:37:43 +01:00
parent d2665d17fa
commit 9636ff0457
215 changed files with 5052 additions and 14150 deletions

View File

@@ -13,23 +13,22 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace HMIToolkit
{
/// <summary>
/// Interaktionslogik für IntlkDetails.xaml
/// </summary>
public partial class IntlkDetails : UserControl
{
public IntlkDetails()
{
InitializeComponent();
// Unloaded += OnUnloaded;
}
namespace HMIToolkit;
private void OnUnloaded(object? sender, EventArgs e)
{
var disposable = DataContext as IDisposable;
disposable?.Dispose();
}
}
}
/// <summary>
/// Interaktionslogik für IntlkDetails.xaml
/// </summary>
public partial class IntlkDetails : UserControl
{
public IntlkDetails()
{
InitializeComponent();
// Unloaded += OnUnloaded;
}
private void OnUnloaded(object? sender, EventArgs e)
{
var disposable = DataContext as IDisposable;
disposable?.Dispose();
}
}

View File

@@ -5,147 +5,146 @@ using System.Windows.Controls;
using TwinCAT.TypeSystem;
using Heisig.HMI.AdsManager;
namespace HMIToolkit
namespace HMIToolkit;
public sealed partial class IntlkDetailsVM : ObservableObject, IDisposable
{
public sealed partial class IntlkDetailsVM : ObservableObject, IDisposable
{
[ObservableProperty]
private string interlockName;
[ObservableProperty]
private string interlockName;
[ObservableProperty]
private BitArray interlockStatus;
[ObservableProperty]
private BitArray interlockStatus;
[ObservableProperty]
private string[] interlockNames;
[ObservableProperty]
private string[] interlockNames;
[ObservableProperty]
private ListBoxItem[] listBoxItemsLeft;
[ObservableProperty]
private ListBoxItem[] listBoxItemsLeft;
[ObservableProperty]
private ListBoxItem[] listBoxItemsRight;
[ObservableProperty]
private ListBoxItem[] listBoxItemsRight;
[ObservableProperty]
private Visibility isVisible;
[ObservableProperty]
private Visibility isVisible;
private readonly BoolToBrushConverter boolToBrushConverter = new();
private readonly BoolToBrushConverter boolToBrushConverter = new();
private readonly int numIntlksLeftSide;
private readonly int numIntlksRightSide;
private readonly int numIntlksLeftSide;
private readonly int numIntlksRightSide;
private readonly string _variableNameStatus;
private readonly string _variableNameNames;
private readonly string _variableNameStatus;
private readonly string _variableNameNames;
private IAdsManager? _adsManager;
private IAdsManager? _adsManager;
public IntlkDetailsVM()
{
interlockName = "Interlocks";
interlockStatus = new BitArray(HMIConstants.NumInterlocks);
interlockNames = new string[HMIConstants.NumInterlocks];
Array.Fill(interlockNames, "Not used");
public IntlkDetailsVM()
{
interlockName = "Interlocks";
interlockStatus = new BitArray(HMIConstants.NumInterlocks);
interlockNames = new string[HMIConstants.NumInterlocks];
Array.Fill(interlockNames, "Not used");
// Split all interlocks into two parts
numIntlksLeftSide = (int)Math.Ceiling(HMIConstants.NumInterlocks * 0.5);
numIntlksRightSide = HMIConstants.NumInterlocks - numIntlksLeftSide;
// Split all interlocks into two parts
numIntlksLeftSide = (int)Math.Ceiling(HMIConstants.NumInterlocks * 0.5);
numIntlksRightSide = HMIConstants.NumInterlocks - numIntlksLeftSide;
listBoxItemsLeft = new ListBoxItem[numIntlksLeftSide];
listBoxItemsRight = new ListBoxItem[numIntlksRightSide];
listBoxItemsLeft = new ListBoxItem[numIntlksLeftSide];
listBoxItemsRight = new ListBoxItem[numIntlksRightSide];
_variableNameStatus = System.String.Empty;
_variableNameNames = System.String.Empty;
_variableNameStatus = System.String.Empty;
_variableNameNames = System.String.Empty;
// CreateContent();
}
// CreateContent();
}
public IntlkDetailsVM(IAdsManager adsManager, string variableNameStatus, string variableNameNames, string intlkName) : this()
{
interlockName = intlkName;
_variableNameStatus = variableNameStatus;
_variableNameNames = variableNameNames;
_adsManager = adsManager;
public IntlkDetailsVM(IAdsManager adsManager, string variableNameStatus, string variableNameNames, string intlkName) : this()
{
interlockName = intlkName;
_variableNameStatus = variableNameStatus;
_variableNameNames = variableNameNames;
_adsManager = adsManager;
interlockStatus = new BitArray(HMIConstants.NumInterlocks);
interlockNames = new string[HMIConstants.NumInterlocks];
interlockStatus = new BitArray(HMIConstants.NumInterlocks);
interlockNames = new string[HMIConstants.NumInterlocks];
_adsManager.Register(_variableNameStatus, InterlockStatusChanged);
_adsManager.Register(_variableNameNames, InterlockNamesChanged);
}
_adsManager.Register(_variableNameStatus, InterlockStatusChanged);
_adsManager.Register(_variableNameNames, InterlockNamesChanged);
}
public void Dispose()
{
_adsManager?.Deregister(_variableNameStatus, InterlockStatusChanged);
_adsManager?.Deregister(_variableNameNames, InterlockNamesChanged);
public void Dispose()
{
_adsManager?.Deregister(_variableNameStatus, InterlockStatusChanged);
_adsManager?.Deregister(_variableNameNames, InterlockNamesChanged);
_adsManager = null;
}
_adsManager = null;
}
/*private void CreateContent()
{
// Create left side
for (int i = 0; i < HMIConstants.NumInterlocks; i++)
{
// Create the stack panel
StackPanel stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal
};
/*private void CreateContent()
{
// Create left side
for (int i = 0; i < HMIConstants.NumInterlocks; i++)
{
// Create the stack panel
StackPanel stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal
};
// Create the box
// <Rectangle Width="10" Height="10" Fill="{Binding Path=InterlockStatus[10], Converter={StaticResource myBoolConverter}}" RadiusX="2" RadiusY="2" Margin="0,2,0,0"/>
Rectangle rectangle = new Rectangle
{
Width = 10,
Height = 10,
RadiusX = 2,
RadiusY = 2
};
// Create the box
// <Rectangle Width="10" Height="10" Fill="{Binding Path=InterlockStatus[10], Converter={StaticResource myBoolConverter}}" RadiusX="2" RadiusY="2" Margin="0,2,0,0"/>
Rectangle rectangle = new Rectangle
{
Width = 10,
Height = 10,
RadiusX = 2,
RadiusY = 2
};
// Create binding
Binding binding = new()
{
Source = this,
Path = new PropertyPath("InterlockStatus[" + i + "]"),
Converter = boolToBrushConverter,
};
// Create binding
Binding binding = new()
{
Source = this,
Path = new PropertyPath("InterlockStatus[" + i + "]"),
Converter = boolToBrushConverter,
};
// Set binding
rectangle.SetBinding(Rectangle.FillProperty, binding);
// Set binding
rectangle.SetBinding(Rectangle.FillProperty, binding);
// Create label
Label label = new();
binding = new()
{
Source = this,
Path = new PropertyPath("InterlockNames[" + i + "]")
};
label.SetBinding(Label.ContentProperty, binding);
// Create label
Label label = new();
binding = new()
{
Source = this,
Path = new PropertyPath("InterlockNames[" + i + "]")
};
label.SetBinding(Label.ContentProperty, binding);
// Add items to stack panel
stackPanel.Children.Add(rectangle);
stackPanel.Children.Add(label);
// Add items to stack panel
stackPanel.Children.Add(rectangle);
stackPanel.Children.Add(label);
// Add stack panel to listbox items
ListBoxItem tempListBoxItem = new()
{
Content = stackPanel
};
if (i < numIntlksLeftSide)
ListBoxItemsLeft[i] = tempListBoxItem;
else
ListBoxItemsRight[i - numIntlksLeftSide] = tempListBoxItem;
}
// Add stack panel to listbox items
ListBoxItem tempListBoxItem = new()
{
Content = stackPanel
};
if (i < numIntlksLeftSide)
ListBoxItemsLeft[i] = tempListBoxItem;
else
ListBoxItemsRight[i - numIntlksLeftSide] = tempListBoxItem;
}
}*/
}*/
private void InterlockStatusChanged(object? sender, ValueChangedEventArgs e)
{
ushort temp = (ushort)e.Value;
InterlockStatus = new BitArray(BitConverter.GetBytes(temp));
}
private void InterlockStatusChanged(object? sender, ValueChangedEventArgs e)
{
ushort temp = (ushort)e.Value;
InterlockStatus = new BitArray(BitConverter.GetBytes(temp));
}
private void InterlockNamesChanged(object? sender, ValueChangedEventArgs e)
{
InterlockNames = (string[])e.Value;
}
}
}
private void InterlockNamesChanged(object? sender, ValueChangedEventArgs e)
{
InterlockNames = (string[])e.Value;
}
}

View File

@@ -12,16 +12,15 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace HMIToolkit
namespace HMIToolkit;
/// <summary>
/// Interaktionslogik für IntlkDetailsWindow.xaml
/// </summary>
public partial class IntlkDetailsWindow : Window
{
/// <summary>
/// Interaktionslogik für IntlkDetailsWindow.xaml
/// </summary>
public partial class IntlkDetailsWindow : Window
{
public IntlkDetailsWindow()
{
InitializeComponent();
}
}
}
public IntlkDetailsWindow()
{
InitializeComponent();
}
}