mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-23 06:25:19 -07:00
Fixed bug
This commit is contained in:
parent
61d06b2d2f
commit
4d9a3728c2
3 changed files with 46 additions and 37 deletions
|
@ -60,29 +60,36 @@ bool IsGraphingModeAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
Box<bool> ^ _isGraphingModeEnabledCached = nullptr;
|
Box<bool> ^ _isGraphingModeEnabledCached = nullptr;
|
||||||
bool IsGraphingModeEnabled()
|
bool IsGraphingModeEnabled(User ^ firstUser = nullptr)
|
||||||
{
|
{
|
||||||
if (!IsGraphingModeAvailable())
|
if (firstUser)
|
||||||
{
|
{
|
||||||
return false;
|
if (!IsGraphingModeAvailable())
|
||||||
}
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (_isGraphingModeEnabledCached != nullptr)
|
if (_isGraphingModeEnabledCached != nullptr)
|
||||||
{
|
{
|
||||||
return _isGraphingModeEnabledCached->Value;
|
return _isGraphingModeEnabledCached->Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
User ^ firstUser;
|
|
||||||
create_task(User::FindAllAsync(UserType::LocalUser)).then([&firstUser](IVectorView<User ^> ^ users) {
|
|
||||||
firstUser = users->GetAt(0); }).wait();
|
|
||||||
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(firstUser, L"Education", L"AllowGraphingCalculator");
|
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(firstUser, L"Education", L"AllowGraphingCalculator");
|
||||||
_isGraphingModeEnabledCached = namedPolicyData->GetBoolean() == true;
|
_isGraphingModeEnabledCached = namedPolicyData->GetBoolean() == true;
|
||||||
|
|
||||||
return _isGraphingModeEnabledCached->Value;
|
return _isGraphingModeEnabledCached->Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _isGraphingModeEnabledCached->Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The order of items in this list determines the order of items in the menu.
|
// The order of items in this list determines the order of items in the menu.
|
||||||
static const list<NavCategoryInitializer> s_categoryManifest = [] {
|
static list<NavCategoryInitializer> s_categoryManifest;
|
||||||
|
|
||||||
|
void NavCategory::CreateCategoryManifest(User ^ user)
|
||||||
|
{
|
||||||
auto res = list<NavCategoryInitializer>{ NavCategoryInitializer{ ViewMode::Standard,
|
auto res = list<NavCategoryInitializer>{ NavCategoryInitializer{ ViewMode::Standard,
|
||||||
STANDARD_ID,
|
STANDARD_ID,
|
||||||
L"Standard",
|
L"Standard",
|
||||||
|
@ -108,7 +115,7 @@ static const list<NavCategoryInitializer> s_categoryManifest = [] {
|
||||||
bool supportGraphingCalculator = IsGraphingModeAvailable();
|
bool supportGraphingCalculator = IsGraphingModeAvailable();
|
||||||
if (supportGraphingCalculator)
|
if (supportGraphingCalculator)
|
||||||
{
|
{
|
||||||
const bool isEnabled = IsGraphingModeEnabled();
|
bool isEnabled = IsGraphingModeEnabled(user);
|
||||||
res.push_back(NavCategoryInitializer{ ViewMode::Graphing,
|
res.push_back(NavCategoryInitializer{ ViewMode::Graphing,
|
||||||
GRAPHING_ID,
|
GRAPHING_ID,
|
||||||
L"Graphing",
|
L"Graphing",
|
||||||
|
@ -273,8 +280,8 @@ static const list<NavCategoryInitializer> s_categoryManifest = [] {
|
||||||
nullptr,
|
nullptr,
|
||||||
SUPPORTS_NEGATIVE,
|
SUPPORTS_NEGATIVE,
|
||||||
true } });
|
true } });
|
||||||
return res;
|
s_categoryManifest = res;
|
||||||
}();
|
}
|
||||||
|
|
||||||
// This function should only be used when storing the mode to app data.
|
// This function should only be used when storing the mode to app data.
|
||||||
int NavCategory::Serialize(ViewMode mode)
|
int NavCategory::Serialize(ViewMode mode)
|
||||||
|
|
|
@ -59,15 +59,15 @@ namespace CalculatorApp
|
||||||
private
|
private
|
||||||
struct NavCategoryInitializer
|
struct NavCategoryInitializer
|
||||||
{
|
{
|
||||||
constexpr NavCategoryInitializer(
|
NavCategoryInitializer(
|
||||||
ViewMode mode,
|
ViewMode mode,
|
||||||
int id,
|
int id,
|
||||||
wchar_t const* name,
|
wchar_t * name,
|
||||||
wchar_t const* nameKey,
|
wchar_t * nameKey,
|
||||||
wchar_t const* glyph,
|
wchar_t * glyph,
|
||||||
CategoryGroupType group,
|
CategoryGroupType group,
|
||||||
MyVirtualKey vKey,
|
MyVirtualKey vKey,
|
||||||
wchar_t const* aKey,
|
wchar_t * aKey,
|
||||||
bool categorySupportsNegative,
|
bool categorySupportsNegative,
|
||||||
bool enabled)
|
bool enabled)
|
||||||
: viewMode(mode)
|
: viewMode(mode)
|
||||||
|
@ -83,22 +83,22 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViewMode viewMode;
|
ViewMode viewMode;
|
||||||
const int serializationId;
|
int serializationId;
|
||||||
const wchar_t* const friendlyName;
|
wchar_t* friendlyName;
|
||||||
const wchar_t* const nameResourceKey;
|
wchar_t* nameResourceKey;
|
||||||
const wchar_t* const glyph;
|
wchar_t* glyph;
|
||||||
const CategoryGroupType groupType;
|
CategoryGroupType groupType;
|
||||||
const MyVirtualKey virtualKey;
|
MyVirtualKey virtualKey;
|
||||||
const wchar_t* const accessKey;
|
wchar_t* accessKey;
|
||||||
const bool supportsNegative;
|
bool supportsNegative;
|
||||||
const bool isEnabled;
|
bool isEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
private
|
private
|
||||||
struct NavCategoryGroupInitializer
|
struct NavCategoryGroupInitializer
|
||||||
{
|
{
|
||||||
constexpr NavCategoryGroupInitializer(CategoryGroupType t, wchar_t const* h, wchar_t const* n, wchar_t const* a)
|
NavCategoryGroupInitializer(CategoryGroupType t, wchar_t * h, wchar_t * n, wchar_t * a)
|
||||||
: type(t)
|
: type(t)
|
||||||
, headerResourceKey(h)
|
, headerResourceKey(h)
|
||||||
, modeResourceKey(n)
|
, modeResourceKey(n)
|
||||||
|
@ -106,10 +106,10 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const CategoryGroupType type;
|
CategoryGroupType type;
|
||||||
const wchar_t* headerResourceKey;
|
wchar_t* headerResourceKey;
|
||||||
const wchar_t* modeResourceKey;
|
wchar_t* modeResourceKey;
|
||||||
const wchar_t* automationResourceKey;
|
wchar_t* automationResourceKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Windows::UI::Xaml::Data::Bindable] public ref class NavCategory sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
[Windows::UI::Xaml::Data::Bindable] public ref class NavCategory sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||||
|
@ -140,6 +140,8 @@ namespace CalculatorApp
|
||||||
static bool IsDateCalculatorViewMode(ViewMode mode);
|
static bool IsDateCalculatorViewMode(ViewMode mode);
|
||||||
static bool IsConverterViewMode(ViewMode mode);
|
static bool IsConverterViewMode(ViewMode mode);
|
||||||
|
|
||||||
|
static void CreateCategoryManifest(Windows::System::User ^ user);
|
||||||
|
|
||||||
static Platform::String ^ GetFriendlyName(ViewMode mode);
|
static Platform::String ^ GetFriendlyName(ViewMode mode);
|
||||||
static Platform::String ^ GetNameResourceKey(ViewMode mode);
|
static Platform::String ^ GetNameResourceKey(ViewMode mode);
|
||||||
static CategoryGroupType GetGroupType(ViewMode mode);
|
static CategoryGroupType GetGroupType(ViewMode mode);
|
||||||
|
|
|
@ -198,12 +198,12 @@ void App::OnLaunched(LaunchActivatedEventArgs ^ args)
|
||||||
// If the app got pre-launch activated, then save that state in a flag
|
// If the app got pre-launch activated, then save that state in a flag
|
||||||
m_preLaunched = true;
|
m_preLaunched = true;
|
||||||
}
|
}
|
||||||
|
NavCategory::CreateCategoryManifest(args->User);
|
||||||
OnAppLaunch(args, args->Arguments);
|
OnAppLaunch(args, args->Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
|
void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Uncomment the following lines to display frame-rate and per-frame CPU usage info.
|
// Uncomment the following lines to display frame-rate and per-frame CPU usage info.
|
||||||
//#if _DEBUG
|
//#if _DEBUG
|
||||||
// if (IsDebuggerPresent())
|
// if (IsDebuggerPresent())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue