コード例 #1
0
        /* ==================================
         * IMPLEMENTED METHODS
         * ==================================*/

        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void SetCurrentState(HttpAnswer answer, Node <HttpQuery> current)
        {
            if (this.InvokeRequired)
            {
                this.textBoxUrlInput.Invoke(new Action(() => this.UpdateControls(answer, current)));
            }
            else
            {
                this.UpdateControls(answer, current);
            }
        }
コード例 #2
0
        /* ==================================
         * INTERNAL METHODS
         * ==================================*/

        /// <summary>
        /// Updates a lot of controls with the received information
        /// Does the heavy-lifting for <see cref="SetCurrentState(HttpAnswer, Node{HttpQuery})"/>
        /// </summary>
        /// <param name="answer">State of the HTML displayer</param>
        /// <param name="current">State of the navigation</param>
        private void UpdateControls(HttpAnswer answer, Node <HttpQuery> current)
        {
            this.Text = "Browser – " + answer.Title;
            this.richTextBoxHtmlDisplay.Text = answer.Html;

            this.toolStripStatusLabelHttpStatusCode.Text = current.Center.StatusCode.ToString();
            this.toolStripStatusLabelHttpStatus.Text     = current.Center.Status;

            this.buttonFav.Enabled    = current.HasCenter;
            this.buttonReload.Enabled = current.HasCenter;

            this.favToolStripMenuItem.Enabled    = current.HasCenter;
            this.reloadToolStripMenuItem.Enabled = current.HasCenter;

            this.generatedToolTips.ForEach(tooltip => tooltip.Dispose());
            this.UpdateNavigationControls(this.buttonBackward, current.Left);
            this.UpdateNavigationControls(this.buttonForward, current.Right);
            this.textBoxUrlInput.Text = current.Center.Uri.AbsoluteUri;
        }
コード例 #3
0
        /* ==================================
         * INTERNAL METHODS
         * ==================================*/

        /// <summary>
        /// Executes the provied <paramref name="query"/> and updates the view with the result.
        /// </summary>
        /// <param name="query"><see cref="HttpQuery"/> to execute</param>
        private async void LoadPageAsync(HttpQuery query)
        {
            this.view.SetCurrentState(HttpAnswer.MakeFetchingAnswer(), this.navigation.CurrentNode);

            HttpAnswer answer;

            try
            {
                answer = await HttpQueryHelper.ExecuteAsync(query);
            }
            catch (HttpRequestException)
            {
                this.view.ErrorDialog("Could not reach host " + query.Host);
                answer = HttpAnswer.MakeErrorAnswer();
            }

            query.Title      = answer.Title;
            query.StatusCode = answer.StatusCode;
            this.UpdateHistory();
            this.view.IsCurrentAFav(this.user.Favorites.Contains(query.Uri));
            this.view.SetCurrentState(answer, this.navigation.CurrentNode);
        }