OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmActivityWindow.cs
1 /*  frmActivityWindow.cs $\r
2         \r
3            This file is part of the HandBrake source code.\r
4            Homepage: <http://handbrake.m0k.org/>.\r
5            It may be used under the terms of the GNU General Public License. */\r
6 \r
7 using System;\r
8 using System.Collections.Generic;\r
9 using System.ComponentModel;\r
10 using System.Data;\r
11 using System.Drawing;\r
12 using System.Text;\r
13 using System.Windows.Forms;\r
14 using System.IO;\r
15 \r
16 \r
17 namespace Handbrake\r
18 {\r
19     public partial class frmActivityWindow : Form\r
20     {\r
21         /// <summary>\r
22         /// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.\r
23         /// </summary>\r
24         public frmActivityWindow()\r
25         {\r
26             InitializeComponent();\r
27             this.rtf_actLog.Text = string.Empty;     \r
28         }\r
29 \r
30         private void btn_close_Click(object sender, EventArgs e)\r
31         {\r
32              this.Hide();\r
33         }\r
34 \r
35         private void frmActivityWindow_Load(object sender, EventArgs e)\r
36         {\r
37             this.rtf_actLog.Text = string.Empty;\r
38             readFile();\r
39         }\r
40 \r
41         private void readFile()\r
42         {\r
43             try\r
44             {\r
45                 string dvdInfoPath = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");\r
46                 FileStream f = System.IO.File.Open(dvdInfoPath, FileMode.Open, FileAccess.Read, FileShare.Read);\r
47 \r
48                 StreamReader sr = new StreamReader(f);\r
49 \r
50 \r
51 \r
52                 string line = sr.ReadLine();\r
53 \r
54                 while (line != null)\r
55                 {\r
56                     this.rtf_actLog.AppendText(line + System.Environment.NewLine);\r
57                     line = sr.ReadLine();\r
58                 }\r
59                 sr.Close();\r
60             }\r
61             catch (Exception)\r
62             {\r
63                 rtf_actLog.Clear();\r
64                 rtf_actLog.Text = "Please wait until the encode has finished to view the log.";\r
65             }\r
66         }\r
67 \r
68         private void btn_copy_Click(object sender, EventArgs e)\r
69         {\r
70             if (rtf_actLog.Text != "")\r
71                 Clipboard.SetText(rtf_actLog.Text, TextDataFormat.Text);\r
72         }\r
73 \r
74         private void btn_refresh_Click(object sender, EventArgs e)\r
75         {\r
76             rtf_actLog.Clear();\r
77             readFile();\r
78         }\r
79 \r
80 \r
81     }\r
82 }