回答編集履歴

3

追記

2021/08/12 11:07

投稿

YAmaGNZ
YAmaGNZ

スコア10266

test CHANGED
@@ -219,3 +219,11 @@
219
219
  ```
220
220
 
221
221
  といったコードと上記のコマンドにてコンパイル、動作の確認ができました。
222
+
223
+ ./binには
224
+
225
+ Microsoft.WindowsAPICodePack.dll
226
+
227
+ Microsoft.WindowsAPICodePack.Shell.dll
228
+
229
+ のDLLを置いてあります。

2

追記

2021/08/12 11:07

投稿

YAmaGNZ
YAmaGNZ

スコア10266

test CHANGED
@@ -65,3 +65,157 @@
65
65
  ```
66
66
 
67
67
  といった感じでコンパイルすれば使用できるはずです。
68
+
69
+
70
+
71
+ ./src/main.cs
72
+
73
+ ```C#
74
+
75
+ using System;
76
+
77
+ using System.Windows.Forms;
78
+
79
+
80
+
81
+ using Sample.Forms;
82
+
83
+
84
+
85
+ namespace Sample{
86
+
87
+ class EntryPoint{
88
+
89
+ [STAThread]
90
+
91
+ static void Main( string[] args ){
92
+
93
+ // メインウィンドウの生成と起動
94
+
95
+ Application.Run( new MainForm( ) );
96
+
97
+ }
98
+
99
+ }
100
+
101
+ }
102
+
103
+ ```
104
+
105
+
106
+
107
+ ./src/sub/MainForm.cs
108
+
109
+ ```C#
110
+
111
+ using System;
112
+
113
+ using System.Drawing;
114
+
115
+ using System.Windows.Forms;
116
+
117
+ using Microsoft.WindowsAPICodePack;
118
+
119
+ using Microsoft.WindowsAPICodePack.Dialogs;
120
+
121
+ using Microsoft.WindowsAPICodePack.Dialogs.Controls;
122
+
123
+
124
+
125
+ namespace Sample.Forms
126
+
127
+ {
128
+
129
+ public partial class MainForm : Form
130
+
131
+ {
132
+
133
+
134
+
135
+ Label label1,label2;
136
+
137
+
138
+
139
+ public MainForm()
140
+
141
+ {
142
+
143
+ Button b = new Button();
144
+
145
+ b.Location = new Point(10,10);
146
+
147
+ b.Size = new Size(100,50);
148
+
149
+ b.Text = "button";
150
+
151
+ b.Click += button_Click;
152
+
153
+ this.Controls.Add(b);
154
+
155
+
156
+
157
+ label1 = new Label();
158
+
159
+ label1.Location = new Point(10,150);
160
+
161
+ label1.AutoSize = true;
162
+
163
+ label2 = new Label();
164
+
165
+ label2.Location = new Point(10,170);
166
+
167
+ label2.AutoSize = true;
168
+
169
+ this.Controls.Add(label1);
170
+
171
+ this.Controls.Add(label2);
172
+
173
+
174
+
175
+ }
176
+
177
+
178
+
179
+ private void button_Click(object sender, EventArgs e)
180
+
181
+ {
182
+
183
+ CommonSaveFileDialog dialog = new CommonSaveFileDialog();
184
+
185
+ CommonFileDialogComboBox comboBox = new CommonFileDialogComboBox();
186
+
187
+ comboBox.Items.Add(new CommonFileDialogComboBoxItem("SHIFT-JIS"));
188
+
189
+ comboBox.Items.Add(new CommonFileDialogComboBoxItem("UTF-8"));
190
+
191
+ comboBox.Items.Add(new CommonFileDialogComboBoxItem("UNICODE"));
192
+
193
+ comboBox.Items.Add(new CommonFileDialogComboBoxItem("EUC"));
194
+
195
+ comboBox.SelectedIndex = 0;
196
+
197
+ dialog.Controls.Add(comboBox);
198
+
199
+
200
+
201
+ if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
202
+
203
+ {
204
+
205
+ label1.Text = dialog.FileName;
206
+
207
+ label2.Text = comboBox.Items[comboBox.SelectedIndex].Text;
208
+
209
+ }
210
+
211
+ }
212
+
213
+ }
214
+
215
+ }
216
+
217
+
218
+
219
+ ```
220
+
221
+ といったコードと上記のコマンドにてコンパイル、動作の確認ができました。

1

追記

2021/08/12 11:06

投稿

YAmaGNZ
YAmaGNZ

スコア10266

test CHANGED
@@ -39,3 +39,29 @@
39
39
  ```
40
40
 
41
41
  こんな感じで
42
+
43
+
44
+
45
+ ---
46
+
47
+ 追記
48
+
49
+ CommonSaveFileDialogを利用するにはWindowsAPICodePack-Shellをインストールしなくてはなりません。
50
+
51
+ これをインストールするとWindowsAPICodePack-Coreもインストールされます。
52
+
53
+ 使用するDLLは
54
+
55
+ Microsoft.WindowsAPICodePack.dll
56
+
57
+ Microsoft.WindowsAPICodePack.Shell.dll
58
+
59
+ の2つのDLLとなります。
60
+
61
+ ```
62
+
63
+ C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc /nologo -reference:./bin/Microsoft.WindowsAPICodePack.dll -reference:./bin/Microsoft.WindowsAPICodePack.Shell.dll /target:winexe /out:.\bin\Main.exe .\src\main.cs .\src\sub\MainForm.cs
64
+
65
+ ```
66
+
67
+ といった感じでコンパイルすれば使用できるはずです。