This commit is contained in:
Wiesław Šoltés 2022-08-20 23:30:03 +02:00
Родитель 1515080f9d
Коммит 32822e8f0a
13 изменённых файлов: 224 добавлений и 190 удалений

Просмотреть файл

@ -38,12 +38,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "props", "props", "{B8ACA4FA
build\Avalonia.props = build\Avalonia.props
build\Base.props = build\Base.props
build\Newtonsoft.Json.props = build\Newtonsoft.Json.props
build\ReactiveUI.props = build\ReactiveUI.props
build\ReferenceAssemblies.props = build\ReferenceAssemblies.props
build\XUnit.props = build\XUnit.props
build\SourceLink.props = build\SourceLink.props
build\Avalonia.Web.Blazor.props = build\Avalonia.Web.Blazor.props
build\Avalonia.Themes.Fluent.props = build\Avalonia.Themes.Fluent.props
build\CommunityToolkit.Mvvm.props = build\CommunityToolkit.Mvvm.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{8A8848E4-0FF5-45C2-84AF-4B9A0F6172C3}"

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="reactiveui" Version="18.3.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,8 +1,8 @@
<Application x:Class="PackageReferenceEditor.App"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/FluentLight.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/DensityStyles/Compact.xaml" />
</Application.Styles>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Package Reference Editor">
<Application.Styles>
<FluentTheme Mode="Light" />
</Application.Styles>
</Application>

Просмотреть файл

@ -17,7 +17,7 @@
<Import Project="..\..\build\ReferenceAssemblies.props" />
<Import Project="..\..\build\Avalonia.props" />
<Import Project="..\..\build\Avalonia.Diagnostics.props" />
<Import Project="..\..\build\Avalonia.Desktop.props" />
<Import Project="..\..\build\Avalonia.Themes.Fluent.props" />
<Import Project="..\..\build\Newtonsoft.Json.props" />
<ItemGroup>

Просмотреть файл

@ -1,147 +1,180 @@
<UserControl x:Class="PackageReferenceEditor.Views.MainView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
UseLayoutRounding="True" Focusable="True">
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="TextBox">
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="ComboBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="CheckBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="ListBox">
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</UserControl.Styles>
<Grid ColumnDefinitions="250,8,*" RowDefinitions="Auto,*">
<Grid RowDefinitions="Auto,Auto" ColumnDefinitions="*,100,100" Margin="2" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<TextBox x:Name="textBoxSearchPath"
Text="{Binding SearchPath}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
<Button x:Name="buttonBrowse"
Content="..."
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="2"/>
<TextBox x:Name="textBoxSearchPattern"
Text="{Binding SearchPattern}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="0"/>
<ComboBox x:Name="comboBoxPatterns"
Items="{Binding SearchPatterns}"
SelectedItem="{Binding SearchPattern, Mode=OneWay}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="1"/>
<Button x:Name="buttonSearch"
Content="Search"
Command="{Binding Search}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="2"/>
</Grid>
<Grid RowDefinitions="*,Auto" Margin="2" Grid.Row="1" Grid.Column="0">
<ListBox x:Name="listBoxGroups"
Items="{Binding Result.GroupedReferences}"
SelectedItem="{Binding CurrentReferences}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0">
<ListBox.DataTemplates>
<DataTemplate>
<TextBlock Text="{Binding Key}" Margin="2"/>
</DataTemplate>
</ListBox.DataTemplates>
</ListBox>
<Button x:Name="buttonUpdateAll"
Content="Update Files"
Command="{Binding UpdateAll}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1"/>
</Grid>
<GridSplitter Width="8" Grid.Row="1" Grid.Column="1"/>
<Grid RowDefinitions="*,Auto,Auto,Auto,Auto" Margin="2" Grid.Row="1" Grid.Column="2">
<ListBox x:Name="listBoxReferences"
Items="{Binding CurrentReferences.Value}"
SelectedItem="{Binding CurrentReference}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0">
<ListBox.DataTemplates>
<DataTemplate>
<StackPanel Margin="2">
<TextBlock Text="{Binding Version}"
Margin="1"
HorizontalAlignment="Stretch"/>
<TextBlock Text="{Binding FileName}"
Foreground="{DynamicResource ThemeBorderMidBrush}"
Margin="1"
HorizontalAlignment="Stretch"/>
</StackPanel>
</DataTemplate>
</ListBox.DataTemplates>
</ListBox>
<Grid RowDefinitions="Auto" ColumnDefinitions="*,100" Grid.Row="1">
<TextBox Text="{Binding CurrentReference.Version}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="0"/>
<Button x:Name="buttonConsolidate"
Content="Consolidate"
Command="{Binding ConsolidateVersions}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="1"/>
</Grid>
<Grid RowDefinitions="Auto" ColumnDefinitions="50*,100,50*,100" Grid.Row="2">
<ComboBox x:Name="comboBoxPVersions"
Items="{Binding Versions}"
SelectedItem="{Binding CurrentVersion}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="0"/>
<Button x:Name="buttonUseVersion"
Content="Use Version"
Command="{Binding UseVersion}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="1"/>
<ComboBox x:Name="comboBoxPFeeds"
Items="{Binding Feeds}"
SelectedItem="{Binding CurrentFeed}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="2">
<ComboBox.DataTemplates>
<DataTemplate>
<TextBlock Text="{Binding Name}" Margin="1"/>
</DataTemplate>
</ComboBox.DataTemplates>
</ComboBox>
<Button x:Name="buttonVersions"
Content="Get Versions"
Command="{Binding GetVersions}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="3"/>
</Grid>
<CheckBox x:Name="checkBoxAlwaysUpdate"
IsChecked="{Binding AlwaysUpdate}"
Content="Always Update"
IsEnabled="{Binding !IsWorking}"
Grid.Row="3"/>
<Button x:Name="buttonUpdateCurrent"
Content="Update Files"
Command="{Binding UpdateCurrent}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="4"/>
</Grid>
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:editor="clr-namespace:PackageReferenceEditor;assembly=PackageReferenceEditor"
mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="450"
UseLayoutRounding="True" Focusable="True"
x:CompileBindings="False" x:DataType="editor:ReferenceEditor">
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0" />
</Style>
<Style Selector="TextBox">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0" />
</Style>
<Style Selector="ComboBox">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
</Style>
<Style Selector="CheckBox">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
</Style>
<Style Selector="ListBox">
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="0" />
</Style>
<Style Selector="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</UserControl.Styles>
<Grid ColumnDefinitions="300,12,*" RowDefinitions="Auto,12,*" Margin="12">
<!-- Search -->
<Grid RowDefinitions="Auto,12,Auto" ColumnDefinitions="*,12,120,12,120"
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<TextBox x:Name="textBoxSearchPath"
Text="{Binding SearchPath}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" />
<Button x:Name="buttonBrowse"
Content="..."
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="4" />
<TextBox x:Name="textBoxSearchPattern"
Text="{Binding SearchPattern}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="2" Grid.Column="0" />
<ComboBox x:Name="comboBoxPatterns"
Items="{Binding SearchPatterns}"
SelectedItem="{Binding SearchPattern, Mode=OneWay}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="2" Grid.Column="2" />
<Button x:Name="buttonSearch"
Content="Search"
Command="{Binding Search}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="2" Grid.Column="4" />
</Grid>
<!-- Groups -->
<Grid RowDefinitions="*,14,Auto" Grid.Row="2" Grid.Column="0">
<ListBox x:Name="listBoxGroups"
Items="{Binding Result.GroupedReferences}"
SelectedItem="{Binding CurrentReferences}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" Margin="2" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="buttonUpdateAll"
Content="Update Files"
Command="{Binding UpdateAll}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="2" />
</Grid>
<GridSplitter Grid.Row="2" Grid.Column="1" />
<!-- References -->
<Grid RowDefinitions="*,12,Auto,12,Auto,12,Auto,12,Auto"
Grid.Row="2" Grid.Column="2">
<ListBox x:Name="listBoxReferences"
Items="{Binding CurrentReferences.Value}"
SelectedItem="{Binding CurrentReference}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="2">
<TextBlock Text="{Binding Version}"
Margin="1"
HorizontalAlignment="Stretch" />
<TextBlock Text="{Binding FileName}"
Foreground="{DynamicResource ThemeBorderMidBrush}"
Margin="1"
HorizontalAlignment="Stretch" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Consolidate -->
<Grid RowDefinitions="Auto" ColumnDefinitions="*,12,120" Grid.Row="2">
<TextBox Text="{Binding CurrentReference.Version}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="0" />
<Button x:Name="buttonConsolidate"
Content="Consolidate"
Command="{Binding ConsolidateVersions}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="2" />
</Grid>
<!-- Versions -->
<Grid RowDefinitions="Auto" ColumnDefinitions="50*,12,120,12,50*,12,120" Grid.Row="4">
<ComboBox x:Name="comboBoxPVersions"
Items="{Binding Versions}"
SelectedItem="{Binding CurrentVersion}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="0" />
<Button x:Name="buttonUseVersion"
Content="Use Version"
Command="{Binding UseVersion}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="2" />
<ComboBox x:Name="comboBoxPFeeds"
Items="{Binding Feeds}"
SelectedItem="{Binding CurrentFeed}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="1" Grid.Column="4">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" Margin="1" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button x:Name="buttonVersions"
Content="Get Versions"
Command="{Binding GetVersions}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="0" Grid.Column="6" />
</Grid>
<CheckBox x:Name="checkBoxAlwaysUpdate"
IsChecked="{Binding AlwaysUpdate}"
Content="Always Update"
IsEnabled="{Binding !IsWorking}"
Grid.Row="6" />
<Button x:Name="buttonUpdateCurrent"
Content="Update Files"
Command="{Binding UpdateCurrent}"
IsEnabled="{Binding !IsWorking}"
Grid.Row="8" />
</Grid>
</Grid>
</UserControl>

Просмотреть файл

@ -4,6 +4,8 @@
xmlns:views="clr-namespace:PackageReferenceEditor.Views;assembly=PackageReferenceEditor.Base"
UseLayoutRounding="True" RenderOptions.BitmapInterpolationMode="HighQuality"
WindowState="Normal" WindowStartupLocation="CenterScreen"
Title="PackageReferenceEditor" Height="600" Width="800">
<views:MainView/>
Title="Package Reference Editor"
Height="750" Width="1100"
MinWidth="700" MinHeight="450">
<views:MainView />
</Window>

Просмотреть файл

@ -1,5 +1,4 @@
using Avalonia;
using PackageReferenceEditor;
namespace PackageReferenceEditor.Desktop;

Просмотреть файл

@ -1,10 +1,10 @@
using System.Runtime.Serialization;
using ReactiveUI;
using CommunityToolkit.Mvvm.ComponentModel;
namespace PackageReferenceEditor;
[DataContract]
public class Feed : ReactiveObject
public class Feed : ObservableObject
{
private string _name;
private string _uri;
@ -13,14 +13,14 @@ public class Feed : ReactiveObject
public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
set => SetProperty(ref _name, value);
}
[DataMember]
public string Uri
{
get => _uri;
set => this.RaiseAndSetIfChanged(ref _uri, value);
set => SetProperty(ref _uri, value);
}
public Feed(string name, string uri)
@ -28,4 +28,4 @@ public class Feed : ReactiveObject
_name = name;
_uri = uri;
}
}
}

Просмотреть файл

@ -1,11 +1,11 @@
using System.Runtime.Serialization;
using System.Xml;
using ReactiveUI;
using CommunityToolkit.Mvvm.ComponentModel;
namespace PackageReferenceEditor;
[DataContract]
public class PackageReference : ReactiveObject
public class PackageReference : ObservableObject
{
private string _name = string.Empty;
private string _version = string.Empty;
@ -18,41 +18,41 @@ public class PackageReference : ReactiveObject
public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
set => SetProperty(ref _name, value);
}
[DataMember]
public string Version
{
get => _version;
set => this.RaiseAndSetIfChanged(ref _version, value);
set => SetProperty(ref _version, value);
}
[DataMember]
public string FileName
{
get => _fileName;
set => this.RaiseAndSetIfChanged(ref _fileName, value);
set => SetProperty(ref _fileName, value);
}
[DataMember]
public XmlDocument? Document
{
get => _document;
set => this.RaiseAndSetIfChanged(ref _document, value);
set => SetProperty(ref _document, value);
}
[DataMember]
public XmlNode? Reference
{
get => _reference;
set => this.RaiseAndSetIfChanged(ref _reference, value);
set => SetProperty(ref _reference, value);
}
[DataMember]
public XmlAttribute? VersionAttribute
{
get => _versionAttribute;
set => this.RaiseAndSetIfChanged(ref _versionAttribute, value);
set => SetProperty(ref _versionAttribute, value);
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@
<Import Project="..\..\build\SourceLink.props" />
<Import Project="..\..\build\ReferenceAssemblies.props" />
<Import Project="..\..\build\Newtonsoft.Json.props" />
<Import Project="..\..\build\ReactiveUI.props" />
<Import Project="..\..\build\CommunityToolkit.Mvvm.props" />
<ItemGroup>
<Compile Include="**\*.cs" Exclude="obj\**" />

Просмотреть файл

@ -4,12 +4,12 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using ReactiveUI;
using CommunityToolkit.Mvvm.ComponentModel;
namespace PackageReferenceEditor;
[DataContract]
public class ReferenceEditor : ReactiveObject
public class ReferenceEditor : ObservableObject
{
private IList<Feed>? _feeds;
private Feed? _currentFeed;
@ -28,84 +28,84 @@ public class ReferenceEditor : ReactiveObject
public IList<Feed>? Feeds
{
get => _feeds;
set => this.RaiseAndSetIfChanged(ref _feeds, value);
set => SetProperty(ref _feeds, value);
}
[DataMember]
public Feed? CurrentFeed
{
get => _currentFeed;
set => this.RaiseAndSetIfChanged(ref _currentFeed, value);
set => SetProperty(ref _currentFeed, value);
}
[IgnoreDataMember]
public IList<string?>? Versions
{
get => _versions;
set => this.RaiseAndSetIfChanged(ref _versions, value);
set => SetProperty(ref _versions, value);
}
[IgnoreDataMember]
public string? CurrentVersion
{
get => _currentVersion;
set => this.RaiseAndSetIfChanged(ref _currentVersion, value);
set => SetProperty(ref _currentVersion, value);
}
[DataMember]
public string? SearchPath
{
get => _searchPath;
set => this.RaiseAndSetIfChanged(ref _searchPath, value);
set => SetProperty(ref _searchPath, value);
}
[DataMember]
public IList<string>? SearchPatterns
{
get => _searchPatterns;
set => this.RaiseAndSetIfChanged(ref _searchPatterns, value);
set => SetProperty(ref _searchPatterns, value);
}
[DataMember]
public string? SearchPattern
{
get => _searchPattern;
set => this.RaiseAndSetIfChanged(ref _searchPattern, value);
set => SetProperty(ref _searchPattern, value);
}
[IgnoreDataMember]
public UpdaterResult? Result
{
get => _result;
set => this.RaiseAndSetIfChanged(ref _result, value);
set => SetProperty(ref _result, value);
}
[IgnoreDataMember]
public KeyValuePair<string, IList<PackageReference>> CurrentReferences
{
get => _currentReferences;
set => this.RaiseAndSetIfChanged(ref _currentReferences, value);
set => SetProperty(ref _currentReferences, value);
}
[IgnoreDataMember]
public PackageReference? CurrentReference
{
get => _currentReference;
set => this.RaiseAndSetIfChanged(ref _currentReference, value);
set => SetProperty(ref _currentReference, value);
}
[DataMember]
public bool AlwaysUpdate
{
get => _alwaysUpdate;
set => this.RaiseAndSetIfChanged(ref _alwaysUpdate, value);
set => SetProperty(ref _alwaysUpdate, value);
}
[IgnoreDataMember]
public bool IsWorking
{
get => _isWorking;
set => this.RaiseAndSetIfChanged(ref _isWorking, value);
set => SetProperty(ref _isWorking, value);
}
public async Task Search()
@ -260,4 +260,4 @@ public class ReferenceEditor : ReactiveObject
Logger.Log(ex.StackTrace);
}
}
}
}

Просмотреть файл

@ -108,7 +108,7 @@ public static class Updater
}
catch (Exception ex)
{
Logger.Log($"Failed to find reference for {fileName}");
Logger.Log($"Failed to find reference for: {fileName}");
Logger.Log(ex.Message);
if (ex.StackTrace != null)
{

Просмотреть файл

@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
using ReactiveUI;
using CommunityToolkit.Mvvm.ComponentModel;
namespace PackageReferenceEditor;
[DataContract]
public class UpdaterResult : ReactiveObject
public class UpdaterResult : ObservableObject
{
private IList<XmlDocument>? _documents;
private IList<PackageReference>? _references;
@ -16,21 +16,21 @@ public class UpdaterResult : ReactiveObject
public IList<XmlDocument>? Documents
{
get => _documents;
set => this.RaiseAndSetIfChanged(ref _documents, value);
set => SetProperty(ref _documents, value);
}
[DataMember]
public IList<PackageReference>? References
{
get => _references;
set => this.RaiseAndSetIfChanged(ref _references, value);
set => SetProperty(ref _references, value);
}
[DataMember]
public Dictionary<string, IList<PackageReference>>? GroupedReferences
{
get => _groupedReferences;
set => this.RaiseAndSetIfChanged(ref _groupedReferences, value);
set => SetProperty(ref _groupedReferences, value);
}
public void Reset()
@ -39,4 +39,4 @@ public class UpdaterResult : ReactiveObject
References?.Clear();
GroupedReferences?.Clear();
}
}
}