Visual Improvements (RichPresenceEventLog)
This commit is contained in:
parent
d76717779d
commit
ffe05ef98a
6 changed files with 144 additions and 46 deletions
|
@ -15,7 +15,7 @@ namespace WeeXnes.Core
|
|||
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
|
||||
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||
public static string SettingsFileName = "settings.ini";
|
||||
public static string version = "3.1.1";
|
||||
public static string version = "3.2";
|
||||
public static bool info_isRpcRunning = false;
|
||||
public static bool info_RpcAutoStart;
|
||||
public static string apiUrl = "http://www.weexnes.com:5169/";
|
||||
|
|
57
WeeXnes/Core/customEvent.cs
Normal file
57
WeeXnes/Core/customEvent.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -207,19 +207,48 @@
|
|||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<RichTextBox Grid.Row="1"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
<ScrollViewer Grid.Column="0" Background="Transparent" VerticalScrollBarVisibility="Hidden" Foreground="White"
|
||||
Padding="5,5,0,5" Name="LogViewer">
|
||||
<StackPanel>
|
||||
<StackPanel>
|
||||
<ItemsControl x:Name="ListViewVersions" ItemsSource="{Binding version}" Loaded="ListViewVersions_OnLoaded">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Border Width="689" Height="30" CornerRadius="4" Margin="0,3,0,0">
|
||||
<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"
|
||||
IsReadOnly="True"
|
||||
IsHitTestVisible="False"
|
||||
Name="RpcLog">
|
||||
<RichTextBox.Resources>
|
||||
<Style TargetType="{x:Type Paragraph}">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
</Style>
|
||||
</RichTextBox.Resources>
|
||||
</RichTextBox>
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Padding="10,0,0,0">
|
||||
|
||||
<TextBlock.Effect>
|
||||
<DropShadowEffect ShadowDepth="1"/>
|
||||
|
||||
</TextBlock.Effect>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
|
|
@ -28,11 +28,12 @@ namespace WeeXnes.MVVM.View
|
|||
/// </summary>
|
||||
public partial class DiscordRpcView : UserControl
|
||||
{
|
||||
public List<customEvent> events = new List<customEvent>();
|
||||
//static bool shouldBeRunning = false;
|
||||
BackgroundWorker backgroundWorker = new BackgroundWorker();
|
||||
List<Game> Games = new List<Game>();
|
||||
Game lastSelectedGame = null;
|
||||
public static string logContent = null;
|
||||
public static customEvent logContent = null;
|
||||
public static UpdateVar<string> triggerLogupdate = new UpdateVar<string>();
|
||||
public DiscordRpcView()
|
||||
{
|
||||
|
@ -47,8 +48,8 @@ namespace WeeXnes.MVVM.View
|
|||
};
|
||||
InitializeSettings();
|
||||
CheckForAutostart();
|
||||
}
|
||||
|
||||
}
|
||||
public void CheckFolders()
|
||||
{
|
||||
if (!Globals.settings_RpcItemsPath_Bool.Value)
|
||||
|
@ -80,25 +81,28 @@ namespace WeeXnes.MVVM.View
|
|||
backgroundWorker.DoWork += BackgroundWorker_DoWork;
|
||||
Refresh();
|
||||
}
|
||||
public void writeLog(string _content, bool _timestamp = true)
|
||||
public void writeLog(customEvent _content, bool _timestamp = true)
|
||||
{
|
||||
string timestamp = DateTime.Now.ToString("HH:mm:ss");
|
||||
if (_timestamp)
|
||||
/*if (_timestamp)
|
||||
{
|
||||
_content = "[" + timestamp + "] " + _content;
|
||||
}
|
||||
Console.WriteLine(_content);
|
||||
*/
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
RpcLog.AppendText(_content + "\n");
|
||||
RpcLog.ScrollToEnd();
|
||||
//RpcLog.AppendText(_content + "\n");
|
||||
//RpcLog.ScrollToEnd();
|
||||
|
||||
ListViewVersions.Items.Add(_content);
|
||||
LogViewer.ScrollToEnd();
|
||||
});
|
||||
}
|
||||
|
||||
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
Globals.info_isRpcRunning = true;
|
||||
writeLog("Thread Started");
|
||||
writeLog(new customEvent("Thread Started", EventType.ProcessStartedEvent));
|
||||
bool runWorker = true;
|
||||
int delay = 2000;
|
||||
while (runWorker)
|
||||
|
@ -129,7 +133,7 @@ namespace WeeXnes.MVVM.View
|
|||
{
|
||||
game.isRunning = false;
|
||||
}
|
||||
writeLog("Thread Closed");
|
||||
writeLog(new customEvent("Thread Closed",EventType.ProcessStoppedEvent));
|
||||
}
|
||||
public void runBackgroundWorker()
|
||||
{
|
||||
|
@ -313,5 +317,10 @@ namespace WeeXnes.MVVM.View
|
|||
stopBackgroundWorker();
|
||||
|
||||
}
|
||||
|
||||
private void ListViewVersions_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,15 @@ using System.Threading.Tasks;
|
|||
using WeeXnes.Core;
|
||||
using WeeXnes.MVVM.View;
|
||||
using DiscordRPC;
|
||||
using DiscordRPC.Message;
|
||||
using EventType = WeeXnes.Core.EventType;
|
||||
|
||||
namespace WeeXnes.RPC
|
||||
{
|
||||
class EventCache
|
||||
{
|
||||
public static string cache1 = "";
|
||||
}
|
||||
public class Game
|
||||
{
|
||||
public DiscordRpcClient client { get; set; }
|
||||
|
@ -44,25 +50,8 @@ namespace WeeXnes.RPC
|
|||
{
|
||||
client.Initialize();
|
||||
}
|
||||
client.OnReady += (sender, e) =>
|
||||
{
|
||||
/*
|
||||
Globals.logContent.Value = "[" + this.ProcessName + ".exe] -> Received Ready from user " + e.User.Username;
|
||||
Globals.logUpdateTrigger.Value = "mgjnoeimgje";
|
||||
*/
|
||||
DiscordRpcView.logContent = "[" + this.ProcessName + ".exe] -> Received Ready from user " + e.User.Username;
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
};
|
||||
client.OnPresenceUpdate += (sender, e) =>
|
||||
{
|
||||
/*
|
||||
Globals.logContent.Value = "[" + this.ProcessName + ".exe] ->Received Update!";
|
||||
Globals.logUpdateTrigger.Value = "mgjnoeimgje";
|
||||
*/
|
||||
DiscordRpcView.logContent = "[" + this.ProcessName + ".exe] -> Received Update on RPC";
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
|
||||
};
|
||||
client.OnReady += ClientOnOnReady;
|
||||
client.OnPresenceUpdate += ClientOnOnPresenceUpdate;
|
||||
client.SetPresence(new RichPresence()
|
||||
{
|
||||
Details = this.details,
|
||||
|
@ -80,11 +69,26 @@ namespace WeeXnes.RPC
|
|||
client.UpdateStartTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClientOnOnPresenceUpdate(object sender, PresenceMessage args)
|
||||
{
|
||||
DiscordRpcView.logContent = new customEvent("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name, EventType.RPCUpdateEvent);
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
}
|
||||
|
||||
private void ClientOnOnReady(object sender, ReadyMessage args)
|
||||
{
|
||||
DiscordRpcView.logContent = new customEvent("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username, EventType.RPCReadyEvent);
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if (this.client.IsInitialized)
|
||||
{
|
||||
client.ClearPresence();
|
||||
client.OnReady -= ClientOnOnReady;
|
||||
client.OnPresenceUpdate -= ClientOnOnPresenceUpdate;
|
||||
}
|
||||
}
|
||||
public void checkState(Process[] processes)
|
||||
|
@ -110,12 +114,11 @@ namespace WeeXnes.RPC
|
|||
//message.running(this.ProcessName);
|
||||
start();
|
||||
|
||||
string output = this.Name + " [" + this.ProcessName + ".exe] started";
|
||||
/*
|
||||
Globals.logContent.Value = output;
|
||||
Globals.logUpdateTrigger.Value = "mjfgoklemkgoeg";
|
||||
*/
|
||||
DiscordRpcView.logContent = output;
|
||||
DiscordRpcView.logContent = new customEvent("↪ " + this.Name + " [" + this.ProcessName + ".exe] started", EventType.ProcessStartedEvent);
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
this.isRunning = true;
|
||||
}
|
||||
|
@ -127,12 +130,11 @@ namespace WeeXnes.RPC
|
|||
//Do when Process is closed
|
||||
//message.closed(this.ProcessName);
|
||||
stop();
|
||||
string output = this.Name + " [" + this.ProcessName + ".exe] closed";
|
||||
/*
|
||||
Globals.logContent.Value = output;
|
||||
Globals.logUpdateTrigger.Value = "mjfgoklemkgoeg";
|
||||
*/
|
||||
DiscordRpcView.logContent = output;
|
||||
DiscordRpcView.logContent = new customEvent( "↩ " + this.Name + " [" + this.ProcessName + ".exe] closed", EventType.ProcessStoppedEvent);
|
||||
DiscordRpcView.triggerLogupdate.Value = "nlejgmolegjog";
|
||||
|
||||
this.isRunning = false;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Core\ApiResponse.cs" />
|
||||
<Compile Include="Core\customEvent.cs" />
|
||||
<Compile Include="Misc\UpdateMessage.xaml.cs">
|
||||
<DependentUpon>UpdateMessage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
Loading…
Add table
Reference in a new issue