Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Modules/PSO2Logger.Modules.Chat/Behaviors/DataGridBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
namespace PSO2Logger.Modules.Chat.Behaviors {
class DataGridBehavior {
public static readonly DependencyProperty AutoscrollProperty = DependencyProperty.RegisterAttached(
"Autoscroll", typeof(bool), typeof(DataGridBehavior), new PropertyMetadata(default(bool), OnAutoScrollPropertyChanged));
"Autoscroll",
typeof(bool),
typeof(DataGridBehavior),
new PropertyMetadata(default(bool), OnAutoScrollPropertyChanged)
);

private static readonly Dictionary<DataGrid, NotifyCollectionChangedEventHandler> handlersDict = new Dictionary<DataGrid, NotifyCollectionChangedEventHandler>();
private static readonly Dictionary<DataGrid, NotifyCollectionChangedEventHandler> handlersDict = new();

private static void OnAutoScrollPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) {
var dataGrid = dependencyObject as DataGrid;
if (dataGrid == null) {
if (dependencyObject is not DataGrid dataGrid) {
throw new InvalidOperationException("Dependency object is not DataGrid.");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PSO2Logger.Models;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PSO2Logger.Modules.Chat.Converters {
class ChatTypeColorConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return value switch {
ChatType.PUBLIC => Color.White.Name,
ChatType.PARTY => "#53A2BA",
ChatType.GUILD => "#CECA66",
ChatType.REPLY => "#BA536E",
ChatType.GROUP => "#53BA85",
_ => Color.White.ToString(),
};
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
}
15 changes: 15 additions & 0 deletions Modules/PSO2Logger.Modules.Chat/Core/DefaultChatColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSO2Logger.Modules.Chat.Core {
static class DefaultChatColor {
readonly static string PublicChat = "White";
readonly static string PartyChat = "Blue";
readonly static string TeamChat = "Yellow";
readonly static string WhisperChat = "Cyan";
readonly static string GroupChat = "Green";
}
}
20 changes: 0 additions & 20 deletions Modules/PSO2Logger.Modules.Chat/Interfaces/IChatDataStore.cs

This file was deleted.

1 change: 0 additions & 1 deletion Modules/PSO2Logger.Modules.Chat/Models/ChatDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSO2Logger.Modules.Chat.Models {
Expand Down
28 changes: 28 additions & 0 deletions Modules/PSO2Logger.Modules.Chat/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace PSO2Logger.Modules.Chat.Properties {


// このクラスでは設定クラスでの特定のイベントを処理することができます:
// SettingChanging イベントは、設定値が変更される前に発生します。
// PropertyChanged イベントは、設定値が変更された後に発生します。
// SettingsLoaded イベントは、設定値が読み込まれた後に発生します。
// SettingsSaving イベントは、設定値が保存される前に発生します。
internal sealed partial class Settings {

public Settings() {
// // 設定の保存と変更のイベント ハンドラーを追加するには、以下の行のコメントを解除します:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}

private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// SettingChangingEvent イベントを処理するコードをここに追加してください。
}

private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// SettingsSaving イベントを処理するコードをここに追加してください。
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using PSO2Logger.Core;
using Prism.Mvvm;
using PSO2Logger.Interfaces;
using PSO2Logger.Models;
using PSO2Logger.Modules.Chat.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows.Data;

namespace PSO2Logger.Modules.Chat.ViewModels {
Expand All @@ -20,7 +13,37 @@ public class CombinedChatViewModel : BindableBase {
public ObservableCollection<ChatLine> PartyChats { get; set; }
public ObservableCollection<ChatLine> TeamChats { get; set; }
public ObservableCollection<ChatLine> WhisperChats { get; set; }
public ObservableCollection<ChatLine> GroupChats { get; set; }
public ObservableCollection<ChatLine> GroupChats { get; set; }

private string _publicChatColor;
public string PublicChatColor {
get { return _publicChatColor; }
set { SetProperty(ref _publicChatColor, value); }
}

private string _partyChatColor;
public string PartyChatColor {
get { return _partyChatColor; }
set { SetProperty(ref _partyChatColor, value); }
}

private string _teamChatColor;
public string TeamChatColor {
get { return _teamChatColor; }
set { SetProperty(ref _teamChatColor, value); }
}

private string _whisperChatColor;
public string WhisperChatColor {
get { return _whisperChatColor; }
set { SetProperty(ref _whisperChatColor, value); }
}

private string _groupChatColor;
public string GroupChatColor {
get { return _groupChatColor; }
set { SetProperty(ref _groupChatColor, value); }
}

public CombinedChatViewModel(ILogService<ChatLine> logService, IWatcherService watcherService) {
chatDataStore = new ChatDataStore(logService, watcherService);
Expand Down
131 changes: 55 additions & 76 deletions Modules/PSO2Logger.Modules.Chat/Views/CombinedChat.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,58 @@
mc:Ignorable="d"
xmlns:prism="http://prismlibrary.com/"
xmlns:core="clr-namespace:PSO2Logger.Core;assembly=PSO2Logger.Core"
xmlns:model="clr-namespace:PSO2Logger.Models;assembly=PSO2Logger.Models"
xmlns:behavior="clr-namespace:PSO2Logger.Modules.Chat.Behaviors"
xmlns:converter="clr-namespace:PSO2Logger.Modules.Chat.Converters"
prism:ViewModelLocator.AutoWireViewModel="True">

<UserControl.Resources>
<!-- Converters -->
<converter:ChatTypeColorConverter x:Key="ChatTypeColorConverter" />

<!-- Style and template for the DataGrid -->
<Style TargetType="DataGrid" BasedOn="{StaticResource MaterialDesignDataGrid}">
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="CanUserResizeColumns" Value="False" />
<Setter Property="behavior:DataGridBehavior.Autoscroll" Value="True" />
<Setter Property="AutoGenerateColumns" Value="False" />
</Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource MahApps.Styles.Hyperlink.DataGrid}">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="TextWrapping" Value="Wrap" />

<!-- Style and template for the DataGridColumnHeader. -->
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!-- Style and template for the DataGridCellTemplate -->
<Style TargetType="DataGridCell" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<StackPanel VerticalAlignment="Stretch">
<DockPanel LastChildFill="True">
<TextBlock x:Name="PlayerIDName"
Text="{Binding PlayerIDName}"
TextWrapping="Wrap"
Foreground="{Binding ChatType, Converter={StaticResource ChatTypeColorConverter}}"/>
<TextBlock DockPanel.Dock="Right"
HorizontalAlignment="Right"
Text="{Binding TimeStamp, StringFormat={}{0:tt hh:mm}}"
Foreground="{Binding Foreground ,ElementName=PlayerIDName}"/>
</DockPanel>
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0"
TextWrapping="Wrap"
Foreground="{Binding Foreground ,ElementName=PlayerIDName}"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>

Expand All @@ -31,104 +70,44 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!-- PublicChat -->
<DataGrid Grid.Column="0"
ItemsSource="{Binding PublicChats}"
Name="PUBLIC" >
Name="PUBLIC">
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock Text="{Binding PlayerIDName}" />
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"/>
</DataGrid.Columns>
</DataGrid>
<!-- PartyChat -->
<DataGrid Grid.Column="1"
ItemsSource="{Binding PartyChats}"
Name="PARTY">
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock Text="{Binding PlayerIDName}" />
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"/>
</DataGrid.Columns>
</DataGrid>
<!-- TeamChat -->
<DataGrid Grid.Column="2"
ItemsSource="{Binding TeamChats}"
Name="TEAM" >
Name="TEAM">
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock Text="{Binding PlayerIDName}" />
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"/>
</DataGrid.Columns>
</DataGrid>
<!-- WhisperChat -->
<DataGrid Grid.Column="3"
ItemsSource="{Binding WhisperChats}"
Name="WHISPER">
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock Text="{Binding PlayerIDName}" />
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"/>
</DataGrid.Columns>
</DataGrid>
<!-- GroupChat -->
<DataGrid Grid.Column="4"
ItemsSource="{Binding GroupChats}"
Name="GROUP" >
Name="GROUP">
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=Name}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock Text="{Binding PlayerIDName}" />
<TextBlock Text="{Binding ChatBody}"
Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PSO2Logger.Core\PSO2Logger.Core.csproj" />
<ProjectReference Include="..\..\PSO2Logger.Services\PSO2Logger.Services.csproj" />
</ItemGroup>
</Project>
Loading