diff --git a/.editorconfig b/.editorconfig index 922679d..93670f4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,3 +18,5 @@ dotnet_diagnostic.IDE0090.severity=silent # Suppress 'use index operator (^)' and 'use substring operator (..)' because they make the code less readable / intuitive dotnet_diagnostic.IDE0056.severity=silent dotnet_diagnostic.IDE0057.severity=silent +# Supress 'do not use implicit cast' because it makes the code much less readable +dotnet_diagnostic.IDE0220.severity=silent diff --git a/.gitattributes b/.gitattributes index 1ff0c42..b72c2c6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ ############################################################################### # Set default behavior to automatically normalize line endings. ############################################################################### -* text=auto +* text eol=lf ############################################################################### # Set default behavior for command prompt diff. diff --git a/App.axaml b/App.axaml new file mode 100644 index 0000000..dec45f8 --- /dev/null +++ b/App.axaml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/App.axaml.cs b/App.axaml.cs new file mode 100644 index 0000000..1422ab5 --- /dev/null +++ b/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace robocopy_gui; + +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(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/App.config b/App.config deleted file mode 100644 index 622859c..0000000 --- a/App.config +++ /dev/null @@ -1,21 +0,0 @@ - - - - -
- - - - - - 1280 - - - 600 - - - - - - - \ No newline at end of file diff --git a/App.xaml b/App.xaml deleted file mode 100644 index 2057281..0000000 --- a/App.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/App.xaml.cs b/App.xaml.cs deleted file mode 100644 index 292125a..0000000 --- a/App.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Windows; - -namespace robocopy_gui -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs deleted file mode 100644 index 8b5504e..0000000 --- a/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/Assets/exclusions.png b/Assets/exclusions.png index c9edf98..4cc7307 100644 Binary files a/Assets/exclusions.png and b/Assets/exclusions.png differ diff --git a/Assets/icon.png b/Assets/icon.png index 30ae757..9af0403 100644 Binary files a/Assets/icon.png and b/Assets/icon.png differ diff --git a/Assets/main-interface.png b/Assets/main-interface.png index 00e9106..5416454 100644 Binary files a/Assets/main-interface.png and b/Assets/main-interface.png differ diff --git a/Classes/StartupTask.cs b/Classes/StartupTask.cs index 1517606..f54d5e6 100644 --- a/Classes/StartupTask.cs +++ b/Classes/StartupTask.cs @@ -1,8 +1,11 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; using Microsoft.Win32; +using robocopy_gui.UI; using System; -using System.Windows; +using System.Threading.Tasks; -namespace robocopy_gui.Classes +namespace robocopy_gui { internal class StartupTask { @@ -35,7 +38,7 @@ public bool CheckRegistration() } return false; //Name is not present in key's values } - public void Register() + public async Task Register() { RegistryKey key = Registry.CurrentUser.OpenSubKey(startupKey, RegistryKeyPermissionCheck.ReadWriteSubTree) ?? throw new ArgumentException("HKEY_CURRENT_USER run key does not exist"); foreach (string valueName in key.GetValueNames()) @@ -44,21 +47,28 @@ public void Register() { if(key?.GetValue(Name)?.ToString() != Path) { - if(MessageBox.Show( + DialogMessage message = new DialogMessage( Name + " is already set to startup with path '" + key?.GetValue(Name)?.ToString() + "'.\nOverwrite?", - "Name conflict!", - MessageBoxButton.YesNo) == MessageBoxResult.Yes ) + "Name conflict!" + ); + message.SetButtons(new string[] { "Yes", "No" }); + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + await message.ShowDialog(desktop.MainWindow); + } + if(message.ReturnValue == "Yes") { break; } else { - return; //User does not want to overwrite existing startup key + return false; //User does not want to overwrite existing startup key } } - return; //Name is already set with correct Path + return true; //Name is already set with correct Path } } key?.SetValue(Name, Path, RegistryValueKind.String); + return true; } public void Unregister() diff --git a/Classes/UIOperationArbitrary.cs b/Classes/UIOperationArbitrary.cs deleted file mode 100644 index ce2dcdc..0000000 --- a/Classes/UIOperationArbitrary.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Windows; -using System.Windows.Controls; - -namespace robocopy_gui.Classes -{ - internal class UIOperationArbitrary - { - public int Index { get; set; } - public Label Label { get; set; } - public TextBox Command { get; set; } - - public UIOperationArbitrary(int operationIndex) - { - Index = operationIndex; - - Label = new Label - { - Content = "Command:", - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center - }; - - Command = new TextBox - { - Name = "arbitraryCommand" + operationIndex, - Text = MainWindow.OperationsList[operationIndex].Command, - VerticalAlignment = VerticalAlignment.Top, - Margin = new Thickness(10, 10, 0, 0), - TextWrapping = TextWrapping.NoWrap, - Tag = operationIndex - }; - } - } -} diff --git a/MainWindow.axaml b/MainWindow.axaml new file mode 100644 index 0000000..f68367f --- /dev/null +++ b/MainWindow.axaml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + +