From 8dc6b31f714a14222bf0cb5985afb0bfaf9e0eaf Mon Sep 17 00:00:00 2001 From: Sinderion Date: Sat, 14 Oct 2023 11:02:56 -0400 Subject: [PATCH 01/74] Update build.bat Re-worked build.bat. Needs verifying --- build.bat | 94 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/build.bat b/build.bat index 06b2559d..f3f6e8a0 100644 --- a/build.bat +++ b/build.bat @@ -1,46 +1,90 @@ @echo off -nuget restore +::Command line arguments set presetsFolder=%1 set version=%2 -msbuild /p:Configuration=Release /p:Platform=x64 /p:SourceLinkCreate=false /p:Version=%version% +::::::::: File structure settings ::::::::::::::::: + +::Release +set "releasesFolderName=Vanguard-SRS-%version%" +set "releasesFolder=%releasesFolderName%\" +::Client Release set clientReleasesFolder=.\SRS-Client -set releasesFolder=. +set clientArchiveName=Vanguard-SRS-Client-%version%.zip +set clientFolder=%clientReleasesFolder%\%clientFolderName%\ -mkdir %clientReleaseFolder% -mkdir %releaseFolder% +::Presets +set "presetsFolderName=SRS-Radio-Presets" +set "presetsFolder=%presetsFolder%\" -DEL /F .\install-build\DCS-SR-ExternalAudio.exe .\install-build\Installer.exe .\install-build\SRS-AutoUpdater.exe .\install-build\SR-Server.exe -echo Removed not needed executables +::Final Release Archive +set "releasesArchiveName=.\Vanguard-SRS-%version%.zip" -set clientArchiveName=Vanguard-SRS-Client-%version%.zip +::::::::::: /File structure settings :::::::::::::::: -tar.exe -a -c -f %clientArchiveName% .\install-build -MOVE /Y .\%clientArchiveName% %clientReleasesFolder%\%clientArchiveName% -echo Copied client-archive to client Release folder -set clientFolderName=Vanguard-SRS-Client-%version% +:: Build -XCOPY .\install-build\ %clientReleasesFolder%\%clientFolderName%\ /Y /q /e -echo Copied client to client Release folder +:: Set to quiet, redirected to NUL for batch file testing - change if needed -set clientFolder=%clientReleasesFolder%\%clientFolderName%\ +nuget restore +msbuild -v:q /p:Configuration=Release /p:Platform=x64 /p:SourceLinkCreate=false /p:Version=%version% > NUL +if %errorlevel% neq 0 then goto builderror +echo msbuild completed with no error level -set "releasesFolderName=Vanguard-SRS-%version%" -set "presetsFolderName=SRS-Radio-Presets" -set "presetsFolder=%presetsFolder%\" -mkdir "%releasesFolder%\%releasesFolderName%\" -echo Created Release Folder -XCOPY "%clientFolder%" "%releasesFolder%\%releasesFolderName%\%clientFolderName%\" /Y /q /e -echo Copied Client Folder to Release +:::: Create File Structure +:: +:: .\Vanguard-SRS-%version%\presets -- Preset manager, etc +:: .\Vanguard-SRS-%version%\radio-client -- SRS Client +:: + +mkdir %releasesFolder% +mkdir %releasesFolder%\%clientReleasesFolder% +mkdir %releasesFolder%\%presetsFolder% +::mkdir %releasesFolderName% +echo Created Release Folders + +::Cleanup uneeded files +DEL /F .\install-build\DCS-SR-ExternalAudio.exe .\install-build\Installer.exe .\install-build\SRS-AutoUpdater.exe .\install-build\SR-Server.exe +echo Removed unneeded files + + +:: Move the build into the client fold + +XCOPY .\install-build\ "%releasesFolder%\%clientReleasesFolder%" /Y /q /e +echo Copied Client to Release -XCOPY %presetsFolder% %releasesFolder%\%releasesFolderName%\%presetsFolderName%\ /q /e /k /h /i /y + +XCOPY %presetsFolder% %releasesFolder%\%presetsFolder%\ /q /e /k /h /i /y echo Copied Presets to Release -set "releasesArchiveName=%releasesFolder%\Vanguard-SRS-%version%.zip" -tar.exe -a -c -f "%releasesArchiveName%" "%releasesFolder%\%releasesFolderName%" + +:: Final release archive +tar.exe -a -c -f "%releasesArchiveName%" "%releasesFolderName%" +if %errorlevel% neq 0 then goto tarerror + +::Cleanup - when I know what to clean up + + echo Finished + + +goto end + +::: Error handling + +:msbuilderror + +Echo msbuild exited with error level %errorlevel% +goto end + +:tarerror + +echo Error creating Archive: tar.exe + + +:end \ No newline at end of file From d7b6701e5cb7dbe261e326d5f77cb6a15e36001b Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Sat, 14 Oct 2023 17:41:59 +0200 Subject: [PATCH 02/74] Fixed build.bat --- DCS-SR-Client/Properties/AssemblyInfo.cs | 4 ++-- build.bat | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/DCS-SR-Client/Properties/AssemblyInfo.cs b/DCS-SR-Client/Properties/AssemblyInfo.cs index bc455909..65fde574 100644 --- a/DCS-SR-Client/Properties/AssemblyInfo.cs +++ b/DCS-SR-Client/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.0")] // DO NOT CHANGE THIS -[assembly: AssemblyFileVersion("0.0.0")] // DO NOT CHANGE THIS +[assembly: AssemblyVersion("1.1.0")] // DO NOT CHANGE THIS +[assembly: AssemblyFileVersion("1.1.0")] // DO NOT CHANGE THIS diff --git a/build.bat b/build.bat index f3f6e8a0..9660689b 100644 --- a/build.bat +++ b/build.bat @@ -8,7 +8,7 @@ set version=%2 ::Release set "releasesFolderName=Vanguard-SRS-%version%" -set "releasesFolder=%releasesFolderName%\" +set "releasesFolder=%releasesFolderName%" ::Client Release set clientReleasesFolder=.\SRS-Client @@ -42,7 +42,7 @@ echo msbuild completed with no error level :: .\Vanguard-SRS-%version%\radio-client -- SRS Client :: -mkdir %releasesFolder% +mkdir %releasesFolder%\ mkdir %releasesFolder%\%clientReleasesFolder% mkdir %releasesFolder%\%presetsFolder% ::mkdir %releasesFolderName% @@ -55,16 +55,15 @@ echo Removed unneeded files :: Move the build into the client fold -XCOPY .\install-build\ "%releasesFolder%\%clientReleasesFolder%" /Y /q /e +XCOPY .\install-build\ %releasesFolder%\%clientReleasesFolder% /Y /q /e echo Copied Client to Release - -XCOPY %presetsFolder% %releasesFolder%\%presetsFolder%\ /q /e /k /h /i /y +XCOPY %presetsFolder% .\%releasesFolder%\%presetsFolderName%\ /q /e /k /h /i /y echo Copied Presets to Release :: Final release archive -tar.exe -a -c -f "%releasesArchiveName%" "%releasesFolderName%" +tar -acf %releasesArchiveName% %releasesFolderName% if %errorlevel% neq 0 then goto tarerror ::Cleanup - when I know what to clean up From c62fe88123d6667fa0c2e59e2e73ae4398f2157e Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Mon, 16 Oct 2023 22:16:20 +0200 Subject: [PATCH 03/74] Fixed Intercom VOX Button Added message when Unexpected error happens. --- DCS-SR-Client/App.xaml.cs | 2 ++ DCS-SR-Client/Properties/AssemblyInfo.cs | 4 ++-- .../Utils/IntercomControlGroup.xaml.cs | 14 +++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/DCS-SR-Client/App.xaml.cs b/DCS-SR-Client/App.xaml.cs index 032ee5a4..b4228de2 100644 --- a/DCS-SR-Client/App.xaml.cs +++ b/DCS-SR-Client/App.xaml.cs @@ -306,6 +306,8 @@ protected override void OnExit(ExitEventArgs e) private void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) { + MessageBox.Show("This is a sample and can be expanded ;)\n If you see this, please let FPGSchiba know how you did it :D"); + if (loggingReady) { Logger logger = LogManager.GetCurrentClassLogger(); diff --git a/DCS-SR-Client/Properties/AssemblyInfo.cs b/DCS-SR-Client/Properties/AssemblyInfo.cs index 65fde574..bc455909 100644 --- a/DCS-SR-Client/Properties/AssemblyInfo.cs +++ b/DCS-SR-Client/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0")] // DO NOT CHANGE THIS -[assembly: AssemblyFileVersion("1.1.0")] // DO NOT CHANGE THIS +[assembly: AssemblyVersion("0.0.0")] // DO NOT CHANGE THIS +[assembly: AssemblyFileVersion("0.0.0")] // DO NOT CHANGE THIS diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs index 5782d591..7562e7ac 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs @@ -30,6 +30,7 @@ public IntercomControlGroup() Radio1Enabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXR1) ? voxEnabled : voxDisabled; IntercomEnabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC) ? voxEnabled : voxicDisabled; + IntercomEnabled.IsEnabled = IntercomNumberSpinner.Value != 1; } public int RadioId { private get; set; } @@ -133,7 +134,10 @@ internal void RepaintRadioStatus() RadioLabel.Text = "VOX / INTERCOM"; Radio1Enabled.IsEnabled = true; - IntercomEnabled.IsEnabled = true; + if (IntercomNumberSpinner.Value != 1) + { + IntercomEnabled.IsEnabled = true; + } IntercomNumberSpinner.IsEnabled = true; if (dcsPlayerRadioInfo.unitId >= DCSPlayerRadioInfo.UnitIdOffset) @@ -159,7 +163,7 @@ internal void RepaintRadioStatus() IntercomNumberSpinner.IsEnabled = false; _clientStateSingleton.IntercomOffset = 1; - Radio1Enabled.Background = voxDisabled; + Radio1Enabled.Background = voxicDisabled; IntercomEnabled.Background = voxicDisabled; } @@ -217,8 +221,8 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE return; } - int? spinnervalue = IntercomNumberSpinner.Value; - int isone = spinnervalue ?? default(int); + int spinnervalue = (int)IntercomNumberSpinner.Value; + bool isone = (int)spinnervalue == 1; if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) { @@ -227,7 +231,7 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE } - if (isone == 1) + if (isone) { IntercomEnabled.IsEnabled = false; IntercomEnabled.Background = voxicDisabled; From c349aaf6940601ba280fe5660a98d5fac162fdce Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Fri, 20 Oct 2023 19:10:47 +0200 Subject: [PATCH 04/74] Begun Multi Overlay Implementation * Added 3V Overlay * Provided method to easily switch between panels, without many ifs * Fixed some errors --- DCS-SR-Client/DCS-SR-Client.csproj | 34 +- DCS-SR-Client/Input/InputDeviceManager.cs | 4 +- DCS-SR-Client/UI/ClientWindow/MainWindow.xaml | 100 +++-- .../UI/ClientWindow/MainWindow.xaml.cs | 253 +++++++------ ...ive.xaml => RadioOverlayFiveVertical.xaml} | 2 +- ...ml.cs => RadioOverlayFiveVertical.xaml.cs} | 10 +- ...ay.xaml => RadioOverlayTenHorizontal.xaml} | 25 +- ...l.cs => RadioOverlayTenHorizontal.xaml.cs} | 15 +- .../RadioOverlayThreeVertical.xaml | 122 +++++++ .../RadioOverlayThreeVertical.xaml.cs | 342 ++++++++++++++++++ ...yTwo.xaml => RadioOverlayTwoVertical.xaml} | 2 +- ...aml.cs => RadioOverlayTwoVertical.xaml.cs} | 10 +- 12 files changed, 727 insertions(+), 192 deletions(-) rename DCS-SR-Client/UI/RadioOverlayWindow/{RadioOverlayFive.xaml => RadioOverlayFiveVertical.xaml} (99%) rename DCS-SR-Client/UI/RadioOverlayWindow/{RadioOverlayFive.xaml.cs => RadioOverlayFiveVertical.xaml.cs} (97%) rename DCS-SR-Client/UI/RadioOverlayWindow/{AwacsOverlay.xaml => RadioOverlayTenHorizontal.xaml} (89%) rename DCS-SR-Client/UI/RadioOverlayWindow/{AwacsOverlay.xaml.cs => RadioOverlayTenHorizontal.xaml.cs} (94%) create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs rename DCS-SR-Client/UI/RadioOverlayWindow/{RadioOverlayTwo.xaml => RadioOverlayTwoVertical.xaml} (99%) rename DCS-SR-Client/UI/RadioOverlayWindow/{RadioOverlayTwo.xaml.cs => RadioOverlayTwoVertical.xaml.cs} (97%) diff --git a/DCS-SR-Client/DCS-SR-Client.csproj b/DCS-SR-Client/DCS-SR-Client.csproj index 3a5096a5..93bdabee 100644 --- a/DCS-SR-Client/DCS-SR-Client.csproj +++ b/DCS-SR-Client/DCS-SR-Client.csproj @@ -317,14 +317,17 @@ ClientListWindow.xaml + + RadioOverlayThreeVertical.xaml + RadioCapabilities.xaml - - RadioOverlayFive.xaml + + RadioOverlayFiveVertical.xaml - - RadioOverlayTwo.xaml + + RadioOverlayTwoVertical.xaml TransponderPanel.xaml @@ -352,8 +355,8 @@ AwacsRadioControlGroup.xaml - - AwacsOverlay.xaml + + RadioOverlayTenHorizontal.xaml @@ -389,15 +392,19 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile - + MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -442,7 +449,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -652,14 +659,12 @@ - - - + ]]> @@ -673,8 +678,7 @@ $([System.IO.File]::ReadAllText($(AssemblyInfo))) (\[\s*assembly\s*:\s*AssemblyVersion\(\s*"(\d+)\.(\d+)\.(\d+)(\.)(\d+)("\)\s*\])) - - + diff --git a/DCS-SR-Client/Input/InputDeviceManager.cs b/DCS-SR-Client/Input/InputDeviceManager.cs index 6ea189c6..862afed0 100644 --- a/DCS-SR-Client/Input/InputDeviceManager.cs +++ b/DCS-SR-Client/Input/InputDeviceManager.cs @@ -690,14 +690,14 @@ public void StartDetectPtt(DetectPttCallback callback) { //run on main Application.Current.Dispatcher.Invoke( - () => { _toggleOverlayCallback(false,false, false); }); + () => { _toggleOverlayCallback(false, 8); }); break; } else if (bindState.IsActive && bindState.MainDevice.InputBind == InputBinding.AwacsOverlayToggle) { //run on main Application.Current.Dispatcher.Invoke( - () => { _toggleOverlayCallback(false, true, false); }); + () => { _toggleOverlayCallback(false, 7); }); break; } else if ((int)bindState.MainDevice.InputBind >= (int)InputBinding.Up100 && diff --git a/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml b/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml index 12493691..9a2b12b8 100644 --- a/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml +++ b/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml @@ -301,34 +301,84 @@ - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs new file mode 100644 index 00000000..222f81da --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs @@ -0,0 +1,342 @@ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Threading; +using Ciribob.DCS.SimpleRadio.Standalone.Client; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Network; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.RadioOverlayWindow; +using NLog; +using Ciribob.DCS.SimpleRadio.Standalone.Common; +using System.Windows.Forms; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow; +using MessageBox = System.Windows.Forms.MessageBox; + +namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay +{ + /// + /// Interaction logic for RadioOverlayWindow.xaml + /// + public partial class RadioOverlayWindowThreeVertical : Window + { + private double _aspectRatio; + private readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly Client.UI.AwacsRadioOverlayWindow.RadioControlGroup[] radioControlGroup = + new Client.UI.AwacsRadioOverlayWindow.RadioControlGroup[3]; + + private readonly DispatcherTimer _updateTimer; + + private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; + + private readonly GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + + private readonly double _originalMinHeight; + + private readonly double _radioHeight; + + private long _lastUnitId; + + + public RadioOverlayWindowThreeVertical() + { + //load opacity before the intialising as the slider changed + //method fires after initialisation + InitializeComponent(); + + this.WindowStartupLocation = WindowStartupLocation.Manual; + + _aspectRatio = MinWidth / MinHeight; + + _originalMinHeight = MinHeight; + _radioHeight = Radio1.Height; + WindowInteropHelper windowInteropHelper = new WindowInteropHelper(MainWindow.GetWindow(this)); + Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle); + MaxHeight = screen.Bounds.Height; + + AllowsTransparency = true; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity).DoubleValue; + WindowOpacitySlider.Value = Opacity; + + radioControlGroup[0] = Radio1; + radioControlGroup[1] = Radio2; + radioControlGroup[2] = Radio3; + + //allows click and drag anywhere on the window + ContainerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; + + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoY).DoubleValue; + + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHeight).DoubleValue; + + // Window_Loaded(null, null); + CalculateScale(); + + LocationChanged += Location_Changed; + + RadioRefresh(null, null); + + //init radio refresh + _updateTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(80)}; + _updateTimer.Tick += RadioRefresh; + _updateTimer.Start(); + } + + private void Location_Changed(object sender, EventArgs e) + { + } + + private void RadioRefresh(object sender, EventArgs eventArgs) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + radio.RepaintRadioReceive(); + } + + Intercom.RepaintRadioStatus(); + + if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent()) + { + //reset when we switch planes + if (_lastUnitId != dcsPlayerRadioInfo.unitId) + { + _lastUnitId = dcsPlayerRadioInfo.unitId; + ResetHeight(); + } + + var availableRadios = 0; + + for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++) + { + if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED) + { + availableRadios++; + + } + } + + if (availableRadios > 1) + { + if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) + { + ControlText.Text = "Three Radio Panel"; + } + else + { + ControlText.Text = "Three Radio Panel"; + } + } + else + { + ControlText.Text = "Three Radio Panel (Disconnected)"; + + } + } + else + { + ResetHeight(); + ControlText.Text = "Three Radio Panel (Disconnected)"; + } + + FocusDCS(); + } + + private void ResetHeight() + { + + if (MinHeight != _originalMinHeight) + { + MinHeight = _originalMinHeight; + Recalculate(); + } + } + + private void Recalculate() + { + _aspectRatio = MinWidth / MinHeight; + containerPanel_SizeChanged(null, null); + Height = Height+1; + } + + private long _lastFocus; + private RadioCapabilities _radioCapabilitiesWindow; + + private void FocusDCS() + { + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RefocusDCS)) + { + var overlayWindow = new WindowInteropHelper(this).Handle; + + //focus DCS if needed + var foreGround = WindowHelper.GetForegroundWindow(); + + Process[] localByName = Process.GetProcessesByName("dcs"); + + if (localByName != null && localByName.Length > 0) + { + //either DCS is in focus OR Overlay window is not in focus + if (foreGround == localByName[0].MainWindowHandle || overlayWindow != foreGround || + this.IsMouseOver) + { + _lastFocus = DateTime.Now.Ticks; + } + else if (DateTime.Now.Ticks > _lastFocus + 20000000 && overlayWindow == foreGround) + { + WindowHelper.BringProcessToFront(localByName[0]); + } + } + } + } + + private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + protected override void OnClosing(CancelEventArgs e) + { + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHeight,Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity,Opacity); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoX,Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoY, Top); + base.OnClosing(e); + + _updateTimer.Stop(); + } + + private void Button_Minimise(object sender, RoutedEventArgs e) + { + // Minimising a window without a taskbar icon leads to the window's menu bar still showing up in the bottom of screen + // Since controls are unusable, but a very small portion of the always-on-top window still showing, we're closing it instead, similar to toggling the overlay + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RadioOverlayTaskbarHide)) + { + Close(); + } + else + { + WindowState = WindowState.Minimized; + } + } + + private void Button_About(object sender, RoutedEventArgs e) + { + //Show Radio Capabilities + if ((_radioCapabilitiesWindow == null) || !_radioCapabilitiesWindow.IsVisible || + (_radioCapabilitiesWindow.WindowState == WindowState.Minimized)) + { + _radioCapabilitiesWindow?.Close(); + + _radioCapabilitiesWindow = new RadioCapabilities(); + _radioCapabilitiesWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; + _radioCapabilitiesWindow.Owner = this; + _radioCapabilitiesWindow.ShowDialog(); + } + else + { + _radioCapabilitiesWindow?.Close(); + _radioCapabilitiesWindow = null; + } + + } + + + private void Button_Close(object sender, RoutedEventArgs e) + { + Close(); + } + + private void windowOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Opacity = e.NewValue; + } + + private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) + { + //force aspect ratio + CalculateScale(); + + WindowState = WindowState.Normal; + } + + + private void CalculateScale() + { + var yScale = ActualHeight / RadioOverlayWin.MinWidth; + var xScale = ActualWidth / RadioOverlayWin.MinWidth; + var value = Math.Min(xScale, yScale); + ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + if (sizeInfo.WidthChanged) + Width = sizeInfo.NewSize.Height * _aspectRatio; + else + Height = sizeInfo.NewSize.Width / _aspectRatio; + + + // Console.WriteLine(this.Height +" width:"+ this.Width); + } + + #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 + + public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", + typeof(double), typeof(RadioOverlayWindowThreeVertical), + new UIPropertyMetadata(1.0, OnScaleValueChanged, + OnCoerceScaleValue)); + + private static object OnCoerceScaleValue(DependencyObject o, object value) + { + var mainWindow = o as RadioOverlayWindowThreeVertical; + if (mainWindow != null) + return mainWindow.OnCoerceScaleValue((double) value); + return value; + } + + private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var mainWindow = o as RadioOverlayWindowThreeVertical; + if (mainWindow != null) + mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); + } + + protected virtual double OnCoerceScaleValue(double value) + { + if (double.IsNaN(value)) + return 1.0f; + + value = Math.Max(0.1, value); + return value; + } + + protected virtual void OnScaleValueChanged(double oldValue, double newValue) + { + } + + public double ScaleValue + { + get { return (double) GetValue(ScaleValueProperty); } + set { SetValue(ScaleValueProperty, value); } + } + + #endregion + + private void RadioOverlayWindow_OnLocationChanged(object sender, EventArgs e) + { + //reset last focus so we dont switch back to dcs while dragging + _lastFocus = DateTime.Now.Ticks; + } + } +} \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwo.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml similarity index 99% rename from DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwo.xaml rename to DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml index 0ddbd491..4c8fcaa0 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwo.xaml +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for RadioOverlayWindow.xaml /// - public partial class RadioOverlayWindowTwo : Window + public partial class RadioOverlayWindowTwoVertical : Window { private double _aspectRatio; private readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -44,7 +44,7 @@ public partial class RadioOverlayWindowTwo : Window private long _lastUnitId; - public RadioOverlayWindowTwo() + public RadioOverlayWindowTwoVertical() { //load opacity before the intialising as the slider changed //method fires after initialisation @@ -308,13 +308,13 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", - typeof(double), typeof(RadioOverlayWindowTwo), + typeof(double), typeof(RadioOverlayWindowTwoVertical), new UIPropertyMetadata(1.0, OnScaleValueChanged, OnCoerceScaleValue)); private static object OnCoerceScaleValue(DependencyObject o, object value) { - var mainWindow = o as RadioOverlayWindowTwo; + var mainWindow = o as RadioOverlayWindowTwoVertical; if (mainWindow != null) return mainWindow.OnCoerceScaleValue((double) value); return value; @@ -322,7 +322,7 @@ private static object OnCoerceScaleValue(DependencyObject o, object value) private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { - var mainWindow = o as RadioOverlayWindowTwo; + var mainWindow = o as RadioOverlayWindowTwoVertical; if (mainWindow != null) mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); } From 3baf66ca326d72182c7441f3a6d5fe362649d55a Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Sat, 21 Oct 2023 15:12:43 +0200 Subject: [PATCH 05/74] Finished Multi Panels * Added 3H Overlay * Added 10V Overlay * Added 5H Overlay * Added 2H Overlay * Cleaned up opening and Closing of Panels * Added persistance to all Overlay settings --- DCS-SR-Client/DCS-SR-Client.csproj | 28 ++ DCS-SR-Client/Settings/GlobalSettingsStore.cs | 146 ++++++++-- DCS-SR-Client/UI/ClientWindow/MainWindow.xaml | 23 +- .../UI/ClientWindow/MainWindow.xaml.cs | 192 ++++++------ .../RadioOverlayFiveHorizontal.xaml | 178 ++++++++++++ .../RadioOverlayFiveHorizontal.xaml.cs | 274 ++++++++++++++++++ .../RadioOverlayFiveVertical.xaml.cs | 8 +- .../RadioOverlayTenHorizontal.xaml | 4 +- .../RadioOverlayTenHorizontal.xaml.cs | 25 +- .../RadioOverlayTenVertical.xaml | 184 ++++++++++++ .../RadioOverlayTenVertical.xaml.cs | 254 ++++++++++++++++ .../RadioOverlayThreeHorizontal.xaml | 171 +++++++++++ .../RadioOverlayThreeHorizontal.xaml.cs | 272 +++++++++++++++++ .../RadioOverlayThreeVertical.xaml.cs | 28 +- .../RadioOverlayTwoHorizontal.xaml | 164 +++++++++++ .../RadioOverlayTwoHorizontal.xaml.cs | 271 +++++++++++++++++ .../RadioOverlayTwoVertical.xaml.cs | 30 +- 17 files changed, 2091 insertions(+), 161 deletions(-) create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveHorizontal.xaml create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveHorizontal.xaml.cs create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml.cs create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml.cs create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml create mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml.cs diff --git a/DCS-SR-Client/DCS-SR-Client.csproj b/DCS-SR-Client/DCS-SR-Client.csproj index 93bdabee..24acd7ff 100644 --- a/DCS-SR-Client/DCS-SR-Client.csproj +++ b/DCS-SR-Client/DCS-SR-Client.csproj @@ -317,6 +317,18 @@ ClientListWindow.xaml + + RadioOverlayTwoHorizontal.xaml + + + RadioOverlayThreeHorizontal.xaml + + + RadioOverlayFiveHorizontal.xaml + + + RadioOverlayTenVertical.xaml + RadioOverlayThreeVertical.xaml @@ -392,6 +404,22 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/DCS-SR-Client/Settings/GlobalSettingsStore.cs b/DCS-SR-Client/Settings/GlobalSettingsStore.cs index fc689e90..b298483e 100644 --- a/DCS-SR-Client/Settings/GlobalSettingsStore.cs +++ b/DCS-SR-Client/Settings/GlobalSettingsStore.cs @@ -28,22 +28,79 @@ public enum GlobalSettingsKeys LastServer, MicBoost , SpeakerBoost, + + #region Radio panel settings + + // Radio 2V + RadioTwoVerticalX, + RadioTwoVerticalY, + RadioTwoVerticalSize, + RadioTwoVerticalOpacity, + RadioTwoVerticalWidth, + RadioTwoVerticalHeight, + + // Radio 3V + RadioThreeVerticalX, + RadioThreeVerticalY, + RadioThreeVerticalSize, + RadioThreeVerticalOpacity, + RadioThreeVerticalWidth, + RadioThreeVerticalHeight, + + // Radio 5V RadioFiveX, - RadioTwoX, RadioFiveY, - RadioTwoY, RadioFiveSize, - RadioTwoSize, RadioFiveOpacity, - RadioTwoOpacity, RadioFiveWidth, - RadioTwoWidth, RadioFiveHeight, - RadioTwoHeight, + + // Radio 10V + RadioTenVerticalX, + RadioTenVerticalY, + RadioTenVerticalSize, + RadioTenVerticalOpacity, + RadioTenVerticalWidth, + RadioTenVerticalHeight, + + + // Radio 2H + RadioTwoHorizontalX, + RadioTwoHorizontalY, + RadioTwoHorizontalSize, + RadioTwoHorizontalOpacity, + RadioTwoHorizontalWidth, + RadioTwoHorizontalHeight, + + // Radio 3H + RadioThreeHorizontalX, + RadioThreeHorizontalY, + RadioThreeHorizontalSize, + RadioThreeHorizontalOpacity, + RadioThreeHorizontalWidth, + RadioThreeHorizontalHeight, + + // Radio 5H + RadioFiveHorizontalX, + RadioFiveHorizontalY, + RadioFiveHorizontalSize, + RadioFiveHorizontalOpacity, + RadioFiveHorizontalWidth, + RadioFiveHorizontalHeight, + + // Radio 10H + RadioTenHorizontalX, + RadioTenHorizontalY, + RadioTenHorizontalSize, + RadioTenHorizontalOpacity, + RadioTenHorizontalWidth, + RadioTenHorizontalHeight, + + // Client Window ClientX, ClientY, - AwacsX, - AwacsY, + #endregion + MicAudioOutputDeviceId, CliendIdShort, // not used anymore @@ -408,29 +465,78 @@ public void SetClientSetting(GlobalSettingsKeys key, string[] strArray) {GlobalSettingsKeys.MicBoost.ToString(), "0.514"}, {GlobalSettingsKeys.SpeakerBoost.ToString(), "0.514"}, - {GlobalSettingsKeys.RadioTwoX.ToString(), "300"}, - {GlobalSettingsKeys.RadioTwoY.ToString(), "300"}, - {GlobalSettingsKeys.RadioTwoSize.ToString(), "1.0"}, - {GlobalSettingsKeys.RadioTwoOpacity.ToString(), "1.0"}, - - {GlobalSettingsKeys.RadioTwoWidth.ToString(), "122"}, - {GlobalSettingsKeys.RadioTwoHeight.ToString(), "270"}, - + #region Radio Panel settings + + // Radio 2V + {GlobalSettingsKeys.RadioTwoVerticalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioTwoVerticalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioTwoVerticalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTwoVerticalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTwoVerticalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioTwoVerticalHeight.ToString(), "270"}, + + // Radio 3V + {GlobalSettingsKeys.RadioThreeVerticalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioThreeVerticalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioThreeVerticalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioThreeVerticalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioThreeVerticalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioThreeVerticalHeight.ToString(), "270"}, + + // Radio 5V {GlobalSettingsKeys.RadioFiveX.ToString(), "300"}, {GlobalSettingsKeys.RadioFiveY.ToString(), "300"}, {GlobalSettingsKeys.RadioFiveSize.ToString(), "1.0"}, {GlobalSettingsKeys.RadioFiveOpacity.ToString(), "1.0"}, - {GlobalSettingsKeys.RadioFiveWidth.ToString(), "122"}, {GlobalSettingsKeys.RadioFiveHeight.ToString(), "270"}, + // Radio 10V + {GlobalSettingsKeys.RadioTenVerticalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioTenVerticalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioTenVerticalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTenVerticalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTenVerticalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioTenVerticalHeight.ToString(), "270"}, + + // Radio 2H + {GlobalSettingsKeys.RadioTwoHorizontalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioTwoHorizontalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioTwoHorizontalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTwoHorizontalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTwoHorizontalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioTwoHorizontalHeight.ToString(), "270"}, + + // Radio 3H + {GlobalSettingsKeys.RadioThreeHorizontalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioThreeHorizontalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioThreeHorizontalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioThreeHorizontalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioThreeHorizontalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioThreeHorizontalHeight.ToString(), "270"}, + + // Radio 5H + {GlobalSettingsKeys.RadioFiveHorizontalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioFiveHorizontalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioFiveHorizontalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioFiveHorizontalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioFiveHorizontalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioFiveHorizontalHeight.ToString(), "270"}, + + // Radio 10H + {GlobalSettingsKeys.RadioTenHorizontalX.ToString(), "300"}, + {GlobalSettingsKeys.RadioTenHorizontalY.ToString(), "300"}, + {GlobalSettingsKeys.RadioTenHorizontalSize.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTenHorizontalOpacity.ToString(), "1.0"}, + {GlobalSettingsKeys.RadioTenHorizontalWidth.ToString(), "122"}, + {GlobalSettingsKeys.RadioTenHorizontalHeight.ToString(), "270"}, + {GlobalSettingsKeys.ClientX.ToString(), "200"}, {GlobalSettingsKeys.ClientY.ToString(), "200"}, - {GlobalSettingsKeys.AwacsX.ToString(), "300"}, - {GlobalSettingsKeys.AwacsY.ToString(), "300"}, +#endregion - // {GlobalSettingsKeys.CliendIdShort.ToString(), ShortGuid.NewGuid().ToString()}, + // {GlobalSettingsKeys.CliendIdShort.ToString(), ShortGuid.NewGuid().ToString()}, {GlobalSettingsKeys.ClientIdLong.ToString(), Guid.NewGuid().ToString()}, {GlobalSettingsKeys.DCSLOSOutgoingUDP.ToString(), "9086"}, diff --git a/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml b/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml index 9a2b12b8..2f27bf8f 100644 --- a/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml +++ b/DCS-SR-Client/UI/ClientWindow/MainWindow.xaml @@ -1,5 +1,5 @@  + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveHorizontal.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveHorizontal.xaml.cs new file mode 100644 index 00000000..d6df4a38 --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveHorizontal.xaml.cs @@ -0,0 +1,274 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Network; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow; +using Ciribob.DCS.SimpleRadio.Standalone.Common; +using NLog; + +namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay +{ + /// + /// Interaction logic for RadioOverlayWindow.xaml + /// + public partial class RadioOverlayWindowFiveHorizontal : Window + { + private readonly double _aspectRatio; + private readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[5]; + + private readonly DispatcherTimer _updateTimer; + + private long _lastUnitId; + + private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; + + private GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + + public RadioOverlayWindowFiveHorizontal() + { + InitializeComponent(); + + this.WindowStartupLocation = WindowStartupLocation.Manual; + + _aspectRatio = MinWidth / MinHeight; + + AllowsTransparency = true; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalOpacity).DoubleValue; + windowOpacitySlider.Value = Opacity; + + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalY).DoubleValue; + + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalHeight).DoubleValue; + + radioControlGroup[0] = radio1; + radioControlGroup[1] = radio2; + radioControlGroup[2] = radio3; + radioControlGroup[3] = radio4; + radioControlGroup[4] = radio5; + + + //allows click and drag anywhere on the window + containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; + + CalculateScale(); + + LocationChanged += Location_Changed; + + RadioRefresh(null, null); + + //init radio refresh + _updateTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(80)}; + _updateTimer.Tick += RadioRefresh; + _updateTimer.Start(); + } + + private void Location_Changed(object sender, EventArgs e) + { + // AppConfiguration.Instance.RadioX = Top; + // AppConfiguration.Instance.RadioY = Left; + } + + private void RadioRefresh(object sender, EventArgs eventArgs) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + radio.RepaintRadioReceive(); + } + + intercom.RepaintRadioStatus(); + + if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent()) + { + //reset when we switch planes + if (_lastUnitId != dcsPlayerRadioInfo.unitId) + { + _lastUnitId = dcsPlayerRadioInfo.unitId; + } + + var availableRadios = 0; + + for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++) + { + if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED) + { + availableRadios++; + + } + } + + if (availableRadios > 1) + { + if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) + { + ControlText.Text = "5 Horizontal"; + } + else + { + ControlText.Text = "5 Horizontal"; + } + } + else + { + ControlText.Text = "5 Horizontal (Disconnected)"; + + } + } + else + { + ControlText.Text = "5 Horizontal (Disconnected)"; + } + } + + private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + protected override void OnClosing(CancelEventArgs e) + { + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalX, Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalHeight, Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioFiveHorizontalOpacity, Opacity); + + base.OnClosing(e); + + _updateTimer.Stop(); + } + + private void Button_Minimise(object sender, RoutedEventArgs e) + { + // Minimising a window without a taskbar icon leads to the window's menu bar still showing up in the bottom of screen + // Since controls are unusable, but a very small portion of the always-on-top window still showing, we're closing it instead, similar to toggling the overlay + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RadioOverlayTaskbarHide)) + { + Close(); + } + else + { + WindowState = WindowState.Minimized; + } + } + + + private void Button_Close(object sender, RoutedEventArgs e) + { + Close(); + } + + private void windowOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Opacity = e.NewValue; + //AppConfiguration.Instance.RadioOpacity = Opacity; + } + + private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) + { + //force aspect ratio + CalculateScale(); + + WindowState = WindowState.Normal; + } + +// +// + private void CalculateScale() + { + var yScale = ActualHeight / RadioOverlayWin.MinHeight; + var xScale = ActualWidth / RadioOverlayWin.MinWidth; + var value = Math.Max(xScale, yScale); + ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + if (sizeInfo.WidthChanged) + Width = sizeInfo.NewSize.Height * _aspectRatio; + else + Height = sizeInfo.NewSize.Width / _aspectRatio; + + // AppConfiguration.Instance.RadioWidth = Width; + // AppConfiguration.Instance.RadioHeight = Height; + // Console.WriteLine(this.Height +" width:"+ this.Width); + } + + #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 + + public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", + typeof(double), typeof(RadioOverlayWindowFiveHorizontal), + new UIPropertyMetadata(1.0, OnScaleValueChanged, + OnCoerceScaleValue)); + + + private static object OnCoerceScaleValue(DependencyObject o, object value) + { + var mainWindow = o as RadioOverlayWindowFiveHorizontal; + if (mainWindow != null) + return mainWindow.OnCoerceScaleValue((double) value); + return value; + } + + private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var mainWindow = o as RadioOverlayWindowFiveHorizontal; + if (mainWindow != null) + mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); + } + + protected virtual double OnCoerceScaleValue(double value) + { + if (double.IsNaN(value)) + return 1.0f; + + value = Math.Max(0.1, value); + return value; + } + + protected virtual void OnScaleValueChanged(double oldValue, double newValue) + { + } + + public double ScaleValue + { + get { return (double) GetValue(ScaleValueProperty); } + set { SetValue(ScaleValueProperty, value); } + } + + #endregion + + private void ToggleGlobalSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + if (dcsPlayerRadioInfo != null) + { + dcsPlayerRadioInfo.simultaneousTransmission = !dcsPlayerRadioInfo.simultaneousTransmission; + + if (!dcsPlayerRadioInfo.simultaneousTransmission) + { + foreach (var radio in dcsPlayerRadioInfo.radios) + { + radio.simul = false; + } + } + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + } + } + } + } +} \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveVertical.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveVertical.xaml.cs index b7133b21..d7fb3bc2 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveVertical.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayFiveVertical.xaml.cs @@ -131,22 +131,22 @@ private void RadioRefresh(object sender, EventArgs eventArgs) { if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) { - ControlText.Text = "Five Radio Panel"; + ControlText.Text = "5 Vertical"; } else { - ControlText.Text = "Five Radio Panel"; + ControlText.Text = "5 Vertical"; } } else { - ControlText.Text = "Five Radio Panel (Disconnected)"; + ControlText.Text = "5 Vertical (Disconnected)"; } } else { - ControlText.Text = "Five Radio Panel (Disconnected)"; + ControlText.Text = "5 Vertical (Disconnected)"; } FocusDCS(); diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenHorizontal.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenHorizontal.xaml index d737656c..f8835da9 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenHorizontal.xaml +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenHorizontal.xaml @@ -58,7 +58,7 @@ FontSize="13" Foreground="#E7E7E7" Padding="0" - Text="10 Radio Panel" /> + Text="10 Horizontal" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml.cs new file mode 100644 index 00000000..232a037e --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml.cs @@ -0,0 +1,254 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Network; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow; +using Ciribob.DCS.SimpleRadio.Standalone.Common; +using NLog; + +namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay +{ + /// + /// Interaction logic for RadioOverlayWindow.xaml + /// + public partial class RadioOverlayWindowTenVertical : Window + { + private readonly double _aspectRatio; + private readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[10]; + + private readonly DispatcherTimer _updateTimer; + + public static bool AwacsActive = false + ; //when false and we're in spectator mode / not in an aircraft the other 7 radios will be disabled + + private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; + + private GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + + public RadioOverlayWindowTenVertical() + { + //load opacity before the intialising as the slider changed + //method fires after initialisation + // var opacity = AppConfiguration.Instance.RadioOpacity; + AwacsActive = true; + + InitializeComponent(); + + this.WindowStartupLocation = WindowStartupLocation.Manual; + + _aspectRatio = MinWidth / MinHeight; + + AllowsTransparency = true; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTenVerticalOpacity).DoubleValue; + windowOpacitySlider.Value = Opacity; + + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTenVerticalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTenVerticalY).DoubleValue; + + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTenVerticalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTenVerticalHeight).DoubleValue; + + radioControlGroup[0] = radio1; + radioControlGroup[1] = radio2; + radioControlGroup[2] = radio3; + radioControlGroup[3] = radio4; + radioControlGroup[4] = radio5; + radioControlGroup[5] = radio6; + radioControlGroup[6] = radio7; + radioControlGroup[7] = radio8; + radioControlGroup[8] = radio9; + radioControlGroup[9] = radio10; + + + //allows click and drag anywhere on the window + containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; + + CalculateScale(); + + RadioRefresh(null, null); + + //init radio refresh + _updateTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(80)}; + _updateTimer.Tick += RadioRefresh; + _updateTimer.Start(); + } + + private void RadioRefresh(object sender, EventArgs eventArgs) + { + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + radio.RepaintRadioReceive(); + } + + intercom.RepaintRadioStatus(); + + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + if (dcsPlayerRadioInfo != null) + { + if (_clientStateSingleton.IsConnected && dcsPlayerRadioInfo.IsCurrent() + && _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.ENABLED_INTERNAL_SRS_CONTROLS) + { + + var avalilableRadios = 0; + + for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++) + { + if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED) + { + avalilableRadios++; + } + } + } + } + } + + private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + protected override void OnClosing(CancelEventArgs e) + { + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTenVerticalX, Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTenVerticalY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTenVerticalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTenVerticalHeight, Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTenVerticalOpacity, Opacity); + + base.OnClosing(e); + + AwacsActive = false; + _updateTimer.Stop(); + } + + private void Button_Minimise(object sender, RoutedEventArgs e) + { + // Minimising a window without a taskbar icon leads to the window's menu bar still showing up in the bottom of screen + // Since controls are unusable, but a very small portion of the always-on-top window still showing, we're closing it instead, similar to toggling the overlay + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RadioOverlayTaskbarHide)) + { + Close(); + } + else + { + WindowState = WindowState.Minimized; + } + } + + + private void Button_Close(object sender, RoutedEventArgs e) + { + Close(); + } + + private void windowOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Opacity = e.NewValue; + //AppConfiguration.Instance.RadioOpacity = Opacity; + } + + private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) + { + //force aspect ratio + CalculateScale(); + + WindowState = WindowState.Normal; + } + +// +// + private void CalculateScale() + { + var yScale = ActualHeight / RadioOverlayWin.MinHeight; + var xScale = ActualWidth / RadioOverlayWin.MinWidth; + var value = Math.Max(xScale, yScale); + ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + if (sizeInfo.WidthChanged) + Width = sizeInfo.NewSize.Height * _aspectRatio; + else + Height = sizeInfo.NewSize.Width / _aspectRatio; + + // AppConfiguration.Instance.RadioWidth = Width; + // AppConfiguration.Instance.RadioHeight = Height; + // Console.WriteLine(this.Height +" width:"+ this.Width); + } + + #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 + + public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", + typeof(double), typeof(RadioOverlayWindowTenVertical), + new UIPropertyMetadata(1.0, OnScaleValueChanged, + OnCoerceScaleValue)); + + + private static object OnCoerceScaleValue(DependencyObject o, object value) + { + var mainWindow = o as RadioOverlayWindowTenVertical; + if (mainWindow != null) + return mainWindow.OnCoerceScaleValue((double) value); + return value; + } + + private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var mainWindow = o as RadioOverlayWindowTenVertical; + if (mainWindow != null) + mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); + } + + protected virtual double OnCoerceScaleValue(double value) + { + if (double.IsNaN(value)) + return 1.0f; + + value = Math.Max(0.1, value); + return value; + } + + protected virtual void OnScaleValueChanged(double oldValue, double newValue) + { + } + + public double ScaleValue + { + get { return (double) GetValue(ScaleValueProperty); } + set { SetValue(ScaleValueProperty, value); } + } + + #endregion + + private void ToggleGlobalSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + if (dcsPlayerRadioInfo != null) + { + dcsPlayerRadioInfo.simultaneousTransmission = !dcsPlayerRadioInfo.simultaneousTransmission; + + if (!dcsPlayerRadioInfo.simultaneousTransmission) + { + foreach (var radio in dcsPlayerRadioInfo.radios) + { + radio.simul = false; + } + } + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + } + } + } + } +} \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml new file mode 100644 index 00000000..25f07916 --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml.cs new file mode 100644 index 00000000..f38cff27 --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeHorizontal.xaml.cs @@ -0,0 +1,272 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Network; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow; +using Ciribob.DCS.SimpleRadio.Standalone.Common; +using NLog; + +namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay +{ + /// + /// Interaction logic for RadioOverlayWindow.xaml + /// + public partial class RadioOverlayWindowThreeHorizontal : Window + { + private readonly double _aspectRatio; + private readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[3]; + + private readonly DispatcherTimer _updateTimer; + + private long _lastUnitId; + + private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; + + private GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + + public RadioOverlayWindowThreeHorizontal() + { + InitializeComponent(); + + this.WindowStartupLocation = WindowStartupLocation.Manual; + + _aspectRatio = MinWidth / MinHeight; + + AllowsTransparency = true; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalOpacity).DoubleValue; + windowOpacitySlider.Value = Opacity; + + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalY).DoubleValue; + + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalHeight).DoubleValue; + + radioControlGroup[0] = radio1; + radioControlGroup[1] = radio2; + radioControlGroup[2] = radio3; + + + //allows click and drag anywhere on the window + containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; + + CalculateScale(); + + LocationChanged += Location_Changed; + + RadioRefresh(null, null); + + //init radio refresh + _updateTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(80)}; + _updateTimer.Tick += RadioRefresh; + _updateTimer.Start(); + } + + private void Location_Changed(object sender, EventArgs e) + { + // AppConfiguration.Instance.RadioX = Top; + // AppConfiguration.Instance.RadioY = Left; + } + + private void RadioRefresh(object sender, EventArgs eventArgs) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + radio.RepaintRadioReceive(); + } + + intercom.RepaintRadioStatus(); + + if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent()) + { + //reset when we switch planes + if (_lastUnitId != dcsPlayerRadioInfo.unitId) + { + _lastUnitId = dcsPlayerRadioInfo.unitId; + } + + var availableRadios = 0; + + for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++) + { + if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED) + { + availableRadios++; + + } + } + + if (availableRadios > 1) + { + if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) + { + ControlText.Text = "3 Horizontal"; + } + else + { + ControlText.Text = "3 Horizontal"; + } + } + else + { + ControlText.Text = "3 Horizontal (Disconnected)"; + + } + } + else + { + ControlText.Text = "3 Horizontal (Disconnected)"; + } + } + + private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + protected override void OnClosing(CancelEventArgs e) + { + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalX, Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalHeight, Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeHorizontalOpacity, Opacity); + + base.OnClosing(e); + + _updateTimer.Stop(); + } + + private void Button_Minimise(object sender, RoutedEventArgs e) + { + // Minimising a window without a taskbar icon leads to the window's menu bar still showing up in the bottom of screen + // Since controls are unusable, but a very small portion of the always-on-top window still showing, we're closing it instead, similar to toggling the overlay + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RadioOverlayTaskbarHide)) + { + Close(); + } + else + { + WindowState = WindowState.Minimized; + } + } + + + private void Button_Close(object sender, RoutedEventArgs e) + { + Close(); + } + + private void windowOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Opacity = e.NewValue; + //AppConfiguration.Instance.RadioOpacity = Opacity; + } + + private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) + { + //force aspect ratio + CalculateScale(); + + WindowState = WindowState.Normal; + } + +// +// + private void CalculateScale() + { + var yScale = ActualHeight / RadioOverlayWin.MinHeight; + var xScale = ActualWidth / RadioOverlayWin.MinWidth; + var value = Math.Max(xScale, yScale); + ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + if (sizeInfo.WidthChanged) + Width = sizeInfo.NewSize.Height * _aspectRatio; + else + Height = sizeInfo.NewSize.Width / _aspectRatio; + + // AppConfiguration.Instance.RadioWidth = Width; + // AppConfiguration.Instance.RadioHeight = Height; + // Console.WriteLine(this.Height +" width:"+ this.Width); + } + + #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 + + public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", + typeof(double), typeof(RadioOverlayWindowThreeHorizontal), + new UIPropertyMetadata(1.0, OnScaleValueChanged, + OnCoerceScaleValue)); + + + private static object OnCoerceScaleValue(DependencyObject o, object value) + { + var mainWindow = o as RadioOverlayWindowThreeHorizontal; + if (mainWindow != null) + return mainWindow.OnCoerceScaleValue((double) value); + return value; + } + + private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var mainWindow = o as RadioOverlayWindowThreeHorizontal; + if (mainWindow != null) + mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); + } + + protected virtual double OnCoerceScaleValue(double value) + { + if (double.IsNaN(value)) + return 1.0f; + + value = Math.Max(0.1, value); + return value; + } + + protected virtual void OnScaleValueChanged(double oldValue, double newValue) + { + } + + public double ScaleValue + { + get { return (double) GetValue(ScaleValueProperty); } + set { SetValue(ScaleValueProperty, value); } + } + + #endregion + + private void ToggleGlobalSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + if (dcsPlayerRadioInfo != null) + { + dcsPlayerRadioInfo.simultaneousTransmission = !dcsPlayerRadioInfo.simultaneousTransmission; + + if (!dcsPlayerRadioInfo.simultaneousTransmission) + { + foreach (var radio in dcsPlayerRadioInfo.radios) + { + radio.simul = false; + } + } + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + } + } + } + } +} \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs index 222f81da..1013336f 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayThreeVertical.xaml.cs @@ -61,7 +61,7 @@ public RadioOverlayWindowThreeVertical() MaxHeight = screen.Bounds.Height; AllowsTransparency = true; - Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity).DoubleValue; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalOpacity).DoubleValue; WindowOpacitySlider.Value = Opacity; radioControlGroup[0] = Radio1; @@ -71,11 +71,11 @@ public RadioOverlayWindowThreeVertical() //allows click and drag anywhere on the window ContainerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; - Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoX).DoubleValue; - Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoY).DoubleValue; + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalY).DoubleValue; - Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoWidth).DoubleValue; - Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHeight).DoubleValue; + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalHeight).DoubleValue; // Window_Loaded(null, null); CalculateScale(); @@ -130,23 +130,23 @@ private void RadioRefresh(object sender, EventArgs eventArgs) { if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) { - ControlText.Text = "Three Radio Panel"; + ControlText.Text = "3 Vertical"; } else { - ControlText.Text = "Three Radio Panel"; + ControlText.Text = "3 Vertical"; } } else { - ControlText.Text = "Three Radio Panel (Disconnected)"; + ControlText.Text = "3 Vertical (Disconnected)"; } } else { ResetHeight(); - ControlText.Text = "Three Radio Panel (Disconnected)"; + ControlText.Text = "3 Vertical (Disconnected)"; } FocusDCS(); @@ -206,11 +206,11 @@ private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e protected override void OnClosing(CancelEventArgs e) { - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoWidth, Width); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHeight,Height); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity,Opacity); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoX,Left); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalHeight,Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalOpacity,Opacity); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalX,Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioThreeVerticalY, Top); base.OnClosing(e); _updateTimer.Stop(); diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml new file mode 100644 index 00000000..c2dd8c7f --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml.cs new file mode 100644 index 00000000..399c802d --- /dev/null +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoHorizontal.xaml.cs @@ -0,0 +1,271 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Network; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; +using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; +using Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow; +using Ciribob.DCS.SimpleRadio.Standalone.Common; +using NLog; + +namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay +{ + /// + /// Interaction logic for RadioOverlayWindow.xaml + /// + public partial class RadioOverlayWindowTwoHorizontal : Window + { + private readonly double _aspectRatio; + private readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[2]; + + private readonly DispatcherTimer _updateTimer; + + private long _lastUnitId; + + private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; + + private GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + + public RadioOverlayWindowTwoHorizontal() + { + InitializeComponent(); + + this.WindowStartupLocation = WindowStartupLocation.Manual; + + _aspectRatio = MinWidth / MinHeight; + + AllowsTransparency = true; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalOpacity).DoubleValue; + windowOpacitySlider.Value = Opacity; + + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalY).DoubleValue; + + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalHeight).DoubleValue; + + radioControlGroup[0] = radio1; + radioControlGroup[1] = radio2; + + + //allows click and drag anywhere on the window + containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; + + CalculateScale(); + + LocationChanged += Location_Changed; + + RadioRefresh(null, null); + + //init radio refresh + _updateTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(80)}; + _updateTimer.Tick += RadioRefresh; + _updateTimer.Start(); + } + + private void Location_Changed(object sender, EventArgs e) + { + // AppConfiguration.Instance.RadioX = Top; + // AppConfiguration.Instance.RadioY = Left; + } + + private void RadioRefresh(object sender, EventArgs eventArgs) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + radio.RepaintRadioReceive(); + } + + intercom.RepaintRadioStatus(); + + if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent()) + { + //reset when we switch planes + if (_lastUnitId != dcsPlayerRadioInfo.unitId) + { + _lastUnitId = dcsPlayerRadioInfo.unitId; + } + + var availableRadios = 0; + + for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++) + { + if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED) + { + availableRadios++; + + } + } + + if (availableRadios > 1) + { + if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) + { + ControlText.Text = "2 Horizontal"; + } + else + { + ControlText.Text = "2 Horizontal"; + } + } + else + { + ControlText.Text = "2 Horizontal (Disconnected)"; + + } + } + else + { + ControlText.Text = "2 Horizontal (Disconnected)"; + } + } + + private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + protected override void OnClosing(CancelEventArgs e) + { + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalX, Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalHeight, Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHorizontalOpacity, Opacity); + + base.OnClosing(e); + + _updateTimer.Stop(); + } + + private void Button_Minimise(object sender, RoutedEventArgs e) + { + // Minimising a window without a taskbar icon leads to the window's menu bar still showing up in the bottom of screen + // Since controls are unusable, but a very small portion of the always-on-top window still showing, we're closing it instead, similar to toggling the overlay + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.RadioOverlayTaskbarHide)) + { + Close(); + } + else + { + WindowState = WindowState.Minimized; + } + } + + + private void Button_Close(object sender, RoutedEventArgs e) + { + Close(); + } + + private void windowOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Opacity = e.NewValue; + //AppConfiguration.Instance.RadioOpacity = Opacity; + } + + private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) + { + //force aspect ratio + CalculateScale(); + + WindowState = WindowState.Normal; + } + +// +// + private void CalculateScale() + { + var yScale = ActualHeight / RadioOverlayWin.MinHeight; + var xScale = ActualWidth / RadioOverlayWin.MinWidth; + var value = Math.Max(xScale, yScale); + ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + if (sizeInfo.WidthChanged) + Width = sizeInfo.NewSize.Height * _aspectRatio; + else + Height = sizeInfo.NewSize.Width / _aspectRatio; + + // AppConfiguration.Instance.RadioWidth = Width; + // AppConfiguration.Instance.RadioHeight = Height; + // Console.WriteLine(this.Height +" width:"+ this.Width); + } + + #region ScaleValue Depdency Property //StackOverflow: http://stackoverflow.com/questions/3193339/tips-on-developing-resolution-independent-application/5000120#5000120 + + public static readonly DependencyProperty ScaleValueProperty = DependencyProperty.Register("ScaleValue", + typeof(double), typeof(RadioOverlayWindowTwoHorizontal), + new UIPropertyMetadata(1.0, OnScaleValueChanged, + OnCoerceScaleValue)); + + + private static object OnCoerceScaleValue(DependencyObject o, object value) + { + var mainWindow = o as RadioOverlayWindowTwoHorizontal; + if (mainWindow != null) + return mainWindow.OnCoerceScaleValue((double) value); + return value; + } + + private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var mainWindow = o as RadioOverlayWindowTwoHorizontal; + if (mainWindow != null) + mainWindow.OnScaleValueChanged((double) e.OldValue, (double) e.NewValue); + } + + protected virtual double OnCoerceScaleValue(double value) + { + if (double.IsNaN(value)) + return 1.0f; + + value = Math.Max(0.1, value); + return value; + } + + protected virtual void OnScaleValueChanged(double oldValue, double newValue) + { + } + + public double ScaleValue + { + get { return (double) GetValue(ScaleValueProperty); } + set { SetValue(ScaleValueProperty, value); } + } + + #endregion + + private void ToggleGlobalSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) + { + var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; + if (dcsPlayerRadioInfo != null) + { + dcsPlayerRadioInfo.simultaneousTransmission = !dcsPlayerRadioInfo.simultaneousTransmission; + + if (!dcsPlayerRadioInfo.simultaneousTransmission) + { + foreach (var radio in dcsPlayerRadioInfo.radios) + { + radio.simul = false; + } + } + + foreach (var radio in radioControlGroup) + { + radio.RepaintRadioStatus(); + } + } + } + } +} \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml.cs index 5be305d8..afb6f965 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTwoVertical.xaml.cs @@ -61,7 +61,7 @@ public RadioOverlayWindowTwoVertical() MaxHeight = screen.Bounds.Height; AllowsTransparency = true; - Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity).DoubleValue; + Opacity = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalOpacity).DoubleValue; WindowOpacitySlider.Value = Opacity; radioControlGroup[0] = Radio1; @@ -70,11 +70,11 @@ public RadioOverlayWindowTwoVertical() //allows click and drag anywhere on the window ContainerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown; - Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoX).DoubleValue; - Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoY).DoubleValue; + Left = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalX).DoubleValue; + Top = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalY).DoubleValue; - Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoWidth).DoubleValue; - Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoHeight).DoubleValue; + Width = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalWidth).DoubleValue; + Height = _globalSettings.GetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalHeight).DoubleValue; // Window_Loaded(null, null); CalculateScale(); @@ -145,23 +145,23 @@ private void RadioRefresh(object sender, EventArgs eventArgs) { if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) { - ControlText.Text = "Two Radio Panel"; + ControlText.Text = "2 Vertical"; } else { - ControlText.Text = "Two Radio Panel"; + ControlText.Text = "2 Vertical"; } } else { - ControlText.Text = "Two Radio Panel (Disconnected)"; + ControlText.Text = "2 Vertical (Disconnected)"; } } else { ResetHeight(); - ControlText.Text = "Two Radio Panel (Disconnected)"; + ControlText.Text = "2 Vertical (Disconnected)"; } FocusDCS(); @@ -221,11 +221,11 @@ private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e protected override void OnClosing(CancelEventArgs e) { - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoWidth, Width); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoHeight,Height); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoOpacity,Opacity); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoX,Left); - _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoY, Top); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalWidth, Width); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalHeight,Height); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalOpacity,Opacity); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalX,Left); + _globalSettings.SetPositionSetting(GlobalSettingsKeys.RadioTwoVerticalY, Top); base.OnClosing(e); _updateTimer.Stop(); @@ -288,7 +288,7 @@ private void containerPanel_SizeChanged(object sender, SizeChangedEventArgs e) private void CalculateScale() { - var yScale = ActualHeight / RadioOverlayWin.MinWidth; + var yScale = ActualHeight / RadioOverlayWin.MinHeight; var xScale = ActualWidth / RadioOverlayWin.MinWidth; var value = Math.Min(xScale, yScale); ScaleValue = (double) OnCoerceScaleValue(RadioOverlayWin, value); From 16b57e7efb016fa1568834a2f7cffef461a47db8 Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Mon, 6 Nov 2023 18:35:20 +0100 Subject: [PATCH 06/74] Added configurable Upper Intercom Limit --- .../AwacsIntercomControlGroup.xaml | 2 -- .../AwacsIntercomControlGroup.xaml.cs | 8 +++++--- .../UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml | 2 -- .../RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs | 8 +++++--- DCS-SR-Client/awacs-radios.json | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml index c272f501..fd815bfc 100644 --- a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml +++ b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml @@ -53,8 +53,6 @@ diff --git a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs index 09998200..95a6691a 100644 --- a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs @@ -20,6 +20,7 @@ public partial class IntercomControlGroup : UserControl private bool _init = true; private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; private readonly GlobalSettingsStore _globalSettings = GlobalSettingsStore.Instance; + private RadioInformation _intercomInformation; @@ -29,15 +30,16 @@ public IntercomControlGroup() Radio1Enabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXR1) ? Overlay.IntercomControlGroup.voxEnabled : Overlay.IntercomControlGroup.voxDisabled; IntercomEnabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC) ? Overlay.IntercomControlGroup.voxEnabled : Overlay.IntercomControlGroup.voxicDisabled; + _intercomInformation = _clientStateSingleton.DcsPlayerRadioInfo.radios[RadioId]; + IntercomNumberSpinner.Maximum = (int)Math.Round(_intercomInformation.freqMax, 0); + IntercomNumberSpinner.Minimum = 1; } public int RadioId { private get; set; } private void RadioSelectSwitch(object sender, RoutedEventArgs e) { - var currentRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[RadioId]; - - if (currentRadio.modulation != RadioInformation.Modulation.DISABLED) + if (_intercomInformation.modulation != RadioInformation.Modulation.DISABLED) { if (_clientStateSingleton.DcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml index 117da3a7..f5f8b7fa 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml +++ b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml @@ -35,8 +35,6 @@ diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs index 5782d591..b2bfb41a 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs @@ -23,6 +23,7 @@ public partial class IntercomControlGroup : UserControl public static Brush voxEnabled = Brushes.MediumSeaGreen; public static Brush voxDisabled = Brushes.IndianRed; public static Brush voxicDisabled = Brushes.Gray; + private RadioInformation _inercomRadioInfo; public IntercomControlGroup() { @@ -30,15 +31,16 @@ public IntercomControlGroup() Radio1Enabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXR1) ? voxEnabled : voxDisabled; IntercomEnabled.Background = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC) ? voxEnabled : voxicDisabled; + _inercomRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo.radios[RadioId]; + IntercomNumberSpinner.Maximum = (int)Math.Round(_inercomRadioInfo.freqMax, 0); + IntercomNumberSpinner.Minimum = 1; } public int RadioId { private get; set; } private void RadioSelectSwitch(object sender, RoutedEventArgs e) { - var currentRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[RadioId]; - - if (currentRadio.modulation != RadioInformation.Modulation.DISABLED) + if (_inercomRadioInfo.modulation != RadioInformation.Modulation.DISABLED) { if (_clientStateSingleton.DcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS) diff --git a/DCS-SR-Client/awacs-radios.json b/DCS-SR-Client/awacs-radios.json index 23fd54d1..de960b66 100644 --- a/DCS-SR-Client/awacs-radios.json +++ b/DCS-SR-Client/awacs-radios.json @@ -3,9 +3,9 @@ "enc": false, "encKey": 0, "encMode": 0, - "freqMax": 100.0, - "freqMin": 100.0, - "freq": 100.0, + "freqMax": 200.0, + "freqMin": 1.0, + "freq": 200.0, "modulation": 2, "name": "INTERCOM", "secFreq": 0.0, From 9b3922ce7fd8345492934bde4eff5508f2d361be Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Mon, 6 Nov 2023 19:24:29 +0100 Subject: [PATCH 07/74] Fixed Issue 51 and 49 --- DCS-SR-Client/Network/UDPVoiceHandler.cs | 3 +-- .../AwacsIntercomControlGroup.xaml.cs | 18 ++++++++++++---- .../Utils/IntercomControlGroup.xaml.cs | 21 ++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/DCS-SR-Client/Network/UDPVoiceHandler.cs b/DCS-SR-Client/Network/UDPVoiceHandler.cs index 0aca6f64..b3aa05d3 100644 --- a/DCS-SR-Client/Network/UDPVoiceHandler.cs +++ b/DCS-SR-Client/Network/UDPVoiceHandler.cs @@ -803,7 +803,7 @@ private int SortRadioReceivingPriorities(RadioReceivingPriority x, RadioReceivin private int getCurrentSelected() { - if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) //If both are active Intercome gets preferred, but UI does not allow this. + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) //If both are active Intercom gets preferred, but UI does not allow this. { return 0; } @@ -960,7 +960,6 @@ public ClientAudio Send(byte[] bytes, int len, bool voice) { if (transmittingRadios.Count > 0) { - List frequencies = new List(transmittingRadios.Count); List encryptions = new List(transmittingRadios.Count); List modulations = new List(transmittingRadios.Count); diff --git a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs index 09998200..9e04f78a 100644 --- a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsIntercomControlGroup.xaml.cs @@ -183,8 +183,11 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE } var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; - int? spinnervalue = IntercomNumberSpinner.Value; - int isone = spinnervalue ?? default(int); + int spinnervalue; + if (!int.TryParse(IntercomNumberSpinner.Value.ToString(), out spinnervalue)) + { + return; + } if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) { @@ -193,7 +196,7 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE } - if (isone == 1) + if (spinnervalue == 1) { IntercomEnabled.IsEnabled = false; IntercomEnabled.Background = Overlay.IntercomControlGroup.voxicDisabled; @@ -201,7 +204,14 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE else { IntercomEnabled.IsEnabled = true; - IntercomEnabled.Background = Overlay.IntercomControlGroup.voxDisabled; + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) + { + IntercomEnabled.Background = Overlay.IntercomControlGroup.voxEnabled; + } + else + { + IntercomEnabled.Background = Overlay.IntercomControlGroup.voxDisabled; + } } if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent() && diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs index 7562e7ac..ae533ca9 100644 --- a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/IntercomControlGroup.xaml.cs @@ -6,6 +6,7 @@ using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; using Ciribob.DCS.SimpleRadio.Standalone.Client.Singletons; using Ciribob.DCS.SimpleRadio.Standalone.Common; +using Newtonsoft.Json.Linq; namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay { @@ -221,9 +222,12 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE return; } - int spinnervalue = (int)IntercomNumberSpinner.Value; - bool isone = (int)spinnervalue == 1; - + int spinnervalue; + if (!int.TryParse(IntercomNumberSpinner.Value.ToString(), out spinnervalue)) + { + return; + } + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) { _globalSettings.SetClientSetting(GlobalSettingsKeys.VOXIC, !_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)); @@ -231,7 +235,7 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE } - if (isone) + if (spinnervalue == 1) { IntercomEnabled.IsEnabled = false; IntercomEnabled.Background = voxicDisabled; @@ -239,7 +243,14 @@ private void IntercomNumber_SpinnerChanged(object sender, RoutedPropertyChangedE else { IntercomEnabled.IsEnabled = true; - IntercomEnabled.Background = voxDisabled; + if (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC)) + { + IntercomEnabled.Background = voxEnabled; + } + else + { + IntercomEnabled.Background = voxDisabled; + } } var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo; From fe558b6c87d358d0c8c1f81bff4e60d81be1c2ef Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Tue, 7 Nov 2023 10:25:35 +0100 Subject: [PATCH 08/74] Intercom Upper limit to 1000 --- DCS-SR-Client/awacs-radios.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DCS-SR-Client/awacs-radios.json b/DCS-SR-Client/awacs-radios.json index de960b66..cfc1ef70 100644 --- a/DCS-SR-Client/awacs-radios.json +++ b/DCS-SR-Client/awacs-radios.json @@ -3,9 +3,9 @@ "enc": false, "encKey": 0, "encMode": 0, - "freqMax": 200.0, + "freqMax": 1000.0, "freqMin": 1.0, - "freq": 200.0, + "freq": 1000.0, "modulation": 2, "name": "INTERCOM", "secFreq": 0.0, From 007ff2b151522210e44e0cfdc3d9d48160edeb5a Mon Sep 17 00:00:00 2001 From: FPG Schiba Date: Tue, 7 Nov 2023 11:38:35 +0100 Subject: [PATCH 09/74] Fixed multiple Transitions This was only visually, so an easy fix :D --- DCS-SR-Client/Audio/Managers/AudioManager.cs | 3 +- DCS-SR-Client/DCS-SR-Client.csproj | 14 - DCS-SR-Client/Network/UDPVoiceHandler.cs | 57 +- .../AwacsRadioControlGroup.xaml.cs | 25 +- .../Utils/RadioControlGroup.xaml | 288 --------- .../Utils/RadioControlGroup.xaml.cs | 564 ------------------ .../Utils/TransponderPanel.xaml | 90 --- .../Utils/TransponderPanel.xaml.cs | 274 --------- 8 files changed, 45 insertions(+), 1270 deletions(-) delete mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/Utils/RadioControlGroup.xaml delete mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/Utils/RadioControlGroup.xaml.cs delete mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/Utils/TransponderPanel.xaml delete mode 100644 DCS-SR-Client/UI/RadioOverlayWindow/Utils/TransponderPanel.xaml.cs diff --git a/DCS-SR-Client/Audio/Managers/AudioManager.cs b/DCS-SR-Client/Audio/Managers/AudioManager.cs index 9254f020..40e381a4 100644 --- a/DCS-SR-Client/Audio/Managers/AudioManager.cs +++ b/DCS-SR-Client/Audio/Managers/AudioManager.cs @@ -343,11 +343,10 @@ private void WasapiCaptureOnDataAvailable(object sender, WaveInEventArgs e) try { //ready for the buffer shortly - //check for voice before any pre-processing bool voice = _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXR1) || _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC); - if (voice) // VOX Setting here + if (voice && !_udpVoiceHandler._ptt) // VOX Setting here { Buffer.BlockCopy(_pcmShort, 0, _pcmBytes, 0, _pcmBytes.Length); voice = DoesFrameContainSpeech(_pcmBytes, _pcmShort); diff --git a/DCS-SR-Client/DCS-SR-Client.csproj b/DCS-SR-Client/DCS-SR-Client.csproj index 24acd7ff..70e48493 100644 --- a/DCS-SR-Client/DCS-SR-Client.csproj +++ b/DCS-SR-Client/DCS-SR-Client.csproj @@ -341,9 +341,6 @@ RadioOverlayTwoVertical.xaml - - TransponderPanel.xaml - InputBindingControl.xaml @@ -378,9 +375,6 @@ IntercomControlGroup.xaml - - RadioControlGroup.xaml - @@ -436,10 +430,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -489,10 +479,6 @@ MSBuild:Compile Designer - - MSBuild:Compile - Designer - Designer MSBuild:Compile diff --git a/DCS-SR-Client/Network/UDPVoiceHandler.cs b/DCS-SR-Client/Network/UDPVoiceHandler.cs index b3aa05d3..ffa33668 100644 --- a/DCS-SR-Client/Network/UDPVoiceHandler.cs +++ b/DCS-SR-Client/Network/UDPVoiceHandler.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Documents; using System.Windows.Threading; using Ciribob.DCS.SimpleRadio.Standalone.Client.Audio.Managers; using Ciribob.DCS.SimpleRadio.Standalone.Client.Settings; @@ -55,7 +56,7 @@ internal class UdpVoiceHandler private ulong _packetNumber = 1; - private volatile bool _ptt; + public volatile bool _ptt; private long _lastPTTPress; // to handle dodgy PTT - release time private long _firstPTTPress; // to delay start PTT time @@ -814,7 +815,7 @@ private int getCurrentSelected() else { return -1; } } - private List PTTPressed(out int sendingOn, bool voice) // voice -> Is bound to setting GlobalSettingsKeys.VOX and detecting voice + private List CheckVOXActivation(out int sendingOn, bool voice) { sendingOn = -1; if (_clientStateSingleton.InhibitTX.InhibitTX) @@ -827,16 +828,12 @@ private List PTTPressed(out int sendingOn, bool voice) // voic return new List(); } } - + var radioInfo = _clientStateSingleton.DcsPlayerRadioInfo; //If its a hot intercom and thats not the currently selected radio //this is special logic currently for the gazelle as it has a hot mic, but no way of knowing if you're transmitting from the module itself //so we have to figure out what you're transmitting on in SRS - if ((radioInfo.intercomHotMic // Hotmic Option is here - // && radioInfo.selected != 0 - && !_ptt - && !radioInfo.ptt) - || _intercomPtt) + if (!_ptt && !radioInfo.ptt && !_intercomPtt && (_globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXR1) || _globalSettings.GetClientSettingBool(GlobalSettingsKeys.VOXIC))) { // Use this for VOX into the selected Channel: _clientStateSingleton.DcsPlayerRadioInfo.selected var currentSelected = getCurrentSelected(); // Change this -> If setting for specific Flick-Back Radio @@ -847,10 +844,7 @@ private List PTTPressed(out int sendingOn, bool voice) // voic var currentlySelectedRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[currentSelected]; if (currentlySelectedRadio != null && currentlySelectedRadio.modulation != - RadioInformation.Modulation.DISABLED - && (currentlySelectedRadio.freq > 100 || - currentlySelectedRadio.modulation == - RadioInformation.Modulation.INTERCOM)) + RadioInformation.Modulation.DISABLED) { selectedRadios.Add(currentlySelectedRadio); // Return not only Intercom as transmitting radio sendingOn = currentSelected; @@ -865,7 +859,7 @@ private List PTTPressed(out int sendingOn, bool voice) // voic _lastVOXSend = DateTime.Now.Ticks; return selectedRadios; } - else if (radioInfo.intercomHotMic && !voice) + if (radioInfo.intercomHotMic && !voice) { TimeSpan lastVOXSendDiff = new TimeSpan(DateTime.Now.Ticks - _lastVOXSend); if (lastVOXSendDiff.TotalMilliseconds < _globalSettings.GetClientSettingInt(GlobalSettingsKeys.VOXMinimumTime)) @@ -877,13 +871,19 @@ private List PTTPressed(out int sendingOn, bool voice) // voic return new List(); } - else - { - return selectedRadios; - } + + return selectedRadios; } } + return new List(); + } + + private List CheckPTTActivation(out int sendingOn) + { + sendingOn = -1; + + var radioInfo = _clientStateSingleton.DcsPlayerRadioInfo; var transmittingRadios = new List(); if (_ptt || _clientStateSingleton.DcsPlayerRadioInfo.ptt) { @@ -941,6 +941,22 @@ private List PTTPressed(out int sendingOn, bool voice) // voic return transmittingRadios; } + + + + private List PTTPressed(out int sendingOn, bool voice) + { + sendingOn = -1; + List pttRadios = CheckPTTActivation(out sendingOn); + if (pttRadios.Count > 0) + { + return pttRadios; + } + + List voxRadios = CheckVOXActivation(out sendingOn, voice); + + return voxRadios; + } public ClientAudio Send(byte[] bytes, int len, bool voice) { @@ -1006,6 +1022,7 @@ public ClientAudio Send(byte[] bytes, int len, bool voice) }; var encodedUdpVoicePacket = udpVoicePacket.EncodePacket(); + // sending UDP Package here: _listener.Send(encodedUdpVoicePacket, encodedUdpVoicePacket.Length, new IPEndPoint(_address, _port)); var currentlySelectedRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[sendingOn]; @@ -1014,6 +1031,7 @@ public ClientAudio Send(byte[] bytes, int len, bool voice) if (currentlySelectedRadio != null && (!_clientStateSingleton.RadioSendingState.IsSending || _clientStateSingleton.RadioSendingState.SendingOn != sendingOn)) { + // Transmission sound again here: _audioManager.PlaySoundEffectStartTransmit(sendingOn, currentlySelectedRadio.enc && (currentlySelectedRadio.encKey > 0), currentlySelectedRadio.volume, currentlySelectedRadio.modulation); @@ -1029,7 +1047,8 @@ public ClientAudio Send(byte[] bytes, int len, bool voice) var send = new ClientAudio() { - Frequency = frequencies[0], Modulation = modulations[0], + Frequency = frequencies[0], + Modulation = modulations[0], EncodedAudio = bytes, Encryption = 0, Volume = 1, @@ -1059,7 +1078,7 @@ public ClientAudio Send(byte[] bytes, int len, bool voice) if (_clientStateSingleton.RadioSendingState.SendingOn >= 0) { var radio = _clientStateSingleton.DcsPlayerRadioInfo.radios[_clientStateSingleton.RadioSendingState.SendingOn]; - + // Transmitting sound is here: _audioManager.PlaySoundEffectEndTransmit(_clientStateSingleton.RadioSendingState.SendingOn, radio.volume, radio.modulation); } } diff --git a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsRadioControlGroup.xaml.cs b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsRadioControlGroup.xaml.cs index 20d2a22b..d4e6d85d 100644 --- a/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsRadioControlGroup.xaml.cs +++ b/DCS-SR-Client/UI/AwacsRadioOverlayWindow/AwacsRadioControlGroup.xaml.cs @@ -22,7 +22,7 @@ namespace Ciribob.DCS.SimpleRadio.Standalone.Client.UI.AwacsRadioOverlayWindow public partial class RadioControlGroup : UserControl { private const double MHz = 1000000; - private const int MaxSimultaneousTransmissions = 3; + private const int MaxSimultaneousTransmissions = 1; private bool _dragging; private readonly ClientStateSingleton _clientStateSingleton = ClientStateSingleton.Instance; private readonly ConnectedClientsSingleton _connectClientsSingleton = ConnectedClientsSingleton.Instance; @@ -295,6 +295,7 @@ internal void RepaintRadioStatus() if (transmitting.IsSending) { + Console.WriteLine(currentRadio.name + " (" + RadioId + ") Sending On: " + transmitting.SendingOn); if (transmitting.SendingOn == RadioId) { RadioActive.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#96FF6D")); @@ -303,6 +304,10 @@ internal void RepaintRadioStatus() { RadioActive.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4F86FF")); } + else + { + RadioActive.Fill = RadioId == dcsPlayerRadioInfo.selected ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Orange); + } } else { @@ -591,23 +596,5 @@ private void EncryptionKeySpinner_OnValueChanged(object sender, RoutedPropertyCh if (EncryptionKeySpinner?.Value != null) RadioHelper.SetEncryptionKey(RadioId, (byte) EncryptionKeySpinner.Value); } - - private void ToggleSimultaneousTransmissionButton_Click(object sender, RoutedEventArgs e) - { - if (_clientStateSingleton.DcsPlayerRadioInfo != null && _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmission) - { - var currentRadio = RadioHelper.GetRadio(RadioId); - - if (currentRadio != null) - { - currentRadio.simul = !currentRadio.simul; - } - } - } - - private void RetransmitClick(object sender, RoutedEventArgs e) - { - RadioHelper.ToggleRetransmit(RadioId); - } } } \ No newline at end of file diff --git a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/RadioControlGroup.xaml b/DCS-SR-Client/UI/RadioOverlayWindow/Utils/RadioControlGroup.xaml deleted file mode 100644 index 692b159f..00000000 --- a/DCS-SR-Client/UI/RadioOverlayWindow/Utils/RadioControlGroup.xaml +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - - - - - - - - - - - -