Exemplo n.º 1
0
 private void TryToSetQuality(YoutubeQuality quality)
 {
     if (IsloadingDone())
     {
         WebBrowser.ExecuteScriptAsync("setQuality", quality.ToString());
     }
 }
Exemplo n.º 2
0
 private void Start()
 {
     if (IsloadingDone())
     {
         WebBrowser.ExecuteScriptAsync("setPlayerState", startVideoParam);
     }
 }
Exemplo n.º 3
0
 private void SetVolume(int volume)
 {
     if (IsloadingDone())
     {
         WebBrowser.ExecuteScriptAsync("setVolume", volume);
     }
 }
        public CefYoutubeController()
        {
            InitializeComponent();
            WebBrowser.Address = @"custom://cefsharp/CefPlayer.html";
            //set startup value for Player
            WebBrowser.LoadingStateChanged += CheckkIfLoadingDone;

            var boundAsync = new BoundObject();

            boundAsync.PlayerLoadingDone    += JavascriptReady;
            boundAsync.PlayerPlayingChanged += BoundOnPlayerPlayingChanged;

            WebBrowser.JavascriptObjectRepository.Register("boundAsync", boundAsync, true);

            WebBrowser.JavascriptObjectRepository.ObjectBoundInJavascript += (sender, e) =>
            {
                var name = e.ObjectName;

                Console.WriteLine($"Object {e.ObjectName} was bound successfully.");
            };

            StartCommand = new Command(Start);
            StopCommand  = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam));
            PauseCommand = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam));
        }
Exemplo n.º 5
0
 private void SetAutoPlay(bool autoPlay)
 {
     if (IsloadingDone())
     {
         var script = string.Format("autoPlay = {0};", autoPlay.ToString().ToLower());
         WebBrowser.ExecuteScriptAsync(script);
     }
 }
        public HideTreasurePageVM(UserDataService userdata)
        {
            UserData = userdata;
            //get the treasures and insert a void selection
            UserTreasures = new ObservableCollection <Treasure>(UserData.GetUnchainedUserTreasures());
            UserTreasures.Insert(0, new Treasure {
                ID = 0, Name = "-Not chained-"
            });
            TreasureChain = UserTreasures[0];

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            CefSharpSettings.WcfEnabled = true;
            MessengerInstance.Register <Treasure>(this, "ChangeTreasure", async Treasur =>
                                                  { Treasure = Treasur; MarkerInfo = Treasur.MarkerInfo;
                                                    Latitude             = MarkerInfo.Latitude;
                                                    Longtitude           = MarkerInfo.Longtitude;
                                                    Address              = MarkerInfo.Address;
                                                    City                 = MarkerInfo.City;
                                                    Country              = MarkerInfo.Country;
                                                    Key                  = Treasur.Key;
                                                    SelectedTreasureSize = Treasur.TreasureSize;
                                                    SelectedTreasureType = Treasur.TreasureType;
                                                    //do the same thing but for the treasure we want to change
                                                    UserTreasures = new ObservableCollection <Treasure>(UserData.GetUnchainedUserTreasures(Treasur.ID));
                                                    UserTreasures.Insert(0, new Treasure {
                    ID = 0, Name = "-Not chained-"
                });
                                                    TreasureChain = UserTreasures[0];
                                                    if (Treasur.IsChained)
                                                    {
                                                        using (var unitOfWork = new UnitOfWork(new GeocachingContext()))
                                                        {
                                                            Treasure tc;
                                                            tc = unitOfWork.ChainedTreasures.GetNextChainedTreasure(Treasur.ID);
                                                            if (tc != null)
                                                            {
                                                                try
                                                                {
                                                                    if (UserTreasures.Single(t => t.ID == tc.ID) == null) //this is so it doesnt get the same treasure
                                                                    {
                                                                        UserTreasures.Add(tc);                            //add it last
                                                                    }
                                                                }catch (InvalidOperationException e)
                                                                {
                                                                    UserTreasures.Add(tc);
                                                                }
                                                                TreasureChain = UserTreasures[UserTreasures.Count - 1]; //set the chained treasure to it
                                                            }
                                                        }
                                                    }
                                                    // when the mainframe of the browser loads this runs
                                                    tcs = new TaskCompletionSource <bool>();
                                                    await tcs.Task;
                                                    WebBrowser.ExecuteScriptAsync("setMarker", Latitude, Longtitude); });
        }
Exemplo n.º 7
0
 private void ExecuteJavaScript(string s)
 {
     try
     {
         WebBrowser.ExecuteScriptAsync(s);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error while executing Javascript: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 8
0
        public MainWindowViewModel()
        {
            ShowDevToolsCommand         = new CommandHandler(() => _webBrowser?.ShowDevTools(), true);
            CloseDevToolsCommand        = new CommandHandler(() => _webBrowser?.CloseDevTools(), true);
            LoadPokedexCommand          = new CommandHandler(() => BrowserAddress = "http://localhost:8000", true);
            LoadExternalWebsiteCommand  = new CommandHandler(() => BrowserAddress = "http://thinktecture.com", true);
            InjectSomeJavaScriptCommand = new CommandHandler(() => WebBrowser?.ExecuteScriptAsync($"alert('Es ist {DateTime.Now.ToShortTimeString()} Uhr.');"), true);

            var uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "index.html").AbsoluteUri;

            LoadLocalFileCommand = new CommandHandler(() => BrowserAddress = uri, true);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Just to make sure WebBrowser is loaded.
            if (IsBrowserInitialized)
            {
                Debug.WriteLine("shareFB executed");

                // Mainly the most important line - calling the 'shareFB' javascript method.
                WebBrowser.ExecuteScriptAsync("shareFB();");
            }
            else
            {
                Debug.WriteLine("WebView not loaded");
            }
        }
Exemplo n.º 10
0
        public CefYoutubeController()
        {
            InitializeComponent();
            WebBrowser.Address = @"custom://cefsharp/CefPlayer.html";
            //set startup value for Player
            WebBrowser.LoadingStateChanged += CheckkIfLoadingDone;
            var bound = new BoundObject();

            bound.PlayerLoadingDone    += JavascriptReady;
            bound.PlayerPlayingChanged += BoundOnPlayerPlayingChanged;
            WebBrowser.RegisterJsObject("bound", bound);

            StartCommand = new Command(Start);
            StopCommand  = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam));
            PauseCommand = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam));
        }
Exemplo n.º 11
0
        public HomePageBrowserVM(UserDataService userData)
        {
            Markers  = new List <MarkerInfo>();
            UserData = userData;
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            CefSharpSettings.WcfEnabled = true;

            MessengerInstance.Register <Treasure>(this, "ShowTreasure", treasr =>
            {
                WebBrowser.ExecuteScriptAsync("removeMarkers", "removed");
                WebBrowser.ExecuteScriptAsync("showTreasures", treasr.MarkerInfo.Latitude, treasr.MarkerInfo.Longtitude,
                                              treasr.ID, treasr.Name, treasr.TreasureType.ToString(),
                                              treasr.TreasureSize.ToString(), treasr.Description,
                                              treasr.Rating, treasr.IsChained.ToString(), true);
            });
        }
Exemplo n.º 12
0
 private void SetVideoId(string videoId)
 {
     if (haventRun)
     {
         //if(WebBrowser.WebBrowser == null)
         //{
         //WebBrowser.LoadingStateChanged += SetStartupId;
         //}
         //else
         //{
         //    WebBrowser.ExecuteScriptAsync("var startUpId = " + VideoId);
         //}
         haventRun = false;
     }
     if (IsloadingDone())
     {
         WebBrowser.ExecuteScriptAsync("setVideoId", videoId);
     }
 }
Exemplo n.º 13
0
        public CefYoutubeController()
        {
            InitializeComponent();
            HttpServer.InitHttpServer(SucsesReqest);
            HttpServer.Run();

            WebBrowser.Address = @"http://localhost:8080/YouPlayer/";
            //set startup value for Player
            WebBrowser.LoadingStateChanged += CheckkIfLoadingDone;
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;

            bound.PlayerLoadingDone    += JavascriptReady;
            bound.PlayerPlayingChanged += BoundOnPlayerPlayingChanged;
            // bound.PlayerPlayingChanged += BoundOnPlayerPlayingChanged2;
            WebBrowser.RegisterJsObject("bound", bound);

            StartCommand = new Command(Start);
            StopCommand  = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam));
            PauseCommand = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam));
        }
Exemplo n.º 14
0
 private void Stop()
 {
     WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam);
 }
Exemplo n.º 15
0
 private void Pause()
 {
     WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam);
 }
 public void SelectGame()
 {
     WebBrowser.ExecuteScriptAsync(@"document.querySelector('#root > div > div.content > div > div.react-wrapper > div > div > div.choose-game-container.col-12.col-lg-8 > div > div.choose-game-body > div > div.select-game-block.col-12.col-lg-8 > div > div > div.scrollContainer > div > div:nth-child(8) > div').click()
     document.querySelector('#root > div > div.content > div > div.react-wrapper > div > div > div.choose-game-container.col-12.col-lg-8 > div > div.choose-game-body > div > div.selected-game-block.col-12.col-lg-4 > div > div.game-stats-block > div.play-game-block > button').click()");
 }