Convert remaining files to file-scoped namespace
This commit is contained in:
@@ -4,16 +4,14 @@ using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace MayShow.Helpers
|
||||
{
|
||||
namespace MayShow.Helpers;
|
||||
|
||||
// https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=netframework-4.7.2
|
||||
class ChangeNotifier : INotifyPropertyChanged
|
||||
// https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=netframework-4.7.2
|
||||
class ChangeNotifier : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,43 +5,42 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MayShow.ViewModels
|
||||
namespace MayShow.ViewModels;
|
||||
|
||||
class BaseViewModel : ChangeNotifier
|
||||
{
|
||||
class BaseViewModel : ChangeNotifier
|
||||
IChangeViewModel _viewModelChanger;
|
||||
ITopLevelGrabber? _topLevelGrabber;
|
||||
|
||||
public BaseViewModel(IChangeViewModel viewModelChanger)
|
||||
{
|
||||
IChangeViewModel _viewModelChanger;
|
||||
ITopLevelGrabber? _topLevelGrabber;
|
||||
|
||||
public BaseViewModel(IChangeViewModel viewModelChanger)
|
||||
{
|
||||
_viewModelChanger = viewModelChanger;
|
||||
_topLevelGrabber = null;
|
||||
}
|
||||
|
||||
public ITopLevelGrabber? TopLevelGrabber
|
||||
{
|
||||
get => _topLevelGrabber;
|
||||
set { _topLevelGrabber = value; }
|
||||
}
|
||||
|
||||
public IChangeViewModel ViewModelChanger
|
||||
{
|
||||
get { return _viewModelChanger; }
|
||||
set { _viewModelChanger = value; }
|
||||
}
|
||||
|
||||
#region IChangeViewModel
|
||||
|
||||
public void PopViewModel()
|
||||
{
|
||||
_viewModelChanger?.PopViewModel();
|
||||
}
|
||||
|
||||
public void PushViewModel(BaseViewModel model)
|
||||
{
|
||||
_viewModelChanger?.PushViewModel(model);
|
||||
}
|
||||
|
||||
#endregion
|
||||
_viewModelChanger = viewModelChanger;
|
||||
_topLevelGrabber = null;
|
||||
}
|
||||
|
||||
public ITopLevelGrabber? TopLevelGrabber
|
||||
{
|
||||
get => _topLevelGrabber;
|
||||
set { _topLevelGrabber = value; }
|
||||
}
|
||||
|
||||
public IChangeViewModel ViewModelChanger
|
||||
{
|
||||
get { return _viewModelChanger; }
|
||||
set { _viewModelChanger = value; }
|
||||
}
|
||||
|
||||
#region IChangeViewModel
|
||||
|
||||
public void PopViewModel()
|
||||
{
|
||||
_viewModelChanger?.PopViewModel();
|
||||
}
|
||||
|
||||
public void PushViewModel(BaseViewModel model)
|
||||
{
|
||||
_viewModelChanger?.PushViewModel(model);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -4,47 +4,46 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MayShow.ViewModels
|
||||
namespace MayShow.ViewModels;
|
||||
|
||||
class MainWindowViewModel : ChangeNotifier, IChangeViewModel
|
||||
{
|
||||
class MainWindowViewModel : ChangeNotifier, IChangeViewModel
|
||||
BaseViewModel _currentViewModel;
|
||||
Stack<BaseViewModel> _viewModels;
|
||||
|
||||
public MainWindowViewModel(ITopLevelGrabber topLevelGrabber)
|
||||
{
|
||||
BaseViewModel _currentViewModel;
|
||||
Stack<BaseViewModel> _viewModels;
|
||||
|
||||
public MainWindowViewModel(ITopLevelGrabber topLevelGrabber)
|
||||
_viewModels = new Stack<BaseViewModel>();
|
||||
var initialViewModel = new MainViewModel(this)
|
||||
{
|
||||
_viewModels = new Stack<BaseViewModel>();
|
||||
var initialViewModel = new MainViewModel(this)
|
||||
{
|
||||
TopLevelGrabber = topLevelGrabber
|
||||
};
|
||||
_viewModels.Push(initialViewModel);
|
||||
_currentViewModel = initialViewModel;
|
||||
}
|
||||
|
||||
public BaseViewModel CurrentViewModel
|
||||
{
|
||||
get { return _currentViewModel; }
|
||||
set { _currentViewModel = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
#region IChangeViewModel
|
||||
|
||||
public void PushViewModel(BaseViewModel model)
|
||||
{
|
||||
_viewModels.Push(model);
|
||||
CurrentViewModel = model;
|
||||
}
|
||||
|
||||
public void PopViewModel()
|
||||
{
|
||||
if (_viewModels.Count > 1)
|
||||
{
|
||||
_viewModels.Pop();
|
||||
CurrentViewModel = _viewModels.Peek();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
TopLevelGrabber = topLevelGrabber
|
||||
};
|
||||
_viewModels.Push(initialViewModel);
|
||||
_currentViewModel = initialViewModel;
|
||||
}
|
||||
|
||||
public BaseViewModel CurrentViewModel
|
||||
{
|
||||
get { return _currentViewModel; }
|
||||
set { _currentViewModel = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
#region IChangeViewModel
|
||||
|
||||
public void PushViewModel(BaseViewModel model)
|
||||
{
|
||||
_viewModels.Push(model);
|
||||
CurrentViewModel = model;
|
||||
}
|
||||
|
||||
public void PopViewModel()
|
||||
{
|
||||
if (_viewModels.Count > 1)
|
||||
{
|
||||
_viewModels.Pop();
|
||||
CurrentViewModel = _viewModels.Peek();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -2,30 +2,29 @@
|
||||
using MayShow.Helpers;
|
||||
using MayShow.Models;
|
||||
|
||||
namespace MayShow.ViewModels
|
||||
namespace MayShow.ViewModels;
|
||||
|
||||
class WarningDeleteItemViewModel : ChangeNotifier
|
||||
{
|
||||
class WarningDeleteItemViewModel : ChangeNotifier
|
||||
ReportFile _file;
|
||||
|
||||
public WarningDeleteItemViewModel(ReportFile file)
|
||||
{
|
||||
ReportFile _file;
|
||||
_file = file;
|
||||
}
|
||||
|
||||
public WarningDeleteItemViewModel(ReportFile file)
|
||||
{
|
||||
_file = file;
|
||||
}
|
||||
public ReportFile File
|
||||
{
|
||||
get => _file;
|
||||
}
|
||||
|
||||
public ReportFile File
|
||||
{
|
||||
get => _file;
|
||||
}
|
||||
public void KeepItem()
|
||||
{
|
||||
DialogHost.Close("DialogHost", false);
|
||||
}
|
||||
|
||||
public void KeepItem()
|
||||
{
|
||||
DialogHost.Close("DialogHost", false);
|
||||
}
|
||||
|
||||
public void RemoveItem()
|
||||
{
|
||||
DialogHost.Close("DialogHost", true);
|
||||
}
|
||||
public void RemoveItem()
|
||||
{
|
||||
DialogHost.Close("DialogHost", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,35 +5,34 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace MayShow.Views
|
||||
{
|
||||
public partial class AboutView : UserControl
|
||||
{
|
||||
public AboutView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
namespace MayShow.Views;
|
||||
|
||||
// set license text
|
||||
var processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
|
||||
var licenseFileName = Path.Combine(processDir, "Assets", "LICENSES.txt");
|
||||
var licenseText = "";
|
||||
public partial class AboutView : UserControl
|
||||
{
|
||||
public AboutView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// set license text
|
||||
var processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
|
||||
var licenseFileName = Path.Combine(processDir, "Assets", "LICENSES.txt");
|
||||
var licenseText = "";
|
||||
if (File.Exists(licenseFileName))
|
||||
{
|
||||
licenseText = File.ReadAllText(licenseFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
licenseFileName = Path.Combine(processDir, "../Resources/Assets/LICENSES.txt");
|
||||
if (File.Exists(licenseFileName))
|
||||
{
|
||||
licenseText = File.ReadAllText(licenseFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
licenseFileName = Path.Combine(processDir, "../Resources/Assets/LICENSES.txt");
|
||||
if (File.Exists(licenseFileName))
|
||||
{
|
||||
licenseText = File.ReadAllText(licenseFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
licenseText = "Error: Unable to find license file!";
|
||||
}
|
||||
licenseText = "Error: Unable to find license file!";
|
||||
}
|
||||
LicenseTextBlock.Text = licenseText.Trim();
|
||||
}
|
||||
LicenseTextBlock.Text = licenseText.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace MayShow.Views
|
||||
namespace MayShow.Views;
|
||||
|
||||
public partial class EditFile : UserControl
|
||||
{
|
||||
public partial class EditFile : UserControl
|
||||
public EditFile()
|
||||
{
|
||||
public EditFile()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
+24
-25
@@ -5,41 +5,40 @@ using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using MayShow.ViewModels;
|
||||
|
||||
namespace MayShow.Views
|
||||
namespace MayShow.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public partial class MainView : UserControl
|
||||
public MainView()
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
|
||||
FilesGrid.CellEditEnded += FileCellEditEnded;
|
||||
}
|
||||
this.InitializeComponent();
|
||||
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
|
||||
FilesGrid.CellEditEnded += FileCellEditEnded;
|
||||
}
|
||||
|
||||
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property.ToString() == "Text")
|
||||
{
|
||||
if (e.Property.ToString() == "Text")
|
||||
{
|
||||
LogScrollView.ScrollToEnd();
|
||||
}
|
||||
LogScrollView.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void UnfocusTextbox()
|
||||
public void UnfocusTextbox()
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
topLevel?.FocusManager?.ClearFocus();
|
||||
if (DataContext is MainViewModel mvm)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
topLevel?.FocusManager?.ClearFocus();
|
||||
if (DataContext is MainViewModel mvm)
|
||||
{
|
||||
mvm?.HasUnsavedWork = true;
|
||||
}
|
||||
mvm?.HasUnsavedWork = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void FileCellEditEnded(object? sender, DataGridCellEditEndedEventArgs args)
|
||||
private void FileCellEditEnded(object? sender, DataGridCellEditEndedEventArgs args)
|
||||
{
|
||||
if (args.EditAction == DataGridEditAction.Commit && DataContext is MainViewModel mvm)
|
||||
{
|
||||
if (args.EditAction == DataGridEditAction.Commit && DataContext is MainViewModel mvm)
|
||||
{
|
||||
mvm?.HasUnsavedWork = true;
|
||||
}
|
||||
mvm?.HasUnsavedWork = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace MayShow.Views
|
||||
namespace MayShow.Views;
|
||||
|
||||
public partial class WarningDeleteItem : UserControl
|
||||
{
|
||||
public partial class WarningDeleteItem : UserControl
|
||||
public WarningDeleteItem()
|
||||
{
|
||||
public WarningDeleteItem()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user