Skip to content

Commit

Permalink
给DanmaOnly增加回车发送弹幕的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jul 3, 2024
1 parent 1b63ac9 commit 9457588
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Desktop/Views/Windows/DanmaOnlyWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBox Name="DanmaOnly_DanmaInput" Grid.Column="0" Margin="10,0,10,4" PlaceholderText="输入弹幕内容" Text="" TextChanged="DanmaOnly_DanmaInput_TextChanged"/>
<ui:TextBox Name="DanmaOnly_DanmaInput" Grid.Column="0" Margin="10,0,10,4" PlaceholderText="输入弹幕内容" Text="" TextChanged="DanmaOnly_DanmaInput_TextChanged" KeyDown="DanmaOnly_DanmaInput_KeyDown"/>
<ui:Button Grid.Column="1" Margin="0,0,10,4" Content="发送" FontSize="20" HorizontalAlignment="Right" Icon="{ui:SymbolIcon Send20}" Click="Send_Danma_Button_Click"/>
</Grid>
</Grid>
Expand Down
14 changes: 14 additions & 0 deletions Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,19 @@ private void DanmaOnly_DanmaInput_TextChanged(object sender, TextChangedEventArg
textBox.SelectionStart = selectionStart > 20 ? 20 : selectionStart;
}
}

private void DanmaOnly_DanmaInput_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyStates == Keyboard.GetKeyStates(Key.Enter))
{
string T = DanmaOnly_DanmaInput.Text;
if (string.IsNullOrEmpty(T) && T.Length > 20)
{
return;
}
Danmu.SendDanmu(roomCard.RoomId.ToString(), T);
DanmaOnly_DanmaInput.Clear();
}
}
}
}
1 change: 0 additions & 1 deletion Desktop/Views/Windows/VlcPlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ private void AddDanmu(string DanmuText, bool IsSubtitle, long uid = 0)
break;
}
}
double b = Core.Init.GetRunTime();
danMuOrbitInfos[Index].Time = (int)(Init.GetRunTime() + 5);
//非UI线程调用UI组件
System.Windows.Application.Current.Dispatcher.Invoke(async () =>
Expand Down

0 comments on commit 9457588

Please sign in to comment.