/// <summary> /// Updates the presence from the app settings. /// </summary> public static void UpdateFromSettings() { if (!RichPresenceHelper.IsInitialized) { RichPresenceHelper.Initialize(Properties.Settings.Default.AppId); } if (RichPresenceHelper.IsInitialized) { RichPresenceHelper.Update(new RichPresence() { Details = Properties.Settings.Default.GameDetails, State = Properties.Settings.Default.GameState, Timestamps = new Timestamps() { Start = Properties.Settings.Default.StartTimestamp == 0 ? null : (RichPresenceViewModel.GetDateTime(Properties.Settings.Default.StartTimestamp)), End = Properties.Settings.Default.EndTimestamp == 0 ? null : (RichPresenceViewModel.GetDateTime(Properties.Settings.Default.EndTimestamp)), }, Assets = new Assets() { LargeImageKey = Properties.Settings.Default.LargeImageKey ?? null, LargeImageText = Properties.Settings.Default.LargeImageText ?? null, SmallImageKey = Properties.Settings.Default.SmallImageKey ?? null, SmallImageText = Properties.Settings.Default.SmallImageText ?? null, } }); } }
/// <summary> /// Handles the exit of the app. /// </summary> private void AppExit(object sender, ExitEventArgs e) { RichPresenceHelper.Dispose(); TaskbarIconHelper.Dispose(); SettingsHelper.SetStartupSettings(); SettingsHelper.SaveTheme(); }
/// <summary> /// Handles the startup of the app. /// </summary> private void AppStart(object sender, StartupEventArgs e) { RichPresenceHelper.Initialize(DiscordPresenceUI.Properties.Settings.Default.AppId); RichPresenceHelper.UpdateFromSettings(); SettingsHelper.SetLocale(); SettingsHelper.CheckForInstances(); SettingsHelper.SetStartupSettings(); SettingsHelper.SetTheme(); TaskbarIconHelper.InitializeTaskbarIcon(); }
private static void OnPresenceUpdate(object sender, PresenceMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Now playing {0}.", args.Presence == null ? "nothing" : args.Presence.State)); }
private static void OnConnectionFailed(object sender, ConnectionFailedMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Pipe connection failed on #{0}.", args.FailedPipe)); RichPresenceHelper.IsInitialized = false; }
private static void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Pipe connection established on #{0}.", args.ConnectedPipe)); }
private static void OnError(object sender, ErrorMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Error occured within discord. ({1}) {0}", args.Message, args.Code)); }
private static void OnClose(object sender, CloseMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Lost connection with client because of '{0}'.", args.Reason)); RichPresenceHelper.IsInitialized = false; }
private static void OnReady(object sender, ReadyMessage args) { RichPresenceHelper.Log(args.Type, args.TimeCreated, string.Format("Ready (RPC version {0})", args.Version)); RichPresenceHelper.IsInitialized = true; }