add command line argument support (specifically for --userprofile= so the directory where UserProfile.yaml can be overridden by the user); expand the Audio device list with the window;

pull/2/head
Bryan Biedenkapp 11 months ago
parent 27cf9fcceb
commit 815d2cdc7f

@ -1,6 +1,7 @@
<Application x:Class="dvmconsole.App" <Application x:Class="dvmconsole.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<!-- Default Button Style --> <!-- Default Button Style -->

@ -12,17 +12,22 @@
* *
*/ */
using fnecore.Utility;
using NAudio.Wave;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Windows; using System.Windows;
namespace dvmconsole namespace dvmconsole
{ {
/// <summary> /// <summary>
/// /// Encapsulates a Windows Presentation Foundation application.
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
public static string USER_PROFILE_PATH_OVERRIDE = string.Empty;
/* /*
** Methods ** Methods
*/ */
@ -44,5 +49,58 @@ namespace dvmconsole
return; return;
} }
} }
/// <summary>
/// Internal helper to prints the program usage.
/// </summary>
private static void Usage(OptionSet p)
{
string messageBoxText = "[-h | --help][--userprofile <path for UserProfile.yaml>]\r\nOptions:\r\n";
using (MemoryStream ms = new MemoryStream())
{
using (TextWriter writer = new StreamWriter(ms))
p.WriteOptionDescriptions(writer);
messageBoxText += Encoding.UTF8.GetString(ms.ToArray());
}
MessageBox.Show(messageBoxText, "Digital Voice Modem - Desktop Dispatch Console",
MessageBoxButton.OK, MessageBoxImage.Information);
Application.Current.Shutdown();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Application_Startup(object sender, StartupEventArgs e)
{
bool showHelp = false;
string configFile = string.Empty;
// command line parameters
OptionSet options = new OptionSet()
{
{ "h|help", "show this message and exit", v => showHelp = v != null },
{ "userprofile=", "sets the path to the UserProfile.yaml", v => USER_PROFILE_PATH_OVERRIDE = v },
};
// attempt to parse the commandline
try
{
options.Parse(e.Args);
}
catch (OptionException)
{
/* ignore */
}
// show help?
if (showHelp)
Usage(options);
}
} // public partial class App : Application } // public partial class App : Application
} // namespace dvmconsole } // namespace dvmconsole

@ -15,7 +15,7 @@
<ComboBox x:Name="InputDeviceComboBox" Width="350" Margin="0,5,0,15" Grid.Row="1"/> <ComboBox x:Name="InputDeviceComboBox" Width="350" Margin="0,5,0,15" Grid.Row="1"/>
<TextBlock Text="Per-Channel Output Devices" FontWeight="Bold" Grid.Row="2" Margin="0,0,0,5"/> <TextBlock Text="Per-Channel Output Devices" FontWeight="Bold" Grid.Row="2" Margin="0,0,0,5"/>
<ScrollViewer Grid.Row="2" Height="200"> <ScrollViewer Grid.Row="2" Margin="0,30,0,30">
<StackPanel x:Name="ChannelOutputStackPanel"/> <StackPanel x:Name="ChannelOutputStackPanel"/>
</ScrollViewer> </ScrollViewer>

@ -0,0 +1,8 @@
{
"profiles": {
"dvmconsole": {
"commandName": "Project",
"commandLineArgs": "--userprofile=."
}
}
}

@ -31,9 +31,9 @@ namespace dvmconsole
Environment.SpecialFolder.ApplicationData); Environment.SpecialFolder.ApplicationData);
public static readonly string RootAppDataPath = "DVMProject" + Path.DirectorySeparatorChar + "dvmconsole"; public static readonly string RootAppDataPath = "DVMProject" + Path.DirectorySeparatorChar + "dvmconsole";
public static readonly string UserAppDataPath = UserAppData + Path.DirectorySeparatorChar + RootAppDataPath; public static string UserAppDataPath = UserAppData + Path.DirectorySeparatorChar + RootAppDataPath;
private static readonly string SettingsFilePath = UserAppDataPath + Path.DirectorySeparatorChar + "UserSettings.json"; private static string SettingsFilePath = UserAppDataPath + Path.DirectorySeparatorChar + "UserSettings.json";
/* /*
** Properties ** Properties
@ -138,9 +138,18 @@ namespace dvmconsole
/// ///
/// </summary> /// </summary>
public bool LoadSettings() public bool LoadSettings()
{
// was the user profile path being overridden?
if (App.USER_PROFILE_PATH_OVERRIDE != string.Empty)
{
UserAppDataPath = App.USER_PROFILE_PATH_OVERRIDE;
SettingsFilePath = UserAppDataPath + Path.DirectorySeparatorChar + "UserSettings.json";
}
else
{ {
if (!Directory.Exists(UserAppDataPath)) if (!Directory.Exists(UserAppDataPath))
Directory.CreateDirectory(UserAppDataPath); Directory.CreateDirectory(UserAppDataPath);
}
if (!File.Exists(SettingsFilePath)) if (!File.Exists(SettingsFilePath))
return false; return false;

Loading…
Cancel
Save

Powered by TurnKey Linux.