Esempio n. 1
0
        /// <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,
                    }
                });
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Handles the exit of the app.
 /// </summary>
 private void AppExit(object sender, ExitEventArgs e)
 {
     RichPresenceHelper.Dispose();
     TaskbarIconHelper.Dispose();
     SettingsHelper.SetStartupSettings();
     SettingsHelper.SaveTheme();
 }
Esempio n. 3
0
 /// <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();
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 private static void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args)
 {
     RichPresenceHelper.Log(args.Type, args.TimeCreated,
                            string.Format("Pipe connection established on #{0}.", args.ConnectedPipe));
 }
Esempio n. 7
0
 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));
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 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;
 }