diff options
author | emkael <emkael@tlen.pl> | 2019-08-29 00:22:50 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-10-27 14:53:42 +0100 |
commit | 16eb9a6f73892981f32d3d4325dcc4b0db849ed2 (patch) | |
tree | 8626a60a5585b5c40254ea165420d6d8480e7bf5 | |
parent | 7d2530a3ed498b129c3949b4c7d33f913ad34a94 (diff) |
Saving default dump directory in app settings
-rw-r--r-- | spedytor/Form1.cs | 23 | ||||
-rw-r--r-- | spedytor/MysqlSettings.Designer.cs | 64 | ||||
-rw-r--r-- | spedytor/MysqlSettings.cs | 30 | ||||
-rw-r--r-- | spedytor/Properties/Settings.Designer.cs | 12 | ||||
-rw-r--r-- | spedytor/Properties/Settings.settings | 3 | ||||
-rw-r--r-- | spedytor/app.config | 3 |
6 files changed, 118 insertions, 17 deletions
diff --git a/spedytor/Form1.cs b/spedytor/Form1.cs index 928682a..cebc8ed 100644 --- a/spedytor/Form1.cs +++ b/spedytor/Form1.cs @@ -75,12 +75,27 @@ namespace spedytor private void bSave_Click(object sender, EventArgs e) { this.setControlState(false, null); - FolderBrowserDialog fd = new FolderBrowserDialog(); - if (fd.ShowDialog() == DialogResult.OK) + String directory = spedytor.Properties.Settings.Default.DIRECTORY; + if (!Directory.Exists(directory)) { - string filePath = Path.Combine(fd.SelectedPath, this.cbDatabaseName.SelectedItem.ToString() + DateTime.Now.ToString("-yyyyMMdd-HHmmss") + ".sql"); - this.saveFile(filePath, this.cbDatabaseName.SelectedItem.ToString(), this.getBucketID()); + directory = ""; + spedytor.Properties.Settings.Default.DIRECTORY = ""; } + if (directory.Length == 0) + { + FolderBrowserDialog fd = new FolderBrowserDialog(); + if (fd.ShowDialog() == DialogResult.OK) + { + directory = fd.SelectedPath; + } + else + { + this.setControlState(true, null); + return; + } + } + string filePath = Path.Combine(directory, this.cbDatabaseName.SelectedItem.ToString() + DateTime.Now.ToString("-yyyyMMdd-HHmmss") + ".sql"); + this.saveFile(filePath, this.cbDatabaseName.SelectedItem.ToString(), this.getBucketID()); this.setControlState(true, null); } diff --git a/spedytor/MysqlSettings.Designer.cs b/spedytor/MysqlSettings.Designer.cs index 0cf00a9..7b367cb 100644 --- a/spedytor/MysqlSettings.Designer.cs +++ b/spedytor/MysqlSettings.Designer.cs @@ -46,22 +46,26 @@ this.label8 = new System.Windows.Forms.Label(); this.eS3ID = new System.Windows.Forms.TextBox(); this.eS3Key = new System.Windows.Forms.TextBox(); + this.eDirectory = new System.Windows.Forms.TextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.bDirectorySelect = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // eHost // this.eHost.Location = new System.Drawing.Point(49, 19); this.eHost.Name = "eHost"; - this.eHost.Size = new System.Drawing.Size(100, 20); + this.eHost.Size = new System.Drawing.Size(155, 20); this.eHost.TabIndex = 0; // // eUser // this.eUser.Location = new System.Drawing.Point(49, 45); this.eUser.Name = "eUser"; - this.eUser.Size = new System.Drawing.Size(100, 20); + this.eUser.Size = new System.Drawing.Size(155, 20); this.eUser.TabIndex = 1; // // ePass @@ -69,21 +73,21 @@ this.ePass.Location = new System.Drawing.Point(49, 71); this.ePass.Name = "ePass"; this.ePass.PasswordChar = '*'; - this.ePass.Size = new System.Drawing.Size(100, 20); + this.ePass.Size = new System.Drawing.Size(155, 20); this.ePass.TabIndex = 2; // // ePort // this.ePort.Location = new System.Drawing.Point(49, 97); this.ePort.Name = "ePort"; - this.ePort.Size = new System.Drawing.Size(100, 20); + this.ePort.Size = new System.Drawing.Size(155, 20); this.ePort.TabIndex = 3; // // bOk // - this.bOk.Location = new System.Drawing.Point(12, 253); + this.bOk.Location = new System.Drawing.Point(12, 310); this.bOk.Name = "bOk"; - this.bOk.Size = new System.Drawing.Size(155, 23); + this.bOk.Size = new System.Drawing.Size(210, 23); this.bOk.TabIndex = 4; this.bOk.Text = "OK"; this.bOk.UseVisualStyleBackColor = true; @@ -101,7 +105,7 @@ this.groupBox1.Controls.Add(this.ePass); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(155, 126); + this.groupBox1.Size = new System.Drawing.Size(210, 126); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = "MySQL"; @@ -154,9 +158,9 @@ this.groupBox2.Controls.Add(this.label8); this.groupBox2.Controls.Add(this.eS3ID); this.groupBox2.Controls.Add(this.eS3Key); - this.groupBox2.Location = new System.Drawing.Point(12, 144); + this.groupBox2.Location = new System.Drawing.Point(12, 202); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(155, 102); + this.groupBox2.Size = new System.Drawing.Size(210, 102); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; this.groupBox2.Text = "S3"; @@ -175,7 +179,7 @@ // this.eS3Bucket.Location = new System.Drawing.Point(49, 71); this.eS3Bucket.Name = "eS3Bucket"; - this.eS3Bucket.Size = new System.Drawing.Size(100, 20); + this.eS3Bucket.Size = new System.Drawing.Size(155, 20); this.eS3Bucket.TabIndex = 6; // // label7 @@ -202,22 +206,51 @@ // this.eS3ID.Location = new System.Drawing.Point(49, 19); this.eS3ID.Name = "eS3ID"; - this.eS3ID.Size = new System.Drawing.Size(100, 20); + this.eS3ID.Size = new System.Drawing.Size(155, 20); this.eS3ID.TabIndex = 0; // // eS3Key // this.eS3Key.Location = new System.Drawing.Point(49, 45); this.eS3Key.Name = "eS3Key"; - this.eS3Key.Size = new System.Drawing.Size(100, 20); + this.eS3Key.Size = new System.Drawing.Size(155, 20); this.eS3Key.TabIndex = 1; // + // eDirectory + // + this.eDirectory.Location = new System.Drawing.Point(6, 23); + this.eDirectory.Name = "eDirectory"; + this.eDirectory.Size = new System.Drawing.Size(166, 20); + this.eDirectory.TabIndex = 10; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.bDirectorySelect); + this.groupBox3.Controls.Add(this.eDirectory); + this.groupBox3.Location = new System.Drawing.Point(12, 144); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(210, 52); + this.groupBox3.TabIndex = 11; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Domyślny katalog"; + // + // bDirectorySelect + // + this.bDirectorySelect.Location = new System.Drawing.Point(178, 21); + this.bDirectorySelect.Name = "bDirectorySelect"; + this.bDirectorySelect.Size = new System.Drawing.Size(26, 23); + this.bDirectorySelect.TabIndex = 11; + this.bDirectorySelect.Text = "..."; + this.bDirectorySelect.UseVisualStyleBackColor = true; + this.bDirectorySelect.Click += new System.EventHandler(this.bDirectorySelect_Click); + // // MysqlSettings // this.AcceptButton = this.bOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(179, 285); + this.ClientSize = new System.Drawing.Size(234, 339); + this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.bOk); @@ -230,6 +263,8 @@ this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); this.ResumeLayout(false); } @@ -253,5 +288,8 @@ private System.Windows.Forms.TextBox eS3Key; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox eS3Bucket; + private System.Windows.Forms.TextBox eDirectory; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Button bDirectorySelect; } } diff --git a/spedytor/MysqlSettings.cs b/spedytor/MysqlSettings.cs index 7c798be..bce4f01 100644 --- a/spedytor/MysqlSettings.cs +++ b/spedytor/MysqlSettings.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; +using System.IO; namespace spedytor { @@ -24,6 +25,7 @@ namespace spedytor eS3ID.Text = Properties.S3Settings.Default.AWS_ACCESS_KEY; eS3Key.Text = Properties.S3Settings.Default.AWS_SECRET_KEY; eS3Bucket.Text = Properties.S3Settings.Default.AWS_BUCKET_ID; + eDirectory.Text = Properties.Settings.Default.DIRECTORY; } private void button1_Click(object sender, EventArgs e) @@ -37,6 +39,25 @@ namespace spedytor Properties.S3Settings.Default.AWS_BUCKET_ID = eS3Bucket.Text.Trim(); Properties.S3Settings.Default.Save(); + String directory = eDirectory.Text.Trim(); + + if (directory.Length > 0) + { + if (Directory.Exists(directory)) + { + Properties.Settings.Default.DIRECTORY = directory; + } + else + { + MessageBox.Show("Ustawiony katalog domyślny jest nieprawidłowy", "Nieprawidłowe ustawienia katalogu", MessageBoxButtons.OK, MessageBoxIcon.Stop); + eDirectory.Text = ""; + } + } + else + { + Properties.Settings.Default.DIRECTORY = ""; + } + string msg = MySQL.test(); if (msg == "") { @@ -49,5 +70,14 @@ namespace spedytor MessageBox.Show(msg, "Nieprawidłowe ustawienia MySQL", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } + + private void bDirectorySelect_Click(object sender, EventArgs e) + { + FolderBrowserDialog fd = new FolderBrowserDialog(); + if (fd.ShowDialog() == DialogResult.OK) + { + eDirectory.Text = fd.SelectedPath; + } + } } } diff --git a/spedytor/Properties/Settings.Designer.cs b/spedytor/Properties/Settings.Designer.cs index 9508165..b4d2ff8 100644 --- a/spedytor/Properties/Settings.Designer.cs +++ b/spedytor/Properties/Settings.Designer.cs @@ -82,5 +82,17 @@ namespace spedytor.Properties { this["CONFIGURED"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string DIRECTORY { + get { + return ((string)(this["DIRECTORY"])); + } + set { + this["DIRECTORY"] = value; + } + } } } diff --git a/spedytor/Properties/Settings.settings b/spedytor/Properties/Settings.settings index 503268a..1fd4aac 100644 --- a/spedytor/Properties/Settings.settings +++ b/spedytor/Properties/Settings.settings @@ -17,5 +17,8 @@ <Setting Name="CONFIGURED" Type="System.Boolean" Scope="User"> <Value Profile="(Default)">False</Value> </Setting> + <Setting Name="DIRECTORY" Type="System.String" Scope="User"> + <Value Profile="(Default)" /> + </Setting> </Settings> </SettingsFile>
\ No newline at end of file diff --git a/spedytor/app.config b/spedytor/app.config index b8ef5b0..fe805a1 100644 --- a/spedytor/app.config +++ b/spedytor/app.config @@ -35,6 +35,9 @@ <setting name="CONFIGURED" serializeAs="String"> <value>False</value> </setting> + <setting name="DIRECTORY" serializeAs="String"> + <value /> + </setting> </spedytor.Properties.Settings> </userSettings> <startup><supportedRuntime version="v2.0.50727"/></startup></configuration> |