Skip to content

Commit

Permalink
feat!: migration to AvaloniaUI
Browse files Browse the repository at this point in the history
  • Loading branch information
crowbait committed Apr 12, 2023
1 parent 21b5900 commit 28bb9ec
Show file tree
Hide file tree
Showing 34 changed files with 1,116 additions and 1,142 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
* text eol=lf

###############################################################################
# Set default behavior for command prompt diff.
Expand Down
9 changes: 9 additions & 0 deletions App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="robocopy_gui.App">

<Application.Styles>
<FluentTheme Mode="Dark"/>
<StyleInclude Source="avares://robocopy-gui/UI/Icons.axaml" />
</Application.Styles>
</Application>
23 changes: 23 additions & 0 deletions App.axaml.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
21 changes: 0 additions & 21 deletions App.config

This file was deleted.

15 changes: 0 additions & 15 deletions App.xaml

This file was deleted.

11 changes: 0 additions & 11 deletions App.xaml.cs

This file was deleted.

10 changes: 0 additions & 10 deletions AssemblyInfo.cs

This file was deleted.

Binary file modified Assets/exclusions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/main-interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions Classes/StartupTask.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -35,7 +38,7 @@ public bool CheckRegistration()
}
return false; //Name is not present in key's values
}
public void Register()
public async Task<bool> 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())
Expand All @@ -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()
Expand Down
34 changes: 0 additions & 34 deletions Classes/UIOperationArbitrary.cs

This file was deleted.

77 changes: 77 additions & 0 deletions MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="clr-namespace:robocopy_gui.UI;assembly=robocopy-gui"
x:Name="MainWindow1"
mc:Ignorable="d" d:DesignWidth="1280" d:DesignHeight="600"
x:Class="robocopy_gui.MainWindow"
TransparencyLevelHint="AcrylicBlur"
Background="Transparent"
ExtendClientAreaToDecorationsHint="True"
Closing="Window_Closing"
Title="Robocopy GUI" WindowStartupLocation="CenterScreen">
<Panel>
<ExperimentalAcrylicBorder IsHitTestVisible="False">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial
BackgroundSource="Digger"
TintColor="Black"
TintOpacity="1"
MaterialOpacity="0.5" />
</ExperimentalAcrylicBorder.Material>
</ExperimentalAcrylicBorder>
<Grid Margin="10,5,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="48" />
</Grid.RowDefinitions>
<Label x:Name="TitleLabel" Grid.Row="0" Content="Robocopy GUI" Margin="0,0,0,0" FontStyle="Oblique" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="60" />
</Grid.ColumnDefinitions>
<TextBox x:Name="InputFilePath" Watermark="File Path" Margin="10,10,0,0" TextWrapping="NoWrap" Grid.Column="0" VerticalAlignment="Top" KeyDown="InputFilePath_KeyDown" LostFocus="InputFilePath_LostFocus" />
<Button x:Name="ButtonPickFile" Margin="0,10,0,0" VerticalAlignment="Center" Grid.Column="1" Width="60" HorizontalAlignment="Center" Click="ButtonPickFile_Click">
<PathIcon Data="{StaticResource search_regular}" />
</Button>
<Button x:Name="ButtonReloadFile" Margin="0,10,0,0" VerticalAlignment="Center" Grid.Column="2" Width="60" HorizontalAlignment="Center" Click="ButtonReloadFile_Click">
<PathIcon Data="{StaticResource arrow_sync_regular}" />
</Button>
</Grid>
<ScrollViewer Grid.Row="2" Margin="10,10,10,10">
<Grid x:Name="GridOperations">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
</Grid>
</ScrollViewer>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="170" />
</Grid.ColumnDefinitions>

<TextBox x:Name="InputScriptTitle" Watermark="Script Title" Margin="10,10,10,0" Grid.Column="0" TextWrapping="NoWrap" VerticalAlignment="Top" LostFocus="InputScriptTitle_LostFocus" KeyDown="InputScriptTitle_KeyDown" />
<CheckBox x:Name="CheckStartup" Grid.Column="1" Content="Run on startup" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="CheckStartup_Checked" Unchecked="CheckStartup_Unchecked" />
<Button x:Name="ButtonCommit" Content="Commit to file" VerticalAlignment="Center" Grid.Column="2" Width="150" HorizontalAlignment="Right" Margin="0,0,10,0" IsEnabled="False" Click="ButtonCommit_Click" />
</Grid>
</Grid>
</Panel>
</Window>
Loading

0 comments on commit 28bb9ec

Please sign in to comment.