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 const string Version = "4.2.3";
|
||||
public const string Version = "4.2.5";
|
||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||
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 WeeXnes.Core;
|
||||
using WeeXnes.Views.Settings;
|
||||
using EventType = WeeXnes.Core.EventType;
|
||||
|
||||
namespace WeeXnes.Views.DiscordRPC
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
{
|
||||
this.IsRunning = true;
|
||||
//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)
|
||||
{
|
||||
|
@ -114,7 +115,7 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
{
|
||||
this.IsRunning = false;
|
||||
//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)
|
||||
{
|
||||
this.PresenceClient.ClearPresence();
|
||||
|
@ -126,13 +127,14 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
private void PresenceClientOnOnPresenceUpdate(object sender, PresenceMessage args)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
|
|
|
@ -24,12 +24,54 @@
|
|||
/>
|
||||
</StackPanel>
|
||||
</ui:CardAction>
|
||||
<RichTextBox Grid.Row="1" Name="RichTextBoxRPCLog" IsReadOnly="True">
|
||||
<RichTextBox.Resources>
|
||||
<Style TargetType="{x:Type Paragraph}">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
</Style>
|
||||
</RichTextBox.Resources>
|
||||
</RichTextBox>
|
||||
<ScrollViewer Grid.Row="1" Name="LogViewer">
|
||||
<ItemsControl Grid.Row="1" Name="RpcLogView" Loaded="RpcLogView_OnLoaded" Margin="0,0,0,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Vertical">
|
||||
|
||||
<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>
|
||||
</Page>
|
|
@ -12,7 +12,7 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
{
|
||||
public static class Data
|
||||
{
|
||||
public static UpdateVar<string> LogCache = new UpdateVar<string>();
|
||||
public static UpdateVar<customEvent> LogCache = new UpdateVar<customEvent>();
|
||||
}
|
||||
BackgroundWorker backgroundWorker = new BackgroundWorker();
|
||||
public RunRPCView()
|
||||
|
@ -36,8 +36,8 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
Console.WriteLine("Log Write Data: " + Data.LogCache.Value);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
RichTextBoxRPCLog.AppendText(Data.LogCache.Value + "\n");
|
||||
RichTextBoxRPCLog.ScrollToEnd();
|
||||
RpcLogView.Items.Add(Data.LogCache.Value);
|
||||
LogViewer.ScrollToEnd();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
|
||||
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;
|
||||
while (runWorker)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
foreach (Game game in DiscordRPCView.Data.Games)
|
||||
game.Stop();
|
||||
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)
|
||||
|
@ -112,5 +112,11 @@ namespace WeeXnes.Views.DiscordRPC
|
|||
{
|
||||
NavigationService.Navigate(new Uri("/Views/DiscordRPC/DiscordRPCView.xaml",UriKind.Relative));
|
||||
}
|
||||
|
||||
|
||||
private void RpcLogView_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Version>4.2.3</Version>
|
||||
<Version>4.2.5</Version>
|
||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WeeXnes</RootNamespace>
|
||||
|
@ -68,6 +68,7 @@
|
|||
</ApplicationDefinition>
|
||||
<Compile Include="Core\EncryptorLibrary.cs" />
|
||||
<Compile Include="Core\HandleLaunchArguments.cs" />
|
||||
<Compile Include="Core\RpcLogEvents.cs" />
|
||||
<Compile Include="Core\SaveSettingsHandler.cs" />
|
||||
<Compile Include="Core\WXFile.cs" />
|
||||
<Compile Include="Views\DiscordRPC\AddRPCView.xaml.cs">
|
||||
|
|
Loading…
Add table
Reference in a new issue