Skip to content

Commit

Permalink
refactor code and prepare using Viewmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
agailloty committed Feb 1, 2025
1 parent f853191 commit 4d968c3
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 118 deletions.
6 changes: 2 additions & 4 deletions xpathrunnerui/xpathrunnerui/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using xpathrunnerui.ViewModels;

namespace xpathrunnerui
{
Expand All @@ -20,10 +21,7 @@ public override void OnFrameworkInitializationCompleted()
// Without this line you will get duplicate validations from both Avalonia and CT
BindingPlugins.DataValidators.RemoveAt(0);

Check warning on line 22 in xpathrunnerui/xpathrunnerui/App.axaml.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Using member 'Avalonia.Data.Core.Plugins.BindingPlugins.DataValidators.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. PropertyAccessors might require unreferenced code.

Check warning on line 22 in xpathrunnerui/xpathrunnerui/App.axaml.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Using member 'Avalonia.Data.Core.Plugins.BindingPlugins.DataValidators.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. PropertyAccessors might require unreferenced code.

Check warning on line 22 in xpathrunnerui/xpathrunnerui/App.axaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Using member 'Avalonia.Data.Core.Plugins.BindingPlugins.DataValidators.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. PropertyAccessors might require unreferenced code.
desktop.MainWindow = new MainWindow();
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView();
desktop.MainWindow.DataContext = new MainWindowViewModel();
}

base.OnFrameworkInitializationCompleted();
Expand Down
32 changes: 0 additions & 32 deletions xpathrunnerui/xpathrunnerui/MainWindow.axaml

This file was deleted.

81 changes: 0 additions & 81 deletions xpathrunnerui/xpathrunnerui/MainWindow.axaml.cs

This file was deleted.

20 changes: 20 additions & 0 deletions xpathrunnerui/xpathrunnerui/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace xpathrunnerui.ViewModels;

public class MainWindowViewModel : ObservableObject
{
private bool _isBusy;

public bool IsBusy
{
get => _isBusy;
set
{
if (_isBusy != value)
{
SetProperty(ref _isBusy, value);
}
}
}
}
File renamed without changes.
12 changes: 12 additions & 0 deletions xpathrunnerui/xpathrunnerui/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<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:local="clr-namespace:xpathrunnerui"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="xpathrunnerui.MainWindow"
Title="XPATH Runner"
Icon="/Assets/html_tag.png"
WindowStartupLocation="CenterScreen">
<local:MainView/>
</Window>
30 changes: 30 additions & 0 deletions xpathrunnerui/xpathrunnerui/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace xpathrunnerui
{
public partial class MainWindow : Window
{
private string? _filepath;

Check warning on line 15 in xpathrunnerui/xpathrunnerui/Views/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The field 'MainWindow._filepath' is never used

Check warning on line 15 in xpathrunnerui/xpathrunnerui/Views/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The field 'MainWindow._filepath' is never used

Check warning on line 15 in xpathrunnerui/xpathrunnerui/Views/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The field 'MainWindow._filepath' is never used
public MainWindow()
{
InitializeComponent();
var screen = Screens.Primary;
// Set width and height as percentages of the screen
if (screen != null)
{
Width = screen.WorkingArea.Width * 0.5;
Height = screen.WorkingArea.Height * 0.6;
}
}


}
}
9 changes: 8 additions & 1 deletion xpathrunnerui/xpathrunnerui/xpathrunnerui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
</ItemGroup>

<ItemGroup>
<Folder Include="ViewModels\" />
<Compile Update="Views\MainView.axaml.cs">
<DependentUpon>MainView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\MainWindow.axaml.cs">
<DependentUpon>MainWindow.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>

0 comments on commit 4d968c3

Please sign in to comment.