Exemple #1
0
        public static async Task <BitmapImage> GetBlueIrisImage(String BlueIrisUrl, String CameraKey)
        {
            BitmapImage image = new BitmapImage();

            Byte[] imageBytes = await WebGetUtils.GetImageBytes(BlueIrisUrl + CameraKey + "?q=20"); //Quality 20 since it's such a small screen...

            using (var ms = new System.IO.MemoryStream(imageBytes))
            {
                await image.SetSourceAsync(ms.AsRandomAccessStream());
            }
            return(image);
        }
Exemple #2
0
        public static async Task <string> GetCurrentTempAsync(String CitySTForGoogleSearch)
        {
            String DisplayTemp    = "";
            String GoogleQuery    = CitySTForGoogleSearch.Replace(" ", "+") + "+" + "Temperature";
            String HTMLFromGoogle = await WebGetUtils.DownloadAStringAsync("https://www.google.com/search?q=" + GoogleQuery);

            //Looking for: <span class="wob_t" style="display:inline">70°F</span>
            Int32 IndexOfTemp = HTMLFromGoogle.IndexOf("class=\"wob_t\"");

            if (IndexOfTemp > -1)
            {
                HTMLFromGoogle = HTMLFromGoogle.Substring(IndexOfTemp + 37);
                IndexOfTemp    = HTMLFromGoogle.IndexOf("</span>");
                if (IndexOfTemp > -1)
                {
                    DisplayTemp = HTMLFromGoogle.Substring(0, IndexOfTemp);
                }
            }
            return(DisplayTemp);
        }
Exemple #3
0
        public static async Task <string> SendKodiCommandAsync(String KodiBaseURL, String Command)
        {
            String Result = "";

            //System.Diagnostics.Debug.WriteLine("KODI COMMAND SENT : " + Command);
            try
            {
                //TODO - need to handle timeout on this one...
                String Request = KodiBaseURL;
                if (!KodiBaseURL.EndsWith("/"))
                {
                    Request += "/";
                }
                Request += "jsonrpc?request=" + Uri.EscapeDataString(Command);
                Result   = await WebGetUtils.DownloadAStringAsync(Request);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            //System.Diagnostics.Debug.WriteLine("KODI COMMAND RESULT: " + Result);
            return(Result);
        }
Exemple #4
0
        public static async Task <string> SendKodiCommandsInOrderAsync(String KodiBaseURL, List <String> Commands)
        {
            String Result = "";

            try
            {
                foreach (String Command in Commands)
                {
                    String Request = KodiBaseURL;
                    if (!KodiBaseURL.EndsWith("/"))
                    {
                        Request += "/";
                    }
                    Request += "jsonrpc?request=" + Uri.EscapeDataString(Command);
                    Result   = await WebGetUtils.DownloadAStringAsync(Request);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            //System.Diagnostics.Debug.WriteLine("KODI MULTIPLE COMMAND LAST RESULT: " + Result);
            return(Result);
        }