mirror of
https://github.com/2dust/v2rayN.git
synced 2026-09-22 22:38:10 +03:00
* Interaction * Remove view action * ViewModel-first * MainGirdOrientation Hot Reload * Fix avalonia preview * Remove CloseWindowInteraction * Fix * Avoid threading issues * Fix * ProfilesSelect * Try fix previewer * Remove AppEvents.ProfilesRefreshRequested * Remove AppEvents.SubscriptionsRefreshRequested * Remove AppEvents.ProxiesReloadRequested * Remove AppEvents.AdjustMainLvColWidthRequested * Remove AppEvents.SetDefaultServerRequested * Remove AppEvents.RoutingsMenuRefreshRequested * Remove AppEvents.TestServerRequested * Remove AppEvents.InboundDisplayRequested * Remove AppEvents.SubscriptionsUpdateRequested * Remove AppEvents.ShowHideWindowRequested * Remove AppEvents.ReloadRequested * Remove AppEvents.AddServerRequested * Fix
86 lines
2.5 KiB
C#
86 lines
2.5 KiB
C#
using v2rayN.Desktop.Common;
|
|
|
|
namespace v2rayN.Desktop.Views;
|
|
|
|
public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
|
{
|
|
//private const int KeepLines = 30;
|
|
|
|
public MsgView()
|
|
{
|
|
InitializeComponent();
|
|
txtMsg.TextArea.TextView.Options.EnableHyperlinks = false;
|
|
|
|
this.WhenActivated(disposables =>
|
|
{
|
|
this.Bind(ViewModel, vm => vm.MsgFilter, v => v.cmbMsgFilter.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
|
|
|
|
ViewModel.DispatcherShowMsgInteraction.RegisterHandler(interaction =>
|
|
{
|
|
var msg = interaction.Input;
|
|
Dispatcher.UIThread.Post(() => ShowMsg(msg),
|
|
DispatcherPriority.ApplicationIdle);
|
|
interaction.SetOutput(Unit.Default);
|
|
}).DisposeWith(disposables);
|
|
});
|
|
|
|
TextEditorKeywordHighlighter.Attach(txtMsg, Global.LogLevelColors.ToDictionary(
|
|
kv => kv.Key,
|
|
kv => (IBrush)new SolidColorBrush(Color.Parse(kv.Value))
|
|
));
|
|
}
|
|
|
|
private void ShowMsg(object msg)
|
|
{
|
|
//var lineCount = txtMsg.LineCount;
|
|
//if (lineCount > ViewModel?.NumMaxMsg)
|
|
//{
|
|
// var cutLine = txtMsg.Document.GetLineByNumber(lineCount - KeepLines);
|
|
// txtMsg.Document.Remove(0, cutLine.Offset);
|
|
//}
|
|
if (txtMsg.LineCount > ViewModel?.NumMaxMsg)
|
|
{
|
|
ClearMsg();
|
|
}
|
|
|
|
txtMsg.AppendText(msg.ToString());
|
|
if (togScrollToEnd.IsChecked ?? true)
|
|
{
|
|
txtMsg.ScrollToEnd();
|
|
}
|
|
}
|
|
|
|
public void ClearMsg()
|
|
{
|
|
txtMsg.Clear();
|
|
txtMsg.AppendText("----- Message cleared -----\n");
|
|
}
|
|
|
|
private void menuMsgViewSelectAll_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
Dispatcher.UIThread.Post(() =>
|
|
{
|
|
txtMsg.TextArea.Focus();
|
|
txtMsg.SelectAll();
|
|
}, DispatcherPriority.Render);
|
|
}
|
|
|
|
private async void menuMsgViewCopy_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
var data = txtMsg.SelectedText.TrimEx();
|
|
await AvaUtils.SetClipboardData(this, data);
|
|
}
|
|
|
|
private async void menuMsgViewCopyAll_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
var data = txtMsg.Text.TrimEx();
|
|
await AvaUtils.SetClipboardData(this, data);
|
|
}
|
|
|
|
private void menuMsgViewClear_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
ClearMsg();
|
|
}
|
|
}
|