-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
266 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System.Windows.Controls; | ||
|
||
namespace clashN | ||
namespace clashN | ||
{ | ||
class Global | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using ReactiveUI; | ||
using ReactiveUI.Fody.Helpers; | ||
|
||
namespace clashN.ViewModels | ||
{ | ||
public class LogsViewModel : ReactiveObject | ||
{ | ||
[Reactive] | ||
public int SortingSelected { get; set; } | ||
[Reactive] | ||
public bool AutoRefresh { get; set; } | ||
[Reactive] | ||
public string MsgFilter { get; set; } | ||
[Reactive] | ||
public int LineCount { get; set; } | ||
|
||
public LogsViewModel() | ||
{ | ||
AutoRefresh = true; | ||
MsgFilter = string.Empty; | ||
LineCount = 1000; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<reactiveui:ReactiveUserControl | ||
x:Class="clashN.Views.LogsView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:clashN.Views" | ||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:reactiveui="http://reactiveui.net" | ||
xmlns:resx="clr-namespace:clashN.Resx" | ||
xmlns:vms="clr-namespace:clashN.ViewModels" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
x:TypeArguments="vms:LogsViewModel" | ||
mc:Ignorable="d"> | ||
<DockPanel Margin="8"> | ||
<StackPanel | ||
Margin="8,0,8,8" | ||
HorizontalAlignment="Left" | ||
DockPanel.Dock="Top" | ||
Orientation="Horizontal"> | ||
<TextBlock Style="{StaticResource ModuleTitle}" Text="{x:Static resx:ResUI.TbLogs}" /> | ||
</StackPanel> | ||
<ToolBarTray Margin="0,8,0,8" DockPanel.Dock="Top"> | ||
<ToolBar ClipToBounds="True" Style="{StaticResource MaterialDesignToolBar}"> | ||
<Button Width="1" Visibility="Hidden"> | ||
<materialDesign:PackIcon Kind="ContentSave" /> | ||
</Button> | ||
<TextBlock | ||
VerticalAlignment="Center" | ||
Style="{StaticResource ToolbarItem}" | ||
Text="{x:Static resx:ResUI.TbFilter}" /> | ||
<TextBox | ||
x:Name="txtFilter" | ||
Width="200" | ||
Margin="8" /> | ||
<Separator /> | ||
<Button x:Name="btnDelete" Click="btnDelete_Click"> | ||
<StackPanel Orientation="Horizontal"> | ||
<materialDesign:PackIcon Kind="Delete" /> | ||
</StackPanel> | ||
</Button> | ||
<Separator /> | ||
<TextBlock | ||
VerticalAlignment="Center" | ||
Style="{StaticResource ToolbarItem}" | ||
Text="{x:Static resx:ResUI.TbAutoRefresh}" /> | ||
<ToggleButton | ||
x:Name="togAutoRefresh" | ||
Margin="8" | ||
HorizontalAlignment="Left" /> | ||
<Separator /> | ||
<TextBlock | ||
VerticalAlignment="Center" | ||
Style="{StaticResource ToolbarItem}" | ||
Text="{x:Static resx:ResUI.TbLineCount}" /> | ||
<ComboBox | ||
x:Name="cmbLineCount" | ||
Width="80" | ||
Margin="8" | ||
Style="{StaticResource DefComboBox}"> | ||
<ComboBoxItem Content="1000" /> | ||
<ComboBoxItem Content="2000" /> | ||
<ComboBoxItem Content="3000" /> | ||
</ComboBox> | ||
</ToolBar> | ||
</ToolBarTray> | ||
<TextBox | ||
Name="txtMsg" | ||
BorderThickness="0" | ||
FontSize="11" | ||
HorizontalScrollBarVisibility="Auto" | ||
IsReadOnly="True" | ||
TextWrapping="Wrap" | ||
VerticalScrollBarVisibility="Visible" /> | ||
</DockPanel> | ||
|
||
</reactiveui:ReactiveUserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using clashN.ViewModels; | ||
using ReactiveUI; | ||
using System.Reactive.Disposables; | ||
using System.Text.RegularExpressions; | ||
using System.Windows; | ||
using System.Windows.Threading; | ||
|
||
namespace clashN.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for LogsView.xaml | ||
/// </summary> | ||
public partial class LogsView | ||
{ | ||
|
||
public LogsView() | ||
{ | ||
InitializeComponent(); | ||
ViewModel = new LogsViewModel(); | ||
|
||
MessageBus.Current.Listen<string>("MsgView").Subscribe(x => DelegateAppendText(x)); | ||
|
||
this.WhenActivated(disposables => | ||
{ | ||
this.Bind(ViewModel, vm => vm.MsgFilter, v => v.txtFilter.Text).DisposeWith(disposables); | ||
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables); | ||
this.Bind(ViewModel, vm => vm.LineCount, v => v.cmbLineCount.Text).DisposeWith(disposables); | ||
}); | ||
} | ||
|
||
|
||
void DelegateAppendText(string msg) | ||
{ | ||
Dispatcher.BeginInvoke(new Action<string>(AppendText), DispatcherPriority.Send, msg); | ||
} | ||
|
||
public void AppendText(string msg) | ||
{ | ||
if (ViewModel?.AutoRefresh == false) | ||
{ | ||
return; | ||
} | ||
string? msgFilter = ViewModel?.MsgFilter; | ||
if (!Utils.IsNullOrEmpty(msgFilter)) | ||
{ | ||
if (!Regex.IsMatch(msg, msgFilter)) | ||
{ | ||
return; | ||
} | ||
} | ||
|
||
ShowMsg(msg); | ||
} | ||
|
||
private void ShowMsg(string msg) | ||
{ | ||
if (txtMsg.LineCount > ViewModel?.LineCount) | ||
{ | ||
ClearMsg(); | ||
} | ||
this.txtMsg.AppendText(msg); | ||
if (!msg.EndsWith(Environment.NewLine)) | ||
{ | ||
this.txtMsg.AppendText(Environment.NewLine); | ||
} | ||
txtMsg.ScrollToEnd(); | ||
} | ||
|
||
public void ClearMsg() | ||
{ | ||
Dispatcher.Invoke((Action)(() => | ||
{ | ||
txtMsg.Clear(); | ||
})); | ||
} | ||
|
||
private void btnDelete_Click(object sender, RoutedEventArgs e) | ||
{ | ||
ClearMsg(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.