feat(desktop): right click to send tell
This commit is contained in:
parent
bcbab4dec0
commit
1d07183bf8
|
@ -12,6 +12,7 @@
|
|||
WindowStartupLocation="CenterOwner"
|
||||
Height="400"
|
||||
Width="700"
|
||||
x:Name="Main"
|
||||
Closed="FriendList_OnClosed"
|
||||
d:DataContext="{d:DesignInstance local:FriendList}">
|
||||
<Grid Margin="8">
|
||||
|
@ -31,9 +32,32 @@
|
|||
IsReadOnly="True"
|
||||
CanUserReorderColumns="True"
|
||||
Visibility="{Binding Waiting, Converter={StaticResource InverseBoolToVisibilityConverter}}">
|
||||
<DataGrid.CommandBindings>
|
||||
<CommandBinding Command="local:FriendList.SendTell"
|
||||
Executed="SendTell_Executed"
|
||||
CanExecute="SendTell_CanExecute" />
|
||||
</DataGrid.CommandBindings>
|
||||
|
||||
<DataGrid.Resources>
|
||||
<local:FriendListStatusConverter x:Key="StatusConverter" />
|
||||
|
||||
<ContextMenu x:Key="RowMenu"
|
||||
DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}"
|
||||
d:DataContext="{d:DesignInstance common:Player}">
|
||||
<MenuItem Header="Send tell"
|
||||
Command="local:FriendList.SendTell"
|
||||
CommandParameter="{Binding}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.Resources>
|
||||
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="{x:Type DataGridRow}"
|
||||
BasedOn="{StaticResource DefaultDataGridRowStyle}">
|
||||
<Setter Property="ContextMenu"
|
||||
Value="{StaticResource RowMenu}" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn d:DataContext="{d:DesignInstance common:Player}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
@ -55,22 +79,6 @@
|
|||
Binding="{Binding FreeCompany}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<!-- <ListView Grid.Row="0" -->
|
||||
<!-- ItemsSource="{Binding App.Window.FriendList}" -->
|
||||
<!-- Visibility="{Binding Waiting, Converter={StaticResource InverseBoolToVisibilityConverter}}"> -->
|
||||
<!-- <ListView.View> -->
|
||||
<!-- <GridView> -->
|
||||
<!-- <GridViewColumn Header="Name" -->
|
||||
<!-- DisplayMemberBinding="{Binding Name}" /> -->
|
||||
<!-- <GridViewColumn Header="Job" -->
|
||||
<!-- DisplayMemberBinding="{Binding JobName}" /> -->
|
||||
<!-- <GridViewColumn Header="Location" -->
|
||||
<!-- DisplayMemberBinding="{Binding TerritoryName}" /> -->
|
||||
<!-- <GridViewColumn Header="FC" -->
|
||||
<!-- DisplayMemberBinding="{Binding FreeCompany}" /> -->
|
||||
<!-- </GridView> -->
|
||||
<!-- </ListView.View> -->
|
||||
<!-- </ListView> -->
|
||||
<Button Grid.Row="1"
|
||||
IsEnabled="{Binding App.Connected}"
|
||||
Content="Refresh"
|
||||
|
|
|
@ -5,11 +5,18 @@ using System.Globalization;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using XIVChatCommon;
|
||||
|
||||
namespace XIVChat_Desktop {
|
||||
public partial class FriendList : INotifyPropertyChanged {
|
||||
public static readonly RoutedUICommand SendTell = new RoutedUICommand(
|
||||
"SendTell",
|
||||
"SendTell",
|
||||
typeof(FriendList)
|
||||
);
|
||||
|
||||
public App App => (App)Application.Current;
|
||||
|
||||
private bool waiting;
|
||||
|
@ -31,6 +38,31 @@ namespace XIVChat_Desktop {
|
|||
this.App.Window.FriendList.CollectionChanged += this.OnFriendListChanged;
|
||||
}
|
||||
|
||||
private void SendTell_Executed(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) {
|
||||
if (!(executedRoutedEventArgs.Parameter is Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var input = this.App.Window.GetCurrentInputBox();
|
||||
if (input == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tell = $"/tell {player.Name}@{player.HomeWorldName} ";
|
||||
|
||||
input.Text = input.Text.Insert(0, tell);
|
||||
input.SelectionStart = tell.Length;
|
||||
input.SelectionLength = input.Text.Length - tell.Length;
|
||||
|
||||
this.Close();
|
||||
|
||||
input.Focus();
|
||||
}
|
||||
|
||||
private void SendTell_CanExecute(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = this.App.Connected;
|
||||
}
|
||||
|
||||
private void Refresh_Click(object sender, RoutedEventArgs e) {
|
||||
var conn = this.App.Connection;
|
||||
if (conn == null) {
|
||||
|
|
|
@ -120,14 +120,14 @@
|
|||
Grid.Row="1"
|
||||
Text="{Binding App.Connection.CurrentChannel, ElementName=Main, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBox
|
||||
ui:ControlHelper.PlaceholderText="{Binding InputPlaceholder, ElementName=Main, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding App.Connection.Available, ElementName=Main, UpdateSourceTrigger=PropertyChanged, FallbackValue=False}"
|
||||
Grid.Row="2"
|
||||
Margin="0,0,0,8"
|
||||
TextWrapping="Wrap"
|
||||
SpellCheck.IsEnabled="True"
|
||||
KeyDown="Input_Submit" />
|
||||
<TextBox x:Name="InputBox"
|
||||
ui:ControlHelper.PlaceholderText="{Binding InputPlaceholder, ElementName=Main, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding App.Connection.Available, ElementName=Main, UpdateSourceTrigger=PropertyChanged, FallbackValue=False}"
|
||||
Grid.Row="2"
|
||||
Margin="0,0,0,8"
|
||||
TextWrapping="Wrap"
|
||||
SpellCheck.IsEnabled="True"
|
||||
KeyDown="Input_Submit" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
|
|
|
@ -144,12 +144,10 @@ namespace XIVChat_Desktop {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(sender is TextBox)) {
|
||||
if (!(sender is TextBox textBox)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var textBox = (TextBox)sender;
|
||||
|
||||
conn.SendMessage(textBox.Text);
|
||||
textBox.Text = "";
|
||||
}
|
||||
|
@ -162,6 +160,10 @@ namespace XIVChat_Desktop {
|
|||
this.Tabs.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public TextBox? GetCurrentInputBox() {
|
||||
return this.FindElementByName<TextBox>(this.Tabs, "InputBox");
|
||||
}
|
||||
|
||||
private void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||
var scroller = this.FindElementByName<ScrollViewer>(this.Tabs, "scroller");
|
||||
scroller?.ScrollToBottom();
|
||||
|
|
Loading…
Reference in New Issue