デュアルディスプレイのセカンドモニターにPDF、動画、画像を表示。
@@ -29,12 +29,9 @@ | ||
29 | 29 | Me.GroupBox1 = New System.Windows.Forms.GroupBox() |
30 | 30 | Me.Timer1 = New System.Windows.Forms.Timer(Me.components) |
31 | 31 | Me.tpMediaPlayer = New System.Windows.Forms.TabPage() |
32 | - Me.CtlMovie1 = New pdfsecondmonitor.ctlMovie() | |
33 | 32 | Me.tbcFileOpes = New System.Windows.Forms.TabControl() |
34 | 33 | Me.tpAdobePDF = New System.Windows.Forms.TabPage() |
35 | - Me.CtlPdf1 = New pdfsecondmonitor.ctlPdf() | |
36 | 34 | Me.tpImage = New System.Windows.Forms.TabPage() |
37 | - Me.CtlImage1 = New pdfsecondmonitor.CtlImage() | |
38 | 35 | Me.Label6 = New System.Windows.Forms.Label() |
39 | 36 | Me.txtPDFFileName = New System.Windows.Forms.TextBox() |
40 | 37 | Me.btnDelete = New System.Windows.Forms.Button() |
@@ -41,7 +38,10 @@ | ||
41 | 38 | Me.lstPDFFiles = New System.Windows.Forms.ListBox() |
42 | 39 | Me.BackgroundWorker1 = New System.ComponentModel.BackgroundWorker() |
43 | 40 | Me.btnUnSelect = New System.Windows.Forms.Button() |
44 | - Me.Button2 = New System.Windows.Forms.Button() | |
41 | + Me.btnFileAdd = New System.Windows.Forms.Button() | |
42 | + Me.CtlPdf1 = New pdfsecondmonitor.ctlPdf() | |
43 | + Me.CtlMovie1 = New pdfsecondmonitor.ctlMovie() | |
44 | + Me.CtlImage1 = New pdfsecondmonitor.CtlImage() | |
45 | 45 | Me.GroupBox1.SuspendLayout() |
46 | 46 | Me.tpMediaPlayer.SuspendLayout() |
47 | 47 | Me.tbcFileOpes.SuspendLayout() |
@@ -96,13 +96,6 @@ | ||
96 | 96 | Me.tpMediaPlayer.Text = "動画" |
97 | 97 | Me.tpMediaPlayer.UseVisualStyleBackColor = True |
98 | 98 | ' |
99 | - 'CtlMovie1 | |
100 | - ' | |
101 | - Me.CtlMovie1.Location = New System.Drawing.Point(37, 31) | |
102 | - Me.CtlMovie1.Name = "CtlMovie1" | |
103 | - Me.CtlMovie1.Size = New System.Drawing.Size(467, 166) | |
104 | - Me.CtlMovie1.TabIndex = 0 | |
105 | - ' | |
106 | 99 | 'tbcFileOpes |
107 | 100 | ' |
108 | 101 | Me.tbcFileOpes.Controls.Add(Me.tpAdobePDF) |
@@ -125,13 +118,6 @@ | ||
125 | 118 | Me.tpAdobePDF.Text = "PDFの表示" |
126 | 119 | Me.tpAdobePDF.UseVisualStyleBackColor = True |
127 | 120 | ' |
128 | - 'CtlPdf1 | |
129 | - ' | |
130 | - Me.CtlPdf1.Location = New System.Drawing.Point(6, 31) | |
131 | - Me.CtlPdf1.Name = "CtlPdf1" | |
132 | - Me.CtlPdf1.Size = New System.Drawing.Size(705, 128) | |
133 | - Me.CtlPdf1.TabIndex = 0 | |
134 | - ' | |
135 | 121 | 'tpImage |
136 | 122 | ' |
137 | 123 | Me.tpImage.Controls.Add(Me.CtlImage1) |
@@ -143,13 +129,6 @@ | ||
143 | 129 | Me.tpImage.Text = "画像" |
144 | 130 | Me.tpImage.UseVisualStyleBackColor = True |
145 | 131 | ' |
146 | - 'CtlImage1 | |
147 | - ' | |
148 | - Me.CtlImage1.Location = New System.Drawing.Point(28, 31) | |
149 | - Me.CtlImage1.Name = "CtlImage1" | |
150 | - Me.CtlImage1.Size = New System.Drawing.Size(600, 179) | |
151 | - Me.CtlImage1.TabIndex = 0 | |
152 | - ' | |
153 | 132 | 'Label6 |
154 | 133 | ' |
155 | 134 | Me.Label6.AutoSize = True |
@@ -195,15 +174,36 @@ | ||
195 | 174 | Me.btnUnSelect.Text = "選択解除" |
196 | 175 | Me.btnUnSelect.UseVisualStyleBackColor = True |
197 | 176 | ' |
198 | - 'Button2 | |
177 | + 'btnFileAdd | |
199 | 178 | ' |
200 | - Me.Button2.Location = New System.Drawing.Point(212, 536) | |
201 | - Me.Button2.Name = "Button2" | |
202 | - Me.Button2.Size = New System.Drawing.Size(130, 23) | |
203 | - Me.Button2.TabIndex = 21 | |
204 | - Me.Button2.Text = "ファイルを追加する" | |
205 | - Me.Button2.UseVisualStyleBackColor = True | |
179 | + Me.btnFileAdd.Location = New System.Drawing.Point(212, 536) | |
180 | + Me.btnFileAdd.Name = "btnFileAdd" | |
181 | + Me.btnFileAdd.Size = New System.Drawing.Size(130, 23) | |
182 | + Me.btnFileAdd.TabIndex = 21 | |
183 | + Me.btnFileAdd.Text = "ファイルを追加する" | |
184 | + Me.btnFileAdd.UseVisualStyleBackColor = True | |
206 | 185 | ' |
186 | + 'CtlPdf1 | |
187 | + ' | |
188 | + Me.CtlPdf1.Location = New System.Drawing.Point(6, 31) | |
189 | + Me.CtlPdf1.Name = "CtlPdf1" | |
190 | + Me.CtlPdf1.Size = New System.Drawing.Size(705, 128) | |
191 | + Me.CtlPdf1.TabIndex = 0 | |
192 | + ' | |
193 | + 'CtlMovie1 | |
194 | + ' | |
195 | + Me.CtlMovie1.Location = New System.Drawing.Point(37, 31) | |
196 | + Me.CtlMovie1.Name = "CtlMovie1" | |
197 | + Me.CtlMovie1.Size = New System.Drawing.Size(467, 166) | |
198 | + Me.CtlMovie1.TabIndex = 0 | |
199 | + ' | |
200 | + 'CtlImage1 | |
201 | + ' | |
202 | + Me.CtlImage1.Location = New System.Drawing.Point(28, 31) | |
203 | + Me.CtlImage1.Name = "CtlImage1" | |
204 | + Me.CtlImage1.Size = New System.Drawing.Size(600, 179) | |
205 | + Me.CtlImage1.TabIndex = 0 | |
206 | + ' | |
207 | 207 | 'frmOperation |
208 | 208 | ' |
209 | 209 | Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!) |
@@ -210,7 +210,7 @@ | ||
210 | 210 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font |
211 | 211 | Me.ClientSize = New System.Drawing.Size(1168, 649) |
212 | 212 | Me.Controls.Add(Me.Label6) |
213 | - Me.Controls.Add(Me.Button2) | |
213 | + Me.Controls.Add(Me.btnFileAdd) | |
214 | 214 | Me.Controls.Add(Me.btnUnSelect) |
215 | 215 | Me.Controls.Add(Me.tbcFileOpes) |
216 | 216 | Me.Controls.Add(Me.GroupBox1) |
@@ -243,7 +243,7 @@ | ||
243 | 243 | Friend WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker |
244 | 244 | Friend WithEvents btnUnSelect As Button |
245 | 245 | Friend WithEvents Label6 As Label |
246 | - Friend WithEvents Button2 As Button | |
246 | + Friend WithEvents btnFileAdd As Button | |
247 | 247 | Friend WithEvents tpImage As TabPage |
248 | 248 | Friend WithEvents CtlPdf1 As ctlPdf |
249 | 249 | Friend WithEvents CtlImage1 As CtlImage |
@@ -198,7 +198,7 @@ | ||
198 | 198 | |
199 | 199 | Private Function IsContain(ext As String, exts As String()) As Boolean |
200 | 200 | For Each target In exts |
201 | - If String.Compare(target, ext, True) = 0 Then | |
201 | + If String.Compare($".{target}", ext, True) = 0 Then | |
202 | 202 | Return True |
203 | 203 | End If |
204 | 204 | Next |
@@ -205,23 +205,44 @@ | ||
205 | 205 | Return False |
206 | 206 | End Function |
207 | 207 | |
208 | + Private movieExts = {"avi", "mpeg", "mp4", "wmv"} | |
209 | + | |
210 | + Private ImageExts = {"jpeg", "jpg", "bmp", "png", "gif", "tiff", "tif"} | |
208 | 211 | Private Function IsImageExt(ext) As Boolean |
209 | - Return IsContain(ext, {".jpeg", ".jpg", ".bmp", ".png", "gif", "tiff"}) | |
212 | + Return IsContain(ext, ImageExts) | |
210 | 213 | End Function |
211 | 214 | |
212 | 215 | Private Function IsMovieExt(ext) As Boolean |
213 | - Return IsContain(ext, {".avi", ".mpeg", ".mp4", ".wmv"}) | |
216 | + Return IsContain(ext, movieExts) | |
214 | 217 | End Function |
215 | 218 | |
219 | + Private Function CreateFilter() As String | |
220 | + Dim buf As New System.Text.StringBuilder | |
221 | + buf.Append("画像、動画、PDFファイル") | |
222 | + buf.Append("|") | |
223 | + buf.Append("*.pdf") | |
224 | + buf.Append(CreateExtsOfFilter(ImageExts)) | |
225 | + buf.Append(CreateExtsOfFilter(movieExts)) | |
226 | + buf.Append("|") | |
227 | + buf.Append("All Files(*.*)") | |
228 | + buf.Append("|") | |
229 | + buf.Append("*.*") | |
230 | + Return buf.ToString() | |
231 | + End Function | |
216 | 232 | |
233 | + Private Function CreateExtsOfFilter(ByVal exts As String()) As String | |
234 | + Dim buf = New System.Text.StringBuilder | |
235 | + For Each ext In exts | |
236 | + buf.Append("*.") | |
237 | + buf.Append(ext) | |
238 | + buf.Append(";") | |
239 | + Next | |
240 | + Return buf.ToString() | |
241 | + End Function | |
217 | 242 | |
218 | - | |
219 | - | |
220 | - | |
221 | - | |
222 | - Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click | |
243 | + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnFileAdd.Click | |
223 | 244 | OpenFileDialog1.Multiselect = True |
224 | - OpenFileDialog1.Filter = "画像、動画、PDFファイル|*.pdf;*.bmp;*.gif;*.png;*.jpeg;*jpg;|All Files(*.*)|*.*;" | |
245 | + OpenFileDialog1.Filter = CreateFilter() | |
225 | 246 | OpenFileDialog1.FileName = txtPDFFileName.Text |
226 | 247 | Dim ret = OpenFileDialog1.ShowDialog() |
227 | 248 | If ret = Windows.Forms.DialogResult.Cancel Then |
@@ -238,6 +259,7 @@ | ||
238 | 259 | End Sub |
239 | 260 | |
240 | 261 | Private Sub btnUnSelect_Click(sender As Object, e As EventArgs) Handles btnUnSelect.Click |
262 | + lstPDFFiles.SelectedItem = Nothing | |
241 | 263 | _dispacher.CloseViewers() |
242 | 264 | End Sub |
243 | 265 |