/// <summary> /// The scan service scan status changed event handler /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ScanStatusChangedHandler(object sender, ScanProgressEventArgs e) { Subscribers.ForEach( delegate(IHbServiceCallback callback) { if (((ICommunicationObject)callback).State == CommunicationState.Opened) { Console.WriteLine("Scan Changed Callback"); callback.ScanProgressCallback(e); } else { Subscribers.Remove(callback); } }); }
/// <summary> /// Update the Status label for the scan /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void SourceScanScanStatusChanged(object sender, ScanProgressEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new ScanProgessStatus(this.SourceScanScanStatusChanged), new[] { sender, e }); return; } labelSource.Text = string.Format("Processing Title: {0} of {1}", e.CurrentTitle, e.Titles); }
/// <summary> /// Fire an event when the scan process progresses /// </summary> /// <param name="sender">the sender</param> /// <param name="currentTitle">the current title being scanned</param> /// <param name="titleCount">the total number of titles</param> private void OnScanProgress(object sender, int currentTitle, int titleCount) { ScanProgressEventArgs eventArgs = new ScanProgressEventArgs { CurrentTitle = currentTitle, Titles = titleCount }; if (this.ScanStatusChanged != null) { this.ScanStatusChanged(this, eventArgs); } }
/// <summary> /// Scan Status has changed, update log window. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ScanServiceScanStatusChanged(object sender, ScanProgressEventArgs e) { this.NotifyOfPropertyChange(() => this.ScanLog); }
/// <summary> /// The scan progress callback. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> public override void ScanProgressCallback(ScanProgressEventArgs eventArgs) { if (this.ScanStatusChanged != null) { ThreadPool.QueueUserWorkItem(delegate { this.ScanStatusChanged(this, eventArgs); }); } base.ScanProgressCallback(eventArgs); }
/// <summary> /// The scan progress. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> public virtual void ScanProgressCallback(ScanProgressEventArgs eventArgs) { }
/// <summary> /// Handle the Scan Status Changed Event. /// </summary> /// <param name="sender"> /// The Sender /// </param> /// <param name="e"> /// The EventArgs /// </param> private void ScanStatusChanged(object sender, ScanProgressEventArgs e) { this.SourceLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage); this.StatusLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage); }