Skip to content

Commit

Permalink
updates (#35)
Browse files Browse the repository at this point in the history
* updates

* installer and readme update
  • Loading branch information
flipswitchingmonkey authored Jul 30, 2022
1 parent 2be72f0 commit 493ed59
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 81 deletions.
3 changes: 2 additions & 1 deletion FlexASIOGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
73 changes: 51 additions & 22 deletions Form1.Designer.cs

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

124 changes: 74 additions & 50 deletions Form1.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
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;
using Commons.Media.PortAudio;
using System.Diagnostics;
Expand All @@ -23,8 +20,8 @@ public partial class Form1 : Form
private string TOMLPath;
private FlexGUIConfig flexGUIConfig;
private Encoding legacyEncoding;
private string flexasioGuiVersion = "0.33";
private string flexasioVersion = "1.8";
private string flexasioGuiVersion = "0.34";
private string flexasioVersion = "1.9";
private string tomlName = "FlexASIO.toml";
private string docUrl = "https://github.com/dechamps/FlexASIO/blob/master/CONFIGURATION.md";

Expand Down Expand Up @@ -52,11 +49,20 @@ public Form1()
CultureInfo.DefaultThreadCurrentUICulture = customCulture;

TOMLPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\{tomlName}";

this.LoadFlexASIOConfig(TOMLPath);

InitDone = true;
SetStatusMessage($"FlexASIO GUI for FlexASIO {flexasioVersion} started ({Configuration.VersionString})");
GenerateOutput();
}

private FlexGUIConfig LoadFlexASIOConfig(string tomlPath)
{
flexGUIConfig = new FlexGUIConfig();
if (File.Exists(TOMLPath))
if (File.Exists(tomlPath))
{
flexGUIConfig = Toml.ReadFile<FlexGUIConfig>(TOMLPath);
flexGUIConfig = Toml.ReadFile<FlexGUIConfig>(tomlPath);
}

numericBufferSize.Maximum = 8192;
Expand All @@ -65,7 +71,7 @@ public Form1()
numericLatencyInput.Increment = 0.1m;
numericLatencyOutput.Increment = 0.1m;

for (var i=0; i<Configuration.HostApiCount; i++)
for (var i = 0; i < Configuration.HostApiCount; i++)
{
comboBackend.Items.Add(Configuration.GetHostApiInfo(i).name);
}
Expand All @@ -82,7 +88,7 @@ public Form1()
if (flexGUIConfig.bufferSizeSamples != null)
numericBufferSize.Value = (Int64)flexGUIConfig.bufferSizeSamples;
checkBoxSetBufferSize.Checked = numericBufferSize.Enabled = flexGUIConfig.bufferSizeSamples != null;

treeDevicesInput.SelectedNode = treeDevicesInput.Nodes.Cast<TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.input.device == "" ? "(None)" : flexGUIConfig.input.device));
treeDevicesOutput.SelectedNode = treeDevicesOutput.Nodes.Cast<TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.output.device == "" ? "(None)" : flexGUIConfig.output.device));

Expand All @@ -109,10 +115,7 @@ public Form1()
wasapiAutoConvertInput.Checked = flexGUIConfig.input.wasapiAutoConvert ?? false;
wasapiAutoConvertOutput.Enabled = flexGUIConfig.output.wasapiAutoConvert != null;
wasapiAutoConvertOutput.Checked = flexGUIConfig.output.wasapiAutoConvert ?? false;

InitDone = true;
SetStatusMessage($"FlexASIO GUI for FlexASIO {flexasioVersion} started ({Configuration.VersionString})");
GenerateOutput();
return flexGUIConfig;
}

private string DescrambleUTF8(string s)
Expand Down Expand Up @@ -256,65 +259,68 @@ private void btSaveAs_Click(object sender, EventArgs e)
SetStatusMessage($"Configuration written to {saveFileDialog.FileName}");
}

private void treeDevicesInput_BeforeSelect(object sender, TreeViewCancelEventArgs e)
private void treeDevicesInput_AfterSelect(object sender, TreeViewEventArgs e)
{
var o = sender as TreeView;
if (o.SelectedNode != null)
if (sender == null) return;
else
{
o.SelectedNode.Checked = false;
e.Node.Checked = true;
this.onTreeViewSelected(eventArgs: e, forInput: true);
}
}

private void treeDevicesOutput_BeforeSelect(object sender, TreeViewCancelEventArgs e)
private void treeDevicesOutput_AfterSelect(object sender, TreeViewEventArgs e)
{
var o = sender as TreeView;
if (o.SelectedNode != null)
if (sender == null) return;
else
{
o.SelectedNode.Checked = false;
e.Node.Checked = true;
this.onTreeViewSelected(eventArgs: e, forInput: false);
}
}

private void treeDevicesInput_BeforeCheck(object sender, TreeViewCancelEventArgs e)
private void treeDevicesOutput_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.IsSelected == false)
if (sender == null) return;
else
{
e.Cancel = true;
this.onTreeViewSelected(eventArgs: e, forInput: false);
}
}

private void treeDevicesOutput_BeforeCheck(object sender, TreeViewCancelEventArgs e)
private void treeDevicesInput_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.IsSelected == false)
if (sender == null) return;
else
{
e.Cancel = true;
this.onTreeViewSelected(eventArgs: e, forInput: true);
}
}

private void treeDevicesInput_AfterSelect(object sender, TreeViewEventArgs e)
private void unCheckAllOthers(TreeNode treeNode)
{
var o = sender as TreeView;
if (o == null) return;
if (o.SelectedNode != null)
foreach (TreeNode node in treeNode.TreeView.Nodes)
{
o.SelectedNode.Checked = true;
flexGUIConfig.input.device = o.SelectedNode.Text == "(None)" ? "" : o.SelectedNode.Text;
GenerateOutput();
if (node != treeNode)
{
node.Checked = false;
}
}
}

private void treeDevicesOutput_AfterSelect(object sender, TreeViewEventArgs e)
private void onTreeViewSelected(TreeViewEventArgs eventArgs, bool forInput)
{
var o = sender as TreeView;
if (o == null) return;
if (o.SelectedNode != null)
if (eventArgs.Node.Checked == true)
{
o.SelectedNode.Checked = true;
flexGUIConfig.output.device = o.SelectedNode.Text == "(None)" ? "" : o.SelectedNode.Text;
if (forInput == true)
flexGUIConfig.input.device = eventArgs.Node.Text == "(None)" ? "" : eventArgs.Node.Text;
else
flexGUIConfig.output.device = eventArgs.Node.Text == "(None)" ? "" : eventArgs.Node.Text;
this.unCheckAllOthers(eventArgs.Node);
GenerateOutput();
}
}


private void numericChannelsOutput_ValueChanged(object sender, EventArgs e)
{
var o = sender as NumericUpDown;
Expand Down Expand Up @@ -393,15 +399,7 @@ private void numericBufferSize_ValueChanged(object sender, EventArgs e)
GenerateOutput();
}

private void treeDevicesOutput_AfterCheck(object sender, TreeViewEventArgs e)
{
}

private void treeDevicesInput_AfterCheck(object sender, TreeViewEventArgs e)
{

}


private void checkBoxSetInputLatency_CheckedChanged(object sender, EventArgs e)
{
var o = sender as CheckBox;
Expand Down Expand Up @@ -499,5 +497,31 @@ private void linkLabelDocs_LinkClicked(object sender, LinkLabelLinkClickedEventA
{
System.Diagnostics.Process.Start(new ProcessStartInfo(docUrl) { UseShellExecute = true });
}

private void btLoadFrom_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
openFileDialog.FileName = tomlName;
openFileDialog.Filter = "FlexASIO Config (*.toml)|*.toml";
openFileDialog.CheckFileExists = true;
var ret = openFileDialog.ShowDialog();
if (ret == DialogResult.OK)
{
try
{
this.LoadFlexASIOConfig(openFileDialog.FileName);
}
catch (Exception)
{
SetStatusMessage($"Error loading from {openFileDialog.FileName}");
this.LoadFlexASIOConfig(TOMLPath);
return;
}

}
SetStatusMessage($"Configuration loaded from {openFileDialog.FileName}");
}
}
}
Loading

0 comments on commit 493ed59

Please sign in to comment.