Example #1
1
 internal WebViewBackend(SWC.WebBrowser browser)
 {
     view = browser;
     view.Navigating += HandleNavigating;
     view.Navigated += HandleNavigated;
     view.LoadCompleted += HandleLoadCompleted;
     view.Loaded += HandleViewLoaded;
     Widget = view;
     view.Navigate ("about:blank"); // force Document initialization
     Title = string.Empty;
 }
Example #2
0
        void UpdateDocumentRef()
        {
            if (currentDocument != view.Document)
            {
                var doc = view.Document as ICustomDoc;
                if (doc != null)
                {
                    doc.SetUIHandler(this);
                    if (mshtmlDocType == null)
                    {
                        mshtmlDocType = view.Document.GetType();
                    }
                }
                if (currentDocument != null)
                {
                    currentDocument.SetUIHandler(null);
                }
                currentDocument = doc;
            }

            // on initialization we load "about:blank" to initialize the document,
            // in that case we load the requested url
            if (currentDocument != null && !initialized)
            {
                initialized = true;
                if (!string.IsNullOrEmpty(url))
                {
                    view.Navigate(url);
                }
            }
        }
Example #3
0
        public RunTabItem (string header)
        {
            FrameName = "";
            this.Header = header; 
            WebBrowser = new WebBrowser();
            WebBrowser.ObjectForScripting = new ScriptHelper(WebBrowser); 
            this.Content = WebBrowser ;
            this.Style = Application.Current.MainWindow.FindResource("MainTabItemStyle") as Style;
            WebBrowser.Navigate("about:blank");
            
            
            var SID_SWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
            var serviceProvider = (IServiceProvider)WebBrowser.Document;

            var serviceGuid = SID_SWebBrowserApp;

            var iid = typeof(SHDocVw.IWebBrowser2).GUID;
            ////Here we will get a reference to the IWebBrowser2 interface
              ExBrowser = (SHDocVw.IWebBrowser2)serviceProvider.QueryService(ref serviceGuid, ref iid);
            ////To hook events we just need to do these casts
                Events2 = (SHDocVw.DWebBrowserEvents_Event)ExBrowser;
              Events = (SHDocVw.DWebBrowserEvents2_Event)ExBrowser;
              System.Runtime.InteropServices.Marshal.ReleaseComObject((object)serviceProvider);
            


        }
Example #4
0
 public static void  autorize(WebBrowser _webBrowser)
 {
     string clientID = "4273691";
     string url = string.Format("http://oauth.vk.com/authorize?client_id={0}&scope=friends,audio&redirect_uri=https://oauth.vk.com/blank.html&display=popup&response_type=token", clientID);
     _webBrowser.Navigated += _webBrowser_Navigated;
     _webBrowser.Navigate(url);
 }
Example #5
0
        private Task<LiveConnectSession> LoginAsync()
        {
            TaskCompletionSource<LiveConnectSession> taskCompletion = new TaskCompletionSource<LiveConnectSession>();

            var url = _client.GetLoginUrl(new[] { "wl.basic", "wl.signin", "onedrive.readonly", "wl.skydrive", "wl.photos" });

            WebBrowser browser = new WebBrowser();
            var window = new Window();
            window.Content = browser;

            NavigatingCancelEventHandler handler = null;
            handler = async (o, args) =>
            {
                if (args.Uri.AbsolutePath.Equals("/oauth20_desktop.srf"))
                {
                    browser.Navigating -= handler;
                    window.Close();

                    var session = await GetConnectSession(args.Uri.Query);
                    taskCompletion.SetResult(session);
                }
            };
            browser.Navigating += handler;
            browser.Navigate(url);
            window.Show();
            return taskCompletion.Task;
        }
        private void RefreshPreview()
        {
            _previousCursor      = Mouse.OverrideCursor;
            Mouse.OverrideCursor = Cursors.Wait;

            HTMLReportsConfiguration currentConf = WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            //changing the solution because report should not be created in installtion folder due to permissions issues + it can be multiple users will run same Ginger on server
            if (Directory.Exists(mPreviewDummyReportPath))
            {
                ClearDirectoryContent(mPreviewDummyReportPath);
            }
            else
            {
                PrepareDummyReportData();
            }

            Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(mPreviewDummyReportDataPath),
                                                                                              false,
                                                                                              _HTMLReportConfiguration,
                                                                                              mPreviewDummyReportPath, false, currentConf.HTMLReportConfigurationMaximalFolderSize);

            WBP = new WebBrowserPage();
            frmBrowser.Content = WBP;
            browser            = WBP.GetBrowser();
            browser.Navigate(System.IO.Path.Combine(mPreviewDummyReportPath, "GingerExecutionReport.html"));

            Mouse.OverrideCursor = _previousCursor;
        }
        /// <summary>
        /// Page_Loaded event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            
            WebBrowser webBrowser = new WebBrowser();
           

            RowDefinition rdWebBrowser=new RowDefinition();
            RowDefinition rdProgressBar = new RowDefinition();

            rdProgressBar.Height = new GridLength(0.3, GridUnitType.Star);
            rdWebBrowser.Height = new GridLength(13, GridUnitType.Star);
            pgBar.Height = 10;
            pgBar.IsIndeterminate = true;
            pgBar.Visibility = Visibility.Visible;
            webBrowser.Navigate(new Uri(RxConstants.myLocalPharmacySupport, UriKind.Absolute));

            webBrowser.Navigated += new EventHandler<NavigationEventArgs>(NavigateHandler);
            webBrowser.Visibility = Visibility.Visible;
            webBrowser.Margin.Top.Equals(-12);
            webBrowser.IsScriptEnabled = true;
            
            ContentPanel.RowDefinitions.Insert(0, rdProgressBar);
            ContentPanel.RowDefinitions.Insert(1, rdWebBrowser);

            Grid.SetRow(pgBar, 0);
            Grid.SetRow(webBrowser, 1);

            ContentPanel.Children.Add(pgBar);
            ContentPanel.Children.Add(webBrowser);
           
        }
Example #8
0
        internal void RetornoXml(WebBrowser webBrowser, string retornoXmlString)
        {
            var stw = new StreamWriter(_path + @"\tmp.xml");

            stw.WriteLine(retornoXmlString);
            stw.Close();
            webBrowser.Navigate(_path + @"\tmp.xml");
        }
Example #9
0
        public MainWindow()
        {
            InitializeComponent();
            WebBrowserOverlay wbo = new WebBrowserOverlay(l_ie, 0, 0);

            System.Windows.Controls.WebBrowser w = wbo.WebBrowser;
            w.Navigate(new Uri("http://mario.web.yymoon.com/client.html"));
        }
Example #10
0
 internal WebViewBackend(SWC.WebBrowser browser)
 {
     view                = browser;
     view.Navigating    += HandleNavigating;
     view.Navigated     += HandleNavigated;
     view.LoadCompleted += HandleLoadCompleted;
     view.Loaded        += HandleViewLoaded;
     Widget              = view;
     view.Navigate("about:blank");              // force Document initialization
     Title = string.Empty;
 }
Example #11
0
        public User()
        {
            LogView = new WebBrowser();
            LogView.Navigate(new Uri(AppResources.Server + "League.aspx"));
            //LogView.Navigate(new Uri("/League.html", UriKind.Relative));
            int loadbrowser = 0;
            while (LogView.SaveToString().Length < 1) { loadbrowser++; }
            string x = LogView.SaveToString();
            MessageBox.Show("Done");

            InitializeComponent();
        }
Example #12
0
    public WebContent(RegionOptions options)
    : base(options.Width, options.Height, options.Top, options.Left)
    {
        duration        = options.Duration;
        scheduleId      = options.scheduleId;
        layoutId        = options.layoutId;
        mediaId         = options.mediaid;
        type = options.FileType;

        webBrowser = new WebBrowser();

        webBrowser.Height = options.Height;
        webBrowser.Width = options.Width;

        //webBrowser.ScrollBarsEnabled = false;
        //webBrowser.ScriptErrorsSuppressed = true;

        // Attach event
        webBrowser.LoadCompleted +=  (WebBrowserDocumentCompleted);

        if (!Settings.Default.powerpointEnabled && options.FileType == "powerpoint")
        {
            webBrowser.Source = new Uri("<html><body><h1>Powerpoint not enabled on this display</h1></body></html>");
            System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Powerpoint is not enabled on this display", scheduleId, layoutId, mediaId));
        }
        else
        {
            try
            {
                // Try to make a URI out of the file path
                try
                {
                    this.filePath = Uri.UnescapeDataString(options.Uri);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message, "WebContent");
                }

                // Navigate
                webBrowser.Navigate(this.filePath);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", ex.Message, scheduleId, layoutId, mediaId));

                webBrowser.Source = new Uri("<html><body><h1>Unable to show this web location - invalid address.</h1></body></html>");

                System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Unable to show the powerpoint, cannot be located", scheduleId, layoutId, mediaId));
            }
        }
    }
Example #13
0
 public Map() {
     /*var map = new StaticMap();
     map.Center = "1000 7h Ave"; // or a lat/lng coordinate
     map.Zoom = "14";
     map.Size = "400x400";
     map.Sensor = "true";
     var uriMap = map.ToUri();
     */
     Uri uriMap = new Uri("http://maps.google.com/");
     wb = new WebBrowser();
     Children.Add(wb);
     wb.Navigate(uriMap);
 }
 /// <summary>
 /// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
 /// for authentication, and providing access to Facebook data for the user.
 /// 
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="user">The user to link with Facebook.</param>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static async Task LinkAsync(ParseUser user,
     WebBrowser webView,
     IEnumerable<string> permissions,
     CancellationToken cancellationToken) {
   authProvider.Permissions = permissions;
   LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
   webView.LoadCompleted += loadCompleted;
   Action<Uri> navigate = uri => webView.Navigate(uri);
   authProvider.Navigate += navigate;
   await user.LinkWithAsync("facebook", cancellationToken);
   authProvider.Navigate -= navigate;
   webView.LoadCompleted -= loadCompleted;
 }
 /// <summary>
 /// Logs in a <see cref="ParseUser" /> using Facebook for authentication. If a user for the
 /// given Facebook credentials does not already exist, a new user will be created.
 /// 
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The user that was either logged in or created.</returns>
 public static async Task<ParseUser> LogInAsync(WebBrowser webView,
     IEnumerable<string> permissions,
     CancellationToken cancellationToken) {
   authProvider.Permissions = permissions;
   LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
   webView.LoadCompleted += loadCompleted;
   Action<Uri> navigate = uri => webView.Navigate(uri);
   authProvider.Navigate += navigate;
   var result = await ParseUser.LogInWithAsync("facebook", cancellationToken);
   authProvider.Navigate -= navigate;
   webView.LoadCompleted -= loadCompleted;
   return result;
 }
Example #16
0
 public void LoadWebBrowser(WebBrowser browser)
 {
     var authorizer = new OAuthAuthorizer(AppBootstrapper.ConsumerKey, AppBootstrapper.ConsumerSecret);
     authorizer.GetRequestToken("https://api.twitter.com/oauth/request_token")
         .Select(x => x.Token)
         .DispatcherSubscribe(
             token =>
             {
                 _token = token;
                 string url = authorizer.BuildAuthorizeUrl("https://api.twitter.com/oauth/authorize", token);
                 browser.Navigate(new Uri(url));
             },
             OnError);
 }
        public void Show(string account, Uri authenticationUri, Uri redirectUri)
        {
            if (window == null) {
                waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
                var uiThread = new Thread(() => {
                    window = new Window() { Title = account };
                    window.Closing += (s, e) => {
                        window.Hide();
                        waitHandle.Set();
                        e.Cancel = true;
                    };

                    browser = new WebBrowser();
                    browser.Loaded += (s, e) => {
                        browser.Navigate(authenticationUri);
                    };
                    browser.Navigating += (s, e) => {
                        if (redirectUri.IsBaseOf(e.Uri) && redirectUri.AbsolutePath == e.Uri.AbsolutePath) {
                            var parameters = new NameValueCollection();
                            foreach (var parameter in e.Uri.Query.TrimStart('?').Split('&')) {
                                var nameValue = parameter.Split('=');
                                parameters.Add(nameValue[0], nameValue[1]);
                            }
                            var handler = Authenticated;
                            handler?.Invoke(this, new AuthenticatedEventArgs(parameters));
                            e.Cancel = true;
                        }
                    };
                    browser.Navigated += (s, e) => {
                        if (authenticationUri.IsBaseOf(e.Uri))
                            SetForegroundWindow(new WindowInteropHelper(window).Handle);
                    };

                    window.Content = browser;
                    window.Show();

                    System.Windows.Threading.Dispatcher.Run();
                });
                uiThread.SetApartmentState(ApartmentState.STA);
                uiThread.Start();
            } else {
                window.Dispatcher.Invoke(() => {
                    browser.Source = authenticationUri;
                    window.Title = account;
                    window.Show();
                });
            }

            waitHandle.WaitOne();
        }
        public override FrameworkElement GetElement(string fileName)
        {
            var maxWidth = SystemParameters.WorkArea.Width - 100;
            var maxHeight = SystemParameters.WorkArea.Height - 100;

            var webBrowser = new WebBrowser();

            webBrowser.BeginInit();
            webBrowser.Width = maxWidth / 2;
            webBrowser.Height = maxHeight / 2;
            webBrowser.EndInit();

            webBrowser.Navigate(new Uri(fileName, UriKind.Absolute));

            return webBrowser;
        }
Example #19
0
 private void GoalB_Click(object sender, RoutedEventArgs e)
 {
     WebBrowser browser1 = new WebBrowser();
     browser1.Navigate(new Uri(AppResources.Server + "Goal.aspx?teamScoring=" + "B" + "&MatchId=" + AppResources.GameId));
     int loadbrowser = 0;
     while (browser1.SaveToString().Length < 1) { loadbrowser++; }
     string Data = browser1.SaveToString();
     string[] RawHtmlSplit = Data.Split('`');
     string DataNeeded = RawHtmlSplit[1];
     if (DataNeeded.Contains("Score Updated"))
     {
         scoreB++;
         ScoreB.Text = String.Format("{0}", scoreB);
     }
     else MessageBox.Show("Action Failed");
 }
        /// <summary>
        /// Loads a new document into the active editor using
        /// MarkdownDocument instance.
        /// </summary>
        /// <param name="mdDoc"></param>
        public void LoadDocument(MarkdownDocument mdDoc = null)
        {
            if (mdDoc != null)
            {
                MarkdownDocument = mdDoc;
            }

            if (AceEditor == null)
            {
                WebBrowser.LoadCompleted += OnDocumentCompleted;
                WebBrowser.Navigate(Path.Combine(Environment.CurrentDirectory, "Editor\\editor.htm"));
            }
            SetMarkdown();

            FindSyntaxFromFileType(MarkdownDocument.Filename);
        }
Example #21
0
        public UserManualWindow()
        {
            InitializeComponent();
            try
            {
                string path = System.Windows.Forms.Application.StartupPath + "\\User_Manual.Pdf";
                windowUserManual.WindowState = WindowState.Maximized;

                webBrowser.Navigate(path);
                windowUserManual.Content = webBrowser;
                windowUserManual.Show();
            }
            catch
            {
                System.Windows.MessageBox.Show("The file location could not be found.", "Location Not Found", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Example #22
0
        public GuideUtilisateur()
        {
            string fullpath = System.IO.Path.GetFullPath("guide_utilisateur.pdf");

            InitializeComponent();
            System.Windows.Controls.WebBrowser browser = new System.Windows.Controls.WebBrowser();
            browser.Navigate(new Uri("about:blank"));

            try
            {
                pdfWebViewer.Navigate(fullpath);
            }
            catch (Exception)
            {
                MessageBox.Show("Erreur lors de l'ouverture du PDF. Vérifiez que Adobe PDF Reader est installé. Vous pouvez l'activer dans Internet Explorer dans les Addons.");
            }
        }
        private void addParaItem()
        {
            PanoramaItem panoItem = new PanoramaItem();
            WebBrowser webBrower = new WebBrowser();
            Common common = new Common();
            common.SaveFilesToIsoStore(category.pageURL);

            for(int i = 0; i < category.pageName.Count; i++) {
                panoItem = new PanoramaItem();
                panoItem.Header = category.pageName[i];
                PageView.Items.Add(panoItem);
                webBrower = new WebBrowser();
                webBrower.Navigate(new Uri(category.pageURL[i], UriKind.Relative));
                panoItem.Content = webBrower;
            }
            //panoItem.Header =
        }
Example #24
0
        private void signup_Click(object sender, RoutedEventArgs e)
        {
            WebBrowser Browser12 = new WebBrowser();
            Browser12.Navigate(new Uri(AppResources.Server + "Login.aspx?Type=Register&Name=" + Name.Text + "&Password="******"&email=" + e_mail.Text + "&team="+team.Text));
            //string Temp = Browser12.SaveToString();
            string Data = null;//
            int loadbrowser = 0;
            while (Browser12.SaveToString().Length < 1) { loadbrowser++; }

            Data = Browser12.SaveToString();

            string[] RawHtmlSplit = Data.Split('`');
            string DataNeeded = RawHtmlSplit[1];
            if(DataNeeded.Contains("User Added"))
            {
                string[] Clean = DataNeeded.Split(',');
                UserData.Text = Clean[0] + "\n" + "Your New Username is: " + Clean[1];
            }
        }
Example #25
0
File: Text.cs Project: afrog33k/eAd
    /// <summary>
    /// Creates a Text display control
    /// </summary>
    /// <param name="options">Region Options for this control</param>
    public Text(RegionOptions options)
    : base(options.Width, options.Height, options.Top, options.Left)
    {
        // Collect some options from the Region Options passed in
        // and store them in member variables.
        _filePath = options.Uri;
        _direction = options.direction;
        _backgroundImage = options.backgroundImage;
        _backgroundColor = options.backgroundColor;
        _scaleFactor = options.ScaleFactor;
        _backgroundTop = options.BackgroundTop + "px";
        _backgroundLeft = options.BackgroundLeft + "px";
        _documentText = options.text;
        _scrollSpeed = options.scrollSpeed;
        _headJavaScript = options.javaScript;

        // Generate a temporary file to store the rendered object in.
        _tempHtml = new TemporaryHtml();

        // Generate the Head Html and store to file.
        GenerateHeadHtml();

        // Generate the Body Html and store to file.
        GenerateBodyHtml();

        // Fire up a webBrowser control to display the completed file.
        _webBrowser = new WebBrowser();
        _webBrowser.Height = options.Height;
        _webBrowser.Width = options.Width;
        _webBrowser.Margin = new Thickness(0,0,0,0);
        //_webBrowser.ScrollBarsEnabled = false;
        //_webBrowser.ScriptErrorsSuppressed = true;
        _webBrowser.LoadCompleted +=  (WebBrowserDocumentCompleted);

        _webBrowser.Navigated += delegate
        {
            HideScriptErrors(_webBrowser, true);
        };
        // Navigate to temp file
        _webBrowser.Navigate(_tempHtml.Path);

        MediaCanvas.Children.Add(_webBrowser);
    }
 public override Task<OAuthResult> Login(string oauthLoginUrl)
 {
     tcs = new TaskCompletionSource<OAuthResult>();
     Uri uri = new Uri(oauthLoginUrl, UriKind.Absolute);
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (null != frame)
         {
             PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
             if (null != page)
             {
                 Grid grid = page.FindName("LayoutRoot") as Grid;
                 if (null != grid)
                 {
                     webBrowser = new WebBrowser();
                     webBrowser.IsScriptEnabled = true;
                     webBrowser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
                     webBrowser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigateFailed);
                     webBrowser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
                     webBrowser.Navigate(uri);
                     grid.Children.Add(webBrowser);
                     page.BackKeyPress += new EventHandler<CancelEventArgs>(backkey_Pressed);
                 }
                 else
                 {
                     tcs.TrySetException(new Exception("Can not find RooLayout"));
                 }
             }
             else
             {
                 tcs.TrySetException(new Exception("Can not find ApplicationPage"));
             }
         }
         else
         {
             tcs.TrySetException(new Exception("Can not find ApplicationFrame"));
         }
     });
     return tcs.Task;
 }
Example #27
0
    public Flash(RegionOptions options)
    : base(options.Width, options.Height, options.Top, options.Left)
    {
        _tempHtml = new TemporaryHtml();

        _backgroundImage = options.backgroundImage;
        _backgroundColor = options.backgroundColor;
        _backgroundTop = options.BackgroundTop + "px";
        _backgroundLeft = options.BackgroundLeft + "px";

        // Create the HEAD of the document
        GenerateHeadHtml();

        // Set the body
        string html =
            @"
                <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' Width='{2}' Height='{3}' id='analog_clock' align='middle'>
                    <param name='allowScriptAccess' value='sameDomain' />
                    <param name='movie' value='{1}' />
                    <param name='quality' value='high' />
                    <param name='bgcolor' value='#000' />
                    <param name='WMODE' value='transparent' />
                    <embed src='{1}' quality='high' wmode='transparent' bgcolor='#ffffff' Width='{2}' Height='{3}' name='analog_clock' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
                </object>
            ";

        _tempHtml.BodyContent = string.Format(html, options.Uri, options.Uri, options.Width.ToString(),
                                              options.Height.ToString());

        // Fire up a webBrowser control to display the completed file.
        _webBrowser = new WebBrowser();
        _webBrowser.RenderSize = this.RenderSize;

        //      _webBrowser.Size = this.Size;
        //        _webBrowser.ScrollBarsEnabled = false;
        //    _webBrowser.ScriptErrorsSuppressed = true;
        _webBrowser.LoadCompleted +=  (_webBrowser_DocumentCompleted);

        // Navigate to temp file
        _webBrowser.Navigate(_tempHtml.Path);
    }
        public void Show(string uriString)
        {
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                var message = "Please set STAThreadAttribute on application entry point (Main method)";
                Console.WriteLine(message);
                throw new InvalidOperationException(message);
            }

            _app = new Application();
            _window = new Window();
            var browser = new WebBrowser();
            _window.Content = browser;

            browser.Loaded += (sender, eventArgs) =>
            {
                browser.Navigate(uriString);
                SetForegroundWindow(new WindowInteropHelper(_window).Handle);
            };

            browser.Navigating += (sender, eventArgs) =>
            {
                if (this.Navigating != null)
                {
                    this.Navigating(this, eventArgs);
                }
            };

            browser.Navigated += (sender, eventArgs) =>
            {
                if (this.Navigated != null)
                {
                    this.Navigated(this, eventArgs);
                }
            };

            _window.Closed += (sender, eventArgs) => _app.Shutdown();

            _app.Run(_window);
        }
 public override Task<OAuthResult> Login(string oauthLoginUrl)
 {
     _tcs = new TaskCompletionSource<OAuthResult>();
     var uri = new Uri(oauthLoginUrl, UriKind.Absolute);
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         var frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (null != frame)
         {
             var page = frame.Content as PhoneApplicationPage;
             if (null != page)
             {
                 var grid = page.FindName("LayoutRoot") as Grid;
                 if (null != grid)
                 {
                     _webBrowser = new WebBrowser {IsScriptEnabled = true};
                     _webBrowser.LoadCompleted += browser_LoadCompleted;
                     _webBrowser.NavigationFailed += browser_NavigateFailed;
                     _webBrowser.Navigating += browser_Navigating;
                     _webBrowser.Navigate(uri);
                     grid.Children.Add(_webBrowser);
                     page.BackKeyPress += backkey_Pressed;
                 }
                 else
                 {
                     _tcs.TrySetException(new Exception("Can not find RooLayout"));
                 }
             }
             else
             {
                 _tcs.TrySetException(new Exception("Can not find ApplicationPage"));
             }
         }
         else
         {
             _tcs.TrySetException(new Exception("Can not find ApplicationFrame"));
         }
     });
     return _tcs.Task;
 }
Example #30
0
        private void InitializeComponent()
        {
            this.Height = this.Width = 400;
            this.Left   = this.Top = 400;
            this.Title  = "WebBrowser Sample";

            var dockPanel = new DockPanel();

            #region Configure WebBrowser

            if (WebBrowser2 != null)
            {
                ((SHDocVw.DWebBrowserEvents_Event)_iWebBrowser2).BeforeNavigate += HandleBeforeNavigate;
                ((SHDocVw.DWebBrowserEvents_Event)_iWebBrowser2).NewWindow      += HandleNewWindow;
            }

            _currentWebBrowser.Height = 300;

            _currentWebBrowser.Cursor = Cursors.Arrow;
            #endregion

            var button = new Button();
            button.Content = "Icon Navigate";

            DockPanel.SetDock(_currentWebBrowser, Dock.Top);
            DockPanel.SetDock(button, Dock.Bottom);

            dockPanel.Children.Add(_currentWebBrowser);
            dockPanel.Children.Add(button);

            _currentWebBrowser.Navigate(new Uri("http://localhost:5000"));

            this.Content = dockPanel;


            Func <string> a = delegate
            {
                return("10086");
            };
        }
Example #31
0
        public Vk Authorize(string scope)
        {
            var vk = new Vk();
            var thread = new Thread(() =>
            {
                var window = new Window { Width = 800, Height = 600 };
                
                Thickness brwsMargin = new Thickness(0, 0, 0, 0);
                var browser = new WebBrowser() { Margin = brwsMargin };
                window.Content = browser;

                var authLink = String.Format("https://oauth.vk.com/authorize?client_id={0}&display=popup&redirect_uri=https://oauth.vk.com/blank.html&scope={1}&response_type=token&v=5.37", appID, scope);
                browser.Navigate(authLink);

                browser.Navigated += (sender, e) =>
                {
                    if (e.Uri.GetLeftPart(UriPartial.Query) == "https://oauth.vk.com/blank.html")
                    {
                        var url = new Uri(e.Uri.AbsoluteUri.Replace('#', '?'));
                        var parameters = HttpUtility.ParseQueryString(url.Query);
                        var accessToken = parameters.Get("access_token");
                        var expiresIn = parameters.Get("expires_in");
                        var userId = parameters.Get("user_id");
                        var isAuthorized = true;
                        vk = new Vk(accessToken, expiresIn, userId, isAuthorized);
                        window.Close();
                    }
                    else if (e.Uri.GetLeftPart(UriPartial.Query) == "https://oauth.vk.com/")
                    {
                        throw new Exception("Ошибка: Проверьте подключен ли Интеренет и пройдена ли авторизация.");
                    }
                };
                window.ShowDialog();
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
            return vk;
        }
Example #32
0
        public void newWb(string url)
        {            
            if (webBrowser != null)
            {
                webBrowser.LoadCompleted -= completed;
                webBrowser.Dispose();
                gridwebBrowser.Children.Remove(webBrowser);
            }

            if (doc != null)
            {
                doc.clear();                
            }

            webBrowser = new WebBrowser();            
            webBrowser.LoadCompleted += completed;
            gridwebBrowser.Children.Add(webBrowser);

            Script.HideScriptErrors(webBrowser, true);

            if (url == "")
            {
                webBrowser.NavigateToString(Properties.Resources.New);
                doc = webBrowser.Document as HTMLDocument;                
                doc.designMode = "On";
                Format.doc = doc;
                return;
            }
            else
            {
                webBrowser.Navigate(url);
            }
            
            doc = webBrowser.Document as HTMLDocument;
            Format.doc = doc;
        }
Example #33
0
    public DataSetView(RegionOptions options)
    : base(options.Width, options.Height, options.Top, options.Left)
    {
        _layoutId = options.layoutId;
        _regionId = options.regionId;
        _mediaId = options.mediaid;
        _duration = options.Duration;
        _scaleFactor = options.ScaleFactor;

        _updateInterval = Convert.ToInt32(options.Dictionary.Get("updateInterval"));

        _backgroundImage = options.backgroundImage;
        _backgroundColor = options.backgroundColor;

        // Set up the backgrounds
        _backgroundTop = options.BackgroundTop + "px";
        _backgroundLeft = options.BackgroundLeft + "px";

        // Create a webbrowser to take the temp file loc
        _webBrowser = new WebBrowser();
        //_webBrowser.ScriptErrorsSuppressed = true;
        //_webBrowser.Size = this.Size;
        //_webBrowser.ScrollBarsEnabled = false;
        _webBrowser.LoadCompleted +=  (webBrowser_DocumentCompleted);

        if (HtmlReady())
        {
            // Navigate to temp file
            string filePath = Settings.Default.LibraryPath + @"\" + _mediaId + ".htm";
            _webBrowser.Navigate(filePath);
        }
        else
        {
            RefreshLocalHtml();
        }
    }
		private void AuthorizeOnUIThread(string authorizeUri)
		{
			// Set an embedded webBrowser that displays the authorize page
			var webBrowser = new WebBrowser();
			webBrowser.Navigating += WebBrowserOnNavigating;

			// Display the webBrowser in a window (default behavior, may be customized by an application)
			_window = new Window
			{
				Content = webBrowser,
				Height = 480,
				Width = 480,
				WindowStartupLocation = WindowStartupLocation.CenterOwner,
				Owner = Application.Current != null && Application.Current.MainWindow != null
							? Application.Current.MainWindow
							: null
			};

			_window.Closed += OnWindowClosed;
			webBrowser.Navigate(authorizeUri);

			// Display the Window
			_window.ShowDialog();
		}
Example #35
0
        private void ShowInAppBrowser(string url)
        {
            Uri loc = new Uri(url);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (browser != null)
                {
                    //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
                    browser.Navigate(loc);
                }
                else
                {
                    PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
                    if (frame != null)
                    {
                        PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
                       // WebBrowser br = (page.FindName("CordovaView") as CordovaView).Browser;//

                        if (page != null)
                        {
                            Grid grid = page.FindName("LayoutRoot") as Grid;
                            if (grid != null)
                            {
                                browser = new WebBrowser();
                                browser.Navigate(loc);

                                browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);

                                browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
                                browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
                                browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
                                browser.IsScriptEnabled = true;
                                //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
                                grid.Children.Add(browser);
                            }

                            ApplicationBar bar = new ApplicationBar();
                            bar.BackgroundColor = Colors.Gray;
                            bar.IsMenuEnabled = false;

                            backButton = new ApplicationBarIconButton();
                            backButton.Text = "Back";
                            backButton.IconUri = new Uri("/Images/appbar.back.rest.png", UriKind.Relative);
                            backButton.Click += new EventHandler(backButton_Click);
                            backButton.IsEnabled = false;
                            bar.Buttons.Add(backButton);

                            fwdButton = new ApplicationBarIconButton();
                            fwdButton.Text = "Forward";
                            fwdButton.IconUri = new Uri("/Images/appbar.next.rest.png", UriKind.Relative);
                            fwdButton.Click += new EventHandler(fwdButton_Click);
                            fwdButton.IsEnabled = false;
                            bar.Buttons.Add(fwdButton);

                            ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
                            closeBtn.Text = "Close";
                            closeBtn.IconUri = new Uri("/Images/appbar.close.rest.png", UriKind.Relative);
                            closeBtn.Click += new EventHandler(closeBtn_Click);
                            bar.Buttons.Add(closeBtn);

                            page.ApplicationBar = bar;
                        }

                    }
                }
            });
        }
        /// <summary>
        /// gets access token
        /// <summary>
        public void getFlickerAccessToken()
        {
            string url = flickr.AuthCalcUrl(frob, FlickrNet.AuthLevel.Write);
            Uri uri = new Uri(url);
           _webBrowser = new WebBrowser();
            _webBrowser.IsScriptEnabled = true;

            container.Children.Add(_webBrowser);
            _webBrowser.Navigate(uri);
            _webBrowser.Navigated += flickrLogin_Navigated;         
            
        }
Example #37
0
        public KanColleBrowser()
        {
            InitializeComponent();
            WebBrowser.Navigated     += (_, __) => ApplyZoomFactor(zoomFactor);
            WebBrowser.LoadCompleted += (_, __) => LockFlash(IsFlashLocked);
            SetSilence(true);
            SetAllowDrop(false);

            //btnBack.Click += (_, __) => WebBrowser.GoBack();
            //btnFoward.Click += (_, __) => WebBrowser.GoForward();
            GotoUrlCommand = new DelegateCommand(() =>
            {
                if (!txtAddress.Text.Contains(":"))
                {
                    txtAddress.Text = "http://" + txtAddress.Text;
                }
                try
                {
                    WebBrowser.Navigate(txtAddress.Text);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);
                }
            });
            btnRefresh.Click      += (_, __) => WebBrowser.Navigate(WebBrowser.Source);
            btnBackToGame.Click   += (_, __) => WebBrowser.Navigate(Properties.Settings.Default.GameUrl);
            btnStop.Click         += (_, __) => Stop();
            WebBrowser.Navigating += (_, e) =>
            {
                txtAddress.Text = e.Uri.AbsoluteUri;
                //btnBack.IsEnabled = WebBrowser.CanGoBack;
                //btnFoward.IsEnabled = WebBrowser.CanGoForward;
                styleSheet = null;
                UpdateSize(false);
            };
            btnScreenShot.Click += (_, __) => TakeScreenShot(Config.Current.GenerateScreenShotFileName());
            btnCleanCache.Click += async(sender, _) =>
            {
                var button = sender as Button;
                button.IsEnabled = false;
                if (MessageBox.Show(StringTable.CleanCache_Alert, "", MessageBoxButton.YesNo, MessageBoxImage.Asterisk) == MessageBoxResult.Yes)
                {
                    if (await WinInetHelper.DeleteInternetCacheAsync())
                    {
                        MessageBox.Show(StringTable.CleanCache_Success);
                    }
                    else
                    {
                        MessageBox.Show(StringTable.CleanCache_Fail);
                    }
                }
                button.IsEnabled = true;
            };

            this.Loaded += (_, __) =>
            {
                if (firstLoad && Officer.Staff.IsStarted)
                {
                    var url = Config.Current.OverrideGameUrl;
                    if (string.IsNullOrWhiteSpace(url))
                    {
                        url = Properties.Settings.Default.GameUrl;
                    }
                    WebBrowser.Navigate(url);
                    firstLoad = false;
                }
            };
        }
Example #38
0
 public WebBrowserSample()
 {
     InitializeComponent();
     _currentWebBrowser.Navigate(new Uri("https://www.baidu.com"));
 }
 private void wikiHelpLink_Click(object sender, RoutedEventArgs e)
 {
     //System.Diagnostics.Process.Start(ScoreboardConfig.SCOREBOARD_SCOREBOARD_WIKI_URL);
     WebBrowser b = new WebBrowser();
     b.Navigate(ScoreboardConfig.SCOREBOARD_SCOREBOARD_WIKI_URL, "_blank", null, null);
 }
Example #40
0
 public void Navigate(string rpUrl) => r_Browser.Navigate(rpUrl);
Example #41
0
		private void InsertWebBrowser (TabItem ParentItem, String WebLinkData, RectangleF Sizing)
			{
			WebBrowser WebContent = new WebBrowser ();
			ParentItem.Content = WebContent;
			WebContent.Width = Sizing.Width;
			WebContent.Height = Sizing.Height;
			if (WebLinkData.IndexOf ('/') == -1)
				{
				WebLinkData = "http://www.citynews.at/WPMediaDataPages/" + WebLinkData;
				}
			Uri LinkUri = new Uri (WebLinkData);
			WebContent.Navigate (LinkUri);
			//ParentItem.Header = (Object) WebLinkData;
			}
Example #42
-2
        //AAAIOfwttlbABADAgOfra14zhgQi2V82yNfuscJjLIwX0rT9nqRg4YYbmxZAZByKwq0lYWVvn9f1fIfEbY3i1wmQx2tZAOtpRxqGEDlE2phqiltqLw3X
        //access token for me
        public static void PostToWall(string message, long userId, string wallAccessToken, WebBrowser fBrowser)
        {
            var fb = new FacebookClient(wallAccessToken);
            string url = string.Format("{0}/{1}", userId, "feed");
            var argList = new Dictionary<string, object>();
            argList["message"] = message;
            fb.Post(url, argList);

            var fb2 = new FacebookClient();
            var logoutUrl = fb.GetLogoutUrl(new { access_token = wallAccessToken, next = "https://www.facebook.com/connect/login_success.html" });
            fBrowser.Navigate(logoutUrl);
        }