teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

見直しキャンペーン中

2023/07/29 08:08

投稿

TN8001
TN8001

スコア10111

answer CHANGED
@@ -1,168 +1,168 @@
1
- > こちらの質問の回答者のように波形や周波数表示するプログラムを実行できるようにしたいです。
2
-
3
- 言及されたので解説しますが回答の(質問も)コードは、「コンソールアプリケーション」ではありません。
4
- 画像の通りGUIアプリケーションです。
5
- その中でもC#では一番~~古い~~歴史のある「Windows フォーム アプリケーション」という種類のものです。
6
- [Windows Forms - Wikipedia](https://ja.wikipedia.org/wiki/Windows_Forms)
7
-
8
- 見分けるポイントは
9
- * `using System.Windows.Forms;`
10
- これがあれば確定
11
- * `public partial class Form1 : Form`
12
- これがあればほぼ確定
13
- * `Form1`や`Form`等の文字が出てくる
14
- 9割がたそうだろうと思われる
15
- * GUIだがなんのヒントもなし
16
- まずそうだろうと思っていい(選択肢がそれしかなかった時代に書かれたもののことが多い)
17
-
18
- 名前の通りWindows上で動くGUIアプリケーションです。
19
- okuda____さんがWindows環境をお持ちでなければ、動かすことはできません(Monoで動くのかもしれませんが詳しく知りません)
20
-
21
- そのうえで回答コードでは、2つのコードが省略されています。
22
- * `Program.cs`
23
- Visual Studioが自動生成するエントリポイントで通常いじることはない。
24
- * `Form1.Designer.cs`
25
- 通常デザイナ画面でマウス操作によりコントロール等を配置するが、それをもとにVisual Studioが自動生成する。
26
- かなり長くなるため画像から判断してもらったほうが早い。
27
-
28
- さらに質問者が前提としている外部ライブラリが必要です(`using OxyPlot;`等から判断可能)
29
- 回答当時使用したライブラリはこの3つです。
30
- * [NuGet Gallery | MathNet.Numerics 4.12.0](https://www.nuget.org/packages/MathNet.Numerics/4.12.0)
31
- * [NuGet Gallery | NAudio 1.10.0](https://www.nuget.org/packages/NAudio/1.10.0)
32
- * [NuGet Gallery | OxyPlot.WindowsForms 2.0.0](https://www.nuget.org/packages/OxyPlot.WindowsForms/2.0.0)
33
-
34
- ---
35
-
36
- 省略したコードを上げるのはやぶさかではないですが、私はVisual Studio Codeでの実行方法は全く分かりません。
37
-
38
- Visual Studioを入れてもらうのが一番いいと思います(ちょうどVisual Studio 2022も出たとこですし)
39
-
40
- ---
41
-
42
- Visual Studioもあるんですね^^;
43
- NuGetでライブラリを入れたうえで、画像のようにコントロールを配置してください(位置や大きさはあまり関係ないです)
44
- `Label`2つ(`micname`・`label1`)
45
- `Button`1つ(`Click`イベント`recording_Click`)
46
- `PlotView`2つ(`plotView1`・`plotView2`)
47
-
48
- 念のためForm1.Designer.cs
49
- ```C#
50
- namespace Questions296462
51
- {
52
- partial class Form1
53
- {
54
- /// <summary>
55
- /// 必要なデザイナー変数です。
56
- /// </summary>
57
- private System.ComponentModel.IContainer components = null;
58
-
59
- /// <summary>
60
- /// 使用中のリソースをすべてクリーンアップします。
61
- /// </summary>
62
- /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
63
- protected override void Dispose(bool disposing)
64
- {
65
- if(disposing && (components != null))
66
- {
67
- components.Dispose();
68
- }
69
- base.Dispose(disposing);
70
- }
71
-
72
- #region Windows フォーム デザイナーで生成されたコード
73
-
74
- /// <summary>
75
- /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
76
- /// コード エディターで変更しないでください。
77
- /// </summary>
78
- private void InitializeComponent()
79
- {
80
- this.micname = new System.Windows.Forms.Label();
81
- this.plotView1 = new OxyPlot.WindowsForms.PlotView();
82
- this.plotView2 = new OxyPlot.WindowsForms.PlotView();
83
- this.button1 = new System.Windows.Forms.Button();
84
- this.label1 = new System.Windows.Forms.Label();
85
- this.SuspendLayout();
86
- //
87
- // micname
88
- //
89
- this.micname.AutoSize = true;
90
- this.micname.Location = new System.Drawing.Point(12, 9);
91
- this.micname.Name = "micname";
92
- this.micname.Size = new System.Drawing.Size(35, 12);
93
- this.micname.TabIndex = 0;
94
- this.micname.Text = "label1";
95
- //
96
- // plotView1
97
- //
98
- this.plotView1.BackColor = System.Drawing.Color.White;
99
- this.plotView1.Location = new System.Drawing.Point(14, 67);
100
- this.plotView1.Name = "plotView1";
101
- this.plotView1.PanCursor = System.Windows.Forms.Cursors.Hand;
102
- this.plotView1.Size = new System.Drawing.Size(316, 161);
103
- this.plotView1.TabIndex = 1;
104
- this.plotView1.Text = "plotView1";
105
- this.plotView1.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
106
- this.plotView1.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
107
- this.plotView1.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
108
- //
109
- // plotView2
110
- //
111
- this.plotView2.BackColor = System.Drawing.Color.White;
112
- this.plotView2.Location = new System.Drawing.Point(14, 243);
113
- this.plotView2.Name = "plotView2";
114
- this.plotView2.PanCursor = System.Windows.Forms.Cursors.Hand;
115
- this.plotView2.Size = new System.Drawing.Size(316, 161);
116
- this.plotView2.TabIndex = 2;
117
- this.plotView2.Text = "plotView2";
118
- this.plotView2.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
119
- this.plotView2.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
120
- this.plotView2.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
121
- //
122
- // button1
123
- //
124
- this.button1.Location = new System.Drawing.Point(255, 38);
125
- this.button1.Name = "button1";
126
- this.button1.Size = new System.Drawing.Size(75, 23);
127
- this.button1.TabIndex = 3;
128
- this.button1.Text = "button1";
129
- this.button1.UseVisualStyleBackColor = true;
130
- this.button1.Click += new System.EventHandler(this.recording_Click);
131
- //
132
- // label1
133
- //
134
- this.label1.AutoSize = true;
135
- this.label1.Location = new System.Drawing.Point(14, 49);
136
- this.label1.Name = "label1";
137
- this.label1.Size = new System.Drawing.Size(35, 12);
138
- this.label1.TabIndex = 4;
139
- this.label1.Text = "label1";
140
- //
141
- // Form1
142
- //
143
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
144
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
145
- this.ClientSize = new System.Drawing.Size(342, 414);
146
- this.Controls.Add(this.label1);
147
- this.Controls.Add(this.button1);
148
- this.Controls.Add(this.plotView2);
149
- this.Controls.Add(this.plotView1);
150
- this.Controls.Add(this.micname);
151
- this.Name = "Form1";
152
- this.Text = "Form1";
153
- this.Load += new System.EventHandler(this.Form1_Load);
154
- this.ResumeLayout(false);
155
- this.PerformLayout();
156
-
157
- }
158
-
159
- #endregion
160
-
161
- private System.Windows.Forms.Label micname;
162
- private OxyPlot.WindowsForms.PlotView plotView1;
163
- private OxyPlot.WindowsForms.PlotView plotView2;
164
- private System.Windows.Forms.Button button1;
165
- private System.Windows.Forms.Label label1;
166
- }
167
- }
1
+ > こちらの質問の回答者のように波形や周波数表示するプログラムを実行できるようにしたいです。
2
+
3
+ 言及されたので解説しますが回答の(質問も)コードは、「コンソールアプリケーション」ではありません。
4
+ 画像の通りGUIアプリケーションです。
5
+ その中でもC#では一番~~古い~~歴史のある「Windows フォーム アプリケーション」という種類のものです。
6
+ [Windows Forms - Wikipedia](https://ja.wikipedia.org/wiki/Windows_Forms)
7
+
8
+ 見分けるポイントは
9
+ * `using System.Windows.Forms;`
10
+ これがあれば確定
11
+ * `public partial class Form1 : Form`
12
+ これがあればほぼ確定
13
+ * `Form1`や`Form`等の文字が出てくる
14
+ 9割がたそうだろうと思われる
15
+ * GUIだがなんのヒントもなし
16
+ まずそうだろうと思っていい(選択肢がそれしかなかった時代に書かれたもののことが多い)
17
+
18
+ 名前の通りWindows上で動くGUIアプリケーションです。
19
+ okuda____さんがWindows環境をお持ちでなければ、動かすことはできません(Monoで動くのかもしれませんが詳しく知りません)
20
+
21
+ そのうえで回答コードでは、2つのコードが省略されています。
22
+ * `Program.cs`
23
+ Visual Studioが自動生成するエントリポイントで通常いじることはない。
24
+ * `Form1.Designer.cs`
25
+ 通常デザイナ画面でマウス操作によりコントロール等を配置するが、それをもとにVisual Studioが自動生成する。
26
+ かなり長くなるため画像から判断してもらったほうが早い。
27
+
28
+ さらに質問者が前提としている外部ライブラリが必要です(`using OxyPlot;`等から判断可能)
29
+ 回答当時使用したライブラリはこの3つです。
30
+ * [NuGet Gallery | MathNet.Numerics 4.12.0](https://www.nuget.org/packages/MathNet.Numerics/4.12.0)
31
+ * [NuGet Gallery | NAudio 1.10.0](https://www.nuget.org/packages/NAudio/1.10.0)
32
+ * [NuGet Gallery | OxyPlot.WindowsForms 2.0.0](https://www.nuget.org/packages/OxyPlot.WindowsForms/2.0.0)
33
+
34
+ ---
35
+
36
+ 省略したコードを上げるのはやぶさかではないですが、私はVisual Studio Codeでの実行方法は全く分かりません。
37
+
38
+ Visual Studioを入れてもらうのが一番いいと思います(ちょうどVisual Studio 2022も出たとこですし)
39
+
40
+ ---
41
+
42
+ Visual Studioもあるんですね^^;
43
+ NuGetでライブラリを入れたうえで、画像のようにコントロールを配置してください(位置や大きさはあまり関係ないです)
44
+ `Label`2つ(`micname`・`label1`)
45
+ `Button`1つ(`Click`イベント`recording_Click`)
46
+ `PlotView`2つ(`plotView1`・`plotView2`)
47
+
48
+ 念のため
49
+ ```cs:Form1.Designer.cs
50
+ namespace Questions296462
51
+ {
52
+ partial class Form1
53
+ {
54
+ /// <summary>
55
+ /// 必要なデザイナー変数です。
56
+ /// </summary>
57
+ private System.ComponentModel.IContainer components = null;
58
+
59
+ /// <summary>
60
+ /// 使用中のリソースをすべてクリーンアップします。
61
+ /// </summary>
62
+ /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
63
+ protected override void Dispose(bool disposing)
64
+ {
65
+ if(disposing && (components != null))
66
+ {
67
+ components.Dispose();
68
+ }
69
+ base.Dispose(disposing);
70
+ }
71
+
72
+ #region Windows フォーム デザイナーで生成されたコード
73
+
74
+ /// <summary>
75
+ /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
76
+ /// コード エディターで変更しないでください。
77
+ /// </summary>
78
+ private void InitializeComponent()
79
+ {
80
+ this.micname = new System.Windows.Forms.Label();
81
+ this.plotView1 = new OxyPlot.WindowsForms.PlotView();
82
+ this.plotView2 = new OxyPlot.WindowsForms.PlotView();
83
+ this.button1 = new System.Windows.Forms.Button();
84
+ this.label1 = new System.Windows.Forms.Label();
85
+ this.SuspendLayout();
86
+ //
87
+ // micname
88
+ //
89
+ this.micname.AutoSize = true;
90
+ this.micname.Location = new System.Drawing.Point(12, 9);
91
+ this.micname.Name = "micname";
92
+ this.micname.Size = new System.Drawing.Size(35, 12);
93
+ this.micname.TabIndex = 0;
94
+ this.micname.Text = "label1";
95
+ //
96
+ // plotView1
97
+ //
98
+ this.plotView1.BackColor = System.Drawing.Color.White;
99
+ this.plotView1.Location = new System.Drawing.Point(14, 67);
100
+ this.plotView1.Name = "plotView1";
101
+ this.plotView1.PanCursor = System.Windows.Forms.Cursors.Hand;
102
+ this.plotView1.Size = new System.Drawing.Size(316, 161);
103
+ this.plotView1.TabIndex = 1;
104
+ this.plotView1.Text = "plotView1";
105
+ this.plotView1.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
106
+ this.plotView1.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
107
+ this.plotView1.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
108
+ //
109
+ // plotView2
110
+ //
111
+ this.plotView2.BackColor = System.Drawing.Color.White;
112
+ this.plotView2.Location = new System.Drawing.Point(14, 243);
113
+ this.plotView2.Name = "plotView2";
114
+ this.plotView2.PanCursor = System.Windows.Forms.Cursors.Hand;
115
+ this.plotView2.Size = new System.Drawing.Size(316, 161);
116
+ this.plotView2.TabIndex = 2;
117
+ this.plotView2.Text = "plotView2";
118
+ this.plotView2.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
119
+ this.plotView2.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
120
+ this.plotView2.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
121
+ //
122
+ // button1
123
+ //
124
+ this.button1.Location = new System.Drawing.Point(255, 38);
125
+ this.button1.Name = "button1";
126
+ this.button1.Size = new System.Drawing.Size(75, 23);
127
+ this.button1.TabIndex = 3;
128
+ this.button1.Text = "button1";
129
+ this.button1.UseVisualStyleBackColor = true;
130
+ this.button1.Click += new System.EventHandler(this.recording_Click);
131
+ //
132
+ // label1
133
+ //
134
+ this.label1.AutoSize = true;
135
+ this.label1.Location = new System.Drawing.Point(14, 49);
136
+ this.label1.Name = "label1";
137
+ this.label1.Size = new System.Drawing.Size(35, 12);
138
+ this.label1.TabIndex = 4;
139
+ this.label1.Text = "label1";
140
+ //
141
+ // Form1
142
+ //
143
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
144
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
145
+ this.ClientSize = new System.Drawing.Size(342, 414);
146
+ this.Controls.Add(this.label1);
147
+ this.Controls.Add(this.button1);
148
+ this.Controls.Add(this.plotView2);
149
+ this.Controls.Add(this.plotView1);
150
+ this.Controls.Add(this.micname);
151
+ this.Name = "Form1";
152
+ this.Text = "Form1";
153
+ this.Load += new System.EventHandler(this.Form1_Load);
154
+ this.ResumeLayout(false);
155
+ this.PerformLayout();
156
+
157
+ }
158
+
159
+ #endregion
160
+
161
+ private System.Windows.Forms.Label micname;
162
+ private OxyPlot.WindowsForms.PlotView plotView1;
163
+ private OxyPlot.WindowsForms.PlotView plotView2;
164
+ private System.Windows.Forms.Button button1;
165
+ private System.Windows.Forms.Label label1;
166
+ }
167
+ }
168
168
  ```

1

Form1.Designer.cs 追記

2021/11/10 08:47

投稿

TN8001
TN8001

スコア10111

answer CHANGED
@@ -35,4 +35,134 @@
35
35
 
36
36
  省略したコードを上げるのはやぶさかではないですが、私はVisual Studio Codeでの実行方法は全く分かりません。
37
37
 
38
- Visual Studioを入れてもらうのが一番いいと思います(ちょうどVisual Studio 2022も出たとこですし)
38
+ Visual Studioを入れてもらうのが一番いいと思います(ちょうどVisual Studio 2022も出たとこですし)
39
+
40
+ ---
41
+
42
+ Visual Studioもあるんですね^^;
43
+ NuGetでライブラリを入れたうえで、画像のようにコントロールを配置してください(位置や大きさはあまり関係ないです)
44
+ `Label`2つ(`micname`・`label1`)
45
+ `Button`1つ(`Click`イベント`recording_Click`)
46
+ `PlotView`2つ(`plotView1`・`plotView2`)
47
+
48
+ 念のためForm1.Designer.cs
49
+ ```C#
50
+ namespace Questions296462
51
+ {
52
+ partial class Form1
53
+ {
54
+ /// <summary>
55
+ /// 必要なデザイナー変数です。
56
+ /// </summary>
57
+ private System.ComponentModel.IContainer components = null;
58
+
59
+ /// <summary>
60
+ /// 使用中のリソースをすべてクリーンアップします。
61
+ /// </summary>
62
+ /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
63
+ protected override void Dispose(bool disposing)
64
+ {
65
+ if(disposing && (components != null))
66
+ {
67
+ components.Dispose();
68
+ }
69
+ base.Dispose(disposing);
70
+ }
71
+
72
+ #region Windows フォーム デザイナーで生成されたコード
73
+
74
+ /// <summary>
75
+ /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
76
+ /// コード エディターで変更しないでください。
77
+ /// </summary>
78
+ private void InitializeComponent()
79
+ {
80
+ this.micname = new System.Windows.Forms.Label();
81
+ this.plotView1 = new OxyPlot.WindowsForms.PlotView();
82
+ this.plotView2 = new OxyPlot.WindowsForms.PlotView();
83
+ this.button1 = new System.Windows.Forms.Button();
84
+ this.label1 = new System.Windows.Forms.Label();
85
+ this.SuspendLayout();
86
+ //
87
+ // micname
88
+ //
89
+ this.micname.AutoSize = true;
90
+ this.micname.Location = new System.Drawing.Point(12, 9);
91
+ this.micname.Name = "micname";
92
+ this.micname.Size = new System.Drawing.Size(35, 12);
93
+ this.micname.TabIndex = 0;
94
+ this.micname.Text = "label1";
95
+ //
96
+ // plotView1
97
+ //
98
+ this.plotView1.BackColor = System.Drawing.Color.White;
99
+ this.plotView1.Location = new System.Drawing.Point(14, 67);
100
+ this.plotView1.Name = "plotView1";
101
+ this.plotView1.PanCursor = System.Windows.Forms.Cursors.Hand;
102
+ this.plotView1.Size = new System.Drawing.Size(316, 161);
103
+ this.plotView1.TabIndex = 1;
104
+ this.plotView1.Text = "plotView1";
105
+ this.plotView1.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
106
+ this.plotView1.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
107
+ this.plotView1.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
108
+ //
109
+ // plotView2
110
+ //
111
+ this.plotView2.BackColor = System.Drawing.Color.White;
112
+ this.plotView2.Location = new System.Drawing.Point(14, 243);
113
+ this.plotView2.Name = "plotView2";
114
+ this.plotView2.PanCursor = System.Windows.Forms.Cursors.Hand;
115
+ this.plotView2.Size = new System.Drawing.Size(316, 161);
116
+ this.plotView2.TabIndex = 2;
117
+ this.plotView2.Text = "plotView2";
118
+ this.plotView2.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
119
+ this.plotView2.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
120
+ this.plotView2.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
121
+ //
122
+ // button1
123
+ //
124
+ this.button1.Location = new System.Drawing.Point(255, 38);
125
+ this.button1.Name = "button1";
126
+ this.button1.Size = new System.Drawing.Size(75, 23);
127
+ this.button1.TabIndex = 3;
128
+ this.button1.Text = "button1";
129
+ this.button1.UseVisualStyleBackColor = true;
130
+ this.button1.Click += new System.EventHandler(this.recording_Click);
131
+ //
132
+ // label1
133
+ //
134
+ this.label1.AutoSize = true;
135
+ this.label1.Location = new System.Drawing.Point(14, 49);
136
+ this.label1.Name = "label1";
137
+ this.label1.Size = new System.Drawing.Size(35, 12);
138
+ this.label1.TabIndex = 4;
139
+ this.label1.Text = "label1";
140
+ //
141
+ // Form1
142
+ //
143
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
144
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
145
+ this.ClientSize = new System.Drawing.Size(342, 414);
146
+ this.Controls.Add(this.label1);
147
+ this.Controls.Add(this.button1);
148
+ this.Controls.Add(this.plotView2);
149
+ this.Controls.Add(this.plotView1);
150
+ this.Controls.Add(this.micname);
151
+ this.Name = "Form1";
152
+ this.Text = "Form1";
153
+ this.Load += new System.EventHandler(this.Form1_Load);
154
+ this.ResumeLayout(false);
155
+ this.PerformLayout();
156
+
157
+ }
158
+
159
+ #endregion
160
+
161
+ private System.Windows.Forms.Label micname;
162
+ private OxyPlot.WindowsForms.PlotView plotView1;
163
+ private OxyPlot.WindowsForms.PlotView plotView2;
164
+ private System.Windows.Forms.Button button1;
165
+ private System.Windows.Forms.Label label1;
166
+ }
167
+ }
168
+ ```