mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Fixed bug
This commit is contained in:
parent
61d06b2d2f
commit
4d9a3728c2
3 changed files with 46 additions and 37 deletions
|
@ -60,7 +60,9 @@ bool IsGraphingModeAvailable()
|
|||
}
|
||||
|
||||
Box<bool> ^ _isGraphingModeEnabledCached = nullptr;
|
||||
bool IsGraphingModeEnabled()
|
||||
bool IsGraphingModeEnabled(User ^ firstUser = nullptr)
|
||||
{
|
||||
if (firstUser)
|
||||
{
|
||||
if (!IsGraphingModeAvailable())
|
||||
{
|
||||
|
@ -72,17 +74,22 @@ bool IsGraphingModeEnabled()
|
|||
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");
|
||||
_isGraphingModeEnabledCached = namedPolicyData->GetBoolean() == true;
|
||||
|
||||
return _isGraphingModeEnabledCached->Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _isGraphingModeEnabledCached->Value;
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
STANDARD_ID,
|
||||
L"Standard",
|
||||
|
@ -108,7 +115,7 @@ static const list<NavCategoryInitializer> s_categoryManifest = [] {
|
|||
bool supportGraphingCalculator = IsGraphingModeAvailable();
|
||||
if (supportGraphingCalculator)
|
||||
{
|
||||
const bool isEnabled = IsGraphingModeEnabled();
|
||||
bool isEnabled = IsGraphingModeEnabled(user);
|
||||
res.push_back(NavCategoryInitializer{ ViewMode::Graphing,
|
||||
GRAPHING_ID,
|
||||
L"Graphing",
|
||||
|
@ -273,8 +280,8 @@ static const list<NavCategoryInitializer> s_categoryManifest = [] {
|
|||
nullptr,
|
||||
SUPPORTS_NEGATIVE,
|
||||
true } });
|
||||
return res;
|
||||
}();
|
||||
s_categoryManifest = res;
|
||||
}
|
||||
|
||||
// This function should only be used when storing the mode to app data.
|
||||
int NavCategory::Serialize(ViewMode mode)
|
||||
|
|
|
@ -59,15 +59,15 @@ namespace CalculatorApp
|
|||
private
|
||||
struct NavCategoryInitializer
|
||||
{
|
||||
constexpr NavCategoryInitializer(
|
||||
NavCategoryInitializer(
|
||||
ViewMode mode,
|
||||
int id,
|
||||
wchar_t const* name,
|
||||
wchar_t const* nameKey,
|
||||
wchar_t const* glyph,
|
||||
wchar_t * name,
|
||||
wchar_t * nameKey,
|
||||
wchar_t * glyph,
|
||||
CategoryGroupType group,
|
||||
MyVirtualKey vKey,
|
||||
wchar_t const* aKey,
|
||||
wchar_t * aKey,
|
||||
bool categorySupportsNegative,
|
||||
bool enabled)
|
||||
: viewMode(mode)
|
||||
|
@ -83,22 +83,22 @@ namespace CalculatorApp
|
|||
{
|
||||
}
|
||||
|
||||
const ViewMode viewMode;
|
||||
const int serializationId;
|
||||
const wchar_t* const friendlyName;
|
||||
const wchar_t* const nameResourceKey;
|
||||
const wchar_t* const glyph;
|
||||
const CategoryGroupType groupType;
|
||||
const MyVirtualKey virtualKey;
|
||||
const wchar_t* const accessKey;
|
||||
const bool supportsNegative;
|
||||
const bool isEnabled;
|
||||
ViewMode viewMode;
|
||||
int serializationId;
|
||||
wchar_t* friendlyName;
|
||||
wchar_t* nameResourceKey;
|
||||
wchar_t* glyph;
|
||||
CategoryGroupType groupType;
|
||||
MyVirtualKey virtualKey;
|
||||
wchar_t* accessKey;
|
||||
bool supportsNegative;
|
||||
bool isEnabled;
|
||||
};
|
||||
|
||||
private
|
||||
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)
|
||||
, headerResourceKey(h)
|
||||
, modeResourceKey(n)
|
||||
|
@ -106,10 +106,10 @@ namespace CalculatorApp
|
|||
{
|
||||
}
|
||||
|
||||
const CategoryGroupType type;
|
||||
const wchar_t* headerResourceKey;
|
||||
const wchar_t* modeResourceKey;
|
||||
const wchar_t* automationResourceKey;
|
||||
CategoryGroupType type;
|
||||
wchar_t* headerResourceKey;
|
||||
wchar_t* modeResourceKey;
|
||||
wchar_t* automationResourceKey;
|
||||
};
|
||||
|
||||
[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 IsConverterViewMode(ViewMode mode);
|
||||
|
||||
static void CreateCategoryManifest(Windows::System::User ^ user);
|
||||
|
||||
static Platform::String ^ GetFriendlyName(ViewMode mode);
|
||||
static Platform::String ^ GetNameResourceKey(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
|
||||
m_preLaunched = true;
|
||||
}
|
||||
NavCategory::CreateCategoryManifest(args->User);
|
||||
OnAppLaunch(args, args->Arguments);
|
||||
}
|
||||
|
||||
void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
|
||||
{
|
||||
|
||||
// Uncomment the following lines to display frame-rate and per-frame CPU usage info.
|
||||
//#if _DEBUG
|
||||
// if (IsDebuggerPresent())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue