/// <summary> /// The encode service_ encode status changed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void encodeService_EncodeStatusChanged(object sender, EncodeProgressEventArgs e) { Subscribers.ForEach( delegate(IHbServiceCallback callback) { if (((ICommunicationObject)callback).State == CommunicationState.Opened) { Console.WriteLine("Encode Status Callback"); callback.EncodeProgressCallback(e); } else { Subscribers.Remove(callback); } }); }
/// <summary> /// Display the Encode Status /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void EncodeQueue_EncodeStatusChanged(object sender, EncodeProgressEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new EncodeProgessStatus(EncodeQueue_EncodeStatusChanged), new[] { sender, e }); return; } lbl_encode.Text = string.Format( "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}, Pending Jobs {5}", e.PercentComplete, e.CurrentFrameRate, e.AverageFrameRate, e.EstimatedTimeLeft, e.ElapsedTime, this.queueProcessor.QueueManager.Count); ProgressBarStatus.Value = (int)Math.Round(e.PercentComplete); }
/// <summary> /// Pase the CLI status output (from standard output) /// </summary> /// <param name="encodeStatus"> /// The encode Status. /// </param> /// <param name="startTime"> /// The start Time. /// </param> /// <returns> /// The <see cref="EncodeProgressEventArgs"/>. /// </returns> public EncodeProgressEventArgs ReadEncodeStatus(string encodeStatus, DateTime startTime) { try { Match m = Regex.Match( encodeStatus, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?"); if (m.Success) { int currentTask = int.Parse(m.Groups[1].Value); int totalTasks = int.Parse(m.Groups[2].Value); float percent = float.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture); float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value, CultureInfo.InvariantCulture); float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value, CultureInfo.InvariantCulture); string remaining = string.Empty; if (m.Groups[7].Value != string.Empty) { remaining = m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value; } if (string.IsNullOrEmpty(remaining)) { remaining = "Calculating ..."; } EncodeProgressEventArgs eventArgs = new EncodeProgressEventArgs { AverageFrameRate = avgFps, CurrentFrameRate = currentFps, EstimatedTimeLeft = Converters.EncodeToTimespan( remaining), PercentComplete = percent, Task = currentTask, TaskCount = totalTasks, ElapsedTime = DateTime.Now - startTime, }; return eventArgs; } return null; } catch (Exception exc) { return null; } }
/// <summary> /// Invoke the Encode Status Changed Event. /// </summary> /// <param name="e"> /// The EncodeProgressEventArgs. /// </param> public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e) { EncodeProgessStatus handler = this.EncodeStatusChanged; if (handler != null) { handler(this, e); } }
/// <summary> /// Handle the Encode Status Changed Event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EncodeProgressEventArgs. /// </param> private void EncodeService_EncodeStatusChanged( object sender, EncodeProgressEventArgs e) { this.JobStatus = string.Format( "Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}, Time Remaining: {5}, Elapsed: {6:hh\\:mm\\:ss}", e.Task, e.TaskCount, e.PercentComplete, e.CurrentFrameRate, e.AverageFrameRate, e.EstimatedTimeLeft, e.ElapsedTime); }
/// <summary> /// Displays the Encode status in the GUI /// </summary> /// <param name="sender">The sender</param> /// <param name="currentTask">The current task</param> /// <param name="taskCount">Number of tasks</param> /// <param name="percentComplete">Percent complete</param> /// <param name="currentFps">Current encode speed in fps</param> /// <param name="avg">Avg encode speed</param> /// <param name="timeRemaining">Time Left</param> private void EncodeOnEncodeProgress(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float avg, string timeRemaining) { EncodeProgressEventArgs eventArgs = new EncodeProgressEventArgs { AverageFrameRate = avg, CurrentFrameRate = currentFps, EstimatedTimeLeft = Converters.EncodeToTimespan(timeRemaining), PercentComplete = percentComplete, Task = currentTask, TaskCount = taskCount, ElapsedTime = DateTime.Now - this.startTime, }; this.Invoke_encodeStatusChanged(eventArgs); if (this.WindowsSeven.IsWindowsSeven) { int percent; int.TryParse(Math.Round(percentComplete).ToString(), out percent); this.WindowsSeven.SetTaskBarProgress(percent); } }
/// <summary> /// The encode progress callback. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> public override void EncodeProgressCallback(EncodeProgressEventArgs eventArgs) { if (this.EncodeStatusChanged != null) { ThreadPool.QueueUserWorkItem(delegate { this.EncodeStatusChanged(this, eventArgs); }); } base.EncodeProgressCallback(eventArgs); }
void OnEncodeStatusChanged(object sender, EncodeProgressEventArgs e) { Dispatcher.BeginInvoke(() => { if (this.encodingQueue.IsEncoding) { PercentComplete = e.PercentComplete; ETA = String.Format( "{0}% Complete. ETA: {1}", Math.Round(e.PercentComplete), e.EstimatedTimeLeft); } }); }
/// <summary> /// Encode Status has changed, update log window /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e) { if (encodeLogIndex != this.encodeService.LogIndex || this.encodeService.LogIndex == -1) { this.NotifyOfPropertyChange(() => this.EncodeLog); } encodeLogIndex = this.encodeService.LogIndex; }
/// <summary> /// Displays the Encode status in the GUI /// </summary> /// <param name="sender">The sender</param> /// <param name="currentTask">The current task</param> /// <param name="taskCount">Number of tasks</param> /// <param name="percentComplete">Percent complete</param> /// <param name="currentFps">Current encode speed in fps</param> /// <param name="avg">Avg encode speed</param> /// <param name="timeRemaining">Time Left</param> private void EncodeOnEncodeProgress(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float avg, string timeRemaining) { if (!this.IsEncoding) { // We can get events out of order since the CLI progress is monitored on a background thread. // So make sure we don't send a status update after an encode complete event. return; } EncodeProgressEventArgs eventArgs = new EncodeProgressEventArgs { AverageFrameRate = avg, CurrentFrameRate = currentFps, EstimatedTimeLeft = Converters.EncodeToTimespan(timeRemaining), PercentComplete = percentComplete, Task = currentTask, TaskCount = taskCount, ElapsedTime = DateTime.Now - this.startTime, }; this.Invoke_encodeStatusChanged(eventArgs); if (this.WindowsSeven.IsWindowsSeven) { int percent; int.TryParse(Math.Round(percentComplete).ToString(), out percent); this.WindowsSeven.SetTaskBarProgress(percent); } }
/// <summary> /// The encode progress callback. /// </summary> /// <param name="eventArgs"> /// The event Args. /// </param> public virtual void EncodeProgressCallback(EncodeProgressEventArgs eventArgs) { }
/// <summary> /// The Encode Status has changed Handler /// </summary> /// <param name="sender"> /// The Sender /// </param> /// <param name="e"> /// The Encode Progress Event Args /// </param> private void EncodeStatusChanged(object sender, EncodeProgressEventArgs e) { int percent; int.TryParse(Math.Round(e.PercentComplete).ToString(CultureInfo.InvariantCulture), out percent); Execute.OnUIThread( () => { if (this.queueProcessor.EncodeService.IsEncoding) { string josPending = string.Empty; if (!AppArguments.IsInstantHandBrake) { josPending = ", Pending Jobs {5}"; } this.ProgramStatusLabel = string.Format( "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}" + josPending, e.PercentComplete, e.CurrentFrameRate, e.AverageFrameRate, e.EstimatedTimeLeft, e.ElapsedTime, this.queueProcessor.Count); if (this.lastEncodePercentage != percent && this.windowsSeven.IsWindowsSeven) { this.windowsSeven.SetTaskBarProgress(percent); } this.lastEncodePercentage = percent; this.ProgressPercentage = percent; this.NotifyOfPropertyChange(() => this.ProgressPercentage); } else { this.ProgramStatusLabel = "Queue Finished"; this.IsEncoding = false; if (this.windowsSeven.IsWindowsSeven) { this.windowsSeven.SetTaskBarProgressToNoProgress(); } } }); }
/// <summary> /// Encode Status has changed, update log window /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e) { this.NotifyOfPropertyChange(() => this.Log); }
/// <summary> /// Invoke the Encode Status Changed Event. /// </summary> /// <param name="e"> /// The EncodeProgressEventArgs. /// </param> public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e) { Execute.OnUIThread( () => { EncodeProgessStatus handler = this.EncodeStatusChanged; if (handler != null) { handler(this, e); } }); }