Реализован базовый функционал редактора конфигов
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
125
ConfigEditor/MainForm.Designer.cs
generated
125
ConfigEditor/MainForm.Designer.cs
generated
@@ -30,15 +30,15 @@
|
|||||||
{
|
{
|
||||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.открытьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.сохранитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.сохранитьКакToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.сгенерироватьMD5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.generateMD5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.закрытьФайлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.closeFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.закрытьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.closeProgramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@@ -55,77 +55,89 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.файлToolStripMenuItem});
|
this.fileToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
|
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
|
||||||
this.menuStrip1.TabIndex = 1;
|
this.menuStrip1.TabIndex = 1;
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// файлToolStripMenuItem
|
// fileToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.открытьToolStripMenuItem,
|
this.openToolStripMenuItem,
|
||||||
this.сохранитьToolStripMenuItem,
|
this.saveToolStripMenuItem,
|
||||||
this.сохранитьКакToolStripMenuItem,
|
this.saveAsToolStripMenuItem,
|
||||||
this.toolStripSeparator1,
|
this.toolStripSeparator1,
|
||||||
this.сгенерироватьMD5ToolStripMenuItem,
|
this.generateMD5ToolStripMenuItem,
|
||||||
this.toolStripSeparator2,
|
this.toolStripSeparator2,
|
||||||
this.закрытьФайлToolStripMenuItem,
|
this.closeFileToolStripMenuItem,
|
||||||
this.закрытьToolStripMenuItem});
|
this.closeProgramToolStripMenuItem});
|
||||||
this.файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||||
this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||||
this.файлToolStripMenuItem.Text = "Файл";
|
this.fileToolStripMenuItem.Text = "File";
|
||||||
//
|
//
|
||||||
// открытьToolStripMenuItem
|
// openToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.открытьToolStripMenuItem.Name = "открытьToolStripMenuItem";
|
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||||
this.открытьToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||||
this.открытьToolStripMenuItem.Text = "Открыть";
|
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.открытьToolStripMenuItem.Click += new System.EventHandler(this.открытьToolStripMenuItem_Click);
|
this.openToolStripMenuItem.Text = "Open";
|
||||||
|
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// сохранитьToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem";
|
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
this.сохранитьToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
this.сохранитьToolStripMenuItem.Text = "Сохранить";
|
this.saveToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
||||||
|
this.saveToolStripMenuItem.Text = "Save";
|
||||||
|
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// сохранитьКакToolStripMenuItem
|
// saveAsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.сохранитьКакToolStripMenuItem.Name = "сохранитьКакToolStripMenuItem";
|
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||||
this.сохранитьКакToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||||
this.сохранитьКакToolStripMenuItem.Text = "Сохранить как...";
|
| System.Windows.Forms.Keys.S)));
|
||||||
|
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
||||||
|
this.saveAsToolStripMenuItem.Text = "Save As...";
|
||||||
|
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
this.toolStripSeparator1.Size = new System.Drawing.Size(182, 6);
|
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
|
||||||
//
|
//
|
||||||
// сгенерироватьMD5ToolStripMenuItem
|
// generateMD5ToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.сгенерироватьMD5ToolStripMenuItem.Name = "сгенерироватьMD5ToolStripMenuItem";
|
this.generateMD5ToolStripMenuItem.Name = "generateMD5ToolStripMenuItem";
|
||||||
this.сгенерироватьMD5ToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.generateMD5ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
|
||||||
this.сгенерироватьMD5ToolStripMenuItem.Text = "Сгенерировать MD5";
|
this.generateMD5ToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
||||||
|
this.generateMD5ToolStripMenuItem.Text = "Generate MD5";
|
||||||
|
this.generateMD5ToolStripMenuItem.Click += new System.EventHandler(this.generateMD5ToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripSeparator2
|
// toolStripSeparator2
|
||||||
//
|
//
|
||||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||||
this.toolStripSeparator2.Size = new System.Drawing.Size(182, 6);
|
this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
|
||||||
//
|
//
|
||||||
// закрытьФайлToolStripMenuItem
|
// closeFileToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.закрытьФайлToolStripMenuItem.Name = "закрытьФайлToolStripMenuItem";
|
this.closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem";
|
||||||
this.закрытьФайлToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.closeFileToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
|
||||||
this.закрытьФайлToolStripMenuItem.Text = "Закрыть файл";
|
this.closeFileToolStripMenuItem.Size = new System.Drawing.Size(241, 22);
|
||||||
|
this.closeFileToolStripMenuItem.Text = "Close file";
|
||||||
|
this.closeFileToolStripMenuItem.Click += new System.EventHandler(this.closeFileToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// закрытьToolStripMenuItem
|
// closeProgramToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.закрытьToolStripMenuItem.Name = "закрытьToolStripMenuItem";
|
this.closeProgramToolStripMenuItem.Name = "closeProgramToolStripMenuItem";
|
||||||
this.закрытьToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
this.closeProgramToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||||
this.закрытьToolStripMenuItem.Text = "Закрыть";
|
| System.Windows.Forms.Keys.Q)));
|
||||||
this.закрытьToolStripMenuItem.Click += new System.EventHandler(this.закрытьToolStripMenuItem_Click);
|
this.closeProgramToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||||
|
this.closeProgramToolStripMenuItem.Text = "Close";
|
||||||
|
this.closeProgramToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// Form1
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@@ -133,8 +145,9 @@
|
|||||||
this.Controls.Add(this.richTextBox1);
|
this.Controls.Add(this.richTextBox1);
|
||||||
this.Controls.Add(this.menuStrip1);
|
this.Controls.Add(this.menuStrip1);
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
this.Name = "Form1";
|
this.Name = "MainForm";
|
||||||
this.Text = "SaveWizard Config Editor";
|
this.Text = "SaveWizard Config Editor";
|
||||||
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
|
||||||
this.menuStrip1.ResumeLayout(false);
|
this.menuStrip1.ResumeLayout(false);
|
||||||
this.menuStrip1.PerformLayout();
|
this.menuStrip1.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
@@ -146,15 +159,15 @@
|
|||||||
|
|
||||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem открытьToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem сохранитьToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem сохранитьКакToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem сгенерироватьMD5ToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem generateMD5ToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||||
private System.Windows.Forms.ToolStripMenuItem закрытьФайлToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem closeFileToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem закрытьToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem closeProgramToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ConfigEditor
|
namespace ConfigEditor
|
||||||
{
|
{
|
||||||
public partial class MainForm: Form
|
public partial class MainForm: Form
|
||||||
{
|
{
|
||||||
|
private string opened_file = null;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void открытьToolStripMenuItem_Click(object sender, System.EventArgs e)
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog ofd = new OpenFileDialog()
|
OpenFileDialog ofd = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
@@ -19,11 +24,81 @@ namespace ConfigEditor
|
|||||||
Multiselect = false
|
Multiselect = false
|
||||||
};
|
};
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
opened_file = ofd.FileName;
|
||||||
richTextBox1.Text = File.ReadAllText(ofd.FileName);
|
richTextBox1.Text = File.ReadAllText(ofd.FileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void закрытьToolStripMenuItem_Click(object sender, System.EventArgs e)
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
File.WriteAllText(opened_file, richTextBox1.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog sfd = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Title = "Сохранить файл конфигурации",
|
||||||
|
Filter = "Файл *.json|*.json"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
File.WriteAllText(sfd.FileName, richTextBox1.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateMD5ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (var md5 = MD5.Create())
|
||||||
|
{
|
||||||
|
using (FileStream stream = File.OpenRead(opened_file))
|
||||||
|
md5.ComputeHash(stream);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
byte[] hash = md5.Hash;
|
||||||
|
for (int i = 0; i < hash.Length; i++)
|
||||||
|
sb.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
|
Clipboard.SetText(sb.ToString());
|
||||||
|
MessageBox.Show($"Hash successfully copied into your clipboard.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckChanges()
|
||||||
|
{
|
||||||
|
if (richTextBox1.Text != File.ReadAllText(opened_file))
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("The document has been modified.\nDo you want to save your changes?", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||||
|
if (result == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
File.WriteAllText(opened_file, richTextBox1.Text);
|
||||||
|
MessageBox.Show("File successfully saved.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (result == DialogResult.Cancel)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!CheckChanges())
|
||||||
|
return;
|
||||||
|
richTextBox1.Clear();
|
||||||
|
opened_file = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!CheckChanges())
|
||||||
|
return;
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!CheckChanges())
|
||||||
|
return;
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user