diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index 5dbd92b0..3d27bd36 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -2778,11 +2778,11 @@ {Locked}The Octal button - There’s no history yet + There’s no history yet. The text that shows as the header for the history list - There’s nothing saved in memory + There’s nothing saved in memory. The text that shows as the header for the memory list diff --git a/src/Calculator/Views/Calculator.xaml b/src/Calculator/Views/Calculator.xaml index 933052a9..a943f167 100644 --- a/src/Calculator/Views/Calculator.xaml +++ b/src/Calculator/Views/Calculator.xaml @@ -1374,8 +1374,7 @@ + AutomationProperties.Name="{x:Bind HistoryPivotItemUiaName, Mode=OneWay}"> + AutomationProperties.Name="{x:Bind MemoryPivotItemUiaName, Mode=OneWay}"> (string)GetValue(HistoryPivotItemUiaNameProperty); + set => SetValue(HistoryPivotItemUiaNameProperty, value); + } + + // Using a DependencyProperty as the backing store for HistoryPivotItemUiaName. This enables animation, styling, binding, etc... + public static readonly DependencyProperty HistoryPivotItemUiaNameProperty = + DependencyProperty.Register(nameof(HistoryPivotItemUiaName), typeof(string), typeof(Calculator), new PropertyMetadata(string.Empty)); + + public string MemoryPivotItemUiaName + { + get => (string)GetValue(MemoryPivotItemUiaNameProperty); + set => SetValue(MemoryPivotItemUiaNameProperty, value); + } + + // Using a DependencyProperty as the backing store for MemoryPivotItemUiaName. This enables animation, styling, binding, etc... + public static readonly DependencyProperty MemoryPivotItemUiaNameProperty = + DependencyProperty.Register(nameof(MemoryPivotItemUiaName), typeof(string), typeof(Calculator), new PropertyMetadata(string.Empty)); + public System.Windows.Input.ICommand HistoryButtonPressed { get @@ -159,6 +179,7 @@ namespace CalculatorApp { if (m_historyList == null) { + historyVM.PropertyChanged += (s, e) => UpdateHistoryState(); m_historyList = new HistoryList { DataContext = historyVM @@ -168,6 +189,7 @@ namespace CalculatorApp } } + public void UpdatePanelViewState() { UpdateHistoryState(); @@ -296,6 +318,7 @@ namespace CalculatorApp MemRecall.IsEnabled = false; ClearMemoryButton.IsEnabled = false; } + MemoryPivotItemUiaName = GetMemoryPivotItemUiaString(Model.IsMemoryEmpty); if (DockPanel.Visibility == Visibility.Visible) { @@ -328,6 +351,7 @@ namespace CalculatorApp { DockPivot.SelectedIndex = 0; } + HistoryPivotItemUiaName = GetHistoryPivotItemUiaString(Model.HistoryVM.ItemsCount == 0); } else { @@ -843,5 +867,19 @@ namespace CalculatorApp var mode = IsStandard ? ViewMode.Standard : IsScientific ? ViewMode.Scientific : ViewMode.Programmer; TraceLogger.GetInstance().LogVisualStateChanged(mode, e.NewState.Name, IsAlwaysOnTop); } + + private string GetMemoryPivotItemUiaString(bool isEmpty) + { + var loader = ResourceLoader.GetForCurrentView(); + var label = loader.GetString("MemoryLabel/Text"); + return isEmpty ? $"{loader.GetString("MemoryPaneEmpty/Text")} {label}" : label; + } + + private string GetHistoryPivotItemUiaString(bool isEmpty) + { + var loader = ResourceLoader.GetForCurrentView(); + var label = loader.GetString("HistoryLabel/Text"); + return isEmpty ? $"{loader.GetString("HistoryEmpty/Text")} {label}" : label; + } } }