デュアルディスプレイのセカンドモニターにPDF、動画、画像を表示。
@@ -28,32 +28,29 @@ | ||
28 | 28 | /// </summary> |
29 | 29 | private void InitializeComponent() |
30 | 30 | { |
31 | - this.button1 = new System.Windows.Forms.Button(); | |
32 | - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); | |
31 | + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); | |
32 | + this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF(); | |
33 | + ((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).BeginInit(); | |
33 | 34 | this.SuspendLayout(); |
34 | 35 | // |
35 | - // button1 | |
36 | + // axAcroPDF1 | |
36 | 37 | // |
37 | - this.button1.Location = new System.Drawing.Point(136, 210); | |
38 | - this.button1.Name = "button1"; | |
39 | - this.button1.Size = new System.Drawing.Size(75, 23); | |
40 | - this.button1.TabIndex = 0; | |
41 | - this.button1.Text = "button1"; | |
42 | - this.button1.UseVisualStyleBackColor = true; | |
43 | - this.button1.Click += new System.EventHandler(this.button1_Click); | |
38 | + this.axAcroPDF1.Enabled = true; | |
39 | + this.axAcroPDF1.Location = new System.Drawing.Point(83, 108); | |
40 | + this.axAcroPDF1.Name = "axAcroPDF1"; | |
41 | + this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState"))); | |
42 | + this.axAcroPDF1.Size = new System.Drawing.Size(240, 240); | |
43 | + this.axAcroPDF1.TabIndex = 0; | |
44 | 44 | // |
45 | - // openFileDialog1 | |
46 | - // | |
47 | - this.openFileDialog1.FileName = "openFileDialog1"; | |
48 | - // | |
49 | 45 | // Form1 |
50 | 46 | // |
51 | 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); |
52 | 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
53 | 49 | this.ClientSize = new System.Drawing.Size(282, 253); |
54 | - this.Controls.Add(this.button1); | |
50 | + this.Controls.Add(this.axAcroPDF1); | |
55 | 51 | this.Name = "Form1"; |
56 | 52 | this.Text = "Form1"; |
53 | + ((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).EndInit(); | |
57 | 54 | this.ResumeLayout(false); |
58 | 55 | |
59 | 56 | } |
@@ -60,8 +57,7 @@ | ||
60 | 57 | |
61 | 58 | #endregion |
62 | 59 | |
63 | - private System.Windows.Forms.Button button1; | |
64 | - private System.Windows.Forms.OpenFileDialog openFileDialog1; | |
60 | + private AxAcroPDFLib.AxAcroPDF axAcroPDF1; | |
65 | 61 | } |
66 | 62 | } |
67 | 63 |
@@ -7,42 +7,20 @@ | ||
7 | 7 | using System.Text; |
8 | 8 | using System.Threading.Tasks; |
9 | 9 | using System.Windows.Forms; |
10 | -using System.Windows; | |
11 | -using System.Windows.Media; | |
12 | 10 | |
13 | - | |
14 | 11 | namespace WindowsFormsApp2 |
15 | 12 | { |
16 | 13 | public partial class Form1 : Form |
17 | 14 | { |
15 | + | |
16 | + | |
18 | 17 | public Form1() |
19 | 18 | { |
20 | 19 | InitializeComponent(); |
20 | + axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill; | |
21 | + axAcroPDF1.LoadFile("C:\\Users\\bellm\\Downloads\\CA-brpgm18_J.pdf"); | |
22 | + axAcroPDF1.setZoom(100); | |
23 | + axAcroPDF1.Visible = true; | |
21 | 24 | } |
22 | - | |
23 | - private void button1_Click(object sender, EventArgs e) | |
24 | - { | |
25 | - var ret = openFileDialog1.ShowDialog(); | |
26 | - if (ret == DialogResult.Cancel) | |
27 | - { | |
28 | - return; | |
29 | - } | |
30 | - | |
31 | - // | |
32 | - // Create a VideoDrawing. | |
33 | - // | |
34 | - MediaPlayer player = new MediaPlayer(); | |
35 | - | |
36 | - player.Open(new Uri(openFileDialog1.FileName , UriKind.Absolute )); | |
37 | - | |
38 | - VideoDrawing aVideoDrawing = new VideoDrawing(); | |
39 | - | |
40 | - aVideoDrawing.Rect = new Rect(0, 0, 100, 100); | |
41 | - | |
42 | - aVideoDrawing.Player = player; | |
43 | - | |
44 | - // Play the video once. | |
45 | - player.Play(); | |
46 | - } | |
47 | 25 | } |
48 | 26 | } |
@@ -20,7 +20,7 @@ | ||
20 | 20 | [assembly: ComVisible(false)] |
21 | 21 | |
22 | 22 | // このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります |
23 | -[assembly: Guid("edc52062-9c75-4fd8-925e-5473faf2af2f")] | |
23 | +[assembly: Guid("d24de68b-c8dd-4064-9c54-ff351bbd0ea4")] | |
24 | 24 | |
25 | 25 | // アセンブリのバージョン情報は次の 4 つの値で構成されています: |
26 | 26 | // |
@@ -52,6 +52,7 @@ | ||
52 | 52 | Me.cmbPDFView = New System.Windows.Forms.ComboBox() |
53 | 53 | Me.btnPDFLast = New System.Windows.Forms.Button() |
54 | 54 | Me.btnPDFFirst = New System.Windows.Forms.Button() |
55 | + Me.Button1 = New System.Windows.Forms.Button() | |
55 | 56 | Me.GroupBox1.SuspendLayout() |
56 | 57 | CType(Me.nudWidth, System.ComponentModel.ISupportInitialize).BeginInit() |
57 | 58 | CType(Me.nudHeight, System.ComponentModel.ISupportInitialize).BeginInit() |
@@ -132,9 +133,6 @@ | ||
132 | 133 | Me.Label3.TabIndex = 13 |
133 | 134 | Me.Label3.Text = "高さ" |
134 | 135 | ' |
135 | - 'Timer1 | |
136 | - ' | |
137 | - ' | |
138 | 136 | 'tpMediaPlayer |
139 | 137 | ' |
140 | 138 | Me.tpMediaPlayer.Controls.Add(Me.btnOpenMediaFile) |
@@ -336,11 +334,21 @@ | ||
336 | 334 | Me.btnPDFFirst.Text = "最初へ" |
337 | 335 | Me.btnPDFFirst.UseVisualStyleBackColor = True |
338 | 336 | ' |
337 | + 'Button1 | |
338 | + ' | |
339 | + Me.Button1.Location = New System.Drawing.Point(695, 60) | |
340 | + Me.Button1.Name = "Button1" | |
341 | + Me.Button1.Size = New System.Drawing.Size(75, 23) | |
342 | + Me.Button1.TabIndex = 13 | |
343 | + Me.Button1.Text = "Button1" | |
344 | + Me.Button1.UseVisualStyleBackColor = True | |
345 | + ' | |
339 | 346 | 'frmOperation |
340 | 347 | ' |
341 | 348 | Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!) |
342 | 349 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font |
343 | 350 | Me.ClientSize = New System.Drawing.Size(782, 465) |
351 | + Me.Controls.Add(Me.Button1) | |
344 | 352 | Me.Controls.Add(Me.tbcFileOpes) |
345 | 353 | Me.Controls.Add(Me.GroupBox1) |
346 | 354 | Me.Name = "frmOperation" |
@@ -387,4 +395,5 @@ | ||
387 | 395 | Friend WithEvents btnInsert As Button |
388 | 396 | Friend WithEvents lstPDFFiles As ListBox |
389 | 397 | Friend WithEvents btnDelete As Button |
398 | + Friend WithEvents Button1 As Button | |
390 | 399 | End Class |
@@ -50,7 +50,7 @@ | ||
50 | 50 | lstPDFFiles.Items.Add(info) |
51 | 51 | Next |
52 | 52 | Catch ex As Exception |
53 | - | |
53 | + MessageBox.Show(ex.Message) | |
54 | 54 | End Try |
55 | 55 | |
56 | 56 | End Sub |
@@ -103,9 +103,9 @@ | ||
103 | 103 | If cmbDisplay.SelectedItem Is Nothing Then |
104 | 104 | Exit Sub |
105 | 105 | End If |
106 | - 'フォームを表示するディスプレイのScreenを取得する | |
106 | + ' 'フォームを表示するディスプレイのScreenを取得する | |
107 | 107 | Dim s As Screen = DirectCast(Me.cmbDisplay.SelectedItem, Screen) |
108 | - 'フォームの開始位置をディスプレイの左上座標に設定する | |
108 | + ' 'フォームの開始位置をディスプレイの左上座標に設定する | |
109 | 109 | frmView.StartPosition = FormStartPosition.Manual |
110 | 110 | frmView.Location = s.Bounds.Location |
111 | 111 | frmView.Size = s.Bounds.Size |
@@ -157,8 +157,8 @@ | ||
157 | 157 | If axPDF Is Nothing Then |
158 | 158 | Exit Sub |
159 | 159 | End If |
160 | - axPDF.setZoom(nudPdfZoom.Value) | |
161 | - setLstZoom(nudPdfZoom.Value) | |
160 | + frmView.SetZoom(nudPdfZoom.Value) | |
161 | + SetLstZoom(nudPdfZoom.Value) | |
162 | 162 | End Sub |
163 | 163 | |
164 | 164 | ''' <summary> |
@@ -173,7 +173,7 @@ | ||
173 | 173 | |
174 | 174 | |
175 | 175 | #Region "PDFファイルを開く" |
176 | - Private backFileName As String | |
176 | + ' Private backFileName As String | |
177 | 177 | Private Sub btnFileOpen_Click(sender As Object, e As EventArgs) Handles btnOpenPDFFile.Click |
178 | 178 | OpenFileDialog1.Filter = "PDFファイル (*.pdf) |*.pdf" |
179 | 179 | OpenFileDialog1.FileName = txtPDFFileName.Text |
@@ -194,15 +194,15 @@ | ||
194 | 194 | Return |
195 | 195 | End If |
196 | 196 | frmView.pnlCover.Visible = False |
197 | - If backFileName = txtPDFFileName.Text Then | |
198 | - Return | |
199 | - End If | |
200 | - axPDF.Visible = True | |
201 | - axPDF.LoadFile(txtPDFFileName.Text) | |
202 | - 'todo : pdfが開けなかったときの処理 | |
203 | - backFileName = txtPDFFileName.Text | |
204 | - axPDF.setShowToolbar(False) | |
205 | - axPDF.setShowScrollbars(False) | |
197 | + 'If backFileName = txtPDFFileName.Text Then | |
198 | + ' Return | |
199 | + 'End If | |
200 | + | |
201 | + frmView.LoadFile(txtPDFFileName.Text) | |
202 | + ' 'todo : pdfが開けなかったときの処理 | |
203 | + ' backFileName = txtPDFFileName.Text | |
204 | + 'axPDF.setShowToolbar(False) | |
205 | + 'axPDF.setShowScrollbars(False) | |
206 | 206 | End Sub |
207 | 207 | |
208 | 208 |
@@ -277,6 +277,10 @@ | ||
277 | 277 | frmView.Width = nudWidth.Value |
278 | 278 | End Sub |
279 | 279 | |
280 | + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click | |
281 | + axPDF.LoadFile("C:\Users\bellm\Downloads\CA-brpgm18_J.pdf") | |
282 | + End Sub | |
283 | + | |
280 | 284 | #Region "リストボックス処理" |
281 | 285 | |
282 | 286 | Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles btnInsert.Click |
@@ -12,7 +12,28 @@ | ||
12 | 12 | End Sub |
13 | 13 | |
14 | 14 | Private Sub frmView_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize |
15 | + AxAcroPDF1.Top = 0 | |
16 | + AxAcroPDF1.Left = 0 | |
15 | 17 | AxAcroPDF1.Size = Size |
16 | 18 | pnlCover.Size = Size |
17 | 19 | End Sub |
20 | + | |
21 | + Private loaded As Boolean = False | |
22 | + Public Sub LoadFile(fileName As String) | |
23 | + loaded = True | |
24 | + AxAcroPDF1.LoadFile(fileName) | |
25 | + AxAcroPDF1.Visible = True | |
26 | + End Sub | |
27 | + | |
28 | + Private zoom As Single = 100 | |
29 | + Public Sub SetZoom(ByVal zoom As Single) | |
30 | + If Not loaded Then | |
31 | + Exit Sub | |
32 | + End If | |
33 | + If Math.Abs(Me.zoom - zoom) < 0.1 Then | |
34 | + Exit Sub | |
35 | + End If | |
36 | + Me.zoom = zoom | |
37 | + AxAcroPDF1.setZoom(zoom) | |
38 | + End Sub | |
18 | 39 | End Class |