forked from OpenKH/OpenKh
-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
134 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OpenKh.Tools.ModsManager.Interfaces | ||
{ | ||
public interface IDebugging | ||
{ | ||
void HideDebugger(); | ||
void Log(long ms, string tag, string str); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...sManager/Services/IOperationDispatcher.cs → ...anager/Interfaces/IOperationDispatcher.cs
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
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,12 @@ | ||
<Window x:Class="OpenKh.Tools.ModsManager.Views.DebuggingWindow" | ||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.Views" | ||
mc:Ignorable="d" | ||
Title="Debug window" Height="450" Width="800" FontFamily="Courier New" Background="#FF282C34"> | ||
<ScrollViewer> | ||
<StackPanel x:Name="LogPanel"/> | ||
</ScrollViewer> | ||
</Window> |
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,65 @@ | ||
using OpenKh.Tools.ModsManager.Interfaces; | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media; | ||
|
||
namespace OpenKh.Tools.ModsManager.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for DebuggingWindow.xaml | ||
/// </summary> | ||
public partial class DebuggingWindow : Window, IDebugging, INotifyPropertyChanged | ||
{ | ||
private static readonly Brush[] _brushes = new Brush[] | ||
{ | ||
new SolidColorBrush(Color.FromRgb(220, 223, 228)), | ||
new SolidColorBrush(Color.FromRgb(229, 192, 123)), | ||
new SolidColorBrush(Color.FromRgb(224, 108, 117)), | ||
}; | ||
|
||
public DebuggingWindow() | ||
{ | ||
InitializeComponent(); | ||
DataContext = this; | ||
} | ||
|
||
public void ClearLogs() | ||
{ | ||
LogPanel.Children.Clear(); | ||
} | ||
|
||
public void HideDebugger() | ||
{ | ||
Application.Current.Dispatcher.Invoke(Close); | ||
} | ||
|
||
public void Log(long ms, string tag, string message) | ||
{ | ||
Application.Current.Dispatcher.Invoke(() => | ||
{ | ||
var str = $"[{(ms / 1000):D3}.{(ms % 1000):D3}] {tag} {message}"; | ||
var brush = tag switch | ||
{ | ||
"INF" => _brushes[0], | ||
"WRN" => _brushes[1], | ||
"ERR" => _brushes[2], | ||
_ => _brushes[0], | ||
}; | ||
LogPanel.Children.Insert(0, new TextBlock | ||
{ | ||
Text = str, | ||
Foreground = brush | ||
}); | ||
}); | ||
} | ||
|
||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
} | ||
} |