diff --git a/BambuPrinter.StatusLight/BambuPrinter.StatusLight.csproj b/BambuPrinter.StatusLight/BambuPrinter.StatusLight.csproj index 6e6420e..cb3c84d 100644 --- a/BambuPrinter.StatusLight/BambuPrinter.StatusLight.csproj +++ b/BambuPrinter.StatusLight/BambuPrinter.StatusLight.csproj @@ -8,4 +8,14 @@ true + + + + + + + ..\..\..\..\Downloads\Embrava_SDK_For_Windows_v3.0.4\Binaries\AnyCpu\Blynclight.dll + + + diff --git a/BambuPrinter.StatusLight/MVVM.cs b/BambuPrinter.StatusLight/MVVM.cs new file mode 100644 index 0000000..81555ff --- /dev/null +++ b/BambuPrinter.StatusLight/MVVM.cs @@ -0,0 +1,55 @@ +using System.ComponentModel; +using System.Windows.Input; + +namespace BambuPrinter.StatusLight +{ + public abstract class ModelBase : PropertyChangedBase + { + public void SetProperty(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 execute; + private Func? canExecute; + + + public event EventHandler? CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + + public RelayCommand(Action execute, Func? 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); + } + } +} diff --git a/BambuPrinter.StatusLight/MainWindow.xaml b/BambuPrinter.StatusLight/MainWindow.xaml index 4a72856..812f6ce 100644 --- a/BambuPrinter.StatusLight/MainWindow.xaml +++ b/BambuPrinter.StatusLight/MainWindow.xaml @@ -6,6 +6,9 @@ xmlns:local="clr-namespace:BambuPrinter.StatusLight" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> + + + diff --git a/BambuPrinter.StatusLight/MainWindowModel.cs b/BambuPrinter.StatusLight/MainWindowModel.cs new file mode 100644 index 0000000..30b37f3 --- /dev/null +++ b/BambuPrinter.StatusLight/MainWindowModel.cs @@ -0,0 +1,6 @@ +namespace BambuPrinter.StatusLight +{ + public abstract class MainWindowModel : ModelBase + { + } +} diff --git a/BambuPrinter.StatusLight/MainWindowViewModel.cs b/BambuPrinter.StatusLight/MainWindowViewModel.cs new file mode 100644 index 0000000..9efe800 --- /dev/null +++ b/BambuPrinter.StatusLight/MainWindowViewModel.cs @@ -0,0 +1,21 @@ +namespace BambuPrinter.StatusLight +{ + public class MainWindowViewModel : MainWindowModel + { + public MainWindowViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + public void InitializeVariables() + { + + } + + public void InitializeCommands() + { + + } + } +}