Skip to content

Commit

Permalink
Refactor project structure and update configurations
Browse files Browse the repository at this point in the history
- Added new project `openHAB.Windows.Package` to the solution.
- Replaced `Any CPU` with specific platform configurations (`x86`, `x64`, `arm64`).
- Updated `AppResources.cs` to use `Microsoft.Windows.ApplicationModel.Resources`.
- Modified resource loader initialization in `AppResources.cs`.
- Added `JsonIgnore` to `Profile` in `Connection.cs` and introduced `ProfileId`.
- Created `ConnectionProfiles` class and refactored `Settings` class.
- Replaced `Newtonsoft.Json` with `System.Text.Json` in `SettingsService.cs`.
- Updated image assets and paths in `Package.appxmanifest`.
- Added `openHAB.Windows.Package.wapproj` with project configurations.
- Cleaned up `App.xaml` and removed unused `using` directives.
- Updated `app.manifest` and `openHAB.Windows.csproj` for new configurations.
- Added new publish profile files for different architectures.

Add new project, update configs, and switch to System.Text.Json

Added a new project `openHAB.Windows.Package` to the solution.
Replaced `Any CPU` with specific platform configurations (`x86`, `x64`, `arm64`).
Updated `AppResources.cs` to use `Microsoft.Windows.ApplicationModel.Resources`.
Changed resource loader initialization in `AppResources.cs`.
Added `JsonIgnore` attribute to `Profile` property in `Connection` class.
Introduced `ProfileId` property and created `ConnectionProfiles` class.
Updated `Settings` class to use `ConnectionProfiles.GetProfiles()`.
Simplified `ConnectionProfiles` property in `Settings` class.
Reformatted `LastSitemap` property in `Settings` class.
Switched JSON operations to `System.Text.Json` in `SettingsService.cs`.
Updated namespaces and using directives for new project structure.
Added new binary image files and updated existing ones.
Updated `Package.StoreAssociation.xml` for store association changes.
Updated `Package.appxmanifest` for version, logo paths, and formatting.
Added `openHAB.Windows.Package.wapproj` with platform configurations.
Modified `App.xaml` and `App.xaml.cs` for template and namespace changes.
Removed unused `openHAB.Windows.Services` namespace imports.
Updated `app.manifest` and `openHAB.Windows.csproj` for new configurations.
Added new publish profiles for different platforms.

Signed-off-by: Christoph Hofmann <[email protected]>
  • Loading branch information
hoffe86 committed Dec 23, 2024
1 parent 1aa824f commit 6fa01b1
Show file tree
Hide file tree
Showing 85 changed files with 303 additions and 21,193 deletions.
64 changes: 32 additions & 32 deletions OpenHAB.Windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,30 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "openHAB.Core.Client", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "openHAB.Common", "src\openHAB.Common\openHAB.Common.csproj", "{E53B599D-4BDB-40B1-86E4-47FB90420138}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "openHAB.Windows.Package", "src\openHAB.Windows.Package\openHAB.Windows.Package.wapproj", "{4E463E63-604D-4C3D-8A13-273B787C99B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|arm64 = Debug|arm64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|arm64 = Release|arm64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|Any CPU.ActiveCfg = Debug|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|Any CPU.Build.0 = Debug|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|arm64.ActiveCfg = Debug|arm64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|arm64.Build.0 = Debug|arm64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|x64.ActiveCfg = Debug|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|x64.Build.0 = Debug|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|x86.ActiveCfg = Debug|x86
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Debug|x86.Build.0 = Debug|x86
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|Any CPU.ActiveCfg = Release|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|Any CPU.Build.0 = Release|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|arm64.ActiveCfg = Release|arm64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|arm64.Build.0 = Release|arm64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|x64.ActiveCfg = Release|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|x64.Build.0 = Release|x64
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|x86.ActiveCfg = Release|x86
{2A8FD10E-4EE5-4E25-B47C-2296E071F482}.Release|x86.Build.0 = Release|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|Any CPU.ActiveCfg = Debug|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|Any CPU.Build.0 = Debug|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|Any CPU.Deploy.0 = Debug|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|arm64.ActiveCfg = Debug|arm64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|arm64.Build.0 = Debug|arm64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|arm64.Deploy.0 = Debug|arm64
Expand All @@ -61,9 +54,6 @@ Global
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|x86.ActiveCfg = Debug|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|x86.Build.0 = Debug|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Debug|x86.Deploy.0 = Debug|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|Any CPU.ActiveCfg = Release|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|Any CPU.Build.0 = Release|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|Any CPU.Deploy.0 = Release|x64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|arm64.ActiveCfg = Release|arm64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|arm64.Build.0 = Release|arm64
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|arm64.Deploy.0 = Release|arm64
Expand All @@ -73,38 +63,48 @@ Global
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|x86.ActiveCfg = Release|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|x86.Build.0 = Release|x86
{D65E41CE-1AE7-403A-B178-D69E8DAFB08B}.Release|x86.Deploy.0 = Release|x86
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|Any CPU.ActiveCfg = Debug|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|Any CPU.Build.0 = Debug|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|arm64.ActiveCfg = Debug|arm64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|arm64.Build.0 = Debug|arm64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|x64.ActiveCfg = Debug|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|x64.Build.0 = Debug|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|x86.ActiveCfg = Debug|x86
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Debug|x86.Build.0 = Debug|x86
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|Any CPU.ActiveCfg = Release|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|Any CPU.Build.0 = Release|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|arm64.ActiveCfg = Release|arm64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|arm64.Build.0 = Release|arm64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|x64.ActiveCfg = Release|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|x64.Build.0 = Release|x64
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|x86.ActiveCfg = Release|x86
{3B8F31DD-1AF2-47CF-B7DB-3B732FE4EC5A}.Release|x86.Build.0 = Release|x86
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|arm64.ActiveCfg = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|arm64.Build.0 = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x64.ActiveCfg = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x64.Build.0 = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x86.ActiveCfg = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x86.Build.0 = Debug|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|Any CPU.Build.0 = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|arm64.ActiveCfg = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|arm64.Build.0 = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x64.ActiveCfg = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x64.Build.0 = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x86.ActiveCfg = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x86.Build.0 = Release|Any CPU
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|arm64.ActiveCfg = Debug|arm64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|arm64.Build.0 = Debug|arm64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x64.ActiveCfg = Debug|x64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x64.Build.0 = Debug|x64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x86.ActiveCfg = Debug|x86
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Debug|x86.Build.0 = Debug|x86
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|arm64.ActiveCfg = Release|arm64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|arm64.Build.0 = Release|arm64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x64.ActiveCfg = Release|x64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x64.Build.0 = Release|x64
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x86.ActiveCfg = Release|x86
{E53B599D-4BDB-40B1-86E4-47FB90420138}.Release|x86.Build.0 = Release|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|arm64.ActiveCfg = Debug|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|arm64.Build.0 = Debug|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|arm64.Deploy.0 = Debug|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x64.ActiveCfg = Debug|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x64.Build.0 = Debug|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x64.Deploy.0 = Debug|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x86.ActiveCfg = Debug|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x86.Build.0 = Debug|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Debug|x86.Deploy.0 = Debug|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|arm64.ActiveCfg = Release|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|arm64.Build.0 = Release|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|arm64.Deploy.0 = Release|ARM64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x64.ActiveCfg = Release|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x64.Build.0 = Release|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x64.Deploy.0 = Release|x64
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x86.ActiveCfg = Release|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x86.Build.0 = Release|x86
{4E463E63-604D-4C3D-8A13-273B787C99B2}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
19 changes: 0 additions & 19 deletions openHAB.Core.Client.csproj

This file was deleted.

9 changes: 5 additions & 4 deletions src/openHAB.Common/AppResources.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Windows.ApplicationModel.Resources;
using Microsoft.UI.Xaml.Shapes;
using Microsoft.Windows.ApplicationModel.Resources;

namespace openHAB.Common
{
Expand All @@ -19,7 +20,7 @@ public static ResourceLoader Values
{
if (_resourceLoader == null)
{
_resourceLoader = ResourceLoader.GetForViewIndependentUse("Resources");
_resourceLoader = new ResourceLoader(ResourceLoader.GetDefaultResourceFilePath());
}

return _resourceLoader;
Expand All @@ -35,11 +36,11 @@ public static ResourceLoader Errors
{
if (_errorResourceLoader == null)
{
_errorResourceLoader = ResourceLoader.GetForViewIndependentUse("Errors");
_errorResourceLoader = new ResourceLoader(ResourceLoader.GetDefaultResourceFilePath());
}

return _errorResourceLoader;
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/openHAB.Common/openHAB.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<Platforms>AnyCPU</Platforms>
<Platforms>x86;x64;arm64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions src/openHAB.Core.Client/Connection/Models/Connection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using openHAB.Core.Client.Connection.Contracts;
using System.Text.Json.Serialization;

namespace openHAB.Core.Client.Connection.Models
{
Expand All @@ -9,12 +10,29 @@ public class Connection
{
/// <summary>Gets or sets the connection profile.</summary>
/// <value>The profile.</value>
[JsonIgnore]
public IConnectionProfile Profile
{
get;
set;
}

/// <summary>
/// Gets or sets the connection profile identifier.
/// </summary>
/// <value>The identifier of the connection profile.</value>
public int ProfileId
{
get
{
return this.Profile.Id;
}
set
{
Profile = ConnectionProfiles.GetProfile(value);
}
}

/// <summary>Gets or sets the type of the connection.</summary>
/// <value>The type of the connection.</value>
public HttpClientType Type
Expand Down
38 changes: 38 additions & 0 deletions src/openHAB.Core.Client/Connection/Models/ConnectionProfiles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using openHAB.Core.Client.Connection.Contracts;
using System.Collections.Generic;

namespace openHAB.Core.Client.Connection.Models
{
/// <summary>
/// Manages connection profiles.
/// </summary>
public class ConnectionProfiles
{
private static Dictionary<int, IConnectionProfile> _profiles = new Dictionary<int, IConnectionProfile>()
{
{ 1, new DefaultConnectionProfile() },
{ 2, new LocalConnectionProfile() },
{ 3, new RemoteConnectionProfile() },
{ 4, new CloudConnectionProfile() }
};

/// <summary>
/// Gets the connection profile by the specified identifier.
/// </summary>
/// <param name="id">The identifier of the connection profile.</param>
/// <returns>The connection profile associated with the specified identifier.</returns>
public static IConnectionProfile GetProfile(int id)
{
return _profiles[id];
}

/// <summary>
/// Gets all connection profiles.
/// </summary>
/// <returns>A list of all connection profiles.</returns>
public static List<IConnectionProfile> GetProfiles()
{
return new List<IConnectionProfile>(_profiles.Values);
}
}
}
26 changes: 6 additions & 20 deletions src/openHAB.Core/Model/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace openHAB.Core.Model
[System.Runtime.InteropServices.Guid("6AF3A86A-9AAA-400B-AB7F-E42A780D5ECF")]
public class Settings
{
private static List<IConnectionProfile> _connectionProfiles;
private static List<IConnectionProfile> _connectionProfiles = Client.Connection.Models.ConnectionProfiles.GetProfiles();

/// <summary>
/// Initializes a new instance of the <see cref="Settings"/> class.
Expand All @@ -26,24 +26,7 @@ public Settings()

/// <summary>Gets the list of available connection profiles.</summary>
/// <value>The connection profiles.</value>
public static List<IConnectionProfile> ConnectionProfiles
{
get
{
if (_connectionProfiles == null)
{
_connectionProfiles = new List<IConnectionProfile>
{
new LocalConnectionProfile(),
new DefaultConnectionProfile(),
new RemoteConnectionProfile(),
new CloudConnectionProfile()
};
}

return _connectionProfiles;
}
}
public static List<IConnectionProfile> ConnectionProfiles => _connectionProfiles;

/// <summary>
/// Gets or sets the application language.
Expand All @@ -70,7 +53,10 @@ public bool? IsRunningInDemoMode
/// <value>
/// The last sitemap.
/// </value>
public string LastSitemap { get; set; }
public string LastSitemap
{
get; set;
}

/// <summary>
/// Gets or sets the configuration to the OpenHAB remote instance.
Expand Down
1 change: 1 addition & 0 deletions src/openHAB.Core/Services/IconCaching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using openHAB.Core.Client.Models;
using openHAB.Core.Model;
using openHAB.Core.Services.Contracts;
using openHAB.Core.Services.Models;

namespace openHAB.Core.Services
{
Expand Down
3 changes: 2 additions & 1 deletion src/openHAB.Core/Services/Models/OpenHABException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using openHAB.Core.Client.Models;
using System;

namespace openHAB.Core.Client.Models
namespace openHAB.Core.Services.Models
{
/// <summary>
/// An Exception class used to throw unexpected errors.
Expand Down
11 changes: 4 additions & 7 deletions src/openHAB.Core/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.IO;
using System.Text;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Text.Json;
using openHAB.Core.Client.Models;
using openHAB.Core.Model;
using openHAB.Core.Services.Contracts;
using Windows.System.UserProfile;
using System.Text.Json.Serialization;

namespace openHAB.Core.Services
{
Expand All @@ -18,10 +19,6 @@ public class SettingsService : ISettingsService
private readonly AppPaths _applicationContext;
private readonly ILogger<SettingsService> _logger;
private Settings _settings;
private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto,
};

/// <summary>
/// Initializes a new instance of the <see cref="SettingsService"/> class.
Expand Down Expand Up @@ -67,7 +64,7 @@ public Settings Load()
fileContent = fileContent.Replace("OpenHAB.Core.Model.Connection", "openHAB.Core.Connection");
}

_settings = JsonConvert.DeserializeObject<Settings>(fileContent, _serializerSettings);
_settings = JsonSerializer.Deserialize<Settings>(fileContent);
return _settings;
}

Expand All @@ -79,7 +76,7 @@ public bool Save(Settings settings)
_logger.LogInformation("Save settings to disk");
_settings = settings;

string settingsContent = JsonConvert.SerializeObject(settings, _serializerSettings);
string settingsContent = JsonSerializer.Serialize(settings);
File.WriteAllText(_applicationContext.SettingsFilePath, settingsContent, Encoding.UTF8);

return true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,4 @@
</ProductReservedInfo>
<AccountPackageIdentityNames />
<PackageInfoList LandingUrl="https://developer.microsoft.com/dashboard/Application?appId=9NMQ39CTWXGT" />
</StoreAssociation>
</StoreAssociation>
Loading

0 comments on commit 6fa01b1

Please sign in to comment.