Skip to content

Commit

Permalink
#449 Keyemulator generic radio context menu not opening (#450)
Browse files Browse the repository at this point in the history
* also changed all PanelUserControls OnLoaded to properly set UserControlLoaded and not in Init().
  • Loading branch information
jdahlblom authored Jan 29, 2024
1 parent ced0542 commit 7049097
Show file tree
Hide file tree
Showing 40 changed files with 51 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Source/ClassLibraryCommon/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static IEnumerable<T> FindVisualChildren<T>(DependencyObject dependencyOb
{
if (dependencyObject != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dependencyObject); i++)
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(dependencyObject); i++)
{
var child = VisualTreeHelper.GetChild(dependencyObject, i);
if (child is T o)
Expand Down
1 change: 1 addition & 0 deletions Source/ClassLibraryCommon/DarkMode.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ public void AddPanel(HIDSkeleton hidSkeleton, DCSAircraft dcsAircraft, ref List<
dcsAircraft.UseGenericRadio = true;
AppEventHandler.PanelEvent(this, hidSkeleton.HIDInstance, hidSkeleton, PanelEventType.Created);
}

break;
}
}
Expand Down
11 changes: 7 additions & 4 deletions Source/DCSFlightpanels/DCSFlightpanels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</Authors>
<PackageId>DCSFlightpanels (DCSFP)</PackageId>
<Version>1.0.0</Version>
<AssemblyVersion>4.11.6</AssemblyVersion>
<AssemblyVersion>4.11.7</AssemblyVersion>
<FileVersion>
</FileVersion>
<ApplicationIcon>Images\UI\flightpanels02_8Rc_icon.ico</ApplicationIcon>
Expand Down Expand Up @@ -69,6 +69,12 @@
<ItemGroup>
<Resource Include="Images\*.*" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Resources\**" />
<EmbeddedResource Remove="Resources\**" />
<None Remove="Resources\**" />
<Page Remove="Resources\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibraryCommon\ClassLibraryCommon.csproj" />
<ProjectReference Include="..\DCS-BIOS\DCS-BIOS.csproj" />
Expand Down Expand Up @@ -290,7 +296,4 @@
<ItemGroup>
<None Include="C:\dev\GitHub\DCSFlightpanels\Source\DCSFlightpanels\.editorconfig" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private void BackLitPanelUserControl_OnLoaded(object sender, RoutedEventArgs e)

SetContextMenuClickHandlers();
SetAllBlack();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private void SwitchPanelPZ55UserControl_OnLoaded(object sender, RoutedEventArgs
{
DarkMode.SetFrameworkElementDarkMode(this);
SetTextBoxBills();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private void MultiPanelUserControl_OnLoaded(object sender, RoutedEventArgs e)
DarkMode.SetFrameworkElementDarkMode(this);
ComboBoxLcdKnobSensitivity.SelectedValue = Settings.Default.PZ70LcdKnobSensitivity;
SetTextBoxBills();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ private void SwitchPanelPZ55UserControl_OnLoaded(object sender, RoutedEventArgs
}
}
}
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ private void TPMPanelUserControl_OnLoaded(object sender, RoutedEventArgs e)
DarkMode.SetFrameworkElementDarkMode(this);
HidePositionIndicators();
SetTextBoxBills();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public override void Init()

private void RadioPanelPZ69UserControlEmulator_OnLoaded(object sender, RoutedEventArgs e)
{
if (!UserControlLoaded)
if (!UserControlLoaded || !TextBoxBillsSet)
{
DarkMode.SetFrameworkElementDarkMode(this);
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivityEmulator;
SetTextBoxBills();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ public override void Init()

private void RadioPanelPZ69UserControlGeneric_OnLoaded(object sender, RoutedEventArgs e)
{
if (!UserControlLoaded)
if (!UserControlLoaded || !TextBoxBillsSet)
{
DarkMode.SetFrameworkElementDarkMode(this);
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivityEmulator;
SetTextBoxBills();
SetButtonBills();
UserControlLoaded = true;
}
UserControlLoaded = true;
ShowGraphicConfiguration();
}

Expand Down Expand Up @@ -179,10 +179,8 @@ private void MouseDownFocusLogTextBox(object sender, MouseButtonEventArgs e)

private void SetTextBoxBills()
{
if (TextBoxBillsSet || !Common.FindVisualChildren<PZ69GenericTextBox>(this).Any())
{
return;
}
if (TextBoxBillsSet || !Common.FindVisualChildren<PZ69GenericTextBox>(this).Any()) return;

foreach (var textBox in Common.FindVisualChildren<PZ69GenericTextBox>(this))
{
if (textBox.Bill != null || textBox.Equals(TextBoxLogPZ69))
Expand All @@ -196,10 +194,8 @@ private void SetTextBoxBills()

private void SetButtonBills()
{
if (ButtonBillsSet)
{
return;
}
if (ButtonBillsSet) return;

ButtonUpperLeftLcd.Bill = new BillPZ69LCDButton(ButtonUpperLeftLcd);
ButtonLowerLeftLcd.Bill = new BillPZ69LCDButton(ButtonLowerLeftLcd);
ButtonUpperRightLcd.Bill = new BillPZ69LCDButton(ButtonUpperRightLcd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,9 +75,8 @@ private void RadioPanelPZ69UserControlA10C_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}

UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlA10C_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -78,8 +77,8 @@ private void RadioPanelPZ69UserControlAH64D_OnLoaded(object sender, RoutedEventA
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlAJS37_OnLoaded(object sender, RoutedEventA
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlAV8BNA_OnLoaded(object sender, RoutedEvent
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlBf109_OnLoaded(object sender, RoutedEventA
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlC101_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlF14B_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlF15E_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlF16C_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlF5E_OnLoaded(object sender, RoutedEventArg
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlF86F_OnLoaded(object sender, RoutedEventAr
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override void Init()
ComboBoxFreqKnobSensitivity.SelectedValue = Settings.Default.RadioFrequencyKnobSensitivity;
ComboBoxSyncOKDelayTimeout.SelectedValue = Settings.Default.SyncOKDelayTimeout;
_radioPanelPZ69.SyncOKDelayTimeout = int.Parse(ComboBoxSyncOKDelayTimeout.SelectedValue.ToString());
UserControlLoaded = true;
}
catch (Exception ex)
{
Expand All @@ -76,8 +75,8 @@ private void RadioPanelPZ69UserControlFA18C_OnLoaded(object sender, RoutedEventA
if (!UserControlLoaded)
{
DarkMode.SetFrameworkElementDarkMode(this);
UserControlLoaded = true;
}
UserControlLoaded = true;
}

public override GamingPanel GetGamingPanel()
Expand Down
Loading

0 comments on commit 7049097

Please sign in to comment.