Refactor application to remove Windows Forms dependencies and transition to Avalonia UI
- Deleted MainWindow.xaml.cs, which contained the WPF implementation of the main window. - Updated Program.cs to remove Windows Forms initialization and support only Avalonia UI. - Removed Windows Forms specific code from ViewModelBase, including control marshalling logic.
This commit is contained in:
parent
988a3d94e1
commit
d6b778a648
16 changed files with 64 additions and 4415 deletions
|
|
@ -6,18 +6,12 @@ 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,19 +19,8 @@ namespace ImageCatalog_2
|
|||
_synchronizationContext = SynchronizationContext.Current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
|
||||
// This method is called by the Set accessor of each property.
|
||||
// The CallerMemberName attribute that is applied to the optional propertyName
|
||||
// parameter causes the property name of the caller to be substituted as an argument.
|
||||
|
|
@ -46,22 +29,6 @@ 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)
|
||||
{
|
||||
if (_control.InvokeRequired)
|
||||
{
|
||||
_control.Invoke(() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
// Fallback to SynchronizationContext if available
|
||||
else
|
||||
#endif
|
||||
if (_synchronizationContext != null && SynchronizationContext.Current != _synchronizationContext)
|
||||
{
|
||||
// We're on a different thread, marshal to the UI thread
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue