示例#1
0
        private void ConnectToCam()
        {
            if (Servers.SelectedIndex < 0)
            {
                ShowSettingsPage();
                return;
            }

            Settings settings = Settings.LoadSettings(Servers.Items[Servers.SelectedIndex]);
            IWifi    wifi     = new Wifi();

            string server = wifi.GetSSID() == $"\"{settings.LocalSSID}\""
                ? settings.LocalServerName
                : settings.RemoteServerName;

            string html = "<html><head><style>" +
                          $"body{{Width:{CamWebView.Width - 16}px;Height:{CamWebView.Height - 16}px;}}" +
                          $".loader{{left:{CamWebView.Width/2 - 8};margin:{CamWebView.Height/2 - 46}px auto;position:fixed;}}" +
                          $"img{{width:{CamWebView.Width - 16};height:{CamWebView.Height - 16};position:fixed;}}" +
                          "</style><link rel=\"stylesheet\" type=\"text/css\" href=\"car-cam.css\" /></head><body>" +
                          "<div class=\"loader\">Loading...</div>" +
                          $"<img class=\"camview\" src=\"http://{server}:{settings.CameraPort}/?action=stream\" onerror=\"this.src = '';\" />" +
                          "</body></html>";

            Device.BeginInvokeOnMainThread(() => CamWebView.LoadContent(html, DependencyService.Get <IBaseUrl>().Get()));
        }
示例#2
0
 public void Disconnect()
 {
     try
     {
         movement = new Movement();
         MoveCar();
         if (client != null && client.IsConnected)
         {
             client.Disconnect();
         }
         CamWebView.LoadContent("");
     }
     catch (Exception ex)
     {
         Toaster(ex.Message, ToastPriority.Critical, ToastLength.Long);
     }
     finally
     {
         _clientConnected = false;
     }
 }