Example #1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            var hwnd = new WindowInteropHelper(this).Handle;

            WindowsServices.SetWindowExTransparent(hwnd);
        }
Example #2
0
 private void CheckKeyBoard()
 {
     while (true)
     {
         var modenabled = Keyboard.Modifiers != (ModifierKeys.Shift & ModifierKeys.Alt);
         RunOnUiThread((Action) delegate
         {
             var hwnd = new WindowInteropHelper(this).Handle;
             if (modenabled)
             {
                 WindowsServices.makeNormal(hwnd);
             }
             else
             {
                 WindowsServices.SetWindowExTransparent(hwnd);
             }
         });
         Thread.Sleep(100);
     }
 }
Example #3
0
        private void CheckKeyBoard()
        {
            while (true)
            {
                var modenabled = Keyboard.Modifiers != (ModifierKeys.Shift & ModifierKeys.Alt);
                RunOnUiThread((Action) delegate
                {
                    var hwnd = new WindowInteropHelper(this).Handle;
                    if (modenabled)
                    {
                        WindowsServices.makeNormal(hwnd);
                    }
                    else
                    {
                        WindowsServices.SetWindowExTransparent(hwnd);
                    }
                });
                Thread.Sleep(100);

                clockBox.Dispatcher.Invoke((Action) delegate {
                    clockBox.Text = DateTime.Now.ToShortDateString() + Environment.NewLine + DateTime.Now.ToString("HH:mm:ss");
                });
            }
        }
Example #4
0
        private void CheckKeyBoard()
        {
            while (true)
            {
                var modenabled = Keyboard.Modifiers != (ModifierKeys.Shift & ModifierKeys.Alt);
                RunOnUiThread((Action) delegate
                {
                    var hwnd = new WindowInteropHelper(this).Handle;
                    if (modenabled)
                    {
                        WindowsServices.makeNormal(hwnd);
                    }
                    else
                    {
                        WindowsServices.SetWindowExTransparent(hwnd);
                    }
                });
                Thread.Sleep(1000);
                var currentSong = "Stopped";

                try
                {
                    if (token == "")
                    {
                        using (WebClient wc = new WebClient())
                        {
                            var js = wc.DownloadString("http://open.spotify.com/token");

                            var o = JsonConvert.DeserializeObject <SpotifyToken>(js);

                            token = o.t;
                        }
                    }

                    if (csrf == "")
                    {
                        using (WebClient wc = new WebClient())
                        {
                            wc.Headers.Add("Origin", "https://open.spotify.com");
                            wc.Headers.Add("Referer", "https://open.spotify.com/remote");
                            var js = wc.DownloadString("https://asjdasdkb.spotilocal.com:4370/simplecsrf/token.json");

                            var o = JsonConvert.DeserializeObject <Dictionary <string, string> >(js);
                            csrf = o["token"].ToString();
                        }
                    }

                    var url = "https://asjdasdkb.spotilocal.com:4370/remote/status.json?csrf=" + csrf + "&oauth=" + token + "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap&returnafter=1&ref=http%3A%2F%2Fopen.spotify.com%2Ftrack%2F20LKA97m0dz1u7l8aMBGqK&cors=";
                    using (WebClient wc = new WebClient())
                    {
                        wc.Headers.Add("Origin", "https://open.spotify.com");
                        wc.Headers.Add("Referer", "https://open.spotify.com/remote");
                        var str = wc.DownloadString(url).Replace("\n", "");
                        if (str.ToLower().Contains("expired token"))
                        {
                            token = "";
                        }

                        var o = JsonConvert.DeserializeObject <SpotifyREST>(str);
                        if (o != null)
                        {
                            if (o.Playing)
                            {
                                if (o.Track != null)
                                {
                                    if (o.Track.Artist_Resource != null)
                                    {
                                        if (o.Track.Track_Resource != null)
                                        {
                                            currentSong = o.Track.Artist_Resource.Name + " - " + o.Track.Track_Resource.Name;                                            /* +
                                                                                                                                                                          * " (" + TimeSpan.FromSeconds(o.Playing_Position).ToString("mm\\:ss") + "/" + TimeSpan.FromSeconds(o.Track.Length).ToString("mm\\:ss") + ") " +
                                                                                                                                                                          * (o.Track.Track_Type != "local" ? "[sptfy: " + o.Track.Track_Resource.Location.Og + " ]" : ""));*/
                                        }
                                    }
                                }
                            }
                            else
                            {
                                currentSong = "Stopped";
                            }
                        }
                    }
                }
                catch
                {
                }

                spotifyBox.Dispatcher.Invoke((Action) delegate
                {
                    spotifyBox.Text = "Spotify" + Environment.NewLine + currentSong;
                });
            }
        }