diff --git a/HeatOptimiser.Tests/OptimiserTest.cs b/HeatOptimiser.Tests/OptimiserTest.cs new file mode 100644 index 0000000..af8e954 --- /dev/null +++ b/HeatOptimiser.Tests/OptimiserTest.cs @@ -0,0 +1,37 @@ +using Xunit; + +namespace HeatOptimiser.Tests +{ + public class OptimiserTest + { + + [Fact] + public void TestOptimise() + { + // Arrange + SourceDataManager sourceManager = new SourceDataManager(); + string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; + string file = Path.Combine(projectDirectory, "SourceDataTest.xlsx"); + var data = sourceManager.LoadXLSXFile(file, 4, 2); + + IAssetManager assetManager = new AssetManager(); + assetManager.AddUnit("GB", "none", 5.0, 0, 1.1, 500, 215); + assetManager.AddUnit("OB", "none", 4.0, 0, 1.2, 700, 265); + + Optimiser optimiser = new Optimiser(sourceManager, assetManager); + string startDateStr = "12/02/2023"; + string endDateStr = "25/02/2023"; + DateTime startDate = DateTime.ParseExact(startDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); + DateTime endDate = DateTime.ParseExact(endDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); + + // Act + Schedule schedule = optimiser.Optimise(startDate, endDate); + + // Assert + Assert.NotNull(schedule); + Assert.Equal(startDate, schedule.startDate); + Assert.Equal(endDate, schedule.endDate); + } + } + +} \ No newline at end of file diff --git a/HeatOptimiser.Tests/SourceDataManagerTest.cs b/HeatOptimiser.Tests/SourceDataManagerTest.cs new file mode 100644 index 0000000..89d1357 --- /dev/null +++ b/HeatOptimiser.Tests/SourceDataManagerTest.cs @@ -0,0 +1,40 @@ +using Xunit; + +namespace HeatOptimiser.Tests +{ + public class SourceDataManagerTest + { + [Fact] + public void TestLoadXLSXFile() + { + // Arrange + SourceDataManager sourceManager = new SourceDataManager(); + string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; + string file = Path.Combine(projectDirectory, "SourceDataTest.xlsx"); + Console.WriteLine(file); + + // Act + var result = sourceManager.LoadXLSXFile(file, 4, 2); + + // Assert + Assert.NotNull(result); + Assert.NotEmpty(result); + } + + [Fact] + public void TestGetDataInRange() + { + // Arrange + SourceData data = new SourceData(); + SourceDataManager sourceManager = new SourceDataManager(); + DateTime startDate = new DateTime(2023, 1, 1); + DateTime endDate = new DateTime(2023, 1, 31); + + // Act + var result = sourceManager.GetDataInRange(data, startDate, endDate); + + // Assert + Assert.NotNull(result); + } + } +} \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/data/sourcedata.xlsx b/HeatOptimiser.Tests/SourceDataTest.xlsx similarity index 100% rename from HeatOptimiser/UserInterface/data/sourcedata.xlsx rename to HeatOptimiser.Tests/SourceDataTest.xlsx diff --git a/HeatOptimiser/UserInterface/App.axaml b/HeatOptimiser/App.axaml similarity index 87% rename from HeatOptimiser/UserInterface/App.axaml rename to HeatOptimiser/App.axaml index 070fb55..b4fd970 100644 --- a/HeatOptimiser/UserInterface/App.axaml +++ b/HeatOptimiser/App.axaml @@ -1,16 +1,16 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/App.axaml.cs b/HeatOptimiser/App.axaml.cs similarity index 96% rename from HeatOptimiser/UserInterface/App.axaml.cs rename to HeatOptimiser/App.axaml.cs index 0beb14d..8b635d6 100644 --- a/HeatOptimiser/UserInterface/App.axaml.cs +++ b/HeatOptimiser/App.axaml.cs @@ -1,28 +1,28 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using UserInterface.ViewModels; -using UserInterface.Views; - -namespace UserInterface; - -public partial class App : Application -{ - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - desktop.MainWindow = new MainWindow - { - DataContext = new MainWindowViewModel(), - }; - } - - base.OnFrameworkInitializationCompleted(); - } +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using UserInterface.ViewModels; +using UserInterface.Views; + +namespace UserInterface; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } } \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/Assets/Boiler.png b/HeatOptimiser/Assets/Boiler.png similarity index 100% rename from HeatOptimiser/UserInterface/Assets/Boiler.png rename to HeatOptimiser/Assets/Boiler.png diff --git a/HeatOptimiser/UserInterface/Assets/Icons.axaml b/HeatOptimiser/Assets/Icons.axaml similarity index 100% rename from HeatOptimiser/UserInterface/Assets/Icons.axaml rename to HeatOptimiser/Assets/Icons.axaml diff --git a/HeatOptimiser/UserInterface/Assets/avalonia-logo.ico b/HeatOptimiser/Assets/avalonia-logo.ico similarity index 100% rename from HeatOptimiser/UserInterface/Assets/avalonia-logo.ico rename to HeatOptimiser/Assets/avalonia-logo.ico diff --git a/HeatOptimiser/UserInterface/Classes/AssetManager.cs b/HeatOptimiser/Classes/AssetManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Classes/AssetManager.cs rename to HeatOptimiser/Classes/AssetManager.cs diff --git a/HeatOptimiser/UserInterface/Classes/DataVisualizer.cs b/HeatOptimiser/Classes/DataVisualizer.cs similarity index 100% rename from HeatOptimiser/UserInterface/Classes/DataVisualizer.cs rename to HeatOptimiser/Classes/DataVisualizer.cs diff --git a/HeatOptimiser/UserInterface/Classes/Optimiser.cs b/HeatOptimiser/Classes/Optimiser.cs similarity index 100% rename from HeatOptimiser/UserInterface/Classes/Optimiser.cs rename to HeatOptimiser/Classes/Optimiser.cs diff --git a/HeatOptimiser/UserInterface/Classes/ResultsDataManager.cs b/HeatOptimiser/Classes/ResultsDataManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Classes/ResultsDataManager.cs rename to HeatOptimiser/Classes/ResultsDataManager.cs diff --git a/HeatOptimiser/UserInterface/Classes/SourceDataManager.cs b/HeatOptimiser/Classes/SourceDataManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Classes/SourceDataManager.cs rename to HeatOptimiser/Classes/SourceDataManager.cs diff --git a/HeatOptimiser/HeatOptimiser.csproj b/HeatOptimiser/HeatOptimiser.csproj index b9d5158..9450b6d 100644 --- a/HeatOptimiser/HeatOptimiser.csproj +++ b/HeatOptimiser/HeatOptimiser.csproj @@ -1,12 +1,18 @@  - - Exe + WinExe net8.0 - enable enable + true + app.manifest + true + + + + + @@ -15,9 +21,15 @@ + + + + + - + + + - diff --git a/HeatOptimiser/Interfaces/GUInterface.cs b/HeatOptimiser/Interfaces/GUInterface.cs deleted file mode 100644 index 19e68de..0000000 --- a/HeatOptimiser/Interfaces/GUInterface.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace HeatOptimiser; - -public interface GUInterface -{ - void AddAsset(); - void EditUnit(); - void RemoveAsset(); - void LoadUnits(); - - - -} \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/Interfaces/IAssetManager.cs b/HeatOptimiser/Interfaces/IAssetManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Interfaces/IAssetManager.cs rename to HeatOptimiser/Interfaces/IAssetManager.cs diff --git a/HeatOptimiser/Interfaces/IDataVisualizer.cs b/HeatOptimiser/Interfaces/IDataVisualizer.cs deleted file mode 100644 index 1b1900b..0000000 --- a/HeatOptimiser/Interfaces/IDataVisualizer.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace HeatOptimiser -{ - public interface IDataVisualizer - { - - } -} \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/Interfaces/IOptimiserModule.cs b/HeatOptimiser/Interfaces/IOptimiserModule.cs similarity index 100% rename from HeatOptimiser/UserInterface/Interfaces/IOptimiserModule.cs rename to HeatOptimiser/Interfaces/IOptimiserModule.cs diff --git a/HeatOptimiser/UserInterface/Interfaces/IResultsDataManager.cs b/HeatOptimiser/Interfaces/IResultsDataManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Interfaces/IResultsDataManager.cs rename to HeatOptimiser/Interfaces/IResultsDataManager.cs diff --git a/HeatOptimiser/UserInterface/Interfaces/ISourceDataManager.cs b/HeatOptimiser/Interfaces/ISourceDataManager.cs similarity index 100% rename from HeatOptimiser/UserInterface/Interfaces/ISourceDataManager.cs rename to HeatOptimiser/Interfaces/ISourceDataManager.cs diff --git a/HeatOptimiser/Interfaces/IUserInterface.cs b/HeatOptimiser/Interfaces/IUserInterface.cs deleted file mode 100644 index d67838a..0000000 --- a/HeatOptimiser/Interfaces/IUserInterface.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace HeatOptimiser -{ - public interface IUserInterface { - public void AddUnit(){} - - } -} \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/ProductionAssets.json b/HeatOptimiser/ProductionAssets.json similarity index 100% rename from HeatOptimiser/UserInterface/ProductionAssets.json rename to HeatOptimiser/ProductionAssets.json diff --git a/HeatOptimiser/Program.cs b/HeatOptimiser/Program.cs index 506dc60..4ba47de 100644 --- a/HeatOptimiser/Program.cs +++ b/HeatOptimiser/Program.cs @@ -1,39 +1,23 @@ -namespace HeatOptimiser -{ - class Program { - public static void Main() - { - AssetManager assets = new(); - assets.AddUnit("GB", "none", 5.0, 0, 1.1, 500, 215); - assets.AddUnit("OB", "none", 4.0, 0, 1.2, 700, 265); - - SourceDataManager dataManager = new(); - Optimiser optimiser = new(dataManager, assets); - string startDateStr = "12/02/2023"; - string endDateStr = "25/02/2023"; - DateTime startDate = DateTime.ParseExact(startDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); - DateTime endDate = DateTime.ParseExact(endDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); - Schedule optimisedData = optimiser.Optimise(startDate, endDate); +using Avalonia; +using Avalonia.ReactiveUI; +using System; +namespace UserInterface; - // Example on visualizing the data - - // foreach (ScheduleHour hour in optimisedData.schedule) - // { - // Console.WriteLine(hour.Hour); - // foreach (ProductionAsset asset in hour.Assets) - // { - // Console.Write($"{asset.Name} "); - // } - // Console.WriteLine(); - // foreach (double demand in hour.Demands) - // { - // Console.Write($"{demand} "); - // } - // Console.WriteLine("\n"); - // } +sealed class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); - new TextBasedUI().Interface(); - } - } -} \ No newline at end of file + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace() + .UseReactiveUI(); +} diff --git a/HeatOptimiser/UserInterface/Program.cs b/HeatOptimiser/UserInterface/Program.cs deleted file mode 100644 index 89156bf..0000000 --- a/HeatOptimiser/UserInterface/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Avalonia; -using Avalonia.ReactiveUI; -using System; - -namespace UserInterface; - -sealed class Program -{ - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); - - // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect() - .WithInterFont() - .LogToTrace() - .UseReactiveUI(); -} diff --git a/HeatOptimiser/UserInterface/UserInterface.csproj b/HeatOptimiser/UserInterface/UserInterface.csproj deleted file mode 100644 index 06ef21a..0000000 --- a/HeatOptimiser/UserInterface/UserInterface.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - WinExe - net8.0 - enable - true - app.manifest - true - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/HeatOptimiser/UserInterfaces/Textbased.cs b/HeatOptimiser/UserInterfaces/Textbased.cs deleted file mode 100644 index a55436c..0000000 --- a/HeatOptimiser/UserInterfaces/Textbased.cs +++ /dev/null @@ -1,196 +0,0 @@ -namespace HeatOptimiser -{ - public class TextBasedUI - { - private readonly SourceDataManager sourceDataManager; - private readonly Optimiser optimiser; - private readonly SourceData sourceData; - public AssetManager assetManager; - - - public TextBasedUI() - { - sourceDataManager = new SourceDataManager(); - sourceData = new SourceData(); - assetManager = new AssetManager(); - optimiser = new Optimiser(sourceDataManager, assetManager); - } - public void Interface() - { - - while (true) - { - Console.WriteLine("\nHello, User"); - Console.WriteLine("Type Number To Select:"); - Console.WriteLine("1. Add Unit Option"); - Console.WriteLine("2. Edit Unit"); - Console.WriteLine("3. Delete Unit"); - Console.WriteLine("4. Save Units"); - Console.WriteLine("5. Optimise Schedule"); - Console.WriteLine("6. Exit"); - - string? userInput = Console.ReadLine(); - - switch (userInput) - { - - case "1": - Console.WriteLine("Selected: Add Unit"); - - Console.WriteLine("Enter unit name:"); - string? name = Console.ReadLine(); - - Console.WriteLine("Enter unit image path:"); - string? image = Console.ReadLine(); - - if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(image)) - { - Console.WriteLine("Enter unit heat:"); - double heat; - while (!double.TryParse(Console.ReadLine(), out heat)) - { - Console.WriteLine("Invalid input. Please enter a valid number for heat:"); - } - Console.WriteLine("Enter unit electricity:"); - double electricity; - while (!double.TryParse(Console.ReadLine(), out electricity)) - { - Console.WriteLine("Invalid input. Please enter a valid number for electricity:"); - } - Console.WriteLine("Enter unit energy:"); - double energy; - while (!double.TryParse(Console.ReadLine(), out energy)) - { - Console.WriteLine("Invalid input. Please enter a valid number for energy:"); - } - Console.WriteLine("Enter unit cost:"); - double cost; - while (!double.TryParse(Console.ReadLine(), out cost)) - { - Console.WriteLine("Invalid input. Please enter a valid number for cost:"); - } - Console.WriteLine("Enter unit carbon dioxide:"); - double carbonDioxide; - while (!double.TryParse(Console.ReadLine(), out carbonDioxide)) - { - Console.WriteLine("Invalid input. Please enter a valid number for carbon dioxide:"); - } - assetManager.AddUnit(name, image, heat, electricity, energy, cost, carbonDioxide); - } - else - { - Console.WriteLine("Name and Image cannot be empty or null. Unit not added."); - } - break; - - case "2": - Console.WriteLine("Selected: Edit Unit"); - - Console.WriteLine("Enter Unit ID:"); - Guid id; - while (!Guid.TryParse(Console.ReadLine(), out id)) - { - Console.WriteLine("Invalid GUID. Enter a valid Unit ID"); - } - Console.WriteLine("Enter property index to edit (0: Name, 1: Image, 2: Heat, 3: Electricity, 4: Energy, 5: Cost, 6: CarbonDioxide):"); - int index; - while(!int.TryParse(Console.ReadLine(), out index) || index < 0 || index > 6) - { - Console.WriteLine("Invalid input. Please enter a number from 0 - 6"); - } - - Console.WriteLine("Enter new value:"); - string? value = Console.ReadLine(); - try - { - if(index >= 0 && index <= 1) - { - assetManager.EditUnit(id , index , value!); - } - else if (index >=2 && index <= 6) - { - double doubleValue; - while(!double.TryParse(value, out doubleValue)) - { - Console.WriteLine("Invalid input. Please enter a valid number:"); - value = Console.ReadLine(); - } - assetManager.EditUnit(id, index, doubleValue); - } - } - catch (Exception ex) - { - Console.WriteLine($"An error occurred: {ex.Message}"); - } - break; - case "3": - Console.WriteLine("Selected: Delete Unit"); - Console.WriteLine("Enter Unit ID"); - Guid deleteId; - while(!Guid.TryParse(Console.ReadLine(), out deleteId)) - { - Console.WriteLine("Invalid GUID. Enter a valid Unit ID:"); - } - try - { - assetManager.DeleteUnit(deleteId); - Console.WriteLine("Unit deleted successfully."); - } - catch(Exception ex) - { - Console.WriteLine($"An error occurred: {ex.Message}"); - } - break; - - case "4": - Console.WriteLine("Selected: Save Units"); - Console.WriteLine("Enter file name to save units:"); - string? fileName = Console.ReadLine(); - try - { - assetManager.SaveUnits(assetManager.GetAllUnits(), fileName!); - Console.WriteLine("Units saved successfully."); - } - catch (Exception ex) - { - Console.WriteLine($"An error occurred: {ex.Message}"); - } - break; - case "5": - Console.WriteLine("Selected: Optimise Schedule"); - Console.WriteLine("Enter start date (dd/MM/yyyy):"); - DateTime startDate; - while (!DateTime.TryParseExact(Console.ReadLine(), "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out startDate)) - { - Console.WriteLine("Invalid input. Please enter a valid date (dd/MM/yyyy):"); - } - Console.WriteLine("Enter end date (dd/MM/yyyy):"); - DateTime endDate; - while (!DateTime.TryParseExact(Console.ReadLine(), "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out endDate)) - { - Console.WriteLine("Invalid input. Please enter a valid date (dd/MM/yyyy):"); - } - Schedule schedule = optimiser.Optimise(startDate, endDate); - DisplaySchedule(schedule); - break; - - case "6": - Console.WriteLine("Exiting..."); - return; - default: - Console.WriteLine("Invalid input. Please select a valid option."); - break; - } - } - } - - private void DisplaySchedule(Schedule schedule) - { - Console.WriteLine("Optimised Schedule:"); - foreach (var hour in schedule.schedule) - { - Console.WriteLine($"Hour: {hour.Hour}, Assets: {string.Join(",", hour.Assets!)}, Demands: {string.Join(",", hour.Demands!)}"); - } - } -} -} \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/ViewLocator.cs b/HeatOptimiser/ViewLocator.cs similarity index 95% rename from HeatOptimiser/UserInterface/ViewLocator.cs rename to HeatOptimiser/ViewLocator.cs index e6c8b7b..9bad784 100644 --- a/HeatOptimiser/UserInterface/ViewLocator.cs +++ b/HeatOptimiser/ViewLocator.cs @@ -1,33 +1,33 @@ -using System; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using UserInterface.ViewModels; - -namespace UserInterface; - -public class ViewLocator : IDataTemplate -{ - - public Control? Build(object? data) - { - if (data is null) - return null; - - var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); - var type = Type.GetType(name); - - if (type != null) - { - var control = (Control)Activator.CreateInstance(type)!; - control.DataContext = data; - return control; - } - - return new TextBlock { Text = "Not Found: " + name }; - } - - public bool Match(object? data) - { - return data is ViewModelBase; - } -} +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using UserInterface.ViewModels; + +namespace UserInterface; + +public class ViewLocator : IDataTemplate +{ + + public Control? Build(object? data) + { + if (data is null) + return null; + + var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); + var type = Type.GetType(name); + + if (type != null) + { + var control = (Control)Activator.CreateInstance(type)!; + control.DataContext = data; + return control; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object? data) + { + return data is ViewModelBase; + } +} diff --git a/HeatOptimiser/UserInterface/ViewModels/AssetManagerViewModel.cs b/HeatOptimiser/ViewModels/AssetManagerViewModel.cs similarity index 100% rename from HeatOptimiser/UserInterface/ViewModels/AssetManagerViewModel.cs rename to HeatOptimiser/ViewModels/AssetManagerViewModel.cs diff --git a/HeatOptimiser/UserInterface/ViewModels/HomepageViewModel.cs b/HeatOptimiser/ViewModels/HomepageViewModel.cs similarity index 100% rename from HeatOptimiser/UserInterface/ViewModels/HomepageViewModel.cs rename to HeatOptimiser/ViewModels/HomepageViewModel.cs diff --git a/HeatOptimiser/UserInterface/ViewModels/MainWindowViewModel.cs b/HeatOptimiser/ViewModels/MainWindowViewModel.cs similarity index 97% rename from HeatOptimiser/UserInterface/ViewModels/MainWindowViewModel.cs rename to HeatOptimiser/ViewModels/MainWindowViewModel.cs index 600014a..4992c71 100644 --- a/HeatOptimiser/UserInterface/ViewModels/MainWindowViewModel.cs +++ b/HeatOptimiser/ViewModels/MainWindowViewModel.cs @@ -1,67 +1,67 @@ -using System.Reactive; -using System.Reflection; -using ReactiveUI; -using System.Collections.ObjectModel; - - -namespace UserInterface.ViewModels; - -public class MainWindowViewModel : ViewModelBase -{ - //Colors and Backgrounds maybe store them here? - public string paneBackground{get=>"#85182a";} - public string background{get=>"#cccccc";} - public string showButtons; - - public bool _paneStatus = true; - public bool PaneStatus - { - get => _paneStatus; - set { - this.RaiseAndSetIfChanged(ref _paneStatus, value); - ButtonWidth = _paneStatus ? 200 : 50; - ButtonTextOpacity = _paneStatus ? 1.0 : 0.0; - } - - - } - private double _buttonWidth = 200; - public double ButtonWidth - { - get => _buttonWidth; - set => this.RaiseAndSetIfChanged(ref _buttonWidth, value); - } - private double _buttontextOpacity = 1.0; - public double ButtonTextOpacity - { - get => _buttontextOpacity; - set => this.RaiseAndSetIfChanged(ref _buttontextOpacity, value); - } - - private ReactiveObject _currentView; -public ReactiveObject CurrentView { - get =>_currentView; - set => this.RaiseAndSetIfChanged(ref _currentView, value); - } - -public ReactiveCommand PaneCommand {get;} -public ReactiveCommand OpenAssetManagerCommand {get;} -public ReactiveCommand OpenSourceDataManagerCommand {get;} -public ReactiveCommand OpenHomepageCommand {get;} -public ReactiveCommand OpenOptimiserCommand {get;} -public ReactiveCommand OpenResultsCommand {get;} - -public MainWindowViewModel() -{ - CurrentView=new HomepageViewModel(); - PaneCommand=ReactiveCommand.Create(()=> PaneStatus=!PaneStatus); - OpenAssetManagerCommand=ReactiveCommand.Create(()=> CurrentView=new AssetManagerViewModel()); - OpenHomepageCommand=ReactiveCommand.Create(()=> CurrentView=new HomepageViewModel()); - OpenOptimiserCommand=ReactiveCommand.Create(()=> CurrentView= new OptimiserViewModel()); - OpenResultsCommand=ReactiveCommand.Create(()=> CurrentView= new ResultsViewModel()); -} - - - - -} +using System.Reactive; +using System.Reflection; +using ReactiveUI; +using System.Collections.ObjectModel; + + +namespace UserInterface.ViewModels; + +public class MainWindowViewModel : ViewModelBase +{ + //Colors and Backgrounds maybe store them here? + public string paneBackground{get=>"#85182a";} + public string background{get=>"#cccccc";} + public string showButtons; + + public bool _paneStatus = true; + public bool PaneStatus + { + get => _paneStatus; + set { + this.RaiseAndSetIfChanged(ref _paneStatus, value); + ButtonWidth = _paneStatus ? 200 : 50; + ButtonTextOpacity = _paneStatus ? 1.0 : 0.0; + } + + + } + private double _buttonWidth = 200; + public double ButtonWidth + { + get => _buttonWidth; + set => this.RaiseAndSetIfChanged(ref _buttonWidth, value); + } + private double _buttontextOpacity = 1.0; + public double ButtonTextOpacity + { + get => _buttontextOpacity; + set => this.RaiseAndSetIfChanged(ref _buttontextOpacity, value); + } + + private ReactiveObject _currentView; +public ReactiveObject CurrentView { + get =>_currentView; + set => this.RaiseAndSetIfChanged(ref _currentView, value); + } + +public ReactiveCommand PaneCommand {get;} +public ReactiveCommand OpenAssetManagerCommand {get;} +public ReactiveCommand OpenSourceDataManagerCommand {get;} +public ReactiveCommand OpenHomepageCommand {get;} +public ReactiveCommand OpenOptimiserCommand {get;} +public ReactiveCommand OpenResultsCommand {get;} + +public MainWindowViewModel() +{ + CurrentView=new HomepageViewModel(); + PaneCommand=ReactiveCommand.Create(()=> PaneStatus=!PaneStatus); + OpenAssetManagerCommand=ReactiveCommand.Create(()=> CurrentView=new AssetManagerViewModel()); + OpenHomepageCommand=ReactiveCommand.Create(()=> CurrentView=new HomepageViewModel()); + OpenOptimiserCommand=ReactiveCommand.Create(()=> CurrentView= new OptimiserViewModel()); + OpenResultsCommand=ReactiveCommand.Create(()=> CurrentView= new ResultsViewModel()); +} + + + + +} diff --git a/HeatOptimiser/UserInterface/ViewModels/OptimiserViewModel.cs b/HeatOptimiser/ViewModels/OptimiserViewModel.cs similarity index 100% rename from HeatOptimiser/UserInterface/ViewModels/OptimiserViewModel.cs rename to HeatOptimiser/ViewModels/OptimiserViewModel.cs diff --git a/HeatOptimiser/UserInterface/ViewModels/ResultsViewModel.cs b/HeatOptimiser/ViewModels/ResultsViewModel.cs similarity index 100% rename from HeatOptimiser/UserInterface/ViewModels/ResultsViewModel.cs rename to HeatOptimiser/ViewModels/ResultsViewModel.cs diff --git a/HeatOptimiser/UserInterface/ViewModels/ViewModelBase.cs b/HeatOptimiser/ViewModels/ViewModelBase.cs similarity index 94% rename from HeatOptimiser/UserInterface/ViewModels/ViewModelBase.cs rename to HeatOptimiser/ViewModels/ViewModelBase.cs index f9f972d..744cd75 100644 --- a/HeatOptimiser/UserInterface/ViewModels/ViewModelBase.cs +++ b/HeatOptimiser/ViewModels/ViewModelBase.cs @@ -1,10 +1,10 @@ -using System.Collections.ObjectModel; -using ReactiveUI; -using System.Reactive; - -namespace UserInterface.ViewModels; - -public class ViewModelBase : ReactiveObject -{ - -} +using System.Collections.ObjectModel; +using ReactiveUI; +using System.Reactive; + +namespace UserInterface.ViewModels; + +public class ViewModelBase : ReactiveObject +{ + +} diff --git a/HeatOptimiser/UserInterface/Views/AssetManagerView.axaml b/HeatOptimiser/Views/AssetManagerView.axaml similarity index 98% rename from HeatOptimiser/UserInterface/Views/AssetManagerView.axaml rename to HeatOptimiser/Views/AssetManagerView.axaml index d8b88e5..15ce983 100644 --- a/HeatOptimiser/UserInterface/Views/AssetManagerView.axaml +++ b/HeatOptimiser/Views/AssetManagerView.axaml @@ -1,93 +1,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HeatOptimiser/UserInterface/Views/MainWindow.axaml.cs b/HeatOptimiser/Views/MainWindow.axaml.cs similarity index 94% rename from HeatOptimiser/UserInterface/Views/MainWindow.axaml.cs rename to HeatOptimiser/Views/MainWindow.axaml.cs index b414eb2..5e59543 100644 --- a/HeatOptimiser/UserInterface/Views/MainWindow.axaml.cs +++ b/HeatOptimiser/Views/MainWindow.axaml.cs @@ -1,11 +1,11 @@ -using Avalonia.Controls; - -namespace UserInterface.Views; - -public partial class MainWindow : Window -{ - public MainWindow() - { - InitializeComponent(); - } +using Avalonia.Controls; + +namespace UserInterface.Views; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } } \ No newline at end of file diff --git a/HeatOptimiser/UserInterface/Views/OptimiserView.axaml b/HeatOptimiser/Views/OptimiserView.axaml similarity index 97% rename from HeatOptimiser/UserInterface/Views/OptimiserView.axaml rename to HeatOptimiser/Views/OptimiserView.axaml index 79b1a6e..61fed7a 100644 --- a/HeatOptimiser/UserInterface/Views/OptimiserView.axaml +++ b/HeatOptimiser/Views/OptimiserView.axaml @@ -1,41 +1,41 @@ - - - - - - - - - - - - - - - - - Optimize by Costs - Optimize by CarbonDioxide - -