コード例 #1
0
ファイル: LoginXP.cs プロジェクト: pheisen/EACDM-Utility
        private void startBrowser()
        {
            tryingToClick = 0;
            int logoutCount = 0;

            QTIUtility.wbHelper.ClearCookie();
            if (wb != null)
            {
                wb.Dispose();
                wb = null;
            }
            wb = new MyWebBrowser();
            wb.ScriptErrorsSuppressed = true;
            wb.ScrollBarsEnabled      = true;
            wb.Visible = false;
            pnWb.Controls.Add(wb);
            wb.Dock               = DockStyle.Fill;
            wb.Navigating        += wb_Navigating;
            wb.DocumentCompleted += wb_DocumentCompleted;
            wb.Url = new Uri(BbQuery.BbLoginUrlNative + "/?action=relogin");
            Thread.Sleep(1000);
            while (wb.IsBusy)
            {
                if (logoutCount == 0)
                {
                    //BbLogout();
                    logoutCount++;
                    Debug.WriteLine("pre-logout wth " + BbQuery.BbLogoutUrlNative);
                }
            }
        }
コード例 #2
0
ファイル: Federation.cs プロジェクト: rayalexander/Samples
        string GetToken(string token, string url)
        {
            Form         f  = new Form();
            MyWebBrowser wb = new MyWebBrowser(token);

            wb.Dock = DockStyle.Fill;
            f.Controls.Add(wb);
            wb.Navigate(url);
            f.WindowState = FormWindowState.Maximized;
            f.ShowDialog();

            string st = wb.CapturedUrl;

            f.Dispose();

            if (st == null)
            {
                throw new Exception("Oops! Error getting the token");
            }

            int index = st.IndexOfAny(new char[] { '?', '#' });

            st = index < 0 ? "" : st.Substring(index + 1);
            NameValueCollection pairs = HttpUtility.ParseQueryString(st);

            string tokenValue = pairs[token];

            Console.WriteLine("TOKEN={0}, Value={1}", token, tokenValue);
            return(tokenValue);
        }
コード例 #3
0
ファイル: HelpScreen.xaml.cs プロジェクト: shravyashravz/WPF
 //This was a killer issue audio played in the background hence the work around : Shravya
 private void DoSomething(object sender, EventArgs e)
 {
     if (MyWebBrowser != null)
     {
         MyWebBrowser.Dispose();
     }
 }
コード例 #4
0
        private async void MyButton_Click2(object sender, RoutedEventArgs e)
        {
            string myHtml = "Bla";

            Debug.WriteLine($"Thread Nr {Thread.CurrentThread.ManagedThreadId} before await task");
            await Task.Run(async() =>
            {
                Debug.WriteLine($"Thread Nr {Thread.CurrentThread.ManagedThreadId} during await task");
                HttpClient webClient = new HttpClient();
                //webClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml");
                //webClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate");
                //webClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
                //webClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1");

                //header manipulation solution according to answer by saman shariat in 4 lines above, it's needed for downloads
                // https://www.udemy.com/course/complete-csharp-masterclass/learn/lecture/10736712#questions/7362414
                //this below was to download a file
                //string html = webClient.GetStringAsync("http://ipv4.download.thinkbroadband.com/20MB.zip").Result;
                string html = webClient.GetStringAsync("https://google.com").Result;
                myHtml      = html;
            });

            Debug.WriteLine($"Thread Nr {Thread.CurrentThread.ManagedThreadId} after wait task");

            MyButton.Content = "Done Downloading";
            MyWebBrowser.SetValue(HtmlProperty, myHtml);
        }
コード例 #5
0
        // TODO: Setup this same test in Godot and see if it is blocking or not.
        // Testing threading is something I can use to ease myself into Godot development.
        private async void MyButton_Click2(object sender, RoutedEventArgs e)
        {
            // Two things are going on when you use async/await:
            // 1) You are making a thread that does something
            // 2) You are pausing the execution of the function until the thread is done.
            // Any function that calls the async function has two choices:
            // 1) Call the function as normal, in which case as soon as the async function gets to
            //    await, it will bump back out to the calling function and continue execution there.
            //    I think this is what the yeild statement does in Godot.(Godot's yield statement pauses a function
            //    and saves its state. You can resume the function by calling .resume() on the function
            //    await/async is like a special case of yield, and yield is a general solution.)
            // 2) Call the function and use await on it or a task object you assign the function to.
            //    This will pause the calling function at the await point, and means the calling function
            //    must also be async and return a Task<T>.
            Debug.WriteLine($"Thread Nr. {Thread.CurrentThread.ManagedThreadId} before await task");
            if (!Downloading)
            {
                string myHtml = "Bla";
                await Task.Run(async() =>
                {
                    Debug.WriteLine($"Thread Nr. {Thread.CurrentThread.ManagedThreadId} during await task");
                    Downloading          = true;
                    HttpClient webClient = new HttpClient();
                    myHtml      = webClient.GetStringAsync("https://google.com").Result;
                    Downloading = false;
                });

                Debug.WriteLine($"Thread Nr. {Thread.CurrentThread.ManagedThreadId} after await task");
                MyButton.Content = "Done Downloading";
                MyWebBrowser.SetValue(HtmlProperty, myHtml);
            }
        }
コード例 #6
0
 private void Forward(object sender, RoutedEventArgs e)
 {
     if (!MyWebBrowser.CanGoForward)
     {
         return;
     }
     MyWebBrowser.GoForward();
 }
コード例 #7
0
 private void Back(object sender, RoutedEventArgs e)
 {
     if (!MyWebBrowser.CanGoBack)
     {
         return;
     }
     MyWebBrowser.GoBack();
 }
コード例 #8
0
ファイル: LoginXP.cs プロジェクト: pheisen/EACDM-Utility
 private void btnCancel_Click(object sender, EventArgs e)
 {
     if (wb != null)
     {
         wb.Dispose();
         wb = null;
     }
     Close();
 }
コード例 #9
0
    public Form1()
    {
        InitializeComponent();

        _webBrowser      = new MyWebBrowser();
        _webBrowser.Dock = DockStyle.Fill;

        Controls.Add(_webBrowser);
    }
コード例 #10
0
 private void MyForward_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MyWebBrowser.GoForward();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #11
0
 private void Visit(object sender, RoutedEventArgs e)
 {
     try
     {
         MyWebBrowser.Navigate(new Uri(UrTextBox.Text));
     }
     catch
     {
         UrTextBox.Text = "Ошибка в Url";
     }
 }
コード例 #12
0
        public Form1()
        {
            InitializeComponent();

            //Allow the Webpage to call methods in this form.
            MyWebBrowser.ObjectForScripting = this;

            //Get the file path to the HTML file that has the map.
            string htmlPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName) + "\\Html\\Map.html";

            //Navigate to the local HTML file.
            MyWebBrowser.Navigate(new Uri(htmlPath));
        }
コード例 #13
0
 public void LoadMaps()
 {
     if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"..\..\View\GoogleMapsWebsite\ApplicationGoogleMaps.html"))
     {
         Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\View\GoogleMapsWebsite\ApplicationGoogleMaps.html");
         MyWebBrowser.Navigate(uri);
     }
     else
     {
         Uri toMaps = new Uri("http://62.107.0.222:80/umu/assets/ApplicationGoogleMaps.html");
         MyWebBrowser.Navigate(toMaps);
     }
 }
コード例 #14
0
        public FormPluginBrowser(ViewSupport aSupport, HttpClient aHttpClient, string aUrl)
        {
            iSupport = aSupport;

            AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
            AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            AutoSize            = true;
            ControlBox          = false;
            Font          = new Font(iSupport.FontSmall, FontStyle.Bold);
            Text          = "Kinsky Plugins";
            MaximizeBox   = false;
            MinimizeBox   = false;
            ShowIcon      = true;
            ShowInTaskbar = false;
            //StartPosition = FormStartPosition.CenterParent;
            ForeColor = iSupport.ForeColourBright;

            string html = "<html><head></head><body bgcolor=\"black\"><p><font face=\"arial\" color=\"white\"><b>Not Available</b></font></p></body>";

            Stream stream = aHttpClient.RequestHigh(new Uri(aUrl));

            if (stream != null)
            {
                int          count      = 0;
                byte[]       tempBuffer = new byte[1024];
                MemoryStream buffer     = new MemoryStream();
                do
                {
                    count = stream.Read(tempBuffer, 0, tempBuffer.Length);
                    buffer.Write(tempBuffer, 0, count);
                } while (count > 0);

                byte[] body = buffer.GetBuffer();
                html = ASCIIEncoding.UTF8.GetString(body, 0, body.Length);

                stream.Close();
                buffer.Close();
            }

            iWebBrowser          = new MyWebBrowser(html);
            iWebBrowser.Size     = ClientSize;
            iWebBrowser.Location = ClientRectangle.Location;

            Controls.Add(iWebBrowser);

            ClientSize       = new System.Drawing.Size(600, 400);
            iWebBrowser.Size = ClientSize;

            iSupport.EventSupportChanged += SupportChanged;
        }
コード例 #15
0
        private void LoadInputAndOutputIntoResultGrid(int numColumns)
        {
            var inputLines  = GetText(TbxInput).Split("\n".ToCharArray());
            var outputLines = GetText(TbxOutput).Split("\n".ToCharArray());

            string rows;

            if (numColumns == 1)
            {
                rows = inputLines
                       .Select((inputLine, i) => new[] { inputLine, i < outputLines.Length ? outputLines[i] : "" })
                       .Select((linePair, i) => CreateOneColumnRow(linePair[0], linePair[1]))
                       .Aggregate((a, b) => a + b);
            }
            else
            {
                rows = inputLines
                       .Select((inputLine, i) => new[] { inputLine, i < outputLines.Length ? outputLines[i] : "" })
                       .Select((linePair, i) => CreateTwoColumnRow(linePair[0], linePair[1], i % 2 == 0))
                       .Aggregate((a, b) => a + b);
            }

            var content =
                $@"
<!DOCTYPE html>
<html>
<head>
    <link rel=""stylesheet"" href=""https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"" crossorigin=""anonymous"">
</head>
<body>
    <div class=""container"">
        <table class=""table table-striped"">
        <thead></thead>
        <tbody>
            {rows}
        </tbody>
        </table>
    </div>
</body>
</html>";

            if (numColumns == 2)
            {
                content = content.Replace("<thead></thead>", "<thead><th>Input</th><th>Output</th></thead>");
            }

            MyWebBrowser.NavigateToString(content);
        }
コード例 #16
0
        private async void MyButton_Click2(object sender, RoutedEventArgs e)
        {
            string myHtml = "Browser";

            Debug.WriteLine($"Thread Nr. {Thread.CurrentThread.ManagedThreadId}");

            await Task.Run(async() =>
            {
                HttpClient webClient = new HttpClient();
                string html          = webClient.GetStringAsync("https://Google.com").Result;
                myHtml = html;
            });

            MyButton.Content = "Done Downloading";
            MyWebBrowser.SetValue(HtmlProperty, myHtml);
        }
コード例 #17
0
        /// <summary>
        /// Initializes a new instance of the WebBrowserVM class.
        /// </summary>
        public BuySellShareBaseVM(Uri aUri, CommonVM aCommonVM, Int32 aColumn, Int32 aRow, Int32 aCode)
            : base(aCommonVM)
        {
            MyGrid = new MyWebBrowser();
            MyGrid.DataContext = this;
            Grid.SetRow(MyGrid, aRow);
            Grid.SetColumn(MyGrid, aColumn);
            Grid.SetColumnSpan(MyGrid, 3);
            Grid.SetRowSpan(MyGrid, 4);

            MyUri = aUri;
            WB = this.MyGrid.Children.OfType<WebBrowser>().First();
            MyStatus = Status.Watching;
            Code = aCode;

            User = CVM.GetIniData("login.ini", "LOGIN", "USER");
            Pass = CVM.GetIniData("login.ini", "LOGIN", "PASS");
        }
コード例 #18
0
ファイル: ACheckWBVM.cs プロジェクト: kasuaki/WPFApplication
        /// <summary>
        /// Initializes a new instance of the WebBrowserVM class.
        /// </summary>
        public ACheckWBVM(Uri aUri, CommonVM aCommonVM, Int32 aColumn, Int32 aRow)
            : base(aCommonVM)
        {
            MyGrid = new MyWebBrowser();
            MyGrid.DataContext = this;
            Grid.SetRow(MyGrid, aRow);
            Grid.SetColumn(MyGrid, aColumn);
            Grid.SetColumnSpan(MyGrid, 3);

            MyUri = aUri;
            WB = this.MyGrid.Children.OfType<WebBrowser>().First();
            MyStatus = Status.Watching;

            _MyDispatcherTimer = new DispatcherTimer(new TimeSpan(30 * TimeSpan.TicksPerSecond),
                                                     DispatcherPriority.Normal,
                                                     MyDispatcherTimer_Tick,
                                                     Dispatcher.CurrentDispatcher) { IsEnabled = false };

            LoadCompletedCommand = new RelayCommand<WebBrowser>(LoadCompletedEvent);

            User = CVM.GetIniData("login.ini", "LOGIN", "USER");
            Pass = CVM.GetIniData("login.ini", "LOGIN", "PASS");
        }
コード例 #19
0
ファイル: FormBrowser.cs プロジェクト: AmayerGogh/CobWeb
        void BrowserInit()
        {
            this.browser = new MyWebBrowser("about:blank")
            {
            };
            this.browser.Location    = new System.Drawing.Point(0, 0);
            this.browser.Margin      = new System.Windows.Forms.Padding(0, 0, 0, 0);
            this.browser.MinimumSize = new System.Drawing.Size(20, 20);
            this.browser.Name        = "webBrowser1";
            this.browser.Size        = new System.Drawing.Size(963, 519);
            this.browser.TabIndex    = 1;


            this.browser.StartNewWindow += Browser_StartNewWindow;
            this.browser.TitleChanged   += Browser_TitleChanged; //new EventHandler<TitleChangedEventArgs>
            this.browser.FrameLoadEnd   += Browser_FrameLoadEnd;
            this.browser.FrameLoadStart += Browser_FrameLoadStart;

            this.browser.LoadHandler = new LoadHandler();
            if (CefSharpSettings.ShutdownOnExit)
            {
                Application.ApplicationExit += OnApplicationExit;
            }
        }
コード例 #20
0
 private void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     MyWebBrowser.Navigate(HistoryBox.SelectedItem.ToString());
 }
コード例 #21
0
ファイル: Federation.cs プロジェクト: 40a/Samples
        string GetToken(string token, string url)
        {
            Form f = new Form();
            MyWebBrowser wb = new MyWebBrowser(token);
            wb.Dock = DockStyle.Fill;
            f.Controls.Add(wb);
            wb.Navigate(url);
            f.WindowState = FormWindowState.Maximized;
            f.ShowDialog();

            string st = wb.CapturedUrl;
            f.Dispose();

            if (st == null)
                throw new Exception("Oops! Error getting the token");

            int index = st.IndexOfAny(new char[] { '?', '#' });
            st = index < 0 ? "" : st.Substring(index + 1);
            NameValueCollection pairs = HttpUtility.ParseQueryString(st);

            string tokenValue = pairs[token];
            Console.WriteLine("TOKEN={0}, Value={1}", token, tokenValue);
            return tokenValue;
        }
コード例 #22
0
        private async Task <T> GetFromJS <T>(string javaScript)
        {
            var selectorResult = await MyWebBrowser.EvaluateScriptAsync(javaScript);

            return((T)selectorResult.Result);
        }
コード例 #23
0
 public MyWebBrowserSite(MyWebBrowser myWebBrowser)
     : base(myWebBrowser)
 {
     this.myWebBrowser = myWebBrowser;
 }
コード例 #24
0
ファイル: MyWebBrowser.cs プロジェクト: ovjust/InnerBuyAlarm
 public ExtendedWebBrowserSite(MyWebBrowser host)
     : base(host)
 {
     _Browser = host;
 }
コード例 #25
0
 private void FowardButtonClick(object sender, RoutedEventArgs e)
 {
     MyWebBrowser.GoForward();
 }
コード例 #26
0
 public MyWebBrowserSite(MyWebBrowser host)
     : base(host)
 {
     _host = host;
 }
コード例 #27
0
 private void BackButtonClick(object sender, RoutedEventArgs e)
 {
     MyWebBrowser.GoBack();
 }
コード例 #28
0
ファイル: DilicomForm.cs プロジェクト: etiennec/AideDC
 private void GoButton_Click(object sender, EventArgs e)
 {
     MyWebBrowser.Navigate(UrlText.Text);
 }
コード例 #29
0
 public void DisposeBrowser()
 {
     MyWebBrowser.Dispose();
 }