Exemplo n.º 1
0
 /// <summary>
 /// The stop.
 /// </summary>
 /// <param name="monitor">
 /// The monitor.
 /// </param>
 internal void Stop(FareRequestMonitor monitor)
 {
     this._monitors.Clear(monitor.GetType());
 }
Exemplo n.º 2
0
        /// <summary>
        /// The fare monitor_ request completed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        private void FareMonitor_RequestCompleted(FareRequestMonitor sender, FareBrowserRequestArg args)
        {
            // This method should be triggered both before stopping the request or after the request is completed
            var browser = args.Request.BrowserControl; // The browser might be nulled
            this.InvokeActionIfNeeded(
                new Action(
                    () =>
                        {
                            SwitchButton senderBtn = null;
                            var monType = sender.GetType();
                            var resultRoute = browser == null ? null : browser.LastRetrievedRoute;

                            if (monType == typeof(FareRequestMonitor))
                            {
                                // Browser can be nulled if the request was aborted before it is event started
                                if (browser != null && resultRoute != null && !this.btnSummary.Enabled)
                                {
                                    this.SetDataProcessor(true);
                                }

                                senderBtn = this.btnShowFare;
                            }
                            else if (monType == typeof(FareExportMonitor))
                            {
                                senderBtn = this.btnGetFareAndSave;
                            }

                            this.IncreaseProgress();
                            this.CheckProgress();

                            if (!this.loadProgress.Visible && senderBtn != null)
                            {
                                var senderMonitor = senderBtn.Tag as FareRequestMonitor;
                                if (senderMonitor == sender && senderBtn.IsSecondState)
                                {
                                    senderBtn.IsSecondState = false; // Reset the button after everything is done!
                                }
                            }
                        }));
        }