mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-23 06:25:19 -07:00
Merge branch 'settings' of https://github.com/Chips1234/calculator into settings
This commit is contained in:
commit
1b388ea12d
14 changed files with 414 additions and 429 deletions
|
@ -29,7 +29,7 @@ jobs:
|
||||||
downloadDirectory: $(Build.SourcesDirectory)
|
downloadDirectory: $(Build.SourcesDirectory)
|
||||||
vstsFeed: WindowsInboxApps
|
vstsFeed: WindowsInboxApps
|
||||||
vstsFeedPackage: calculator-internals
|
vstsFeedPackage: calculator-internals
|
||||||
vstsPackageVersion: 0.0.45
|
vstsPackageVersion: 0.0.50
|
||||||
|
|
||||||
- template: ./build-single-architecture.yaml
|
- template: ./build-single-architecture.yaml
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -80,7 +80,7 @@ jobs:
|
||||||
downloadDirectory: $(Build.SourcesDirectory)
|
downloadDirectory: $(Build.SourcesDirectory)
|
||||||
vstsFeed: WindowsInboxApps
|
vstsFeed: WindowsInboxApps
|
||||||
vstsFeedPackage: calculator-internals
|
vstsFeedPackage: calculator-internals
|
||||||
vstsPackageVersion: 0.0.45
|
vstsPackageVersion: 0.0.50
|
||||||
|
|
||||||
- powershell: |
|
- powershell: |
|
||||||
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.
|
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.
|
||||||
|
|
|
@ -310,6 +310,9 @@ bool CopyPasteManager::ExpressionRegExMatch(
|
||||||
|
|
||||||
if (operandMatched)
|
if (operandMatched)
|
||||||
{
|
{
|
||||||
|
// Remember the sign of the operand
|
||||||
|
bool isNegativeValue = operand->Data()[0] == L'-';
|
||||||
|
|
||||||
// Remove characters that are valid in the expression but we do not want to include in length calculations
|
// Remove characters that are valid in the expression but we do not want to include in length calculations
|
||||||
// or which will break conversion from string-to-ULL.
|
// or which will break conversion from string-to-ULL.
|
||||||
auto operandValue = SanitizeOperand(operand);
|
auto operandValue = SanitizeOperand(operand);
|
||||||
|
@ -332,7 +335,11 @@ bool CopyPasteManager::ExpressionRegExMatch(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operandAsULL->Value > maxOperandLengthAndValue.maxValue)
|
// Calculate how much we exceed the maxValue.
|
||||||
|
// In case we exceed it for 1 only, and working with negative number - that's a corner case for max signed values (e.g. -32768)
|
||||||
|
bool isOverflow = operandAsULL->Value > maxOperandLengthAndValue.maxValue;
|
||||||
|
bool isMaxNegativeValue = operandAsULL->Value - 1 == maxOperandLengthAndValue.maxValue;
|
||||||
|
if (isOverflow && !(isNegativeValue && isMaxNegativeValue))
|
||||||
{
|
{
|
||||||
expMatched = false;
|
expMatched = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -63,6 +63,10 @@ namespace CalculatorApp::ViewModel
|
||||||
{
|
{
|
||||||
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
|
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
|
||||||
}
|
}
|
||||||
|
else if (graphEquation->AnalysisError == static_cast<int>(AnalysisErrorType::VariableIsNotX))
|
||||||
|
{
|
||||||
|
AnalysisErrorString = m_resourceLoader->GetString(L"KGFVariableIsNotX");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
NoError,
|
NoError,
|
||||||
AnalysisCouldNotBePerformed,
|
AnalysisCouldNotBePerformed,
|
||||||
AnalysisNotSupported
|
AnalysisNotSupported,
|
||||||
|
VariableIsNotX
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
using namespace Concurrency;
|
using namespace Concurrency;
|
||||||
using namespace Platform;
|
using namespace Platform;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::chrono;
|
using namespace chrono;
|
||||||
using namespace Windows::ApplicationModel::Resources;
|
using namespace Windows::ApplicationModel::Resources;
|
||||||
using namespace Windows::UI::Xaml;
|
using namespace Windows::UI::Xaml;
|
||||||
using namespace Windows::UI::Xaml::Controls;
|
using namespace Windows::UI::Xaml::Controls;
|
||||||
|
@ -32,30 +32,20 @@ DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyControlCho
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyShiftChord);
|
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyShiftChord);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyAltChord);
|
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyAltChord);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyControlShiftChord);
|
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyControlShiftChord);
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyInverseChord);
|
|
||||||
DEPENDENCY_PROPERTY_INITIALIZATION(KeyboardShortcutManager, VirtualKeyControlInverseChord);
|
|
||||||
|
|
||||||
static multimap<int, multimap<wchar_t, WeakReference>> s_CharacterForButtons;
|
map<int, multimap<wchar_t, WeakReference>> KeyboardShortcutManager::s_characterForButtons;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeysForButtons;
|
map<int, multimap<MyVirtualKey, WeakReference>> KeyboardShortcutManager::s_virtualKey;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyControlChordsForButtons;
|
map<int, multimap<MyVirtualKey, WeakReference>> KeyboardShortcutManager::s_VirtualKeyControlChordsForButtons;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyShiftChordsForButtons;
|
map<int, multimap<MyVirtualKey, WeakReference>> KeyboardShortcutManager::s_VirtualKeyShiftChordsForButtons;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyAltChordsForButtons;
|
map<int, multimap<MyVirtualKey, WeakReference>> KeyboardShortcutManager::s_VirtualKeyAltChordsForButtons;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyControlShiftChordsForButtons;
|
map<int, multimap<MyVirtualKey, WeakReference>> KeyboardShortcutManager::s_VirtualKeyControlShiftChordsForButtons;
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyInverseChordsForButtons;
|
|
||||||
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyControlInverseChordsForButtons;
|
|
||||||
|
|
||||||
static map<int, bool> s_ShiftKeyPressed;
|
map<int, bool> KeyboardShortcutManager::s_IsDropDownOpen;
|
||||||
static map<int, bool> s_ControlKeyPressed;
|
map<int, bool> KeyboardShortcutManager::s_ignoreNextEscape;
|
||||||
static map<int, bool> s_ShiftButtonChecked;
|
map<int, bool> KeyboardShortcutManager::s_keepIgnoringEscape;
|
||||||
static map<int, bool> s_IsDropDownOpen;
|
map<int, bool> KeyboardShortcutManager::s_fHonorShortcuts;
|
||||||
|
map<int, bool> KeyboardShortcutManager::s_fDisableShortcuts;
|
||||||
static map<int, bool> s_ignoreNextEscape;
|
reader_writer_lock KeyboardShortcutManager::s_keyboardShortcutMapLock;
|
||||||
static map<int, bool> s_keepIgnoringEscape;
|
|
||||||
static map<int, bool> s_fHonorShortcuts;
|
|
||||||
static map<int, bool> s_fDisableShortcuts;
|
|
||||||
static map<int, Flyout ^> s_AboutFlyout;
|
|
||||||
|
|
||||||
static reader_writer_lock s_keyboardShortcutMapLock;
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
||||||
|
@ -156,7 +146,7 @@ namespace CalculatorApp
|
||||||
auto toggle = dynamic_cast<ToggleButton ^>(button);
|
auto toggle = dynamic_cast<ToggleButton ^>(button);
|
||||||
if (toggle)
|
if (toggle)
|
||||||
{
|
{
|
||||||
toggle->IsChecked = !toggle->IsChecked->Value;
|
toggle->IsChecked = !(toggle->IsChecked != nullptr && toggle->IsChecked->Value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,9 +198,9 @@ void KeyboardShortcutManager::OnCharacterPropertyChanged(DependencyObject ^ targ
|
||||||
auto button = safe_cast<ButtonBase ^>(target);
|
auto button = safe_cast<ButtonBase ^>(target);
|
||||||
|
|
||||||
int viewId = Utils::GetWindowId();
|
int viewId = Utils::GetWindowId();
|
||||||
auto iterViewMap = s_CharacterForButtons.find(viewId);
|
auto iterViewMap = s_characterForButtons.find(viewId);
|
||||||
|
|
||||||
if (iterViewMap != s_CharacterForButtons.end())
|
if (iterViewMap != s_characterForButtons.end())
|
||||||
{
|
{
|
||||||
if (oldValue)
|
if (oldValue)
|
||||||
{
|
{
|
||||||
|
@ -222,26 +212,26 @@ void KeyboardShortcutManager::OnCharacterPropertyChanged(DependencyObject ^ targ
|
||||||
if (newValue == L".")
|
if (newValue == L".")
|
||||||
{
|
{
|
||||||
wchar_t decSep = LocalizationSettings::GetInstance().GetDecimalSeparator();
|
wchar_t decSep = LocalizationSettings::GetInstance().GetDecimalSeparator();
|
||||||
iterViewMap->second.insert(std::make_pair(decSep, WeakReference(button)));
|
iterViewMap->second.insert(make_pair(decSep, WeakReference(button)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue->Data()[0], WeakReference(button)));
|
iterViewMap->second.insert(make_pair(newValue->Data()[0], WeakReference(button)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_CharacterForButtons.insert(std::make_pair(viewId, std::multimap<wchar_t, WeakReference>()));
|
s_characterForButtons.insert(make_pair(viewId, multimap<wchar_t, WeakReference>()));
|
||||||
|
|
||||||
if (newValue == L".")
|
if (newValue == L".")
|
||||||
{
|
{
|
||||||
wchar_t decSep = LocalizationSettings::GetInstance().GetDecimalSeparator();
|
wchar_t decSep = LocalizationSettings::GetInstance().GetDecimalSeparator();
|
||||||
s_CharacterForButtons.find(viewId)->second.insert(std::make_pair(decSep, WeakReference(button)));
|
s_characterForButtons.find(viewId)->second.insert(make_pair(decSep, WeakReference(button)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_CharacterForButtons.find(viewId)->second.insert(std::make_pair(newValue->Data()[0], WeakReference(button)));
|
s_characterForButtons.find(viewId)->second.insert(make_pair(newValue->Data()[0], WeakReference(button)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,18 +244,18 @@ void KeyboardShortcutManager::OnVirtualKeyPropertyChanged(DependencyObject ^ tar
|
||||||
auto button = static_cast<ButtonBase ^>(target);
|
auto button = static_cast<ButtonBase ^>(target);
|
||||||
|
|
||||||
int viewId = Utils::GetWindowId();
|
int viewId = Utils::GetWindowId();
|
||||||
auto iterViewMap = s_VirtualKeysForButtons.find(viewId);
|
auto iterViewMap = s_virtualKey.find(viewId);
|
||||||
|
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (iterViewMap != s_VirtualKeysForButtons.end())
|
if (iterViewMap != s_virtualKey.end())
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(button)));
|
iterViewMap->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
// If the View Id is not already registered, then register it and make the entry
|
||||||
s_VirtualKeysForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_virtualKey.insert(make_pair(viewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
s_VirtualKeysForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(button)));
|
s_virtualKey.find(viewId)->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,13 +278,13 @@ void KeyboardShortcutManager::OnVirtualKeyControlChordPropertyChanged(Dependency
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (iterViewMap != s_VirtualKeyControlChordsForButtons.end())
|
if (iterViewMap != s_VirtualKeyControlChordsForButtons.end())
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(control)));
|
iterViewMap->second.insert(make_pair(newValue, WeakReference(control)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
// If the View Id is not already registered, then register it and make the entry
|
||||||
s_VirtualKeyControlChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyControlChordsForButtons.insert(make_pair(viewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
s_VirtualKeyControlChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(control)));
|
s_VirtualKeyControlChordsForButtons.find(viewId)->second.insert(make_pair(newValue, WeakReference(control)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,13 +301,13 @@ void KeyboardShortcutManager::OnVirtualKeyShiftChordPropertyChanged(DependencyOb
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (iterViewMap != s_VirtualKeyShiftChordsForButtons.end())
|
if (iterViewMap != s_VirtualKeyShiftChordsForButtons.end())
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(button)));
|
iterViewMap->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
// If the View Id is not already registered, then register it and make the entry
|
||||||
s_VirtualKeyShiftChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyShiftChordsForButtons.insert(make_pair(viewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
s_VirtualKeyShiftChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(button)));
|
s_VirtualKeyShiftChordsForButtons.find(viewId)->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,13 +324,13 @@ void KeyboardShortcutManager::OnVirtualKeyAltChordPropertyChanged(DependencyObje
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (iterViewMap != s_VirtualKeyAltChordsForButtons.end())
|
if (iterViewMap != s_VirtualKeyAltChordsForButtons.end())
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(navView)));
|
iterViewMap->second.insert(make_pair(newValue, WeakReference(navView)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
// If the View Id is not already registered, then register it and make the entry
|
||||||
s_VirtualKeyAltChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyAltChordsForButtons.insert(make_pair(viewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
s_VirtualKeyAltChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(navView)));
|
s_VirtualKeyAltChordsForButtons.find(viewId)->second.insert(make_pair(newValue, WeakReference(navView)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,59 +347,13 @@ void KeyboardShortcutManager::OnVirtualKeyControlShiftChordPropertyChanged(Depen
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (iterViewMap != s_VirtualKeyControlShiftChordsForButtons.end())
|
if (iterViewMap != s_VirtualKeyControlShiftChordsForButtons.end())
|
||||||
{
|
{
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(button)));
|
iterViewMap->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
// If the View Id is not already registered, then register it and make the entry
|
||||||
s_VirtualKeyControlShiftChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyControlShiftChordsForButtons.insert(make_pair(viewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(button)));
|
s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second.insert(make_pair(newValue, WeakReference(button)));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnVirtualKeyInverseChordPropertyChanged(DependencyObject ^ target, MyVirtualKey /*oldValue*/, MyVirtualKey newValue)
|
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto button = safe_cast<ButtonBase ^>(target);
|
|
||||||
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
auto iterViewMap = s_VirtualKeyInverseChordsForButtons.find(viewId);
|
|
||||||
|
|
||||||
// Check if the View Id has already been registered
|
|
||||||
if (iterViewMap != s_VirtualKeyInverseChordsForButtons.end())
|
|
||||||
{
|
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(button)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
|
||||||
s_VirtualKeyInverseChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
|
||||||
s_VirtualKeyInverseChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(button)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnVirtualKeyControlInverseChordPropertyChanged(DependencyObject ^ target, MyVirtualKey /*oldValue*/, MyVirtualKey newValue)
|
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto button = safe_cast<ButtonBase ^>(target);
|
|
||||||
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
auto iterViewMap = s_VirtualKeyControlInverseChordsForButtons.find(viewId);
|
|
||||||
|
|
||||||
// Check if the View Id has already been registered
|
|
||||||
if (iterViewMap != s_VirtualKeyControlInverseChordsForButtons.end())
|
|
||||||
{
|
|
||||||
iterViewMap->second.insert(std::make_pair(newValue, WeakReference(button)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If the View Id is not already registered, then register it and make the entry
|
|
||||||
s_VirtualKeyControlInverseChordsForButtons.insert(std::make_pair(viewId, std::multimap<MyVirtualKey, WeakReference>()));
|
|
||||||
s_VirtualKeyControlInverseChordsForButtons.find(viewId)->second.insert(std::make_pair(newValue, WeakReference(button)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,104 +365,90 @@ void KeyboardShortcutManager::OnCharacterReceivedHandler(CoreWindow ^ sender, Ch
|
||||||
int viewId = Utils::GetWindowId();
|
int viewId = Utils::GetWindowId();
|
||||||
auto currentHonorShortcuts = s_fHonorShortcuts.find(viewId);
|
auto currentHonorShortcuts = s_fHonorShortcuts.find(viewId);
|
||||||
|
|
||||||
if (currentHonorShortcuts != s_fHonorShortcuts.end())
|
if (currentHonorShortcuts == s_fHonorShortcuts.end() || currentHonorShortcuts->second)
|
||||||
{
|
|
||||||
if (currentHonorShortcuts->second)
|
|
||||||
{
|
{
|
||||||
wchar_t character = static_cast<wchar_t>(args->KeyCode);
|
wchar_t character = static_cast<wchar_t>(args->KeyCode);
|
||||||
auto buttons = s_CharacterForButtons.find(viewId)->second.equal_range(character);
|
auto buttons = s_characterForButtons.find(viewId)->second.equal_range(character);
|
||||||
RunFirstEnabledButtonCommand(buttons);
|
RunFirstEnabledButtonCommand(buttons);
|
||||||
|
|
||||||
LightUpButtons(buttons);
|
LightUpButtons(buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const std::multimap<MyVirtualKey, WeakReference>& GetCurrentKeyDictionary(MyVirtualKey key, bool altPressed = false)
|
const multimap<MyVirtualKey, WeakReference>* KeyboardShortcutManager::GetCurrentKeyDictionary(bool controlKeyPressed, bool shiftKeyPressed, bool altPressed)
|
||||||
{
|
{
|
||||||
int viewId = Utils::GetWindowId();
|
int viewId = Utils::GetWindowId();
|
||||||
|
|
||||||
|
if (controlKeyPressed)
|
||||||
|
{
|
||||||
if (altPressed)
|
if (altPressed)
|
||||||
{
|
{
|
||||||
return s_VirtualKeyAltChordsForButtons.find(viewId)->second;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else if (
|
else
|
||||||
(s_ShiftKeyPressed.find(viewId)->second)
|
|
||||||
&& ((Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down))
|
|
||||||
{
|
{
|
||||||
return s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second;
|
if (shiftKeyPressed)
|
||||||
|
{
|
||||||
|
return &s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second;
|
||||||
}
|
}
|
||||||
else if (s_ShiftKeyPressed.find(viewId)->second)
|
else
|
||||||
{
|
{
|
||||||
return s_VirtualKeyShiftChordsForButtons.find(viewId)->second;
|
return &s_VirtualKeyControlChordsForButtons.find(viewId)->second;
|
||||||
}
|
|
||||||
else if (s_ShiftButtonChecked.find(viewId)->second)
|
|
||||||
{
|
|
||||||
if ((Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down)
|
|
||||||
{
|
|
||||||
auto iterViewMap = s_VirtualKeyControlInverseChordsForButtons.find(viewId);
|
|
||||||
if (iterViewMap != s_VirtualKeyControlInverseChordsForButtons.end())
|
|
||||||
{
|
|
||||||
for (auto iterator = iterViewMap->second.begin(); iterator != iterViewMap->second.end(); ++iterator)
|
|
||||||
{
|
|
||||||
if (key == iterator->first)
|
|
||||||
{
|
|
||||||
return s_VirtualKeyControlInverseChordsForButtons.find(viewId)->second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto iterViewMap = s_VirtualKeyInverseChordsForButtons.find(viewId);
|
if (altPressed)
|
||||||
if (iterViewMap != s_VirtualKeyInverseChordsForButtons.end())
|
|
||||||
{
|
{
|
||||||
for (auto iterator = iterViewMap->second.begin(); iterator != iterViewMap->second.end(); ++iterator)
|
if (!shiftKeyPressed)
|
||||||
{
|
{
|
||||||
if (key == iterator->first)
|
return &s_VirtualKeyAltChordsForButtons.find(viewId)->second;
|
||||||
{
|
|
||||||
return s_VirtualKeyInverseChordsForButtons.find(viewId)->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down)
|
|
||||||
{
|
|
||||||
return s_VirtualKeyControlChordsForButtons.find(viewId)->second;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return s_VirtualKeysForButtons.find(viewId)->second;
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (shiftKeyPressed)
|
||||||
|
{
|
||||||
|
return &s_VirtualKeyShiftChordsForButtons.find(viewId)->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return &s_virtualKey.find(viewId)->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs ^ args)
|
void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs ^ args)
|
||||||
{
|
{
|
||||||
// If keyboard shortcuts like Ctrl+C or Ctrl+V are not handled
|
if (args->Handled)
|
||||||
if (!args->Handled)
|
|
||||||
{
|
|
||||||
auto key = args->VirtualKey;
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
|
|
||||||
auto currentControlKeyPressed = s_ControlKeyPressed.find(viewId);
|
|
||||||
auto currentShiftKeyPressed = s_ShiftKeyPressed.find(viewId);
|
|
||||||
|
|
||||||
bool isControlKeyPressed = (currentControlKeyPressed != s_ControlKeyPressed.end()) && (currentControlKeyPressed->second);
|
|
||||||
bool isShiftKeyPressed = (currentShiftKeyPressed != s_ShiftKeyPressed.end()) && (currentShiftKeyPressed->second);
|
|
||||||
|
|
||||||
// Handle Ctrl + E for DateCalculator
|
|
||||||
if ((key == VirtualKey::E) && isControlKeyPressed && !isShiftKeyPressed)
|
|
||||||
{
|
|
||||||
const auto& lookupMap = GetCurrentKeyDictionary(static_cast<MyVirtualKey>(key));
|
|
||||||
auto buttons = lookupMap.equal_range(static_cast<MyVirtualKey>(key));
|
|
||||||
auto navView = buttons.first->second.Resolve<MUXC::NavigationView>();
|
|
||||||
|
|
||||||
if (navView == nullptr)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto key = args->VirtualKey;
|
||||||
|
int viewId = Utils::GetWindowId();
|
||||||
|
|
||||||
|
const bool isControlKeyPressed = (Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down;
|
||||||
|
const bool isShiftKeyPressed = (Window::Current->CoreWindow->GetKeyState(VirtualKey::Shift) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down;
|
||||||
|
const bool isAltKeyPressed = (Window::Current->CoreWindow->GetKeyState(VirtualKey::Menu) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down;
|
||||||
|
|
||||||
|
// Handle Ctrl + E for DateCalculator
|
||||||
|
if ((key == VirtualKey::E) && isControlKeyPressed && !isShiftKeyPressed && !isAltKeyPressed)
|
||||||
|
{
|
||||||
|
const auto lookupMap = GetCurrentKeyDictionary(isControlKeyPressed, isShiftKeyPressed, false);
|
||||||
|
if (lookupMap == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto buttons = lookupMap->equal_range(static_cast<MyVirtualKey>(key));
|
||||||
|
auto navView = buttons.first->second.Resolve<MUXC::NavigationView>();
|
||||||
auto appViewModel = safe_cast<ApplicationViewModel ^>(navView->DataContext);
|
auto appViewModel = safe_cast<ApplicationViewModel ^>(navView->DataContext);
|
||||||
appViewModel->Mode = ViewMode::Date;
|
appViewModel->Mode = ViewMode::Date;
|
||||||
auto categoryName = AppResourceProvider::GetInstance()->GetResourceString(L"DateCalculationModeText");
|
auto categoryName = AppResourceProvider::GetInstance()->GetResourceString(L"DateCalculationModeText");
|
||||||
|
@ -530,10 +460,7 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentHonorShortcuts = s_fHonorShortcuts.find(viewId);
|
|
||||||
|
|
||||||
auto currentIgnoreNextEscape = s_ignoreNextEscape.find(viewId);
|
auto currentIgnoreNextEscape = s_ignoreNextEscape.find(viewId);
|
||||||
|
|
||||||
if (currentIgnoreNextEscape != s_ignoreNextEscape.end())
|
if (currentIgnoreNextEscape != s_ignoreNextEscape.end())
|
||||||
{
|
{
|
||||||
if (currentIgnoreNextEscape->second && key == VirtualKey::Escape)
|
if (currentIgnoreNextEscape->second && key == VirtualKey::Escape)
|
||||||
|
@ -551,47 +478,31 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == VirtualKey::Control)
|
auto currentHonorShortcuts = s_fHonorShortcuts.find(viewId);
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto currControlKeyPressed = s_ControlKeyPressed.find(viewId);
|
|
||||||
|
|
||||||
if (currControlKeyPressed != s_ControlKeyPressed.end())
|
|
||||||
{
|
|
||||||
s_ControlKeyPressed[viewId] = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (key == VirtualKey::Shift)
|
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto currShiftKeyPressed = s_ShiftKeyPressed.find(viewId);
|
|
||||||
|
|
||||||
if (currShiftKeyPressed != s_ShiftKeyPressed.end())
|
|
||||||
{
|
|
||||||
s_ShiftKeyPressed[viewId] = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentHonorShortcuts != s_fHonorShortcuts.end())
|
if (currentHonorShortcuts != s_fHonorShortcuts.end())
|
||||||
{
|
{
|
||||||
if (currentHonorShortcuts->second)
|
if (currentHonorShortcuts->second)
|
||||||
{
|
{
|
||||||
const auto myVirtualKey = static_cast<MyVirtualKey>(key);
|
const auto myVirtualKey = static_cast<MyVirtualKey>(key);
|
||||||
const auto& lookupMap = GetCurrentKeyDictionary(myVirtualKey);
|
const auto lookupMap = GetCurrentKeyDictionary(isControlKeyPressed, isShiftKeyPressed, isAltKeyPressed);
|
||||||
auto buttons = lookupMap.equal_range(myVirtualKey);
|
if (lookupMap == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto buttons = lookupMap->equal_range(myVirtualKey);
|
||||||
|
if (buttons.first == buttons.second)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RunFirstEnabledButtonCommand(buttons);
|
RunFirstEnabledButtonCommand(buttons);
|
||||||
|
|
||||||
// Ctrl+C and Ctrl+V shifts focus to some button because of which enter doesn't work after copy/paste. So don't shift focus if Ctrl+C or Ctrl+V
|
// Ctrl+C and Ctrl+V shifts focus to some button because of which enter doesn't work after copy/paste. So don't shift focus if Ctrl+C or Ctrl+V
|
||||||
// is pressed. When drop down is open, pressing escape shifts focus to clear button. So dont's shift focus if drop down is open. Ctrl+Insert is
|
// is pressed. When drop down is open, pressing escape shifts focus to clear button. So dont's shift focus if drop down is open. Ctrl+Insert is
|
||||||
// equivalent to Ctrl+C and Shift+Insert is equivalent to Ctrl+V
|
// equivalent to Ctrl+C and Shift+Insert is equivalent to Ctrl+V
|
||||||
auto currentIsDropDownOpen = s_IsDropDownOpen.find(viewId);
|
auto currentIsDropDownOpen = s_IsDropDownOpen.find(viewId);
|
||||||
if (currentIsDropDownOpen != s_IsDropDownOpen.end() && !currentIsDropDownOpen->second)
|
if (currentIsDropDownOpen == s_IsDropDownOpen.end() || !currentIsDropDownOpen->second)
|
||||||
{
|
{
|
||||||
// Do not Light Up Buttons when Ctrl+C, Ctrl+V, Ctrl+Insert or Shift+Insert is pressed
|
// Do not Light Up Buttons when Ctrl+C, Ctrl+V, Ctrl+Insert or Shift+Insert is pressed
|
||||||
if (!(isControlKeyPressed && (key == VirtualKey::C || key == VirtualKey::V || key == VirtualKey::Insert))
|
if (!(isControlKeyPressed && (key == VirtualKey::C || key == VirtualKey::V || key == VirtualKey::Insert))
|
||||||
|
@ -603,45 +514,13 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnKeyUpHandler(CoreWindow ^ sender, KeyEventArgs ^ args)
|
|
||||||
{
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
auto key = args->VirtualKey;
|
|
||||||
|
|
||||||
if (key == VirtualKey::Shift)
|
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto currentShiftKeyPressed = s_ShiftKeyPressed.find(viewId);
|
|
||||||
|
|
||||||
if (currentShiftKeyPressed != s_ShiftKeyPressed.end())
|
|
||||||
{
|
|
||||||
s_ShiftKeyPressed[viewId] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (key == VirtualKey::Control)
|
|
||||||
{
|
|
||||||
// Writer lock for the static maps
|
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
|
||||||
|
|
||||||
auto currControlKeyPressed = s_ControlKeyPressed.find(viewId);
|
|
||||||
|
|
||||||
if (currControlKeyPressed != s_ControlKeyPressed.end())
|
|
||||||
{
|
|
||||||
s_ControlKeyPressed[viewId] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher ^, AcceleratorKeyEventArgs ^ args)
|
void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher ^, AcceleratorKeyEventArgs ^ args)
|
||||||
{
|
{
|
||||||
if (args->KeyStatus.IsKeyReleased)
|
if (args->KeyStatus.IsKeyReleased)
|
||||||
{
|
{
|
||||||
auto key = args->VirtualKey;
|
auto key = args->VirtualKey;
|
||||||
bool altPressed = args->KeyStatus.IsMenuKeyDown;
|
const bool altPressed = args->KeyStatus.IsMenuKeyDown;
|
||||||
|
|
||||||
// If the Alt/Menu key is not pressed then we don't care about the key anymore
|
// If the Alt/Menu key is not pressed then we don't care about the key anymore
|
||||||
if (!altPressed)
|
if (!altPressed)
|
||||||
|
@ -649,15 +528,18 @@ void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher ^, Accele
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool controlKeyPressed = (Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down;
|
||||||
// Ctrl is pressed in addition to alt, this means Alt Gr is intended. do not navigate.
|
// Ctrl is pressed in addition to alt, this means Alt Gr is intended. do not navigate.
|
||||||
if ((static_cast<short>(Window::Current->CoreWindow->GetKeyState(VirtualKey::Control)) & static_cast<short>(CoreVirtualKeyStates::Down))
|
if (controlKeyPressed)
|
||||||
== static_cast<short>(CoreVirtualKeyStates::Down))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& lookupMap = GetCurrentKeyDictionary(static_cast<MyVirtualKey>(key), altPressed);
|
const bool shiftKeyPressed = (Window::Current->CoreWindow->GetKeyState(VirtualKey::Shift) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down;
|
||||||
auto listItems = lookupMap.equal_range(static_cast<MyVirtualKey>(key));
|
const auto lookupMap = GetCurrentKeyDictionary(controlKeyPressed, shiftKeyPressed, altPressed);
|
||||||
|
if (lookupMap != nullptr)
|
||||||
|
{
|
||||||
|
auto listItems = lookupMap->equal_range(static_cast<MyVirtualKey>(key));
|
||||||
for (auto listIterator = listItems.first; listIterator != listItems.second; ++listIterator)
|
for (auto listIterator = listItems.first; listIterator != listItems.second; ++listIterator)
|
||||||
{
|
{
|
||||||
auto item = listIterator->second.Resolve<MUXC::NavigationView>();
|
auto item = listIterator->second.Resolve<MUXC::NavigationView>();
|
||||||
|
@ -684,16 +566,6 @@ void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher ^, Accele
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->VirtualKey == VirtualKey::Escape)
|
|
||||||
{
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
auto iterViewMap = s_AboutFlyout.find(viewId);
|
|
||||||
|
|
||||||
if ((iterViewMap != s_AboutFlyout.end()) && (iterViewMap->second != nullptr))
|
|
||||||
{
|
|
||||||
iterViewMap->second->Hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,23 +575,12 @@ void KeyboardShortcutManager::Initialize()
|
||||||
coreWindow->CharacterReceived +=
|
coreWindow->CharacterReceived +=
|
||||||
ref new TypedEventHandler<CoreWindow ^, CharacterReceivedEventArgs ^>(&KeyboardShortcutManager::OnCharacterReceivedHandler);
|
ref new TypedEventHandler<CoreWindow ^, CharacterReceivedEventArgs ^>(&KeyboardShortcutManager::OnCharacterReceivedHandler);
|
||||||
coreWindow->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(&KeyboardShortcutManager::OnKeyDownHandler);
|
coreWindow->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(&KeyboardShortcutManager::OnKeyDownHandler);
|
||||||
coreWindow->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(&KeyboardShortcutManager::OnKeyUpHandler);
|
|
||||||
coreWindow->Dispatcher->AcceleratorKeyActivated +=
|
coreWindow->Dispatcher->AcceleratorKeyActivated +=
|
||||||
ref new TypedEventHandler<CoreDispatcher ^, AcceleratorKeyEventArgs ^>(&KeyboardShortcutManager::OnAcceleratorKeyActivated);
|
ref new TypedEventHandler<CoreDispatcher ^, AcceleratorKeyEventArgs ^>(&KeyboardShortcutManager::OnAcceleratorKeyActivated);
|
||||||
|
|
||||||
KeyboardShortcutManager::RegisterNewAppViewId();
|
KeyboardShortcutManager::RegisterNewAppViewId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardShortcutManager::ShiftButtonChecked(bool checked)
|
|
||||||
{
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
|
|
||||||
if (s_ShiftButtonChecked.find(viewId) != s_ShiftButtonChecked.end())
|
|
||||||
{
|
|
||||||
s_ShiftButtonChecked[viewId] = checked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::UpdateDropDownState(bool isOpen)
|
void KeyboardShortcutManager::UpdateDropDownState(bool isOpen)
|
||||||
{
|
{
|
||||||
int viewId = Utils::GetWindowId();
|
int viewId = Utils::GetWindowId();
|
||||||
|
@ -730,16 +591,6 @@ void KeyboardShortcutManager::UpdateDropDownState(bool isOpen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardShortcutManager::UpdateDropDownState(Flyout ^ aboutPageFlyout)
|
|
||||||
{
|
|
||||||
int viewId = Utils::GetWindowId();
|
|
||||||
|
|
||||||
if (s_AboutFlyout.find(viewId) != s_AboutFlyout.end())
|
|
||||||
{
|
|
||||||
s_AboutFlyout[viewId] = aboutPageFlyout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyboardShortcutManager::HonorShortcuts(bool allow)
|
void KeyboardShortcutManager::HonorShortcuts(bool allow)
|
||||||
{
|
{
|
||||||
// Writer lock for the static maps
|
// Writer lock for the static maps
|
||||||
|
@ -770,55 +621,41 @@ void KeyboardShortcutManager::RegisterNewAppViewId()
|
||||||
int appViewId = Utils::GetWindowId();
|
int appViewId = Utils::GetWindowId();
|
||||||
|
|
||||||
// Check if the View Id has already been registered
|
// Check if the View Id has already been registered
|
||||||
if (s_CharacterForButtons.find(appViewId) == s_CharacterForButtons.end())
|
if (s_characterForButtons.find(appViewId) == s_characterForButtons.end())
|
||||||
{
|
{
|
||||||
s_CharacterForButtons.insert(std::make_pair(appViewId, std::multimap<wchar_t, WeakReference>()));
|
s_characterForButtons.insert(make_pair(appViewId, multimap<wchar_t, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeysForButtons.find(appViewId) == s_VirtualKeysForButtons.end())
|
if (s_virtualKey.find(appViewId) == s_virtualKey.end())
|
||||||
{
|
{
|
||||||
s_VirtualKeysForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_virtualKey.insert(make_pair(appViewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeyControlChordsForButtons.find(appViewId) == s_VirtualKeyControlChordsForButtons.end())
|
if (s_VirtualKeyControlChordsForButtons.find(appViewId) == s_VirtualKeyControlChordsForButtons.end())
|
||||||
{
|
{
|
||||||
s_VirtualKeyControlChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyControlChordsForButtons.insert(make_pair(appViewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeyShiftChordsForButtons.find(appViewId) == s_VirtualKeyShiftChordsForButtons.end())
|
if (s_VirtualKeyShiftChordsForButtons.find(appViewId) == s_VirtualKeyShiftChordsForButtons.end())
|
||||||
{
|
{
|
||||||
s_VirtualKeyShiftChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyShiftChordsForButtons.insert(make_pair(appViewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeyAltChordsForButtons.find(appViewId) == s_VirtualKeyAltChordsForButtons.end())
|
if (s_VirtualKeyAltChordsForButtons.find(appViewId) == s_VirtualKeyAltChordsForButtons.end())
|
||||||
{
|
{
|
||||||
s_VirtualKeyAltChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyAltChordsForButtons.insert(make_pair(appViewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeyControlShiftChordsForButtons.find(appViewId) == s_VirtualKeyControlShiftChordsForButtons.end())
|
if (s_VirtualKeyControlShiftChordsForButtons.find(appViewId) == s_VirtualKeyControlShiftChordsForButtons.end())
|
||||||
{
|
{
|
||||||
s_VirtualKeyControlShiftChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
s_VirtualKeyControlShiftChordsForButtons.insert(make_pair(appViewId, multimap<MyVirtualKey, WeakReference>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_VirtualKeyInverseChordsForButtons.find(appViewId) == s_VirtualKeyInverseChordsForButtons.end())
|
|
||||||
{
|
|
||||||
s_VirtualKeyInverseChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s_VirtualKeyControlInverseChordsForButtons.find(appViewId) == s_VirtualKeyControlInverseChordsForButtons.end())
|
|
||||||
{
|
|
||||||
s_VirtualKeyControlInverseChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
s_ShiftKeyPressed[appViewId] = false;
|
|
||||||
s_ControlKeyPressed[appViewId] = false;
|
|
||||||
s_ShiftButtonChecked[appViewId] = false;
|
|
||||||
s_IsDropDownOpen[appViewId] = false;
|
s_IsDropDownOpen[appViewId] = false;
|
||||||
s_ignoreNextEscape[appViewId] = false;
|
s_ignoreNextEscape[appViewId] = false;
|
||||||
s_keepIgnoringEscape[appViewId] = false;
|
s_keepIgnoringEscape[appViewId] = false;
|
||||||
s_fHonorShortcuts[appViewId] = true;
|
s_fHonorShortcuts[appViewId] = true;
|
||||||
s_fDisableShortcuts[appViewId] = false;
|
s_fDisableShortcuts[appViewId] = false;
|
||||||
s_AboutFlyout[appViewId] = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardShortcutManager::OnWindowClosed(int viewId)
|
void KeyboardShortcutManager::OnWindowClosed(int viewId)
|
||||||
|
@ -826,25 +663,19 @@ void KeyboardShortcutManager::OnWindowClosed(int viewId)
|
||||||
// Writer lock for the static maps
|
// Writer lock for the static maps
|
||||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
||||||
|
|
||||||
s_CharacterForButtons.erase(viewId);
|
s_characterForButtons.erase(viewId);
|
||||||
|
|
||||||
s_VirtualKeysForButtons.erase(viewId);
|
s_virtualKey.erase(viewId);
|
||||||
s_VirtualKeyControlChordsForButtons.erase(viewId);
|
s_VirtualKeyControlChordsForButtons.erase(viewId);
|
||||||
s_VirtualKeyShiftChordsForButtons.erase(viewId);
|
s_VirtualKeyShiftChordsForButtons.erase(viewId);
|
||||||
s_VirtualKeyAltChordsForButtons.erase(viewId);
|
s_VirtualKeyAltChordsForButtons.erase(viewId);
|
||||||
s_VirtualKeyControlShiftChordsForButtons.erase(viewId);
|
s_VirtualKeyControlShiftChordsForButtons.erase(viewId);
|
||||||
s_VirtualKeyInverseChordsForButtons.erase(viewId);
|
|
||||||
s_VirtualKeyControlInverseChordsForButtons.erase(viewId);
|
|
||||||
|
|
||||||
s_ShiftKeyPressed.erase(viewId);
|
|
||||||
s_ControlKeyPressed.erase(viewId);
|
|
||||||
s_ShiftButtonChecked.erase(viewId);
|
|
||||||
s_IsDropDownOpen.erase(viewId);
|
s_IsDropDownOpen.erase(viewId);
|
||||||
s_ignoreNextEscape.erase(viewId);
|
s_ignoreNextEscape.erase(viewId);
|
||||||
s_keepIgnoringEscape.erase(viewId);
|
s_keepIgnoringEscape.erase(viewId);
|
||||||
s_fHonorShortcuts.erase(viewId);
|
s_fHonorShortcuts.erase(viewId);
|
||||||
s_fDisableShortcuts.erase(viewId);
|
s_fDisableShortcuts.erase(viewId);
|
||||||
s_AboutFlyout.erase(viewId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardShortcutManager::DisableShortcuts(bool disable)
|
void KeyboardShortcutManager::DisableShortcuts(bool disable)
|
||||||
|
|
|
@ -26,8 +26,6 @@ namespace CalculatorApp
|
||||||
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyShiftChord);
|
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyShiftChord);
|
||||||
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyAltChord);
|
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyAltChord);
|
||||||
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyControlShiftChord);
|
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyControlShiftChord);
|
||||||
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyInverseChord);
|
|
||||||
DEPENDENCY_PROPERTY_ATTACHED_WITH_CALLBACK(MyVirtualKey, VirtualKeyControlInverseChord);
|
|
||||||
|
|
||||||
internal :
|
internal :
|
||||||
|
|
||||||
|
@ -45,8 +43,6 @@ namespace CalculatorApp
|
||||||
static void HonorShortcuts(bool allow);
|
static void HonorShortcuts(bool allow);
|
||||||
static void DisableShortcuts(bool disable);
|
static void DisableShortcuts(bool disable);
|
||||||
static void UpdateDropDownState(bool);
|
static void UpdateDropDownState(bool);
|
||||||
static void ShiftButtonChecked(bool checked);
|
|
||||||
static void UpdateDropDownState(Windows::UI::Xaml::Controls::Flyout ^ aboutPageFlyout);
|
|
||||||
|
|
||||||
static void RegisterNewAppViewId();
|
static void RegisterNewAppViewId();
|
||||||
static void OnWindowClosed(int viewId);
|
static void OnWindowClosed(int viewId);
|
||||||
|
@ -60,11 +56,6 @@ namespace CalculatorApp
|
||||||
|
|
||||||
static void OnVirtualKeyShiftChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
static void OnVirtualKeyShiftChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
||||||
|
|
||||||
static void OnVirtualKeyInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
|
||||||
|
|
||||||
static void
|
|
||||||
OnVirtualKeyControlInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
|
||||||
|
|
||||||
static void OnVirtualKeyAltChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
static void OnVirtualKeyAltChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -72,8 +63,25 @@ namespace CalculatorApp
|
||||||
|
|
||||||
static void OnCharacterReceivedHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args);
|
static void OnCharacterReceivedHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args);
|
||||||
static void OnKeyDownHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
|
static void OnKeyDownHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
|
||||||
static void OnKeyUpHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);
|
|
||||||
static void OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^, Windows::UI::Core::AcceleratorKeyEventArgs ^ args);
|
static void OnAcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher ^, Windows::UI::Core::AcceleratorKeyEventArgs ^ args);
|
||||||
|
static const std::multimap<MyVirtualKey, Platform::WeakReference>*
|
||||||
|
KeyboardShortcutManager::GetCurrentKeyDictionary(bool controlKeyPressed, bool shiftKeyPressed, bool altPressed);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::map<int, std::multimap<wchar_t, Platform::WeakReference>> s_characterForButtons;
|
||||||
|
static std::map<int, std::multimap<MyVirtualKey, Platform::WeakReference>> s_virtualKey;
|
||||||
|
static std::map<int, std::multimap<MyVirtualKey, Platform::WeakReference>> s_VirtualKeyControlChordsForButtons;
|
||||||
|
static std::map<int, std::multimap<MyVirtualKey, Platform::WeakReference>> s_VirtualKeyShiftChordsForButtons;
|
||||||
|
static std::map<int, std::multimap<MyVirtualKey, Platform::WeakReference>> s_VirtualKeyAltChordsForButtons;
|
||||||
|
static std::map<int, std::multimap<MyVirtualKey, Platform::WeakReference>> s_VirtualKeyControlShiftChordsForButtons;
|
||||||
|
|
||||||
|
static std::map<int, bool> s_IsDropDownOpen;
|
||||||
|
static std::map<int, bool> s_ignoreNextEscape;
|
||||||
|
static std::map<int, bool> s_keepIgnoringEscape;
|
||||||
|
static std::map<int, bool> s_fHonorShortcuts;
|
||||||
|
static std::map<int, bool> s_fDisableShortcuts;
|
||||||
|
|
||||||
|
static Concurrency::reader_writer_lock s_keyboardShortcutMapLock;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,50 +481,26 @@
|
||||||
<value>O</value>
|
<value>O</value>
|
||||||
<comment>{Locked}The shortcut for the inverted cos button</comment>
|
<comment>{Locked}The shortcut for the inverted cos button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcosButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>O</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted cos button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invcoshButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
<data name="invcoshButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
||||||
<value>O</value>
|
<value>O</value>
|
||||||
<comment>{Locked}The shortcut for the inverted cosh button</comment>
|
<comment>{Locked}The shortcut for the inverted cosh button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcoshButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>O</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted cosh button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invsinButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
|
<data name="invsinButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
|
||||||
<value>S</value>
|
<value>S</value>
|
||||||
<comment>{Locked}This is the shortcut for the inverted sin button</comment>
|
<comment>{Locked}This is the shortcut for the inverted sin button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invsinButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>S</value>
|
|
||||||
<comment>{Locked}This is the shortcut for the inverted sin button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invsinhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
<data name="invsinhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
||||||
<value>S</value>
|
<value>S</value>
|
||||||
<comment>{Locked}This is the shortcut for the inverted sinh button</comment>
|
<comment>{Locked}This is the shortcut for the inverted sinh button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invsinhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>S</value>
|
|
||||||
<comment>{Locked}This is the shortcut for the inverted sinh button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invtanButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
|
<data name="invtanButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
|
||||||
<value>T</value>
|
<value>T</value>
|
||||||
<comment>{Locked}This is the shortcut for the inverted tan button. </comment>
|
<comment>{Locked}This is the shortcut for the inverted tan button. </comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invtanButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>T</value>
|
|
||||||
<comment>{Locked}This is the shortcut for the inverted tan button. </comment>
|
|
||||||
</data>
|
|
||||||
<data name="invtanhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
<data name="invtanhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
||||||
<value>T</value>
|
<value>T</value>
|
||||||
<comment>{Locked}This is the shortcut for the inverted tanh button</comment>
|
<comment>{Locked}This is the shortcut for the inverted tanh button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invtanhButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>T</value>
|
|
||||||
<comment>{Locked}This is the shortcut for the inverted tanh button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="powerOfEButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlChord" xml:space="preserve">
|
<data name="powerOfEButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlChord" xml:space="preserve">
|
||||||
<value>N</value>
|
<value>N</value>
|
||||||
<comment>{Locked}This is the shortcut for the power x button.</comment>
|
<comment>{Locked}This is the shortcut for the power x button.</comment>
|
||||||
|
@ -3555,10 +3531,6 @@
|
||||||
<value>U</value>
|
<value>U</value>
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invsecButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>U</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invsechButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="invsechButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Hyperbolic Arc Secant</value>
|
<value>Hyperbolic Arc Secant</value>
|
||||||
<comment>Screen reader prompt for the Calculator button arc sec in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button arc sec in the scientific flyout keypad</comment>
|
||||||
|
@ -3567,10 +3539,6 @@
|
||||||
<value>U</value>
|
<value>U</value>
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invsechButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>U</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="cscButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="cscButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Cosecant</value>
|
<value>Cosecant</value>
|
||||||
<comment>Screen reader prompt for the Calculator button csc in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button csc in the scientific flyout keypad</comment>
|
||||||
|
@ -3591,14 +3559,6 @@
|
||||||
<value>Arc Cosecant</value>
|
<value>Arc Cosecant</value>
|
||||||
<comment>Screen reader prompt for the Calculator button arc csc in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button arc csc in the scientific flyout keypad</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcscButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
|
|
||||||
<value>I</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invcscButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>I</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invcschButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="invcschButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Hyperbolic Arc Cosecant</value>
|
<value>Hyperbolic Arc Cosecant</value>
|
||||||
<comment>Screen reader prompt for the Calculator button arc csc in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button arc csc in the scientific flyout keypad</comment>
|
||||||
|
@ -3607,10 +3567,6 @@
|
||||||
<value>I</value>
|
<value>I</value>
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcschButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>I</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="cotButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="cotButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Cotangent</value>
|
<value>Cotangent</value>
|
||||||
<comment>Screen reader prompt for the Calculator button cot in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button cot in the scientific flyout keypad</comment>
|
||||||
|
@ -3635,18 +3591,10 @@
|
||||||
<value>J</value>
|
<value>J</value>
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcotButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyInverseChord" xml:space="preserve">
|
|
||||||
<value>J</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sec button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invcothButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="invcothButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Hyperbolic Arc Cotangent</value>
|
<value>Hyperbolic Arc Cotangent</value>
|
||||||
<comment>Screen reader prompt for the Calculator button arc coth in the scientific flyout keypad</comment>
|
<comment>Screen reader prompt for the Calculator button arc coth in the scientific flyout keypad</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="invcothButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlInverseChord" xml:space="preserve">
|
|
||||||
<value>J</value>
|
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
|
||||||
</data>
|
|
||||||
<data name="invcothButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
<data name="invcothButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlShiftChord" xml:space="preserve">
|
||||||
<value>J</value>
|
<value>J</value>
|
||||||
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
<comment>{Locked}The shortcut for the inverted sech button</comment>
|
||||||
|
@ -4039,6 +3987,10 @@
|
||||||
<value>Analysis is not supported for this function.</value>
|
<value>Analysis is not supported for this function.</value>
|
||||||
<comment>Error displayed when graph analysis is not supported or had an error.</comment>
|
<comment>Error displayed when graph analysis is not supported or had an error.</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="KGFVariableIsNotX" xml:space="preserve">
|
||||||
|
<value>Analysis is only supported for functions in the f(x) format. Example: y=x</value>
|
||||||
|
<comment>Error displayed when graph analysis detects the function format is not f(x).</comment>
|
||||||
|
</data>
|
||||||
<data name="Maxima" xml:space="preserve">
|
<data name="Maxima" xml:space="preserve">
|
||||||
<value>Maxima</value>
|
<value>Maxima</value>
|
||||||
<comment>Title for KeyGraphFeatures Maxima Property</comment>
|
<comment>Title for KeyGraphFeatures Maxima Property</comment>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
using System;
|
using System;
|
||||||
|
using OpenQA.Selenium.Interactions;
|
||||||
|
|
||||||
namespace CalculatorUITestFramework
|
namespace CalculatorUITestFramework
|
||||||
{
|
{
|
||||||
|
@ -12,6 +13,8 @@ namespace CalculatorUITestFramework
|
||||||
private WindowsElement CalculatorAlwaysOnTopResults => this.session.TryFindElementByAccessibilityId("CalculatorAlwaysOnTopResults");
|
private WindowsElement CalculatorAlwaysOnTopResults => this.session.TryFindElementByAccessibilityId("CalculatorAlwaysOnTopResults");
|
||||||
private WindowsElement CalculatorResult => this.session.TryFindElementByAccessibilityId("CalculatorResults");
|
private WindowsElement CalculatorResult => this.session.TryFindElementByAccessibilityId("CalculatorResults");
|
||||||
private WindowsElement CalculatorExpression => this.session.TryFindElementByAccessibilityId("CalculatorExpression");
|
private WindowsElement CalculatorExpression => this.session.TryFindElementByAccessibilityId("CalculatorExpression");
|
||||||
|
private WindowsElement MenuItemCopy => this.session.WaitForElementByAccessibilityId("CopyMenuItem");
|
||||||
|
private WindowsElement MenuItemPaste => this.session.WaitForElementByAccessibilityId("PasteMenuItem");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the text from the display control in AoT mode and removes the narrator text that is not displayed in the UI.
|
/// Gets the text from the display control in AoT mode and removes the narrator text that is not displayed in the UI.
|
||||||
|
@ -61,5 +64,33 @@ namespace CalculatorUITestFramework
|
||||||
throw new Exception("The Calculator Expression is not clear");
|
throw new Exception("The Calculator Expression is not clear");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens the context menu in order to be able to click its items
|
||||||
|
/// </summary>
|
||||||
|
private void OpenContextMenu()
|
||||||
|
{
|
||||||
|
Actions actions = new Actions(CalculatorResult.WrappedDriver);
|
||||||
|
// It is important to move not to the centre in order to avoid click on the text
|
||||||
|
actions.MoveToElement(CalculatorResult, 1,1).ContextClick().Perform();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens the context menu and clicks the "Copy" item there
|
||||||
|
/// </summary>
|
||||||
|
public void ContextMenuItemCopyClick()
|
||||||
|
{
|
||||||
|
OpenContextMenu();
|
||||||
|
MenuItemCopy.Click();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens the context menu and clicks the "Paste" item there
|
||||||
|
/// </summary>
|
||||||
|
public void ContextMenuItemPasteClick()
|
||||||
|
{
|
||||||
|
OpenContextMenu();
|
||||||
|
MenuItemPaste.Click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
using OpenQA.Selenium.Appium.Windows;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace CalculatorUITestFramework
|
namespace CalculatorUITestFramework
|
||||||
{
|
{
|
||||||
|
@ -68,5 +71,43 @@ namespace CalculatorUITestFramework
|
||||||
// process id (any entry of allWindowHandles)
|
// process id (any entry of allWindowHandles)
|
||||||
driver.SwitchTo().Window(allWindowHandles[0]);
|
driver.SwitchTo().Window(allWindowHandles[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Waits for an element to be created.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="driver">this</param>
|
||||||
|
/// <param name="id">the automation id</param>
|
||||||
|
/// <param name="timeout">optional timeout in ms</param>
|
||||||
|
/// <returns>the element with the matching automation id</returns>
|
||||||
|
public static WindowsElement WaitForElementByAccessibilityId(this WindowsDriver<WindowsElement> driver, string id, int timeout = 1000)
|
||||||
|
{
|
||||||
|
Stopwatch timer = new Stopwatch();
|
||||||
|
timer.Reset();
|
||||||
|
timer.Start();
|
||||||
|
while (timer.ElapsedMilliseconds < timeout)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var element = driver.TryFindElementByAccessibilityId(id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
catch(WebDriverException ex)
|
||||||
|
{
|
||||||
|
if (ex.Message.Contains("An element could not be located on the page using the given search parameters"))
|
||||||
|
{
|
||||||
|
Logger.LogMessage("Element not found. Waiting for 10ms in WaitForElementByAccessibilityId");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Thread.Sleep(10);
|
||||||
|
}
|
||||||
|
timer.Stop();
|
||||||
|
|
||||||
|
// one last attempt. Throws the not found exception if this fails
|
||||||
|
return driver.TryFindElementByAccessibilityId(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
using CalculatorUITestFramework;
|
using CalculatorUITestFramework;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Appium.Windows;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace CalculatorUITests
|
namespace CalculatorUITests
|
||||||
{
|
{
|
||||||
|
@ -890,5 +888,95 @@ namespace CalculatorUITests
|
||||||
Assert.AreEqual("8 0 8", page.CalculatorResults.GetCalculatorResultText());
|
Assert.AreEqual("8 0 8", page.CalculatorResults.GetCalculatorResultText());
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copy and Paste the numbers into/from the calculator
|
||||||
|
/// </summary>
|
||||||
|
#region Copy-Paste operations
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Simple_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit1.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("2", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Invalid_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit63.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.ProgrammerOperators.QWordButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("Invalid input", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Big_QWord_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit63.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("-9,223,372,036,854,775,808", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Big_DWord_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.QWordButton.Click();
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit31.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("-2,147,483,648", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Big_Word_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.QWordButton.Click();
|
||||||
|
page.ProgrammerOperators.DWordButton.Click();
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit15.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("-32,768", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(1)]
|
||||||
|
public void Copy_And_Paste_Big_Byte_Number()
|
||||||
|
{
|
||||||
|
page.ProgrammerOperators.QWordButton.Click();
|
||||||
|
page.ProgrammerOperators.DWordButton.Click();
|
||||||
|
page.ProgrammerOperators.WordButton.Click();
|
||||||
|
page.ProgrammerOperators.BitFlip.Click();
|
||||||
|
page.ProgrammerOperators.Bit7.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemCopyClick();
|
||||||
|
page.ProgrammerOperators.FullKeypad.Click();
|
||||||
|
page.StandardOperators.ClearEntryButton.Click();
|
||||||
|
page.CalculatorResults.ContextMenuItemPasteClick();
|
||||||
|
Assert.AreEqual("-128", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,14 @@ namespace CalculatorUnitTests
|
||||||
NumberBase::DecBase,
|
NumberBase::DecBase,
|
||||||
BitLength::BitLengthQWord),
|
BitLength::BitLengthQWord),
|
||||||
L"Verify operand values == max return true.");
|
L"Verify operand values == max return true.");
|
||||||
|
VERIFY_IS_TRUE(
|
||||||
|
m_CopyPasteManager->ExpressionRegExMatch(
|
||||||
|
ref new Vector<String ^>({ L"-9223372036854775808" }),
|
||||||
|
ViewMode::Programmer,
|
||||||
|
CategoryGroupType::Calculator,
|
||||||
|
NumberBase::DecBase,
|
||||||
|
BitLength::BitLengthQWord),
|
||||||
|
L"Verify operand values == max negative return true.");
|
||||||
|
|
||||||
Logger::WriteMessage(L"Verify all operands must match patterns.");
|
Logger::WriteMessage(L"Verify all operands must match patterns.");
|
||||||
VERIFY_IS_TRUE(m_CopyPasteManager->ExpressionRegExMatch(
|
VERIFY_IS_TRUE(m_CopyPasteManager->ExpressionRegExMatch(
|
||||||
|
@ -950,6 +958,7 @@ namespace CalculatorUnitTests
|
||||||
L"aef",
|
L"aef",
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"A1a3" /*within boundary*/,
|
L"A1a3" /*within boundary*/,
|
||||||
|
L"FFFF" /*boundary condition: max allowed number*/,
|
||||||
L"0x1234",
|
L"0x1234",
|
||||||
L"0xab12",
|
L"0xab12",
|
||||||
L"0X1234",
|
L"0X1234",
|
||||||
|
@ -1046,7 +1055,7 @@ namespace CalculatorUnitTests
|
||||||
L"123*4*-3",
|
L"123*4*-3",
|
||||||
L"123*+4*-3",
|
L"123*+4*-3",
|
||||||
L"9223372036854775807",
|
L"9223372036854775807",
|
||||||
L"-9223372036854775807" /*boundary condition: max/min allowed number*/,
|
L"-9223372036854775808" /*boundary condition: max/min allowed number*/,
|
||||||
L"0n1234",
|
L"0n1234",
|
||||||
L"0N1234",
|
L"0N1234",
|
||||||
L"1234u",
|
L"1234u",
|
||||||
|
@ -1069,6 +1078,7 @@ namespace CalculatorUnitTests
|
||||||
L"xyz",
|
L"xyz",
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"e+234",
|
L"e+234",
|
||||||
|
L"9223372036854775808" /*boundary condition: greater than max allowed number 9223372036854775807*/,
|
||||||
L"9223372036854775809" /*boundary condition: greater than max allowed number 9223372036854775807*/,
|
L"9223372036854775809" /*boundary condition: greater than max allowed number 9223372036854775807*/,
|
||||||
L"SIN(2)",
|
L"SIN(2)",
|
||||||
L"-0n123",
|
L"-0n123",
|
||||||
|
@ -1145,7 +1155,8 @@ namespace CalculatorUnitTests
|
||||||
L"123*4*-3",
|
L"123*4*-3",
|
||||||
L"123*+4*-3",
|
L"123*+4*-3",
|
||||||
L"32767",
|
L"32767",
|
||||||
L"-32767" /*boundary condition: max/min allowed number*/,
|
L"-32767",
|
||||||
|
L"-32768" /*boundary condition: max/min allowed number*/,
|
||||||
L"0n1234",
|
L"0n1234",
|
||||||
L"0N1234",
|
L"0N1234",
|
||||||
L"1234u",
|
L"1234u",
|
||||||
|
@ -1208,7 +1219,8 @@ namespace CalculatorUnitTests
|
||||||
{
|
{
|
||||||
String ^ qwordPositiveInput[] = { L"123", L"123+456", L"1,234", L"1 2 3", L"1'2'3'4", L"1_2_3_4", L"\n\r1,234\n", L"\f\n1+2\t\r\v\x85",
|
String ^ qwordPositiveInput[] = { L"123", L"123+456", L"1,234", L"1 2 3", L"1'2'3'4", L"1_2_3_4", L"\n\r1,234\n", L"\f\n1+2\t\r\v\x85",
|
||||||
L"\n 1+\n2 ", L"1\"2", L"(123)+(456)", L"0t1234", L"0T1234", L"0o1234", L"0O1234", L"1234u",
|
L"\n 1+\n2 ", L"1\"2", L"(123)+(456)", L"0t1234", L"0T1234", L"0o1234", L"0O1234", L"1234u",
|
||||||
L"1234ul", L"1234ULL", L"2+2=", L"2+2= ", L"127%71" };
|
L"1234ul", L"1234ULL", L"2+2=", L"2+2= ",
|
||||||
|
L"127%71", L"1777777777777777777777" /*boundary condition: the max allowed number*/ };
|
||||||
String ^ qwordNegativeInput[] = { L"+123",
|
String ^ qwordNegativeInput[] = { L"+123",
|
||||||
L"1.23",
|
L"1.23",
|
||||||
L"1''2",
|
L"1''2",
|
||||||
|
@ -1226,6 +1238,7 @@ namespace CalculatorUnitTests
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"e+234",
|
L"e+234",
|
||||||
L"12345678901234567890123" /*boundary condition: greater than max allowed digits 22*/,
|
L"12345678901234567890123" /*boundary condition: greater than max allowed digits 22*/,
|
||||||
|
L"2000000000000000000000" /*boundary condition: greater than max allowed number*/,
|
||||||
L"SIN(2)",
|
L"SIN(2)",
|
||||||
L"123+-234",
|
L"123+-234",
|
||||||
L"0ot1234",
|
L"0ot1234",
|
||||||
|
@ -1260,6 +1273,7 @@ namespace CalculatorUnitTests
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"e+234",
|
L"e+234",
|
||||||
L"377777777771" /*boundary condition: greater than max allowed number 37777777777*/,
|
L"377777777771" /*boundary condition: greater than max allowed number 37777777777*/,
|
||||||
|
L"40000000000" /*boundary condition: greater than max allowed number 37777777777*/,
|
||||||
L"SIN(2)",
|
L"SIN(2)",
|
||||||
L"123+-234",
|
L"123+-234",
|
||||||
L"0ot1234",
|
L"0ot1234",
|
||||||
|
@ -1303,6 +1317,7 @@ namespace CalculatorUnitTests
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"e+234",
|
L"e+234",
|
||||||
L"1777771" /*boundary condition: greater than max allowed number 177777*/,
|
L"1777771" /*boundary condition: greater than max allowed number 177777*/,
|
||||||
|
L"200000" /*boundary condition: greater than max allowed number 177777*/,
|
||||||
L"SIN(2)",
|
L"SIN(2)",
|
||||||
L"123+-234",
|
L"123+-234",
|
||||||
L"0ot1234",
|
L"0ot1234",
|
||||||
|
@ -1332,6 +1347,7 @@ namespace CalculatorUnitTests
|
||||||
L"ABab",
|
L"ABab",
|
||||||
L"e+24",
|
L"e+24",
|
||||||
L"477" /*boundary condition: greater than max allowed number 377*/,
|
L"477" /*boundary condition: greater than max allowed number 377*/,
|
||||||
|
L"400" /*boundary condition: greater than max allowed number 377*/,
|
||||||
L"SIN(2)",
|
L"SIN(2)",
|
||||||
L"123+-34",
|
L"123+-34",
|
||||||
L"0ot123",
|
L"0ot123",
|
||||||
|
@ -1497,7 +1513,8 @@ namespace CalculatorUnitTests
|
||||||
String
|
String
|
||||||
^ bytePositiveInput[] = { L"100", L"100+101", L"1,001", L"1 0 1", L"1'0'0'1", L"1_0_0_1", L"\n\r1,010\n",
|
^ bytePositiveInput[] = { L"100", L"100+101", L"1,001", L"1 0 1", L"1'0'0'1", L"1_0_0_1", L"\n\r1,010\n",
|
||||||
L"\n 1+\n1 ", L"1\"1", L"(101)+(10)", L"0b1001", L"0B1111", L"0y1001", L"0Y1001",
|
L"\n 1+\n1 ", L"1\"1", L"(101)+(10)", L"0b1001", L"0B1111", L"0y1001", L"0Y1001",
|
||||||
L"1100b", L"1101B", L"1111u", L"1111ul", L"1111ULL", L"10100010" /*boundary condition: max allowed number*/ };
|
L"1100b", L"1101B", L"1111u", L"1111ul", L"1111ULL", L"10100010",
|
||||||
|
L"11111111" /*boundary condition: max allowed number*/ };
|
||||||
String ^ byteNegativeInput[] = { L"+10101",
|
String ^ byteNegativeInput[] = { L"+10101",
|
||||||
L"1.01",
|
L"1.01",
|
||||||
L"1''0",
|
L"1''0",
|
||||||
|
@ -1524,6 +1541,7 @@ namespace CalculatorUnitTests
|
||||||
L"1111uu",
|
L"1111uu",
|
||||||
L"1111ulll",
|
L"1111ulll",
|
||||||
L"101000101" /*boundary condition: greater than max allowed digits 8*/,
|
L"101000101" /*boundary condition: greater than max allowed digits 8*/,
|
||||||
|
L"100000000" /*boundary condition: greater than max allowed value*/,
|
||||||
L"SIN(01010)",
|
L"SIN(01010)",
|
||||||
L"10+-1010101" };
|
L"10+-1010101" };
|
||||||
|
|
||||||
|
|
|
@ -254,8 +254,8 @@ namespace GraphControl
|
||||||
vector<Equation ^> equationVector;
|
vector<Equation ^> equationVector;
|
||||||
equationVector.push_back(equation);
|
equationVector.push_back(equation);
|
||||||
UpdateGraphOptions(graph->GetOptions(), equationVector);
|
UpdateGraphOptions(graph->GetOptions(), equationVector);
|
||||||
|
bool variableIsNotX;
|
||||||
if (analyzer->CanFunctionAnalysisBePerformed())
|
if (analyzer->CanFunctionAnalysisBePerformed(variableIsNotX) && !variableIsNotX)
|
||||||
{
|
{
|
||||||
if (S_OK
|
if (S_OK
|
||||||
== analyzer->PerformFunctionAnalysis(
|
== analyzer->PerformFunctionAnalysis(
|
||||||
|
@ -265,6 +265,10 @@ namespace GraphControl
|
||||||
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
|
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (variableIsNotX)
|
||||||
|
{
|
||||||
|
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::VariableIsNotX);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);
|
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Graphing::Analyzer
|
||||||
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
|
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
|
||||||
{
|
{
|
||||||
virtual ~IGraphAnalyzer() = default;
|
virtual ~IGraphAnalyzer() = default;
|
||||||
virtual bool CanFunctionAnalysisBePerformed() = 0;
|
virtual bool CanFunctionAnalysisBePerformed(bool& variableIsNotX) = 0;
|
||||||
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
|
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
|
||||||
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
|
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
|
||||||
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
|
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue