X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmActivityWindow.cs;h=ee3d3bf750d20980f044f3efd290bbfaad629469;hb=4560ade3c833f282f02d15a9473e233488617df9;hp=7686a0d1d97a6d512208b41c373f9b185fb5ced6;hpb=c5f9ff4bdc1935bfa25a9e25abb0a22504eadbaf;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 7686a0d1..ee3d3bf7 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -12,9 +12,12 @@ namespace Handbrake using System.Text; using System.Threading; using System.Windows.Forms; - using Functions; + + using HandBrake.Framework.Services; + using HandBrake.Framework.Services.Interfaces; + using HandBrake.ApplicationServices.Services.Interfaces; + using Model; - using Services; using Timer = System.Threading.Timer; /// @@ -25,24 +28,29 @@ namespace Handbrake /* Private Variables */ /// - /// The current position in the log file + /// The Encode Object /// - private int position; + private readonly IQueue encode; /// - /// A Timer for this window + /// The Scan Object /// - private Timer windowTimer; + private readonly IScan scan; /// - /// The Encode Object + /// The Error service /// - private Encode encode; + private readonly IErrorService errorService = new ErrorService(); /// - /// The Scan Object + /// The current position in the log file + /// + private int position; + + /// + /// A Timer for this window /// - private ScanService scan; + private Timer windowTimer; /// /// The Type of log that the window is currently dealing with @@ -60,7 +68,7 @@ namespace Handbrake /// /// The scan. /// - public frmActivityWindow(Encode encode, ScanService scan) + public frmActivityWindow(IQueue encode, IScan scan) { InitializeComponent(); @@ -96,7 +104,7 @@ namespace Handbrake /// private delegate void SetModeCallback(ActivityLogMode setMode); - /* Public Methods */ + /* Private Methods */ /// /// Set the window to scan mode @@ -110,7 +118,7 @@ namespace Handbrake { if (rtf_actLog.InvokeRequired) { - IAsyncResult invoked = BeginInvoke(new SetModeCallback(SetMode), new object[] {setMode}); + IAsyncResult invoked = BeginInvoke(new SetModeCallback(SetMode), new object[] { setMode }); EndInvoke(invoked); } else @@ -119,7 +127,7 @@ namespace Handbrake this.mode = setMode; Array values = Enum.GetValues(typeof(ActivityLogMode)); - Properties.Settings.Default.ActivityWindowLastMode = (int) values.GetValue(Convert.ToInt32(setMode)); + Properties.Settings.Default.ActivityWindowLastMode = (int)values.GetValue(Convert.ToInt32(setMode)); Properties.Settings.Default.Save(); this.Text = mode == ActivityLogMode.Scan @@ -143,8 +151,6 @@ namespace Handbrake } } - /* Private Methods */ - /// /// On Window load, start a new timer /// @@ -152,12 +158,32 @@ namespace Handbrake /// The sender. /// /// - /// The e. + /// The EventArgs. /// - private void NewActivityWindow_Load(object sender, EventArgs e) + private void ActivityWindowLoad(object sender, EventArgs e) { - ActivityLogMode activitLogMode = (ActivityLogMode) Enum.ToObject(typeof(ActivityLogMode), Properties.Settings.Default.ActivityWindowLastMode); - SetMode(activitLogMode); + try + { + // Set the inital log file. + if (encode.IsEncoding) + { + this.logSelector.SelectedIndex = 1; + } + else if (scan.IsScanning) + { + this.logSelector.SelectedIndex = 0; + } + else + { + // Otherwise, use the last mode the window was in. + ActivityLogMode activitLogMode = (ActivityLogMode)Enum.ToObject(typeof(ActivityLogMode), Properties.Settings.Default.ActivityWindowLastMode); + this.logSelector.SelectedIndex = activitLogMode == ActivityLogMode.Scan ? 0 : 1; + } + } + catch (Exception exc) + { + errorService.ShowError("Error during load.", exc.ToString()); + } } /// @@ -200,6 +226,7 @@ namespace Handbrake private void stopWindowRefresh(object sender, EventArgs e) { windowTimer.Dispose(); + Reset(); LogMonitor(null); } @@ -224,38 +251,45 @@ namespace Handbrake { StringBuilder appendText = new StringBuilder(); - if (this.mode == ActivityLogMode.Scan) + try { - if (scan == null || scan.ActivityLog == string.Empty) + if (this.mode == ActivityLogMode.Scan) { - appendText.AppendFormat("Waiting for the log to be generated ...\n"); - position = 0; - ClearWindowText(); - PrintLogHeader(); - return appendText; - } + if (scan == null || scan.ActivityLog == string.Empty) + { + appendText.AppendFormat("Waiting for the log to be generated ...\n"); + position = 0; + ClearWindowText(); + return appendText; + } - using (StringReader reader = new StringReader(scan.ActivityLog)) - { - LogReader(reader, appendText); + using (StringReader reader = new StringReader(scan.ActivityLog)) + { + LogReader(reader, appendText); + } } - } - else - { - if (encode == null || encode.ActivityLog == string.Empty) + else { - appendText.AppendFormat("Waiting for the log to be generated ...\n"); - position = 0; - ClearWindowText(); - PrintLogHeader(); - return appendText; - } + if (encode == null || encode.ActivityLog == string.Empty) + { + appendText.AppendFormat("Waiting for the log to be generated ...\n"); + position = 0; + ClearWindowText(); + return appendText; + } - using (StringReader reader = new StringReader(encode.ActivityLog)) - { - LogReader(reader, appendText); + using (StringReader reader = new StringReader(encode.ActivityLog)) + { + LogReader(reader, appendText); + } } } + catch (Exception exc) + { + windowTimer.Dispose(); + errorService.ShowError("GetLog() Error", exc.ToString()); + } + return appendText; } @@ -343,48 +377,6 @@ namespace Handbrake } /// - /// Display the log header - /// - private void PrintLogHeader() - { - try - { - if (IsHandleCreated) - { - if (rtf_actLog.InvokeRequired) - { - IAsyncResult invoked = BeginInvoke(new SetTextClearCallback(PrintLogHeader)); - EndInvoke(invoked); - } - else - { - lock (rtf_actLog) - { - // Print the log header. This function will be re-implimented later. Do not delete. - StringBuilder header = new StringBuilder(); - - header.Append(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version)); - header.Append(String.Format("### Running: {0} \n###\n", Environment.OSVersion)); - header.Append(String.Format("### CPU: {0} \n", SystemInfo.GetCpuCount)); - header.Append(String.Format("### Ram: {0} MB \n", SystemInfo.TotalPhysicalMemory)); - header.Append(String.Format("### Screen: {0}x{1} \n", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height)); - header.Append(String.Format("### Temp Dir: {0} \n", Path.GetTempPath())); - header.Append(String.Format("### Install Dir: {0} \n", Application.StartupPath)); - header.Append(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath)); - header.Append("#########################################\n\n"); - - rtf_actLog.AppendText(header.ToString()); - } - } - } - } - catch (Exception) - { - return; - } - } - - /// /// Reset Everything /// private void Reset() @@ -393,7 +385,6 @@ namespace Handbrake windowTimer.Dispose(); position = 0; ClearWindowText(); - PrintLogHeader(); windowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000); } @@ -452,31 +443,13 @@ namespace Handbrake } /// - /// Set scan mode + /// Change the Log file in the viewer /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void BtnScanLogClick(object sender, EventArgs e) + /// The Sender + /// The EventArgs + private void LogSelectorClick(object sender, EventArgs e) { - SetMode(ActivityLogMode.Scan); - } - - /// - /// Set the encode mode - /// - /// - /// The sender. - /// - /// - /// The e. - /// - private void BtnEncodeLogClick(object sender, EventArgs e) - { - SetMode(ActivityLogMode.Encode); + this.SetMode((string)this.logSelector.SelectedItem == "Scan Log" ? ActivityLogMode.Scan : ActivityLogMode.Encode); } /* Overrides */