diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index fdc7f98..002271d 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -44,6 +44,7 @@ private void InitializeComponent() this.linkOpenTunerUpdates = new System.Windows.Forms.Label(); this.linkDocumentation = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.LinkDatvReportMoreInfo = new System.Windows.Forms.Label(); this.linkDATVReporterSettings = new System.Windows.Forms.Label(); this.checkDATVReporter = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); @@ -245,6 +246,7 @@ private void InitializeComponent() // // groupBox2 // + this.groupBox2.Controls.Add(this.LinkDatvReportMoreInfo); this.groupBox2.Controls.Add(this.linkDATVReporterSettings); this.groupBox2.Controls.Add(this.checkDATVReporter); this.groupBox2.Controls.Add(this.checkBox2); @@ -265,6 +267,14 @@ private void InitializeComponent() this.groupBox2.Name = "groupBox2"; this.groupBox2.TabStop = false; // + // LinkDatvReportMoreInfo + // + resources.ApplyResources(this.LinkDatvReportMoreInfo, "LinkDatvReportMoreInfo"); + this.LinkDatvReportMoreInfo.Cursor = System.Windows.Forms.Cursors.Hand; + this.LinkDatvReportMoreInfo.ForeColor = System.Drawing.Color.RoyalBlue; + this.LinkDatvReportMoreInfo.Name = "LinkDatvReportMoreInfo"; + this.LinkDatvReportMoreInfo.Click += new System.EventHandler(this.LinkDatvReportMoreInfo_Click); + // // linkDATVReporterSettings // resources.ApplyResources(this.linkDATVReporterSettings, "linkDATVReporterSettings"); @@ -788,6 +798,7 @@ private void InitializeComponent() private System.Windows.Forms.TabControl ExtraToolsTab; private System.Windows.Forms.TabPage ExtraSpectrumTab; private System.Windows.Forms.PictureBox spectrum; + private System.Windows.Forms.Label LinkDatvReportMoreInfo; } } diff --git a/MainForm.cs b/MainForm.cs index b85cdcc..618e3c1 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -25,6 +25,7 @@ using Serilog; using System.Runtime.CompilerServices; using System.Drawing; +using opentuner.SettingsManagement; namespace opentuner { @@ -281,6 +282,9 @@ public MainForm(string[] args) Application.AddMessageFilter(this); _settings = new MainSettings(); + + //SettingsFormBuilder test = new SettingsFormBuilder(_settings); + _settingsManager = new SettingsManager("open_tuner_settings"); _settings = (_settingsManager.LoadSettings(_settings)); @@ -1181,6 +1185,11 @@ private void ExtraToolsTab_DrawItem(object sender, DrawItemEventArgs e) { } + + private void LinkDatvReportMoreInfo_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start("https://www.zr6tg.co.za/opentuner-datv-reporter/"); + } } diff --git a/MainForm.resx b/MainForm.resx index 3c0449b..5eb08f2 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -447,6 +447,39 @@ 0 + + True + + + Microsoft Sans Serif, 8.25pt, style=Underline + + + NoControl + + + 342, 180 + + + 64, 13 + + + 19 + + + More Info ... + + + LinkDatvReportMoreInfo + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + True @@ -478,7 +511,7 @@ groupBox2 - 0 + 1 True @@ -508,7 +541,7 @@ groupBox2 - 1 + 2 True @@ -541,7 +574,7 @@ groupBox2 - 2 + 3 True @@ -574,7 +607,7 @@ groupBox2 - 3 + 4 True @@ -607,7 +640,7 @@ groupBox2 - 4 + 5 True @@ -640,7 +673,7 @@ groupBox2 - 5 + 6 True @@ -676,7 +709,7 @@ groupBox2 - 6 + 7 True @@ -709,7 +742,7 @@ groupBox2 - 7 + 8 True @@ -742,7 +775,7 @@ groupBox2 - 8 + 9 True @@ -769,7 +802,7 @@ groupBox2 - 9 + 10 True @@ -802,7 +835,7 @@ groupBox2 - 10 + 11 True @@ -835,7 +868,7 @@ groupBox2 - 11 + 12 True @@ -865,7 +898,7 @@ groupBox2 - 12 + 13 True @@ -892,7 +925,7 @@ groupBox2 - 13 + 14 True @@ -922,7 +955,7 @@ groupBox2 - 14 + 15 True @@ -949,7 +982,7 @@ groupBox2 - 15 + 16 Top diff --git a/MainSettings.cs b/MainSettings.cs index e92f979..9eba815 100644 --- a/MainSettings.cs +++ b/MainSettings.cs @@ -1,4 +1,5 @@ -using System; +using opentuner.SettingsManagement; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,10 +7,13 @@ namespace opentuner { - public class MainSettings + public class MainSettings : GenericSettings { + [Group("Settings 1")] + [FriendlyName("Media Path")] public string media_path = ""; + [Group("Settings 2")] public bool enable_spectrum_checkbox = true; public bool enable_chatform_checkbox = true; public bool enable_mqtt_checkbox = true; diff --git a/Resources/BuildDate.txt b/Resources/BuildDate.txt index cde34fd..1b1c30a 100644 --- a/Resources/BuildDate.txt +++ b/Resources/BuildDate.txt @@ -1 +1 @@ -2024/07/13 18:17:53.68 +2024/07/14 13:06:17.88 diff --git a/SettingsManagement/FriendlyNameAttribute.cs b/SettingsManagement/FriendlyNameAttribute.cs new file mode 100644 index 0000000..abb4dae --- /dev/null +++ b/SettingsManagement/FriendlyNameAttribute.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.SettingsManagement +{ + [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] + public class FriendlyNameAttribute : Attribute + { + public string FriendlyName { get; } + + public FriendlyNameAttribute(string friendlyName) + { + FriendlyName = friendlyName; + } + } +} diff --git a/SettingsManagement/GenericSettings.cs b/SettingsManagement/GenericSettings.cs new file mode 100644 index 0000000..a3f7127 --- /dev/null +++ b/SettingsManagement/GenericSettings.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.SettingsManagement +{ + public class GenericSettings + { + } +} diff --git a/SettingsManagement/GroupAttribute.cs b/SettingsManagement/GroupAttribute.cs new file mode 100644 index 0000000..2ee10b9 --- /dev/null +++ b/SettingsManagement/GroupAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.SettingsManagement +{ + + [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] + public class GroupAttribute : Attribute + { + public string GroupName { get; } + + public GroupAttribute(string groupName) + { + GroupName = groupName; + } + } +} diff --git a/SettingsManagement/SelectionAttribute.cs b/SettingsManagement/SelectionAttribute.cs new file mode 100644 index 0000000..4f7ce6c --- /dev/null +++ b/SettingsManagement/SelectionAttribute.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace opentuner.SettingsManagement +{ + [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] + public class SelectionAttribute : Attribute + { + + public SelectionAttribute(string[] options) + { + + } + } +} diff --git a/SettingsManagement/SettingsFormBuilder.cs b/SettingsManagement/SettingsFormBuilder.cs new file mode 100644 index 0000000..3a56067 --- /dev/null +++ b/SettingsManagement/SettingsFormBuilder.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Reflection; +using Serilog; + +namespace opentuner.SettingsManagement +{ + public class SettingsFormBuilder + { + private readonly Type _type; + private readonly object _instance; + + public SettingsFormBuilder(object instance) + { + _type = instance.GetType(); + _instance = instance; + + // Get all public fields of the class + FieldInfo[] fields = _type.GetFields(BindingFlags.Public | BindingFlags.Instance); + + foreach (var field in fields) + { + var group_attrib = (GroupAttribute)Attribute.GetCustomAttribute(field, typeof(GroupAttribute)); + + Log.Information($"Field : {field.Name} {field.FieldType} { (group_attrib != null ? group_attrib.GroupName : "Misc") }"); + } + + } + /* + // Method to print field information + public void PrintFieldInfo() + { + // Get all public fields of the class + FieldInfo[] fields = _type.GetFields(BindingFlags.Public | BindingFlags.Instance); + + // Print the name and type of each public field + foreach (var field in fields) + { + Console.WriteLine($"Field Name: {field.Name}"); + Console.WriteLine($"Field Type: {field.FieldType}"); + Console.WriteLine(); + } + } + + // Method to get field values + public void PrintFieldValues() + { + // Get all public fields of the class + FieldInfo[] fields = _type.GetFields(BindingFlags.Public | BindingFlags.Instance); + + // Print the name and value of each public field + foreach (var field in fields) + { + object value = field.GetValue(_instance); + Console.WriteLine($"Field Name: {field.Name}"); + Console.WriteLine($"Field Value: {value}"); + Console.WriteLine(); + } + } + */ + } + +} diff --git a/Utilities/CustomGroupBox.cs b/Utilities/CustomGroupBox.cs index 49ac7c5..be76772 100644 --- a/Utilities/CustomGroupBox.cs +++ b/Utilities/CustomGroupBox.cs @@ -8,19 +8,25 @@ namespace opentuner.Utilities { - // an attempt at making a collapsable group box :p public class CustomGroupBox : GroupBox { - public string db_margin = ""; + public string _db_margin = ""; public CustomGroupBox() { - this.SetStyle(ControlStyles.UserPaint, true); + this.SetStyle(ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer, true); } + public string db_margin + { + get { return this._db_margin; } + set { _db_margin = value; Invalidate(); } + } protected override void OnPaint(PaintEventArgs e) { @@ -45,14 +51,14 @@ protected override void OnPaint(PaintEventArgs e) TextRenderer.DrawText(g, this.Text, textFont, new Point(10, 0), textColor); - if (db_margin.Length > 1) + if (_db_margin.Length > 1) { Font db_margin_font = new Font(this.Font.FontFamily, 15f, FontStyle.Bold); - SizeF db_margin_textSize = g.MeasureString(db_margin.ToString(), db_margin_font); + SizeF db_margin_textSize = g.MeasureString(_db_margin.ToString(), db_margin_font); g.FillRectangle(new SolidBrush(Color.FromArgb(240, 240, 240)), new Rectangle(this.Width - (int)db_margin_textSize.Width - 15, 0, (int)db_margin_textSize.Width + 5, (int)db_margin_textSize.Height)); - TextRenderer.DrawText(g, db_margin.ToString(), db_margin_font, new Point(this.Width - (int)db_margin_textSize.Width - 15, 0), textColor); + TextRenderer.DrawText(g, _db_margin.ToString(), db_margin_font, new Point(this.Width - (int)db_margin_textSize.Width - 15, 0), textColor); } } } diff --git a/opentuner.csproj b/opentuner.csproj index c54bc90..09cd735 100644 --- a/opentuner.csproj +++ b/opentuner.csproj @@ -318,6 +318,11 @@ + + + + + Form