From f14a9b52a09dadc3c7709627a3bef7516836d6bb Mon Sep 17 00:00:00 2001 From: BytingBulldogs3539 Date: Sun, 4 Feb 2024 22:04:46 -0500 Subject: [PATCH] Adjust save button to save to a predefined location if specified. Fix java formatting to match spotless. --- .../Motion-Profile-Mapper/App.config | 57 ++++++ .../Forms/ConfigurationView.cs | 51 +++-- .../Forms/MotionProfiler.cs | 56 ++++-- .../Forms/Settings.Designer.cs | 178 ++++++++++++++++-- .../Motion-Profile-Mapper/Forms/Settings.cs | 52 +++++ .../Properties/AssemblyInfo.cs | 4 +- .../Properties/Settings.Designer.cs | 36 ++++ .../Properties/Settings.settings | 11 +- .../Motion-Profile-Mapper/Utilities/INI.cs | 16 +- 9 files changed, 406 insertions(+), 55 deletions(-) diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/App.config b/Motion-Profile-Mapper/Motion-Profile-Mapper/App.config index 22a2f10..dc4a0a1 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/App.config +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/App.config @@ -2,6 +2,7 @@ +
@@ -9,6 +10,62 @@ + + + 10.35.39.2 + + + lvuser + + + + + + /home/lvuser/profiles/ + + + 0.711 + + + 2 + + + 1 + + + 0 + + + 0 + + + 12 + + + True + + + /home/lvuser/ + + + 2.5 + + + 0.711 + + + False + + + + + + + + + + + 10.35.39.2 diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs index 5b041ff..41bd0b0 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs @@ -291,6 +291,7 @@ private Boolean validateINIS() private void saveAllLocalButton_Click(object sender, EventArgs e) { if (validateINIS()) return; + SaveFileDialog browser = new SaveFileDialog(); browser.RestoreDirectory = true; String files = ""; @@ -304,19 +305,34 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) browser.FileName = files; browser.OverwritePrompt = false; - if (browser.ShowDialog() != DialogResult.OK) return; + String iniBasePath = ""; + String javaBasePath = ""; - Cursor = Cursors.WaitCursor; + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) + { + if (browser.ShowDialog() != DialogResult.OK) return; + iniBasePath = Path.GetDirectoryName(browser.FileName.Trim()); + javaBasePath = iniBasePath; + } + else + { + iniBasePath = Properties.Settings.Default.iniSavePath; + javaBasePath = Properties.Settings.Default.javaSavePath; + } + + Cursor = Cursors.WaitCursor; setStatus("Saving profiles to file system...", Color.Black); List paths = new List(); List iniList = new List(); + foreach (INI ini in inis) { - string iniPath = Path.Combine(Path.GetDirectoryName(browser.FileName.Trim()), Path.GetFileNameWithoutExtension(ini.fileName) + ".ini"); - string javaPath = Path.Combine(Path.GetDirectoryName(browser.FileName.Trim()), Path.GetFileNameWithoutExtension(ini.fileName) + ".java"); + string iniPath = Path.Combine(iniBasePath, Path.GetFileNameWithoutExtension(ini.fileName) + ".ini"); + string javaPath = Path.Combine(javaBasePath, Path.GetFileNameWithoutExtension(ini.fileName) + ".java"); + if (browser.FilterIndex == 2) { paths.Add(iniPath); @@ -335,7 +351,6 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) iniList.Add(ini); } } - bool yesToAll = false; for (int i = 0; i < paths.Count; i++) { @@ -394,18 +409,27 @@ private void saveLocalButton_Click(object sender, EventArgs e) browser.Title = "Save initialization file locally"; browser.OverwritePrompt = false; + String iniBasePath = ""; + String javaBasePath = ""; - - if (browser.ShowDialog() != DialogResult.OK) return; + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) + { + if (browser.ShowDialog() != DialogResult.OK) return; + iniBasePath = Path.GetDirectoryName(browser.FileName.Trim()); + javaBasePath = iniBasePath; + } + else + { + iniBasePath = Properties.Settings.Default.iniSavePath; + javaBasePath = Properties.Settings.Default.javaSavePath; + } Cursor = Cursors.WaitCursor; - string iniPath = Path.Combine( - Path.GetDirectoryName(browser.FileName.Trim()), + string iniPath = Path.Combine(iniBasePath, selectedIni.fileName + ".ini" ); - string javaPath = Path.Combine( - Path.GetDirectoryName(browser.FileName.Trim()), + string javaPath = Path.Combine(javaBasePath, selectedIni.fileName + ".java" ); @@ -653,6 +677,11 @@ private void loadLocalButton_Click(object sender, EventArgs e) fileDialog.Title = "Select initialization files to load"; fileDialog.Multiselect = true; + if (Directory.Exists(Properties.Settings.Default.iniSavePath)) + { + fileDialog.InitialDirectory = Properties.Settings.Default.iniSavePath; + } + if (fileDialog.ShowDialog() != DialogResult.OK) return; Cursor = Cursors.WaitCursor; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs index 69bda09..0b45a32 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs @@ -573,22 +573,33 @@ private void SaveAllProfiles(object sender, EventArgs e) FolderBrowserDialog browser = new FolderBrowserDialog(); browser.Description = "Save all motion profiles to folder\n\nCAUTION: Existing profiles will be overridden!"; - if (browser.ShowDialog() != DialogResult.OK) return; + String mpBasePath = ""; + + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) + { + if (browser.ShowDialog() != DialogResult.OK) return; + mpBasePath = System.IO.Path.GetDirectoryName(browser.SelectedPath); + } + else + { + mpBasePath = Properties.Settings.Default.mpSavePath; + } + Cursor = Cursors.WaitCursor; setStatus("Saving profiles to file system...", false); foreach (Profile profile in profiles) { - string mpPath = System.IO.Path.Combine(browser.SelectedPath, profile.Name.Replace(' ', '_') + ".mp"); - string javaPath = System.IO.Path.Combine(browser.SelectedPath, profile.Name.Replace(' ', '_') + ".java"); + string mpPath = System.IO.Path.Combine(mpBasePath, profile.Name.Replace(' ', '_') + ".mp"); + //string javaPath = System.IO.Path.Combine(mpBasePath, profile.Name.Replace(' ', '_') + ".java"); using (var writer = new StreamWriter(mpPath)) { writer.Write(profile.toJSON().ToString()); } - using (var writer = new StreamWriter(javaPath)) - { - writer.Write(profile.toJava()); - } + //using (var writer = new StreamWriter(javaPath)) + //{ + // writer.Write(profile.toJava()); + //} } setStatus("Profiles saved to file system", false); Cursor = Cursors.Default; @@ -607,13 +618,24 @@ private void SaveSelectedProfile(object sender, EventArgs e) browser.Filter = "Motion Profile|*.mp;"; browser.Title = "Save motion profile file"; - if (browser.ShowDialog() != DialogResult.OK || browser.FileName.Trim().Length <= 3) return; + + String mpBasePath = ""; + + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) + { + if (browser.ShowDialog() != DialogResult.OK || browser.FileName.Trim().Length <= 3) return; + mpBasePath = System.IO.Path.GetDirectoryName(browser.FileName.Trim()); + } + else + { + mpBasePath = Properties.Settings.Default.mpSavePath; + } Cursor = Cursors.WaitCursor; setStatus("Saving profile to file system...", false); // Write mp file to load from string filePath = System.IO.Path.Combine( - System.IO.Path.GetDirectoryName(browser.FileName.Trim()), + mpBasePath, System.IO.Path.GetFileNameWithoutExtension(browser.FileName.Trim()) + ".mp" ); using (var writer = new StreamWriter(filePath)) @@ -622,14 +644,14 @@ private void SaveSelectedProfile(object sender, EventArgs e) } // Write java file to pre-compile into robot - string pointPath = System.IO.Path.Combine( - System.IO.Path.GetDirectoryName(browser.FileName.Trim()), - System.IO.Path.GetFileNameWithoutExtension(browser.FileName.Trim()) + ".java" - ); - using (var writer = new StreamWriter(pointPath)) - { - writer.Write(selectedProfile.toJava()); - } + //string pointPath = System.IO.Path.Combine( + // System.IO.Path.GetDirectoryName(browser.FileName.Trim()), + // System.IO.Path.GetFileNameWithoutExtension(browser.FileName.Trim()) + ".java" + //); + //using (var writer = new StreamWriter(pointPath)) + //{ + // writer.Write(selectedProfile.toJava()); + //} setStatus("Profile saved to file system", false); Cursor = Cursors.Default; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.Designer.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.Designer.cs index 74fb0db..b727938 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.Designer.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.Designer.cs @@ -44,6 +44,16 @@ private void InitializeComponent() this.label7 = new System.Windows.Forms.Label(); this.iniPath = new System.Windows.Forms.TextBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.iniSavePath = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.javaSavePath = new System.Windows.Forms.TextBox(); + this.iconButton1 = new FontAwesome.Sharp.IconButton(); + this.iconButton2 = new FontAwesome.Sharp.IconButton(); + this.iconButton3 = new FontAwesome.Sharp.IconButton(); + this.label11 = new System.Windows.Forms.Label(); + this.mpSavePath = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // save @@ -53,7 +63,7 @@ private void InitializeComponent() this.save.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.save.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.save.ForeColor = System.Drawing.Color.Black; - this.save.Location = new System.Drawing.Point(267, 214); + this.save.Location = new System.Drawing.Point(285, 403); this.save.Name = "save"; this.save.Size = new System.Drawing.Size(90, 25); this.save.TabIndex = 0; @@ -67,7 +77,7 @@ private void InitializeComponent() this.ipaddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.ipaddress.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ipaddress.ForeColor = System.Drawing.Color.Black; - this.ipaddress.Location = new System.Drawing.Point(115, 38); + this.ipaddress.Location = new System.Drawing.Point(133, 38); this.ipaddress.Name = "ipaddress"; this.ipaddress.Size = new System.Drawing.Size(242, 23); this.ipaddress.TabIndex = 1; @@ -78,7 +88,7 @@ private void InitializeComponent() this.username.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.username.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.username.ForeColor = System.Drawing.Color.Black; - this.username.Location = new System.Drawing.Point(115, 65); + this.username.Location = new System.Drawing.Point(133, 65); this.username.Name = "username"; this.username.Size = new System.Drawing.Size(242, 23); this.username.TabIndex = 2; @@ -89,7 +99,7 @@ private void InitializeComponent() this.password.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.password.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.password.ForeColor = System.Drawing.Color.Black; - this.password.Location = new System.Drawing.Point(115, 92); + this.password.Location = new System.Drawing.Point(133, 92); this.password.Name = "password"; this.password.Size = new System.Drawing.Size(242, 23); this.password.TabIndex = 3; @@ -100,7 +110,7 @@ private void InitializeComponent() this.riopath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.riopath.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.riopath.ForeColor = System.Drawing.Color.Black; - this.riopath.Location = new System.Drawing.Point(115, 119); + this.riopath.Location = new System.Drawing.Point(133, 119); this.riopath.Name = "riopath"; this.riopath.Size = new System.Drawing.Size(242, 23); this.riopath.TabIndex = 4; @@ -110,7 +120,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.ForeColor = System.Drawing.Color.Black; - this.label1.Location = new System.Drawing.Point(21, 40); + this.label1.Location = new System.Drawing.Point(39, 40); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(84, 17); this.label1.TabIndex = 5; @@ -122,7 +132,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.ForeColor = System.Drawing.Color.Black; - this.label2.Location = new System.Drawing.Point(27, 67); + this.label2.Location = new System.Drawing.Point(45, 67); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(78, 17); this.label2.TabIndex = 6; @@ -134,7 +144,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.ForeColor = System.Drawing.Color.Black; - this.label3.Location = new System.Drawing.Point(30, 94); + this.label3.Location = new System.Drawing.Point(48, 94); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(75, 17); this.label3.TabIndex = 7; @@ -143,7 +153,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(14, 100); + this.label4.Location = new System.Drawing.Point(32, 100); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(0, 17); this.label4.TabIndex = 8; @@ -153,7 +163,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.ForeColor = System.Drawing.Color.Black; - this.label5.Location = new System.Drawing.Point(35, 121); + this.label5.Location = new System.Drawing.Point(53, 121); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(66, 17); this.label5.TabIndex = 9; @@ -166,7 +176,7 @@ private void InitializeComponent() this.cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cancel.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cancel.ForeColor = System.Drawing.Color.Black; - this.cancel.Location = new System.Drawing.Point(171, 214); + this.cancel.Location = new System.Drawing.Point(189, 403); this.cancel.Name = "cancel"; this.cancel.Size = new System.Drawing.Size(90, 25); this.cancel.TabIndex = 10; @@ -179,7 +189,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label6.ForeColor = System.Drawing.Color.Black; - this.label6.Location = new System.Drawing.Point(76, 9); + this.label6.Location = new System.Drawing.Point(94, 9); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(223, 17); this.label6.TabIndex = 11; @@ -190,7 +200,7 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label7.ForeColor = System.Drawing.Color.Black; - this.label7.Location = new System.Drawing.Point(35, 150); + this.label7.Location = new System.Drawing.Point(53, 150); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(64, 17); this.label7.TabIndex = 13; @@ -202,7 +212,7 @@ private void InitializeComponent() this.iniPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.iniPath.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.iniPath.ForeColor = System.Drawing.Color.Black; - this.iniPath.Location = new System.Drawing.Point(115, 148); + this.iniPath.Location = new System.Drawing.Point(133, 148); this.iniPath.Name = "iniPath"; this.iniPath.Size = new System.Drawing.Size(242, 23); this.iniPath.TabIndex = 12; @@ -213,19 +223,145 @@ private void InitializeComponent() this.checkBox1.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; this.checkBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.checkBox1.ForeColor = System.Drawing.Color.Black; - this.checkBox1.Location = new System.Drawing.Point(24, 177); + this.checkBox1.Location = new System.Drawing.Point(42, 177); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(166, 21); this.checkBox1.TabIndex = 14; this.checkBox1.Text = "Default alliance is red"; this.checkBox1.UseVisualStyleBackColor = true; // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.ForeColor = System.Drawing.Color.Black; + this.label8.Location = new System.Drawing.Point(75, 201); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(271, 17); + this.label8.TabIndex = 15; + this.label8.Text = "INI Configuration Local Save Settings"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.ForeColor = System.Drawing.Color.Black; + this.label9.Location = new System.Drawing.Point(24, 228); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(103, 17); + this.label9.TabIndex = 17; + this.label9.Text = "INI Save Path"; + // + // iniSavePath + // + this.iniSavePath.BackColor = System.Drawing.Color.White; + this.iniSavePath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.iniSavePath.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.iniSavePath.ForeColor = System.Drawing.Color.Black; + this.iniSavePath.Location = new System.Drawing.Point(133, 226); + this.iniSavePath.Name = "iniSavePath"; + this.iniSavePath.Size = new System.Drawing.Size(221, 23); + this.iniSavePath.TabIndex = 16; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.ForeColor = System.Drawing.Color.Black; + this.label10.Location = new System.Drawing.Point(14, 257); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(113, 17); + this.label10.TabIndex = 19; + this.label10.Text = "Java Save Path"; + // + // javaSavePath + // + this.javaSavePath.BackColor = System.Drawing.Color.White; + this.javaSavePath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.javaSavePath.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.javaSavePath.ForeColor = System.Drawing.Color.Black; + this.javaSavePath.Location = new System.Drawing.Point(133, 255); + this.javaSavePath.Name = "javaSavePath"; + this.javaSavePath.Size = new System.Drawing.Size(221, 23); + this.javaSavePath.TabIndex = 18; + // + // iconButton1 + // + this.iconButton1.IconChar = FontAwesome.Sharp.IconChar.FolderClosed; + this.iconButton1.IconColor = System.Drawing.Color.Black; + this.iconButton1.IconFont = FontAwesome.Sharp.IconFont.Auto; + this.iconButton1.IconSize = 20; + this.iconButton1.Location = new System.Drawing.Point(360, 226); + this.iconButton1.Name = "iconButton1"; + this.iconButton1.Size = new System.Drawing.Size(29, 23); + this.iconButton1.TabIndex = 20; + this.iconButton1.UseVisualStyleBackColor = true; + this.iconButton1.Click += new System.EventHandler(this.iconButton1_Click); + // + // iconButton2 + // + this.iconButton2.IconChar = FontAwesome.Sharp.IconChar.FolderClosed; + this.iconButton2.IconColor = System.Drawing.Color.Black; + this.iconButton2.IconFont = FontAwesome.Sharp.IconFont.Auto; + this.iconButton2.IconSize = 20; + this.iconButton2.Location = new System.Drawing.Point(360, 255); + this.iconButton2.Name = "iconButton2"; + this.iconButton2.Size = new System.Drawing.Size(29, 23); + this.iconButton2.TabIndex = 21; + this.iconButton2.UseVisualStyleBackColor = true; + this.iconButton2.Click += new System.EventHandler(this.iconButton2_Click); + // + // iconButton3 + // + this.iconButton3.IconChar = FontAwesome.Sharp.IconChar.FolderClosed; + this.iconButton3.IconColor = System.Drawing.Color.Black; + this.iconButton3.IconFont = FontAwesome.Sharp.IconFont.Auto; + this.iconButton3.IconSize = 20; + this.iconButton3.Location = new System.Drawing.Point(360, 284); + this.iconButton3.Name = "iconButton3"; + this.iconButton3.Size = new System.Drawing.Size(29, 23); + this.iconButton3.TabIndex = 24; + this.iconButton3.UseVisualStyleBackColor = true; + this.iconButton3.Click += new System.EventHandler(this.iconButton3_Click); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.ForeColor = System.Drawing.Color.Black; + this.label11.Location = new System.Drawing.Point(21, 286); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(102, 17); + this.label11.TabIndex = 23; + this.label11.Text = "MP Save Path"; + // + // mpSavePath + // + this.mpSavePath.BackColor = System.Drawing.Color.White; + this.mpSavePath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.mpSavePath.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.mpSavePath.ForeColor = System.Drawing.Color.Black; + this.mpSavePath.Location = new System.Drawing.Point(133, 284); + this.mpSavePath.Name = "mpSavePath"; + this.mpSavePath.Size = new System.Drawing.Size(221, 23); + this.mpSavePath.TabIndex = 22; + // // Settings // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; - this.ClientSize = new System.Drawing.Size(383, 251); + this.ClientSize = new System.Drawing.Size(404, 440); + this.Controls.Add(this.iconButton3); + this.Controls.Add(this.label11); + this.Controls.Add(this.mpSavePath); + this.Controls.Add(this.iconButton2); + this.Controls.Add(this.iconButton1); + this.Controls.Add(this.label10); + this.Controls.Add(this.javaSavePath); + this.Controls.Add(this.label9); + this.Controls.Add(this.iniSavePath); + this.Controls.Add(this.label8); this.Controls.Add(this.checkBox1); this.Controls.Add(this.label7); this.Controls.Add(this.iniPath); @@ -269,5 +405,15 @@ private void InitializeComponent() private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox iniPath; private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox iniSavePath; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox javaSavePath; + private FontAwesome.Sharp.IconButton iconButton1; + private FontAwesome.Sharp.IconButton iconButton2; + private FontAwesome.Sharp.IconButton iconButton3; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.TextBox mpSavePath; } } \ No newline at end of file diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs index 5ebec02..f572f23 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -21,6 +22,9 @@ public Settings() this.riopath.Text = Properties.Settings.Default.RioLocation; this.iniPath.Text = Properties.Settings.Default.INILocation; this.checkBox1.Checked = Properties.Settings.Default.defaultAllianceIsRed; + this.iniSavePath.Text = Properties.Settings.Default.iniSavePath; + this.javaSavePath.Text = Properties.Settings.Default.javaSavePath; + this.mpSavePath.Text = Properties.Settings.Default.mpSavePath; } private void save_Click(object sender, EventArgs e) @@ -38,6 +42,12 @@ private void save_Click(object sender, EventArgs e) Properties.Settings.Default.INILocation = this.iniPath.Text + (this.iniPath.Text.Last().ToString() == "/" ? "" : "/"); Properties.Settings.Default.defaultAllianceIsRed = this.checkBox1.Checked; + Properties.Settings.Default.iniSavePath = iniSavePath.Text; + Properties.Settings.Default.javaSavePath = javaSavePath.Text; + Properties.Settings.Default.mpSavePath = mpSavePath.Text; + + + Properties.Settings.Default.Save(); this.Close(); @@ -71,5 +81,47 @@ private void cancel_Click(object sender, EventArgs e) { this.Close(); } + + private void iconButton1_Click(object sender, EventArgs e) + { + SaveFileDialog browser = new SaveFileDialog(); + browser.RestoreDirectory = true; + browser.Filter = "Directory | directory"; + browser.Title = "Directory to save INI Files to"; + browser.OverwritePrompt = false; + browser.FileName = "DoNotChangeMe.ini"; + + if (browser.ShowDialog() != DialogResult.OK) return; + + iniSavePath.Text = Path.GetDirectoryName(browser.FileName.Trim()); + } + + private void iconButton2_Click(object sender, EventArgs e) + { + SaveFileDialog browser = new SaveFileDialog(); + browser.RestoreDirectory = true; + browser.Filter = "Directory | directory"; + browser.Title = "Directory to save JAVA Files to"; + browser.OverwritePrompt = false; + browser.FileName = "DoNotChangeMe.java"; + + if (browser.ShowDialog() != DialogResult.OK) return; + + javaSavePath.Text = Path.GetDirectoryName(browser.FileName.Trim()); + } + + private void iconButton3_Click(object sender, EventArgs e) + { + SaveFileDialog browser = new SaveFileDialog(); + browser.RestoreDirectory = true; + browser.Filter = "Directory | directory"; + browser.Title = "Directory to save MP Files to"; + browser.OverwritePrompt = false; + browser.FileName = "DoNotChangeMe.mp"; + + if (browser.ShowDialog() != DialogResult.OK) return; + + mpSavePath.Text = Path.GetDirectoryName(browser.FileName.Trim()); + } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/AssemblyInfo.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/AssemblyInfo.cs index 23a3482..4a27174 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/AssemblyInfo.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.0.0")] -[assembly: AssemblyFileVersion("1.4.0.0")] +[assembly: AssemblyVersion("2024.0.1")] +[assembly: AssemblyFileVersion("2024.0.1")] diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.Designer.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.Designer.cs index 496f01c..00442d3 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.Designer.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.Designer.cs @@ -202,5 +202,41 @@ public bool defaultAllianceIsRed { this["defaultAllianceIsRed"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string iniSavePath { + get { + return ((string)(this["iniSavePath"])); + } + set { + this["iniSavePath"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string javaSavePath { + get { + return ((string)(this["javaSavePath"])); + } + set { + this["javaSavePath"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string mpSavePath { + get { + return ((string)(this["mpSavePath"])); + } + set { + this["mpSavePath"] = value; + } + } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.settings b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.settings index 0fea5b5..3e5cadc 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.settings +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Properties/Settings.settings @@ -1,5 +1,5 @@  - + @@ -47,5 +47,14 @@ False + + + + + + + + + \ No newline at end of file diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs index 0baec3f..4f87227 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs @@ -245,32 +245,32 @@ public string toIni() public string toJava() { - string fileContent = "package frc.robot.constants;\n\nimport org.frcteam3539.BulldogLibrary.INIConfiguration.BBConstants;\n\n"; + string fileContent = "package frc.robot.constants;\r\n\r\nimport org.frcteam3539.BulldogLibrary.INIConfiguration.BBConstants;\r\n\r\n"; - fileContent+=$"public class {this.fileName.Replace(" ", "").Trim()} extends BBConstants"+"{"+"\n"; + fileContent+=$"public class {this.fileName.Replace(" ", "").Trim()} extends BBConstants "+"{"+"\r\n"; - fileContent += "\tpublic "+this.fileName+"() {\n\t\tsuper(\""+ Properties.Settings.Default.INILocation + this.fileName+".ini\", true);\n\t\tsave();\n\t}\n"; + fileContent += "public "+this.fileName+"() {\r\n\tsuper(\""+ Properties.Settings.Default.INILocation + this.fileName+".ini\", true);\r\n\tsave();\r\n}\r\n\r\n"; foreach (INIVariable variable in variables) { if(variable.type.ToLower() == "string") - fileContent += $"\tpublic static {variable.type} {variable.name} = \"{variable.value}\";\n"; + fileContent += $"public static {variable.type} {variable.name} = \"{variable.value}\";\r\n"; else if(variable.type.ToLower() == "boolean") { if(variable.value.ToLower() == "true") { - fileContent += $"\tpublic static {variable.type} {variable.name} = true;\n"; + fileContent += $"public static {variable.type} {variable.name} = true;\r\n"; } else if (variable.value.ToLower() == "false") { - fileContent += $"\tpublic static {variable.type} {variable.name} = false;\n"; + fileContent += $"public static {variable.type} {variable.name} = false;\r\n"; } } else - fileContent += $"\tpublic static {variable.type} {variable.name} = {variable.value};\n"; + fileContent += $"public static {variable.type} {variable.name} = {variable.value};\r\n"; } - fileContent += "}\n"; + fileContent += "}\r"; return fileContent; }