Beautified RPC Log
This commit is contained in:
parent
6ce57b90ca
commit
8df1154cc4
6 changed files with 119 additions and 18 deletions
|
@ -8,7 +8,7 @@ namespace WeeXnes.Core
|
||||||
{
|
{
|
||||||
public class Information
|
public class Information
|
||||||
{
|
{
|
||||||
public const string Version = "4.2.3";
|
public const string Version = "4.2.5";
|
||||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||||
}
|
}
|
||||||
|
|
50
WeeXnes/Core/RpcLogEvents.cs
Normal file
50
WeeXnes/Core/RpcLogEvents.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
namespace WeeXnes.Core
|
||||||
|
{
|
||||||
|
public enum EventType
|
||||||
|
{
|
||||||
|
ProcessStartedEvent,
|
||||||
|
ProcessStoppedEvent,
|
||||||
|
RPCUpdateEvent,
|
||||||
|
RPCReadyEvent
|
||||||
|
}
|
||||||
|
public class customEvent
|
||||||
|
{
|
||||||
|
|
||||||
|
public string Content { get; set; }
|
||||||
|
public EventType Type { get; set; }
|
||||||
|
|
||||||
|
public string GradientColor1 { get; set; }
|
||||||
|
public string GradientColor2 { get; set; }
|
||||||
|
public customEvent(string content, EventType type)
|
||||||
|
{
|
||||||
|
this.Content = content;
|
||||||
|
this.Type = type;
|
||||||
|
if (this.Type == EventType.ProcessStartedEvent)
|
||||||
|
{
|
||||||
|
this.GradientColor1 = "#46db69";
|
||||||
|
this.GradientColor2 = "#33a34d";
|
||||||
|
}
|
||||||
|
else if (this.Type == EventType.ProcessStoppedEvent)
|
||||||
|
{
|
||||||
|
this.GradientColor1 = "#d1415d";
|
||||||
|
this.GradientColor2 = "#a33349";
|
||||||
|
}
|
||||||
|
else if (this.Type == EventType.RPCUpdateEvent)
|
||||||
|
{
|
||||||
|
this.GradientColor1 = "#3e65c9";
|
||||||
|
this.GradientColor2 = "#3352a3";
|
||||||
|
}
|
||||||
|
else if (this.Type == EventType.RPCReadyEvent)
|
||||||
|
{
|
||||||
|
this.GradientColor1 = "#c93eb4";
|
||||||
|
this.GradientColor2 = "#a33389";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return this.Content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ using DiscordRPC.Message;
|
||||||
using Nocksoft.IO.ConfigFiles;
|
using Nocksoft.IO.ConfigFiles;
|
||||||
using WeeXnes.Core;
|
using WeeXnes.Core;
|
||||||
using WeeXnes.Views.Settings;
|
using WeeXnes.Views.Settings;
|
||||||
|
using EventType = WeeXnes.Core.EventType;
|
||||||
|
|
||||||
namespace WeeXnes.Views.DiscordRPC
|
namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
|
@ -88,7 +89,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
this.IsRunning = true;
|
this.IsRunning = true;
|
||||||
//Console.WriteLine("Process started");
|
//Console.WriteLine("Process started");
|
||||||
RunRPCView.Data.LogCache.Value = this.ProcessName + " is running";
|
RunRPCView.Data.LogCache.Value = new customEvent("[" + this.ProcessName + ".exe] ➜ is running", EventType.ProcessStartedEvent);
|
||||||
|
|
||||||
if (!this.PresenceClient.IsInitialized)
|
if (!this.PresenceClient.IsInitialized)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +115,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
this.IsRunning = false;
|
this.IsRunning = false;
|
||||||
//Console.WriteLine("Process stopped");
|
//Console.WriteLine("Process stopped");
|
||||||
RunRPCView.Data.LogCache.Value = this.ProcessName + " stopped running";
|
RunRPCView.Data.LogCache.Value = new customEvent("[" + this.ProcessName + ".exe] ➜ stopped running", EventType.ProcessStoppedEvent);
|
||||||
if (this.PresenceClient.IsInitialized)
|
if (this.PresenceClient.IsInitialized)
|
||||||
{
|
{
|
||||||
this.PresenceClient.ClearPresence();
|
this.PresenceClient.ClearPresence();
|
||||||
|
@ -126,13 +127,14 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
private void PresenceClientOnOnPresenceUpdate(object sender, PresenceMessage args)
|
private void PresenceClientOnOnPresenceUpdate(object sender, PresenceMessage args)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name);
|
//Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name);
|
||||||
RunRPCView.Data.LogCache.Value = "[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name;
|
RunRPCView.Data.LogCache.Value = new customEvent("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name, EventType.RPCUpdateEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PresenceClientOnOnReady(object sender, ReadyMessage args)
|
private void PresenceClientOnOnReady(object sender, ReadyMessage args)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username);
|
//Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username);
|
||||||
RunRPCView.Data.LogCache.Value = "[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username;
|
RunRPCView.Data.LogCache.Value =
|
||||||
|
new customEvent("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username, EventType.RPCReadyEvent);
|
||||||
}
|
}
|
||||||
public void CheckState(Process[] processes)
|
public void CheckState(Process[] processes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,12 +24,54 @@
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardAction>
|
</ui:CardAction>
|
||||||
<RichTextBox Grid.Row="1" Name="RichTextBoxRPCLog" IsReadOnly="True">
|
<ScrollViewer Grid.Row="1" Name="LogViewer">
|
||||||
<RichTextBox.Resources>
|
<ItemsControl Grid.Row="1" Name="RpcLogView" Loaded="RpcLogView_OnLoaded" Margin="0,0,0,0">
|
||||||
<Style TargetType="{x:Type Paragraph}">
|
<ItemsControl.ItemTemplate>
|
||||||
<Setter Property="Margin" Value="0"/>
|
<DataTemplate>
|
||||||
</Style>
|
<StackPanel Orientation="Vertical">
|
||||||
</RichTextBox.Resources>
|
|
||||||
</RichTextBox>
|
<Border Height="30" CornerRadius="4" Margin="0,3,0,0" Name="ParentBorder"
|
||||||
|
Opacity="0">
|
||||||
|
<Border.Triggers>
|
||||||
|
|
||||||
|
<!-- Animate the button's Width property. -->
|
||||||
|
<EventTrigger RoutedEvent="Border.Loaded">
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<DoubleAnimation
|
||||||
|
Storyboard.TargetName="ParentBorder"
|
||||||
|
Storyboard.TargetProperty="(Border.Opacity)"
|
||||||
|
To="1" Duration="0:0:00.5" AutoReverse="False"
|
||||||
|
/>
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</EventTrigger>
|
||||||
|
|
||||||
|
</Border.Triggers>
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush StartPoint="0 0" EndPoint="1 1">
|
||||||
|
<LinearGradientBrush.GradientStops>
|
||||||
|
<GradientStop Offset="0" Color="{Binding GradientColor1}" />
|
||||||
|
<GradientStop Offset="1" Color="{Binding GradientColor2}" />
|
||||||
|
</LinearGradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
<TextBlock Margin="5 0" Text="{Binding Content}" FontSize="12"
|
||||||
|
Foreground="White"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Padding="10,0,0,0">
|
||||||
|
|
||||||
|
<TextBlock.Effect>
|
||||||
|
<DropShadowEffect ShadowDepth="1"/>
|
||||||
|
|
||||||
|
</TextBlock.Effect>
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
|
@ -12,7 +12,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
public static class Data
|
public static class Data
|
||||||
{
|
{
|
||||||
public static UpdateVar<string> LogCache = new UpdateVar<string>();
|
public static UpdateVar<customEvent> LogCache = new UpdateVar<customEvent>();
|
||||||
}
|
}
|
||||||
BackgroundWorker backgroundWorker = new BackgroundWorker();
|
BackgroundWorker backgroundWorker = new BackgroundWorker();
|
||||||
public RunRPCView()
|
public RunRPCView()
|
||||||
|
@ -36,8 +36,8 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
Console.WriteLine("Log Write Data: " + Data.LogCache.Value);
|
Console.WriteLine("Log Write Data: " + Data.LogCache.Value);
|
||||||
this.Dispatcher.Invoke(() =>
|
this.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
RichTextBoxRPCLog.AppendText(Data.LogCache.Value + "\n");
|
RpcLogView.Items.Add(Data.LogCache.Value);
|
||||||
RichTextBoxRPCLog.ScrollToEnd();
|
LogViewer.ScrollToEnd();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
|
|
||||||
private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs e)
|
private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
Data.LogCache.Value = "RPC Thread is running";
|
Data.LogCache.Value = new customEvent("[INFO] RPC Thread is running", EventType.ProcessStartedEvent);
|
||||||
bool runWorker = true;
|
bool runWorker = true;
|
||||||
while (runWorker)
|
while (runWorker)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
foreach (Game game in DiscordRPCView.Data.Games)
|
foreach (Game game in DiscordRPCView.Data.Games)
|
||||||
game.Stop();
|
game.Stop();
|
||||||
Console.WriteLine("Thread Stopped");
|
Console.WriteLine("Thread Stopped");
|
||||||
Data.LogCache.Value = "RPC Thread has stopped";
|
Data.LogCache.Value = new customEvent("[INFO] RPC Thread has stopped", EventType.ProcessStoppedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunRPCView_OnUnloaded(object sender, RoutedEventArgs e)
|
private void RunRPCView_OnUnloaded(object sender, RoutedEventArgs e)
|
||||||
|
@ -112,5 +112,11 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
|
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void RpcLogView_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<Version>4.2.3</Version>
|
<Version>4.2.5</Version>
|
||||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>WeeXnes</RootNamespace>
|
<RootNamespace>WeeXnes</RootNamespace>
|
||||||
|
@ -68,6 +68,7 @@
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Core\EncryptorLibrary.cs" />
|
<Compile Include="Core\EncryptorLibrary.cs" />
|
||||||
<Compile Include="Core\HandleLaunchArguments.cs" />
|
<Compile Include="Core\HandleLaunchArguments.cs" />
|
||||||
|
<Compile Include="Core\RpcLogEvents.cs" />
|
||||||
<Compile Include="Core\SaveSettingsHandler.cs" />
|
<Compile Include="Core\SaveSettingsHandler.cs" />
|
||||||
<Compile Include="Core\WXFile.cs" />
|
<Compile Include="Core\WXFile.cs" />
|
||||||
<Compile Include="Views\DiscordRPC\AddRPCView.xaml.cs">
|
<Compile Include="Views\DiscordRPC\AddRPCView.xaml.cs">
|
||||||
|
|
Loading…
Add table
Reference in a new issue