feat: disable analysis buttons

capture button enabled when all combobox filled
combobox buttons enabled when can interact
This commit is contained in:
2026-08-10 09:43:33 +03:00
parent 68843c6f95
commit 19fe72bdc3
2 changed files with 25 additions and 0 deletions
@@ -839,6 +839,11 @@ public partial class AnalysisViewModel : ViewModelBase
/// </summary>
[ObservableProperty] public partial bool CanInteract { get; set; } = true;
/// <summary>
/// Можно ли снять изображение
/// </summary>
[ObservableProperty] public partial bool CanCapture { get; set; } = true;
/// <summary>
/// Создаётся ли новая запись
/// </summary>
@@ -995,6 +1000,9 @@ public partial class AnalysisViewModel : ViewModelBase
ea.PropertyName == nameof(MainSectionIsScrolling) ||
ea.PropertyName == nameof(InfoSectionIsScrolling))
UpdateCanInteract();
if (ea.PropertyName == nameof(BrandComboBoxSelectedIndex) ||
ea.PropertyName == nameof(SeparatorComboBoxSelectedIndex))
UpdateCanCapture();
if (ea.PropertyName == nameof(MenuSelectedIndex) ||
ea.PropertyName == nameof(InfoSectionCurrentIndex))
UpdateCharts?.Invoke(this, EventArgs.Empty);
@@ -1082,6 +1090,8 @@ public partial class AnalysisViewModel : ViewModelBase
// Вычисляем дополнительные свойства
Record.CalculateProperties();
CanCapture = false;
return;
}
@@ -1116,6 +1126,9 @@ public partial class AnalysisViewModel : ViewModelBase
IsNewRecord = true;
// Вычисляем дополнительные свойства
Record.CalculateProperties();
BrandComboBoxSelectedIndex = -1;
SeparatorComboBoxSelectedIndex = -1;
}
/// <summary>
@@ -1206,6 +1219,15 @@ public partial class AnalysisViewModel : ViewModelBase
CanInteract &= !InfoSectionIsScrolling;
}
/// <summary>
/// Обновить значение <see cref="CanCapture"/>
/// </summary>
private void UpdateCanCapture()
{
CanCapture = BrandComboBoxSelectedIndex >= 0;
CanCapture &= SeparatorComboBoxSelectedIndex >= 0;
}
// Команды управления меню
/// <summary>
/// Открыть меню
@@ -161,6 +161,7 @@
Grid.Row="3"
HorizontalAlignment="Stretch"
IsEditable="False"
IsEnabled="{Binding CanInteract}"
IsVisible="{Binding IsNewRecord}"
ItemsSource="{Binding SeparatorComboBoxItems}"
PlaceholderText="Тип сепаратора"
@@ -201,6 +202,7 @@
Grid.Row="3"
HorizontalAlignment="Stretch"
IsEditable="False"
IsEnabled="{Binding CanInteract}"
IsVisible="{Binding IsNewRecord}"
ItemsSource="{Binding BrandComboBoxItems}"
PlaceholderText="Марка пробы"
@@ -1091,6 +1093,7 @@
Command="{Binding CaptureImageCommand}"
Grid.Row="1"
HorizontalAlignment="Stretch"
IsEnabled="{Binding CanCapture}"
IsVisible="{Binding !ImagesIsCapturing}"
>
<TextBlock Text="Получить изображения"/>