1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using FastReport.Forms;
- using FastReport.Utils;
- namespace FastReport.Cloud.StorageClient.Box
- {
- /// <summary>
- /// Represents form of the web browser.
- /// </summary>
- public partial class WebBrowserForm : BaseForm
- {
- #region Fields
- private string url;
- private string authCode;
- #endregion // Fields
- #region Properties
- /// <summary>
- /// Gets obtained authorization code.
- /// </summary>
- public string AuthCode
- {
- get { return authCode; }
- }
- #endregion // Properties
- #region Constructros
- /// <inheritdoc/>
- public WebBrowserForm(string url)
- {
- InitializeComponent();
- this.url = url;
- authCode = "";
- UIUtils.CheckRTL(this);
- }
- #endregion // Constructros
- #region Events Handlers
- private void WebBrowserForm_Shown(object sender, EventArgs e)
- {
- wbBrowser.Navigate(url);
- }
- private void wbBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
- {
- if (wbBrowser.Url.ToString().Contains("code="))
- {
- Console.WriteLine(wbBrowser.Url.ToString());
- authCode = Regex.Split(Regex.Split(wbBrowser.Url.ToString(), "code=")[1], "<")[0];
- Close();
- }
- }
- #endregion // Events Handlers
- }
- }
|