この問題どうすれば、いいのですか?
公開質問状
終わっても、動き続けているの。
// Class1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cyi_syapu_test
{
internal class Class1
{
public class Global //グローバルclass
{
public string My_Variable = "fast value.";
// 意味は無い
}
}
}
// Form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static cyi_syapu_test.Class1;
namespace cyi_syapu_test
{
public partial class Form1 : Form
{
string My_Variable = "";
public Form1()
{
InitializeComponent();
}
private void MainForm_Form1Closing_Click(object sender, FormClosingEventArgs e)
{
// アプリケーションを終了する
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "ようこそ C# の世界に。!";
My_Variable = "it grovaru!";
string my_text = label1.Text+"\n"; // label1.Text + "\n";
string my_path = "./my_module.txt";
my_text += My_Variable + "\n";
StreamWriter text_fail;
text_fail =new StreamWriter(my_path);
text_fail.Write(my_text);
text_fail.Close();
Form2 form2 = new Form2();
form2.Show();
Hide();
}
}
}
// Form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace cyi_syapu_test
{
public partial class Form2 : Form
{
string My_Variable = "";
public Form2()
{
InitializeComponent();
string my_path = "./my_module.txt";
if (File.Exists(my_path) == false) //
{
label2.Text = "モジュールはありません。";
}
else
{
string fast_line = "";
string str_reed_in;
string[] sr_arrey_lin;
StreamReader rs;
rs = new StreamReader(my_path,Encoding.UTF8);
str_reed_in = rs.ReadToEnd();//srは配列
rs.Close();
sr_arrey_lin = str_reed_in.Split("\n");
fast_line = sr_arrey_lin[0];
My_Variable = sr_arrey_lin[1];
label2.Text = fast_line;
}
}
private void Form2Closing_Click(object sender, FormClosingEventArgs e)
{
Close();
// アプリケーションを終了する
Application.Exit();
}
private void label3_Click(object sender, EventArgs e)
{
label3.Text =My_Variable;
MessageBox.Show("終わります。", "EXIT", MessageBoxButtons.OK, MessageBoxIcon.Hand);
Form1 form1 = new Form1();
// main_form1.Show();
Close();
form1.Close(); //mainの呼び出しfoam1は最後に
Application.Exit(); //All End !!
}
private static void Form2Closing_Click(object sender, FormClosingEventArgs e, Form1 main_form1)
{
MessageBox.Show("きたよ");
FormWindowState formState = main_form1.WindowState;
switch (formState)
{
case FormWindowState.Normal: //Minimized:Maximized:
MessageBox.Show("通常表示");
main_form1.Close();
Application.Exit();
break;
}
// throw new NotImplementedException();
}
}
}