Added basic structure and dependencies.

This commit is contained in:
2026-05-27 12:51:50 -04:00
parent bc441328a1
commit 66d06a50de
5 changed files with 95 additions and 0 deletions
@@ -8,4 +8,14 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MQTTnet" Version="5.1.0.1559" />
</ItemGroup>
<ItemGroup>
<Reference Include="Blynclight">
<HintPath>..\..\..\..\Downloads\Embrava_SDK_For_Windows_v3.0.4\Binaries\AnyCpu\Blynclight.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
+55
View File
@@ -0,0 +1,55 @@
using System.ComponentModel;
using System.Windows.Input;
namespace BambuPrinter.StatusLight
{
public abstract class ModelBase : PropertyChangedBase
{
public void SetProperty<T>(ref T storage, T value, string name)
{
//if (storage == null)
//throw new InvalidCastException("osrs_toolbox.ModelBase.UpdateProperty\nStorage cannot be null.");
if (value == null)
throw new InvalidCastException("ModelBase.UpdateProperty\nValue cannot be null.");
//if (storage.GetType() != value.GetType())
//throw new InvalidCastException("osrs_toolbox.ModelBase.UpdateProperty\nVariable type mismatch between storage and value.");
storage = value;
OnPropertyChanged(name);
}
}
public abstract class PropertyChangedBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
public class RelayCommand : ICommand
{
private Action<object> execute;
private Func<object, bool>? canExecute;
public event EventHandler? CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public RelayCommand(Action<object> execute, Func<object, bool>? canExecute = null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object? parameter)
{
return this.canExecute == null || this.canExecute(parameter);
}
public void Execute(object? parameter)
{
this.execute(parameter);
}
}
}
+3
View File
@@ -6,6 +6,9 @@
xmlns:local="clr-namespace:BambuPrinter.StatusLight"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainWindowViewModel/>
</Window.DataContext>
<Grid>
</Grid>
@@ -0,0 +1,6 @@
namespace BambuPrinter.StatusLight
{
public abstract class MainWindowModel : ModelBase
{
}
}
@@ -0,0 +1,21 @@
namespace BambuPrinter.StatusLight
{
public class MainWindowViewModel : MainWindowModel
{
public MainWindowViewModel()
{
InitializeVariables();
InitializeCommands();
}
public void InitializeVariables()
{
}
public void InitializeCommands()
{
}
}
}