~ruther/NosTale-PacketLogger

1c64e3b4d60e1a82d78d878c1fac1a61cc95093f — Rutherther 2 years ago 2576a4b
feat: add data grid with process selection to new document tab
M src/PacketLogger/PacketLogger.csproj => src/PacketLogger/PacketLogger.csproj +2 -0
@@ 27,6 27,8 @@
    <PackageReference Include="DataBox" Version="0.10.13" />
    <PackageReference Include="Dock.Avalonia" Version="0.10.18" />
    <PackageReference Include="Dock.Model.Mvvm" Version="0.10.18" />
    <PackageReference Include="NosSmooth.Comms.Local" Version="1.0.2" />
    <PackageReference Include="NosSmooth.LocalBinding" Version="1.0.0" />
    <PackageReference Include="NosSmooth.PacketSerializer.Abstractions" Version="1.3.1" />
    <PackageReference Include="Projektanker.Icons.Avalonia" Version="5.8.0" />
    <PackageReference Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="5.8.0" />

M src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs => src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs +12 -1
@@ 5,6 5,7 @@
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reactive;


@@ 15,6 16,7 @@ using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Dock.Model.Mvvm.Controls;
using PacketLogger.Models;
using PacketLogger.Models.Packets;
using ReactiveUI;



@@ 23,11 25,15 @@ namespace PacketLogger.ViewModels;
/// <inheritdoc />
public class PacketLogDocumentViewModel : Document, INotifyPropertyChanged
{
    private readonly NostaleProcesses _processes;

    /// <summary>
    /// Initializes a new instance of the <see cref="PacketLogDocumentViewModel"/> class.
    /// </summary>
    public PacketLogDocumentViewModel()
    /// <param name="processes">The NosTale processes collection.</param>
    public PacketLogDocumentViewModel(NostaleProcesses processes)
    {
        _processes = processes;
        OpenDummy = ReactiveCommand.CreateFromTask
        (
            () => Task.Run(() =>


@@ 74,6 80,11 @@ public class PacketLogDocumentViewModel : Document, INotifyPropertyChanged
    }

    /// <summary>
    /// Gets the processes observable.
    /// </summary>
    public ObservableCollection<NostaleProcess> Processes => _processes.Processes;

    /// <summary>
    /// Gets or sets the name of the tab.
    /// </summary>
    public string Name { get; set; } = "New tab";

M src/PacketLogger/Views/LogTabView.axaml => src/PacketLogger/Views/LogTabView.axaml +1 -1
@@ 4,7 4,7 @@
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="clr-namespace:PacketLogger.ViewModels"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="PacketLogger.Views.LogTab"
             x:Class="PacketLogger.Views.LogTabView"
             xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
             xmlns:converters="clr-namespace:PacketLogger.Converters"
             xmlns:views="clr-namespace:PacketLogger.Views"

M src/PacketLogger/Views/LogTabView.axaml.cs => src/PacketLogger/Views/LogTabView.axaml.cs +3 -3
@@ 12,12 12,12 @@ using PropertyChanged;
namespace PacketLogger.Views;

[DoNotNotify]
public partial class LogTab : UserControl
public partial class LogTabView : UserControl
{
    /// <summary>
    /// Initializes a new instance of the <see cref="LogTab"/> class.
    /// Initializes a new instance of the <see cref="LogTabView"/> class.
    /// </summary>
    public LogTab()
    public LogTabView()
    {
        InitializeComponent();
    }

M src/PacketLogger/Views/PacketLogDocumentView.axaml => src/PacketLogger/Views/PacketLogDocumentView.axaml +73 -6
@@ 5,17 5,84 @@
             xmlns:views="clr-namespace:PacketLogger.Views"
             xmlns:viewModels="clr-namespace:PacketLogger.ViewModels"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
             x:Class="PacketLogger.Views.PacketLogDocumentView">
    <Design.DataContext>
        <viewModels:PacketLogDocumentViewModel />
    </Design.DataContext>

    <Grid>
        <Grid IsVisible="{Binding !Loaded}">
            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                <Button Content="Open File" IsEnabled="{Binding !Loading}" Command="{Binding OpenFile}"></Button>
                <Button Content="Open Dummy" IsEnabled="{Binding !Loading}" Command="{Binding OpenDummy}"></Button>
            </StackPanel>
        </Grid>
        <Border IsVisible="{Binding !Loaded}"
                MaxWidth="800" MaxHeight="600"
                CornerRadius="25"
                Background="{DynamicResource SystemControlPageBackgroundChromeLowBrush}">
            <Grid Margin="50">
                <Grid ColumnDefinitions="*,*" RowDefinitions="60, 80, 80, *">
                    <Grid.Styles>
                        <Style Selector="Button.open">
                            <Setter Property="FontSize" Value="24"></Setter>
                            <Setter Property="Width" Value="200" />
                            <Setter Property="Height" Value="60" />
                            <Setter Property="Margin" Value="0" />
                        </Style>
                        <Style Selector="Button.open i|Icon">
                            <Setter Property="Margin" Value="0,0,5,0"></Setter>
                        </Style>
                        <Style Selector="Button.open TextBlock">
                            <Setter Property="Margin" Value="5, 0, 0, 0"></Setter>
                        </Style>
                        <Style Selector="Button.open Border">
                            <Setter Property="BorderThickness" Value="1" />
                            <Setter Property="BorderBrush" Value="{DynamicResource TextControlForeground}"></Setter>
                        </Style>
                    </Grid.Styles>

                    <TextBlock Grid.Row="0" Grid.Column="0" Margin="-10,0,0,0" FontSize="34" Text="Packet Logger" />

                    <Button Grid.Row="1" Grid.Column="0"
                            Classes="open"
                            IsEnabled="{Binding !Loading}"
                            Command="{Binding OpenFile}">
                        <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                            <i:Icon HorizontalAlignment="Left" Value="mdi-file-document-outline" />
                            <Border></Border>
                            <TextBlock HorizontalAlignment="Right" Text="Open File" />
                        </StackPanel>
                    </Button>
                    <Button Grid.Row="2" Grid.Column="0"
                            Classes="open"
                            IsEnabled="{Binding !Loading}"
                            Command="{Binding OpenDummy}">
                        <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                            <i:Icon HorizontalAlignment="Left" Value="mdi-file-document-plus-outline" />
                            <Border></Border>
                            <TextBlock HorizontalAlignment="Right" Text="Open Empty" />
                        </StackPanel>
                    </Button>

                    <StackPanel Grid.Row="3" Grid.Column="0" Orientation="Vertical">
                        <TextBlock FontSize="30" Margin="0,0,0,5" Text="Connect to NosTale process" />
                        <DataGrid Margin="0,0,30,0" Items="{Binding Processes}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Character" Binding="{Binding CharacterString}" />
                                <DataGridTextColumn Header="Process" Binding="{Binding ProcessString}" />
                                <DataGridTemplateColumn Header="Connect">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Connect" />
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </StackPanel>

                    <TextBlock Grid.Row="0" Grid.Column="1" FontSize="34" Margin="-10,0,0,0" Text="Packet Sender" />
                    
                    <TextBlock Grid.Row="1" Grid.Column="1" Text="To be implemented..." />
                </Grid>
            </Grid>
        </Border>

        <ContentControl IsVisible="{Binding Loaded}" Content="{Binding  LogViewModel}" />
    </Grid>

Do not follow this link