示例#1
0
        private static void UpdateStatus()
        {
            // Update current project
            richPresence.State = Path.GetFileName(ProcessHandler.PullProjectName());

            client.SetPresence(richPresence);
        }
示例#2
0
        static void Main(string[] args)
        {
            var handle = GetConsoleWindow();

            // Hide console window
            ShowWindow(handle, SW_HIDE);

            ProcessHandler.OpenBlender();

            DiscordRPC.Init();

            DiscordRPC.Run();
        }
示例#3
0
        static public void Run()
        {
            while (true)
            {
                if (!ProcessHandler.isBlenderRunning())
                {
                    break;
                }

                UpdateStatus();


                Thread.Sleep(1000);
            }

            Console.WriteLine("Blender not running anymore.");
            client.Dispose();
        }
示例#4
0
        static public void Init()
        {
            // Create a discord client
            client = new DiscordRpcClient(appID);

            // Set the logger
            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Warning
            };

            // Subscribe to events
            client.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            // Connect to the RPC
            client.Initialize();

            // Create RichPresence object
            richPresence = new RichPresence()
            {
                Details = "Working On A Project",
                State   = Path.GetFileName(ProcessHandler.PullProjectName()),
                Assets  = new Assets()
                {
                    LargeImageKey  = "blender_icon_1024x1024",
                    LargeImageText = "Blender " + ProcessHandler.PullBlenderVersion()
                },
                Timestamps = new Timestamps
                {
                    Start = startTime
                }
            };

            // Set the rich presence
            client.SetPresence(richPresence);
        }