Skip to content

Commit a495420

Browse files
fix for case whne examples are not found, rename form, window resize fix
1 parent 9a7a87f commit a495420

File tree

5 files changed

+45
-34
lines changed

5 files changed

+45
-34
lines changed
Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
namespace TuyaMCUAnalyzer
1212
{
13-
public partial class Form1 : Form
13+
public partial class FormTuyaMCUAnalyzer : Form
1414
{
1515
IDsTracker tracker;
1616
SinglePort portRX, portTX;
1717

18-
public Form1()
18+
public FormTuyaMCUAnalyzer()
1919
{
2020
InitializeComponent();
2121
}
@@ -497,25 +497,36 @@ string formatByteSize(string fname)
497497
long filelen = new FileInfo(fname).Length;
498498
return formatByteSize(filelen);
499499
}
500-
private void Form1_Load(object sender, EventArgs e)
500+
void scanForExamplesCaptures()
501501
{
502-
comboBoxBaud.SelectedIndex = 0;
503-
string samplesDir = findSamplesPath();
504-
string [] samples = Directory.GetFiles(samplesDir);
505-
for(int i = 0; i < samples.Length; i++)
506-
{
507-
string path = samples[i];
508-
path = path.Replace('/', '\\');
509-
string lenStr = formatByteSize(path);
510-
var item2 = new System.Windows.Forms.ToolStripMenuItem()
502+
try
503+
{
504+
string samplesDir = findSamplesPath();
505+
string[] samples = Directory.GetFiles(samplesDir);
506+
for (int i = 0; i < samples.Length; i++)
511507
{
512-
Name = "Test",
513-
Text = path+" "+ lenStr,
514-
Tag = path
515-
};
516-
item2.Click += exampleClickListener;
517-
examplesToolStripMenuItem.DropDownItems.Add(item2);
508+
string path = samples[i];
509+
path = path.Replace('/', '\\');
510+
string lenStr = formatByteSize(path);
511+
var item2 = new System.Windows.Forms.ToolStripMenuItem()
512+
{
513+
Name = "Test",
514+
Text = path + " " + lenStr,
515+
Tag = path
516+
};
517+
item2.Click += exampleClickListener;
518+
examplesToolStripMenuItem.DropDownItems.Add(item2);
519+
}
518520
}
521+
catch(Exception ex)
522+
{
523+
MessageBox.Show("No examples found? Get sample captures from Github!");
524+
}
525+
}
526+
private void Form1_Load(object sender, EventArgs e)
527+
{
528+
comboBoxBaud.SelectedIndex = 0;
529+
scanForExamplesCaptures();
519530
setDualCaptureEnabled(false);
520531
refresh();
521532
}

project/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static void Main()
1414
{
1515
Application.EnableVisualStyles();
1616
Application.SetCompatibleTextRenderingDefault(false);
17-
Application.Run(new Form1());
17+
Application.Run(new FormTuyaMCUAnalyzer());
1818
}
1919
}
2020
}

project/TuyaMCUAnalyzer.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@
4949
<ItemGroup>
5050
<Compile Include="ArrayUtils.cs" />
5151
<Compile Include="ByteRingBuffer.cs" />
52-
<Compile Include="Form1.cs">
52+
<Compile Include="FormTuyaMCUAnalyzer.cs">
5353
<SubType>Form</SubType>
5454
</Compile>
55-
<Compile Include="Form1.Designer.cs">
56-
<DependentUpon>Form1.cs</DependentUpon>
55+
<Compile Include="FormTuyaMCUAnalyzer.Designer.cs">
56+
<DependentUpon>FormTuyaMCUAnalyzer.cs</DependentUpon>
5757
</Compile>
5858
<Compile Include="IDsTracker.cs" />
5959
<Compile Include="Program.cs" />
6060
<Compile Include="Properties\AssemblyInfo.cs" />
6161
<Compile Include="RichTextBoxExtensions.cs" />
6262
<Compile Include="SinglePort.cs" />
6363
<Compile Include="TuyaTypes.cs" />
64-
<EmbeddedResource Include="Form1.resx">
65-
<DependentUpon>Form1.cs</DependentUpon>
64+
<EmbeddedResource Include="FormTuyaMCUAnalyzer.resx">
65+
<DependentUpon>FormTuyaMCUAnalyzer.cs</DependentUpon>
6666
<SubType>Designer</SubType>
6767
</EmbeddedResource>
6868
<EmbeddedResource Include="Properties\Resources.resx">

0 commit comments

Comments
 (0)