Skip to content

Commit

Permalink
Added Debug Tools form with config editor (TODO: Log Viewer)
Browse files Browse the repository at this point in the history
  • Loading branch information
n00mkrad committed May 3, 2021
1 parent 337c045 commit f8d7537
Show file tree
Hide file tree
Showing 12 changed files with 3,458 additions and 7 deletions.
16 changes: 16 additions & 0 deletions Code/Flowframes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="AdamsLair.WinForms, Version=1.1.18.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\AdamsLair.WinForms.1.1.18\lib\net45\AdamsLair.WinForms.dll</HintPath>
</Reference>
<Reference Include="CircularProgressBar, Version=2.8.0.16, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<HintPath>packages\CircularProgressBar.2.8.0.16\lib\net40\CircularProgressBar.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -127,6 +130,9 @@
<Reference Include="PagedControl, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\PagedControl.2.2.0\lib\net35\PagedControl.dll</HintPath>
</Reference>
<Reference Include="PopupControl, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\AdamsLair.WinForms.PopupControl.1.0.1\lib\net40\PopupControl.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down Expand Up @@ -342,6 +348,12 @@
<Compile Include="Forms\BigPreviewForm.Designer.cs">
<DependentUpon>BigPreviewForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\DebugForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\DebugForm.Designer.cs">
<DependentUpon>DebugForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -418,6 +430,9 @@
<EmbeddedResource Include="Forms\BigPreviewForm.resx">
<DependentUpon>BigPreviewForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\DebugForm.resx">
<DependentUpon>DebugForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -463,6 +478,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="FlowframesLogo2021.ico" />
<None Include="Resources\baseline_list_alt_white_48dp.png" />
<None Include="Resources\baseline_play_arrow_white_48dp.png" />
<None Include="Resources\baseline_pause_white_48dp.png" />
<None Include="Resources\baseline_stop_white_48dp.png" />
Expand Down
29 changes: 25 additions & 4 deletions Code/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Code/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,5 +566,10 @@ private void pauseBtn_Click(object sender, EventArgs e)
{
AiProcessSuspend.SuspendResumeAi(!AiProcessSuspend.aiProcFrozen);
}

private void debugBtn_Click(object sender, EventArgs e)
{
new DebugForm().ShowDialog();
}
}
}
150 changes: 150 additions & 0 deletions Code/Forms/DebugForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Code/Forms/DebugForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Flowframes.IO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Flowframes.Forms
{
public partial class DebugForm : Form
{
public DebugForm()
{
InitializeComponent();
}

private void DebugForm_Load(object sender, EventArgs e)
{
Dictionary<string, string> configDict = new Dictionary<string, string>();

configDataGrid.Columns.Add("keys", "Key Name");
configDataGrid.Columns.Add("vals", "Saved Value");

foreach (string entry in Config.cachedLines)
{
string[] data = entry.Split('|');
configDict.Add(data[0], data[1]);
configDataGrid.Rows.Add(data[0], data[1]);
}

configDataGrid.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
configDataGrid.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}

void Save ()
{
foreach(DataGridViewRow row in configDataGrid.Rows)
{
string key = row.Cells[0].Value?.ToString();
string val = row.Cells[1].Value?.ToString();

if (key == null || val == null || string.IsNullOrWhiteSpace(key.Trim()) || string.IsNullOrWhiteSpace(val.Trim()))
continue;

Config.Set(key, val);
Logger.Log($"Config Editor: Saved Key '{key}' with value '{val}'", true);
}
}

private void DebugForm_FormClosing(object sender, FormClosingEventArgs e)
{
Save();
}
}
}
Loading

0 comments on commit f8d7537

Please sign in to comment.