Cross-platform: remove System.Drawing deps, add #if WINDOWS
Refactored image creation APIs to use byte[] for logo data instead of System.Drawing.Image, enabling cross-platform support. Wrapped all GDI+/Windows-specific code in #if WINDOWS and updated project files to conditionally include Windows-only dependencies. Defaulted to ImageSharp on non-Windows, and updated UI and settings to reflect platform capabilities. Application now builds and runs on Linux/macOS with Avalonia and ImageSharp, while retaining full Windows functionality.
This commit is contained in:
parent
311b3e76f0
commit
73597689ed
16 changed files with 115 additions and 90 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
|
@ -6,14 +6,18 @@ using System.Runtime.CompilerServices;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#if WINDOWS
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
|
||||
namespace ImageCatalog_2
|
||||
{
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
private readonly SynchronizationContext? _synchronizationContext;
|
||||
#if WINDOWS
|
||||
private Control? _control;
|
||||
#endif
|
||||
|
||||
protected ViewModelBase()
|
||||
{
|
||||
|
|
@ -25,10 +29,12 @@ namespace ImageCatalog_2
|
|||
/// Set a Control to use for thread marshalling in WinForms applications.
|
||||
/// This is required for proper cross-thread handling with data binding.
|
||||
/// </summary>
|
||||
#if WINDOWS
|
||||
public void SetControl(Control control)
|
||||
{
|
||||
_control = control;
|
||||
}
|
||||
#endif
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
|
|
@ -40,6 +46,7 @@ namespace ImageCatalog_2
|
|||
if (PropertyChanged == null)
|
||||
return;
|
||||
|
||||
#if WINDOWS
|
||||
// If we have a Control reference (WinForms), use Control.Invoke for proper marshalling
|
||||
if (_control != null)
|
||||
{
|
||||
|
|
@ -53,7 +60,9 @@ namespace ImageCatalog_2
|
|||
}
|
||||
}
|
||||
// Fallback to SynchronizationContext if available
|
||||
else if (_synchronizationContext != null && SynchronizationContext.Current != _synchronizationContext)
|
||||
else
|
||||
#endif
|
||||
if (_synchronizationContext != null && SynchronizationContext.Current != _synchronizationContext)
|
||||
{
|
||||
// We're on a different thread, marshal to the UI thread
|
||||
_synchronizationContext.Send(_ =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue