mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Persist message auto-scroll setting
This commit is contained in:
parent
e6f1efd4f4
commit
9326a4ad79
4 changed files with 17 additions and 5 deletions
|
|
@ -83,6 +83,7 @@ public class MsgUIItem
|
|||
{
|
||||
public string? MainMsgFilter { get; set; }
|
||||
public bool? AutoRefresh { get; set; }
|
||||
public bool? AutoScrollToEnd { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
|
|||
|
|
@ -13,21 +13,30 @@ public class MsgViewModel : MyReactiveObject
|
|||
[Reactive]
|
||||
public bool AutoRefresh { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool AutoScrollToEnd { get; set; }
|
||||
|
||||
public MsgViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppManager.Instance.Config;
|
||||
_updateView = updateView;
|
||||
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
|
||||
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
||||
AutoScrollToEnd = _config.MsgUIItem.AutoScrollToEnd ?? true;
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.MsgFilter)
|
||||
.Subscribe(c => DoMsgFilter());
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.AutoRefresh,
|
||||
y => y == true)
|
||||
.Subscribe(c => _config.MsgUIItem.AutoRefresh = AutoRefresh);
|
||||
x => x.AutoRefresh,
|
||||
y => y == true)
|
||||
.Subscribe(c => _config.MsgUIItem.AutoRefresh = AutoRefresh);
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.AutoScrollToEnd,
|
||||
y => y == true)
|
||||
.Subscribe(c => _config.MsgUIItem.AutoScrollToEnd = AutoScrollToEnd);
|
||||
|
||||
AppEvents.SendMsgViewRequested
|
||||
.AsObservable()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
|||
{
|
||||
this.Bind(ViewModel, vm => vm.MsgFilter, v => v.cmbMsgFilter.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoScrollToEnd, v => v.togScrollToEnd.IsChecked).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
TextEditorKeywordHighlighter.Attach(txtMsg, Global.LogLevelColors.ToDictionary(
|
||||
|
|
@ -55,7 +56,7 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
|||
}
|
||||
|
||||
txtMsg.AppendText(msg.ToString());
|
||||
if (togScrollToEnd.IsChecked ?? true)
|
||||
if (ViewModel?.AutoScrollToEnd == true)
|
||||
{
|
||||
txtMsg.ScrollToEnd();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public partial class MsgView
|
|||
{
|
||||
this.Bind(ViewModel, vm => vm.MsgFilter, v => v.cmbMsgFilter.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoScrollToEnd, v => v.togScrollToEnd.IsChecked).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
btnCopy.Click += menuMsgViewCopyAll_Click;
|
||||
|
|
@ -51,7 +52,7 @@ public partial class MsgView
|
|||
}
|
||||
|
||||
txtMsg.AppendText(msg.ToString());
|
||||
if (togScrollToEnd.IsChecked ?? true)
|
||||
if (ViewModel?.AutoScrollToEnd == true)
|
||||
{
|
||||
txtMsg.ScrollToEnd();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue