сохранение и открытие файла

This commit is contained in:
SvyatkinYura 2018-02-10 17:12:46 +03:00 committed by GitHub
parent b3c96aeb42
commit 1230d49f9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 297 additions and 208 deletions

View file

@ -31,33 +31,36 @@
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.nazvanieTextBox = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel2 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel3 = new System.Windows.Forms.Panel();
this.label7 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.button4 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label7 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.button5 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
@ -94,12 +97,12 @@
this.label3.Text = "Название:";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// textBox1
// nazvanieTextBox
//
this.textBox1.Location = new System.Drawing.Point(80, 86);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(138, 20);
this.textBox1.TabIndex = 3;
this.nazvanieTextBox.Location = new System.Drawing.Point(80, 86);
this.nazvanieTextBox.Name = "nazvanieTextBox";
this.nazvanieTextBox.Size = new System.Drawing.Size(138, 20);
this.nazvanieTextBox.TabIndex = 3;
//
// panel1
//
@ -110,7 +113,7 @@
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.textBox1);
this.panel1.Controls.Add(this.nazvanieTextBox);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label3);
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
@ -119,6 +122,65 @@
this.panel1.Size = new System.Drawing.Size(227, 273);
this.panel1.TabIndex = 4;
//
// comboBox1
//
this.comboBox1.ForeColor = System.Drawing.SystemColors.WindowText;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"4К",
"1080HD",
"720HD",
"480",
"360",
"240"});
this.comboBox1.Location = new System.Drawing.Point(77, 159);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 9;
this.comboBox1.Text = "Авто";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(14, 159);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(57, 13);
this.label6.TabIndex = 8;
this.label6.Text = "Качество:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(156, 128);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(11, 13);
this.label5.TabIndex = 7;
this.label5.Text = "*";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(173, 121);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(45, 20);
this.textBox3.TabIndex = 6;
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(105, 121);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(45, 20);
this.textBox2.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(14, 121);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(84, 13);
this.label4.TabIndex = 4;
this.label4.Text = "Размеры окна:";
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(227, 0);
@ -139,88 +201,20 @@
this.panel2.Size = new System.Drawing.Size(408, 273);
this.panel2.TabIndex = 6;
//
// label4
// button3
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(14, 121);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(84, 13);
this.label4.TabIndex = 4;
this.label4.Text = "Размеры окна:";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(105, 121);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(45, 20);
this.textBox2.TabIndex = 5;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(173, 121);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(45, 20);
this.textBox3.TabIndex = 6;
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(156, 128);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(11, 13);
this.label5.TabIndex = 7;
this.label5.Text = "*";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(14, 159);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(57, 13);
this.label6.TabIndex = 8;
this.label6.Text = "Качество:";
//
// comboBox1
//
this.comboBox1.ForeColor = System.Drawing.SystemColors.WindowText;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"4К",
"1080HD",
"720HD",
"480",
"360",
"240"});
this.comboBox1.Location = new System.Drawing.Point(77, 159);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 9;
this.comboBox1.Text = "Авто";
//
// button1
//
this.button1.Dock = System.Windows.Forms.DockStyle.Top;
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(408, 26);
this.button1.TabIndex = 0;
this.button1.Text = "Добавть персонажа";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button2.Location = new System.Drawing.Point(0, 243);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(408, 30);
this.button2.TabIndex = 1;
this.button2.Text = "Сохранить мульт";
this.button2.UseVisualStyleBackColor = true;
this.button3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button3.Location = new System.Drawing.Point(0, 213);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(408, 30);
this.button3.TabIndex = 3;
this.button3.Text = "Сохранить персонажа";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// panel3
//
this.panel3.Controls.Add(this.button5);
this.panel3.Controls.Add(this.button4);
this.panel3.Controls.Add(this.label12);
this.panel3.Controls.Add(this.label11);
@ -241,14 +235,100 @@
this.panel3.TabIndex = 2;
this.panel3.Visible = false;
//
// label7
// button4
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(16, 8);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(82, 13);
this.label7.TabIndex = 0;
this.label7.Text = "Вид движения:";
this.button4.Location = new System.Drawing.Point(19, 134);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(65, 20);
this.button4.TabIndex = 13;
this.button4.Text = "Добавить";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(19, 117);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(58, 13);
this.label12.TabIndex = 12;
this.label12.Text = "Картинка:";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(19, 79);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(54, 13);
this.label11.TabIndex = 11;
this.label11.Text = "Тайминг:";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(240, 79);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(13, 13);
this.label10.TabIndex = 10;
this.label10.Text = "--";
this.label10.Click += new System.EventHandler(this.label10_Click);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(240, 50);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(13, 13);
this.label9.TabIndex = 9;
this.label9.Text = "--";
this.label9.Click += new System.EventHandler(this.label9_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(19, 50);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(107, 13);
this.label8.TabIndex = 8;
this.label8.Text = "Границы движения:";
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(90, 117);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(103, 64);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(132, 76);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(100, 20);
this.textBox7.TabIndex = 5;
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(259, 76);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 4;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(259, 47);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 3;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(132, 47);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 2;
//
// comboBox2
//
@ -264,108 +344,49 @@
this.comboBox2.TabIndex = 1;
this.comboBox2.Text = "Прямо";
//
// textBox4
// label7
//
this.textBox4.Location = new System.Drawing.Point(132, 47);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 2;
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(16, 8);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(82, 13);
this.label7.TabIndex = 0;
this.label7.Text = "Вид движения:";
//
// textBox5
// button2
//
this.textBox5.Location = new System.Drawing.Point(259, 47);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 3;
this.button2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button2.Location = new System.Drawing.Point(0, 243);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(408, 30);
this.button2.TabIndex = 1;
this.button2.Text = "Сохранить мульт";
this.button2.UseVisualStyleBackColor = true;
//
// textBox6
// button1
//
this.textBox6.Location = new System.Drawing.Point(259, 76);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 4;
this.button1.Dock = System.Windows.Forms.DockStyle.Top;
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(408, 26);
this.button1.TabIndex = 0;
this.button1.Text = "Добавить персонажа";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox7
// openFileDialog1
//
this.textBox7.Location = new System.Drawing.Point(132, 76);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(100, 20);
this.textBox7.TabIndex = 5;
this.openFileDialog1.FileName = "openFileDialog1";
//
// pictureBox1
// button5
//
this.pictureBox1.Location = new System.Drawing.Point(90, 117);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(103, 64);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(19, 50);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(107, 13);
this.label8.TabIndex = 8;
this.label8.Text = "Границы движения:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(240, 50);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(13, 13);
this.label9.TabIndex = 9;
this.label9.Text = "--";
this.label9.Click += new System.EventHandler(this.label9_Click);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(240, 79);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(13, 13);
this.label10.TabIndex = 10;
this.label10.Text = "--";
this.label10.Click += new System.EventHandler(this.label10_Click);
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(19, 79);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(54, 13);
this.label11.TabIndex = 11;
this.label11.Text = "Тайминг:";
//
// button3
//
this.button3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button3.Location = new System.Drawing.Point(0, 213);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(408, 30);
this.button3.TabIndex = 3;
this.button3.Text = "Сохранить персонажа";
this.button3.UseVisualStyleBackColor = true;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(19, 117);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(58, 13);
this.label12.TabIndex = 12;
this.label12.Text = "Картинка:";
//
// button4
//
this.button4.Location = new System.Drawing.Point(19, 134);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(65, 20);
this.button4.TabIndex = 13;
this.button4.Text = "Добавить";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
this.button5.Location = new System.Drawing.Point(234, 158);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(171, 30);
this.button5.TabIndex = 14;
this.button5.Text = "Открыть персонажа";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form1
//
@ -377,6 +398,7 @@
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
@ -392,7 +414,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox nazvanieTextBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox3;
@ -419,6 +441,9 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
}
}

View file

@ -9,13 +9,41 @@ using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public struct Personazh
{
public string ce_nibud;
public string nazvanie_personazha;
}
public partial class Form1 : Form
{
PictureBox[] pic1 = new PictureBox[1000];
public Form1()
{
InitializeComponent();
button1.Click += button1_Click;
button3.Click += button3_Click;
openFileDialog1.Filter = "Text files(*OpenFileDialog.txt)|*.txt|All files(*.*)|*.*";
saveFileDialog1.Filter = "Text files(*SaveFileDialog.txt)|*.txt|All files(*.*)|*.*";
}
private void Form1_Load(object sender, EventArgs e)
{
/*int i=0;
for (; i < 10; i++)
{
PictureBox pic2 = new PictureBox();
pic2.Location = new Point(pic2.Location.X + (i*100), pic2.Location.Y);
pic2.BorderStyle = BorderStyle.FixedSingle;
pic1[i] = pic2;
Controls.Add(pic1[i]);
}*/
}
private void label1_Click(object sender, EventArgs e)
{
@ -48,7 +76,37 @@ namespace WindowsFormsApplication1
private void button4_Click(object sender, EventArgs e)
{
button4.BackgroundImage = Image.FromFile("kartinka.jpg");
//Список всех файлов папки
//Создаешь из них массив (или список)
//Выбираешь рандомный номер
pictureBox1.Image = Image.FromFile("kartinka.jpg");
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = saveFileDialog1.FileName;
System.IO.File.WriteAllText(filename, nazvanieTextBox.Text);
MessageBox.Show("Файл сохранен");
}
private void button5_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
string fileText = System.IO.File.ReadAllText(filename);
nazvanieTextBox.Text = fileText;
MessageBox.Show("Файл открыт");
}
}
}

View file

@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB