mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Updated the DateCalculation narrator logic to use PropertyChangedCallbacks for the DateResultLabel and DateDiffAllUnitsResultLabel TextBlocks.
This commit is contained in:
parent
a342421603
commit
df7b3950be
5 changed files with 18 additions and 29 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
@ -57,7 +57,7 @@ namespace CalculatorApp::Common::Automation
|
|||
private:
|
||||
// Make CalculatorAnnouncement a friend class so it is the only
|
||||
// class that can access the private constructor.
|
||||
friend class CalculatorAnnouncement;
|
||||
friend ref class CalculatorAnnouncement;
|
||||
|
||||
NarratorAnnouncement(
|
||||
Platform::String^ announcement,
|
||||
|
@ -73,7 +73,7 @@ namespace CalculatorApp::Common::Automation
|
|||
|
||||
// CalculatorAnnouncement is intended to contain only static methods
|
||||
// that return announcements made for the Calculator app.
|
||||
class CalculatorAnnouncement
|
||||
public ref class CalculatorAnnouncement sealed
|
||||
{
|
||||
public:
|
||||
static NarratorAnnouncement^ GetDisplayUpdatedAnnouncement(Platform::String^ announcement);
|
||||
|
@ -90,5 +90,9 @@ namespace CalculatorApp::Common::Automation
|
|||
static NarratorAnnouncement^ GetUpdateCurrencyRatesAnnouncement(Platform::String^ announcement);
|
||||
|
||||
static NarratorAnnouncement^ GetDisplayCopiedAnnouncement(Platform::String^ announcement);
|
||||
|
||||
private:
|
||||
CalculatorAnnouncement() { }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<UserControl x:Class="CalculatorApp.DateCalculator"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:automation="using:CalculatorApp.Common.Automation"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
xmlns:converters="using:CalculatorApp.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
|
@ -428,7 +429,6 @@
|
|||
Style="{StaticResource DateCalculation_CalendarPickerStyle}"
|
||||
AutomationProperties.LabeledBy="{x:Bind Date_FromLabel}"
|
||||
CalendarViewStyle="{StaticResource DateCalculation_CalendarViewStyle}"
|
||||
Closed="CalendarFlyoutClosed"
|
||||
DateChanged="FromDate_DateChanged"/>
|
||||
|
||||
<!-- To Date -->
|
||||
|
@ -444,7 +444,6 @@
|
|||
Style="{StaticResource DateCalculation_CalendarPickerStyle}"
|
||||
AutomationProperties.LabeledBy="{x:Bind Date_ToLabel}"
|
||||
CalendarViewStyle="{StaticResource DateCalculation_CalendarViewStyle}"
|
||||
Closed="CalendarFlyoutClosed"
|
||||
DateChanged="ToDate_DateChanged"/>
|
||||
|
||||
<!-- Difference Result -->
|
||||
|
@ -502,7 +501,6 @@
|
|||
Style="{StaticResource DateCalculation_CalendarPickerStyle}"
|
||||
AutomationProperties.LabeledBy="{x:Bind AddSubtract_Date_FromLabel}"
|
||||
CalendarViewStyle="{StaticResource DateCalculation_CalendarViewStyle}"
|
||||
Closed="CalendarFlyoutClosed"
|
||||
DateChanged="AddSubtract_DateChanged"/>
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
|
@ -551,7 +549,6 @@
|
|||
Grid.Row="1"
|
||||
MinWidth="84"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=YearsLabel}"
|
||||
DropDownClosed="OffsetDropDownClosed"
|
||||
ItemsSource="{Binding OffsetValues, Mode=OneTime}"
|
||||
SelectedIndex="{Binding YearsOffset, Mode=TwoWay}"
|
||||
SelectionChanged="OffsetValue_Changed"/>
|
||||
|
@ -567,7 +564,6 @@
|
|||
MinWidth="84"
|
||||
Margin="12,0,12,0"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=MonthsLabel}"
|
||||
DropDownClosed="OffsetDropDownClosed"
|
||||
ItemsSource="{Binding OffsetValues, Mode=OneTime}"
|
||||
SelectedIndex="{Binding MonthsOffset, Mode=TwoWay}"
|
||||
SelectionChanged="OffsetValue_Changed"/>
|
||||
|
@ -582,7 +578,6 @@
|
|||
Grid.Column="2"
|
||||
MinWidth="84"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=DaysLabel}"
|
||||
DropDownClosed="OffsetDropDownClosed"
|
||||
ItemsSource="{Binding OffsetValues, Mode=OneTime}"
|
||||
SelectedIndex="{Binding DaysOffset, Mode=TwoWay}"
|
||||
SelectionChanged="OffsetValue_Changed"/>
|
||||
|
|
|
@ -182,6 +182,10 @@ void DateCalculator::DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_
|
|||
{
|
||||
FindName("AddSubtractDateGrid");
|
||||
DateCalculationOption->SelectionChanged -= m_dateCalcOptionChangedEventToken;
|
||||
|
||||
DateResultLabel->RegisterPropertyChangedCallback(TextBlock::TextProperty, ref new DependencyPropertyChangedCallback(this, &DateCalculator::OnDateResultLabelChanged));
|
||||
DateDiffAllUnitsResultLabel->RegisterPropertyChangedCallback(TextBlock::TextProperty, ref new DependencyPropertyChangedCallback(this, &DateCalculator::OnDateResultLabelChanged));
|
||||
|
||||
}
|
||||
|
||||
void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
|
@ -207,20 +211,8 @@ void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::Cale
|
|||
calendarDatePicker->IsCalendarOpen = false;
|
||||
}
|
||||
|
||||
void DateCalculator::OffsetDropDownClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void DateCalculator::OnDateResultLabelChanged(Windows::UI::Xaml::DependencyObject^ sender, Windows::UI::Xaml::DependencyProperty^ dp)
|
||||
{
|
||||
RaiseLiveRegionChangedAutomationEvent(false);
|
||||
}
|
||||
|
||||
void DateCalculator::CalendarFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
RaiseLiveRegionChangedAutomationEvent(dateCalcViewModel->IsDateDiffMode);
|
||||
}
|
||||
|
||||
void DateCalculator::RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode)
|
||||
{
|
||||
TextBlock^ resultTextBlock = (isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel);
|
||||
String^ automationName = AutomationProperties::GetName(resultTextBlock);
|
||||
TextBlockAutomationPeer::FromElement(resultTextBlock)->RaiseAutomationEvent(AutomationEvents::LiveRegionChanged);
|
||||
String^ automationName = AutomationProperties::GetName(sender);
|
||||
TextBlockAutomationPeer::FromElement((TextBlock^)sender)->RaiseAutomationEvent(AutomationEvents::LiveRegionChanged);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//
|
||||
|
@ -39,9 +39,7 @@ namespace CalculatorApp
|
|||
void DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
void AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ calendarDatePicker, Windows::Foundation::DateTime dateTime);
|
||||
void OffsetDropDownClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void CalendarFlyoutClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
|
||||
void OnDateResultLabelChanged(Windows::UI::Xaml::DependencyObject ^ sender, Windows::UI::Xaml::DependencyProperty ^ dp);
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue