Disable bootloader ComboBox if selected device in fastboot mode

This commit is contained in:
mashed-potatoes 2020-06-28 20:21:28 +05:00
parent dccfa80598
commit 54df618fd0
2 changed files with 19 additions and 4 deletions

View file

@ -9,7 +9,7 @@
<StackPanel Style="{x:Null}"> <StackPanel Style="{x:Null}">
<StackPanel> <StackPanel>
<Label Content="Target device" /> <Label Content="Target device" />
<ComboBox Name="deviceList" /> <ComboBox Name="deviceList" SelectionChanged="DeviceList_SelectionChanged" />
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<Label Content="Bootloader" /> <Label Content="Bootloader" />

View file

@ -26,6 +26,8 @@ namespace PotatoNV_next.Controls
public delegate void FormHandler(FormEventArgs formEventArgs); public delegate void FormHandler(FormEventArgs formEventArgs);
public static event FormHandler OnFormSubmit; public static event FormHandler OnFormSubmit;
private bool IsSelectedDeviceInFastbootMode;
public NVForm() public NVForm()
{ {
InitializeComponent(); InitializeComponent();
@ -42,7 +44,7 @@ namespace PotatoNV_next.Controls
public string UnlockCode { get; set; } public string UnlockCode { get; set; }
public string SerialNumber { get; set; } public string SerialNumber { get; set; }
public bool FBLOCK { get; set; } public bool FBLOCK { get; set; }
public Bootloader bootloader { get; set; } = null; public Bootloader Bootloader { get; set; } = null;
} }
private void Assert(bool result, string message) private void Assert(bool result, string message)
@ -115,9 +117,8 @@ namespace PotatoNV_next.Controls
} }
Log.Success("Form is valid, starting"); Log.Success("Form is valid, starting");
IsEnabled = false;
//OnFormSubmit(); IsEnabled = false;
} }
private void NVForm_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) private void NVForm_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
@ -130,5 +131,19 @@ namespace PotatoNV_next.Controls
disableFBLOCK.IsEnabled = IsEnabled; disableFBLOCK.IsEnabled = IsEnabled;
startButton.IsEnabled = IsEnabled; startButton.IsEnabled = IsEnabled;
} }
private void DeviceList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (deviceList.SelectedIndex == -1)
{
IsSelectedDeviceInFastbootMode = false;
}
else
{
IsSelectedDeviceInFastbootMode = deviceList.SelectedItem.ToString().StartsWith("Fastboot");
}
deviceBootloader.IsEnabled = !IsSelectedDeviceInFastbootMode;
}
} }
} }