From 1c64e3b4d60e1a82d78d878c1fac1a61cc95093f Mon Sep 17 00:00:00 2001 From: Rutherther Date: Thu, 2 Feb 2023 17:55:24 +0100 Subject: [PATCH] feat: add data grid with process selection to new document tab --- src/PacketLogger/PacketLogger.csproj | 2 + .../ViewModels/PacketLogDocumentViewModel.cs | 13 ++- src/PacketLogger/Views/LogTabView.axaml | 2 +- src/PacketLogger/Views/LogTabView.axaml.cs | 6 +- .../Views/PacketLogDocumentView.axaml | 79 +++++++++++++++++-- 5 files changed, 91 insertions(+), 11 deletions(-) diff --git a/src/PacketLogger/PacketLogger.csproj b/src/PacketLogger/PacketLogger.csproj index dde61b1..fee625d 100644 --- a/src/PacketLogger/PacketLogger.csproj +++ b/src/PacketLogger/PacketLogger.csproj @@ -27,6 +27,8 @@ + + diff --git a/src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs b/src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs index 933f68e..b1c55a5 100644 --- a/src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs +++ b/src/PacketLogger/ViewModels/PacketLogDocumentViewModel.cs @@ -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; /// public class PacketLogDocumentViewModel : Document, INotifyPropertyChanged { + private readonly NostaleProcesses _processes; + /// /// Initializes a new instance of the class. /// - public PacketLogDocumentViewModel() + /// The NosTale processes collection. + public PacketLogDocumentViewModel(NostaleProcesses processes) { + _processes = processes; OpenDummy = ReactiveCommand.CreateFromTask ( () => Task.Run(() => @@ -73,6 +79,11 @@ public class PacketLogDocumentViewModel : Document, INotifyPropertyChanged ); } + /// + /// Gets the processes observable. + /// + public ObservableCollection Processes => _processes.Processes; + /// /// Gets or sets the name of the tab. /// diff --git a/src/PacketLogger/Views/LogTabView.axaml b/src/PacketLogger/Views/LogTabView.axaml index d9cd529..4ce189c 100644 --- a/src/PacketLogger/Views/LogTabView.axaml +++ b/src/PacketLogger/Views/LogTabView.axaml @@ -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" diff --git a/src/PacketLogger/Views/LogTabView.axaml.cs b/src/PacketLogger/Views/LogTabView.axaml.cs index 9b9d7dd..7516baf 100644 --- a/src/PacketLogger/Views/LogTabView.axaml.cs +++ b/src/PacketLogger/Views/LogTabView.axaml.cs @@ -12,12 +12,12 @@ using PropertyChanged; namespace PacketLogger.Views; [DoNotNotify] -public partial class LogTab : UserControl +public partial class LogTabView : UserControl { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public LogTab() + public LogTabView() { InitializeComponent(); } diff --git a/src/PacketLogger/Views/PacketLogDocumentView.axaml b/src/PacketLogger/Views/PacketLogDocumentView.axaml index 27fb008..e5834a6 100644 --- a/src/PacketLogger/Views/PacketLogDocumentView.axaml +++ b/src/PacketLogger/Views/PacketLogDocumentView.axaml @@ -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"> + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +