Hello GitHub
This commit is contained in:
5
src/Calculator/DesignData/DesignAppViewModel.cpp
Normal file
5
src/Calculator/DesignData/DesignAppViewModel.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "DesignAppViewModel.h"
|
46
src/Calculator/DesignData/DesignAppViewModel.h
Normal file
46
src/Calculator/DesignData/DesignAppViewModel.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DesignStandardCalculatorViewModel.h"
|
||||
#include "DesignUnitConverterViewModel.h"
|
||||
|
||||
namespace Numbers
|
||||
{
|
||||
namespace DesignData
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// These class are to be consumed exclusively by Blend and the VS designer
|
||||
// with these classes Blend will be able to populate the controls
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with UnitConverterViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
|
||||
|
||||
public ref class AppViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
AppViewModel() :
|
||||
m_IsStandardMode(true),
|
||||
m_IsScientificMode(false),
|
||||
m_IsConverterMode(false),
|
||||
m_CalculatorViewModel(ref new StandardCalculatorViewModel()),
|
||||
m_ConverterViewModel(ref new UnitConverterViewModel())
|
||||
{}
|
||||
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel^, CalculatorViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(UnitConverterViewModel^, ConverterViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsStandardMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsScientificMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsConverterMode);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "DesignStandardCalculatorViewModel.h"
|
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Numbers
|
||||
{
|
||||
namespace DesignData
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
public ref class MemorySlot sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
MemorySlot(int slotPosition, Platform::String^ value) :
|
||||
m_SlotPosition(slotPosition),
|
||||
m_SlotValue(value)
|
||||
{}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
OBSERVABLE_PROPERTY_RW(int, SlotPosition);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, SlotValue);
|
||||
};
|
||||
|
||||
// This class is to be consumbed exclusively by Blend and the VS designer
|
||||
// with this class Blend will be able to populate the controls, the CalculationResults control for example,
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with StandardCalculatorViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
public ref class StandardCalculatorViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
|
||||
StandardCalculatorViewModel():
|
||||
m_DisplayValue("1234569"),
|
||||
m_DisplayStringExpression("14560 x 1890"),
|
||||
m_DegreeButtonContent("Deg"),
|
||||
m_IsMemoryEmpty(false)
|
||||
{
|
||||
m_MemorizedNumbers = ref new Platform::Collections::Vector<MemorySlot^>();
|
||||
for (int i = 1000; i < 1100; i++)
|
||||
{
|
||||
wchar_t wzi[5];
|
||||
_itow_s(i, wzi, 10);
|
||||
m_MemorizedNumbers->Append(ref new MemorySlot(i, ref new Platform::String(wzi)));
|
||||
}
|
||||
}
|
||||
|
||||
typedef Windows::Foundation::Collections::IMap<NumbersAndOperatorsEnum, bool> KeyboardButtonStates;
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DisplayValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DisplayStringExpression);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DegreeButtonContent);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::Foundation::Collections::IVector<MemorySlot^>^, MemorizedNumbers);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsMemoryEmpty);
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(KeyboardButtonStates^, PressedButtons);
|
||||
|
||||
COMMAND_FOR_METHOD(ButtonPressed, StandardCalculatorViewModel::OnButtonPressed);
|
||||
|
||||
private:
|
||||
|
||||
void OnButtonPressed(Platform::Object^ parameter)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "DesignUnitConverterViewModel.h"
|
118
src/Calculator/DesignData/DesignUnitConverterViewModel.h
Normal file
118
src/Calculator/DesignData/DesignUnitConverterViewModel.h
Normal file
@@ -0,0 +1,118 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Numbers
|
||||
{
|
||||
namespace DesignData
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// These class are to be consumed exclusively by Blend and the VS designer
|
||||
// with these classes Blend will be able to populate the controls
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with UnitConverterViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
|
||||
|
||||
public ref class CategoryViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
CategoryViewModel(Platform::String^ name) :
|
||||
m_Name(name),
|
||||
m_NegateVisibility(Windows::UI::Xaml::Visibility::Collapsed)
|
||||
{}
|
||||
|
||||
CategoryViewModel(Platform::String^ name, Windows::UI::Xaml::Visibility negateVisibility) :
|
||||
m_Name(name),
|
||||
m_NegateVisibility(negateVisibility)
|
||||
{}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::UI::Xaml::Visibility, NegateVisibility);
|
||||
};
|
||||
|
||||
public ref class UnitViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
UnitViewModel(Platform::String^ unit, Platform::String^ abbr) :
|
||||
m_Name(unit),
|
||||
m_Abbreviation(abbr)
|
||||
{}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Abbreviation);
|
||||
};
|
||||
|
||||
public ref class UnitConverterSupplementaryResultViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
UnitConverterSupplementaryResultViewModel(Platform::String^ value, Platform::String^ unit, Platform::String^ abbr) :
|
||||
m_Value(value)
|
||||
{
|
||||
m_Unit = ref new UnitViewModel(unit, abbr);
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit);
|
||||
};
|
||||
|
||||
public ref class UnitConverterViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
|
||||
UnitConverterViewModel():
|
||||
m_Value1("Åy24"),
|
||||
m_Value2("Åy183"),
|
||||
m_Value1Active(true),
|
||||
m_Value2Active(false)
|
||||
{
|
||||
m_SupplementaryResults = ref new Platform::Collections::Vector<UnitConverterSupplementaryResultViewModel^>();
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("128", "Kilograms", "Kgs"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("42.55", "Liters", "ÅyL"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("1.5e3", "Gallons", "G"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("1929", "Gigabyte", "GB"));
|
||||
|
||||
m_Categories = ref new Platform::Collections::Vector<CategoryViewModel^>();
|
||||
m_Categories->Append(ref new CategoryViewModel("Volume"));
|
||||
m_Categories->Append(ref new CategoryViewModel("Temperature", Windows::UI::Xaml::Visibility::Visible));
|
||||
m_CurrentCategory = ref new CategoryViewModel("ÅyTime");
|
||||
m_Categories->Append(m_CurrentCategory);
|
||||
m_Categories->Append(ref new CategoryViewModel("Speed"));
|
||||
|
||||
m_Units = ref new Platform::Collections::Vector<UnitViewModel^>();
|
||||
m_Unit1 = ref new UnitViewModel("ÅySeconds", "S");
|
||||
m_Unit2 = ref new UnitViewModel("ÅyMinutes", "M");
|
||||
m_Units->Append(ref new UnitViewModel("Miliseconds", "MS"));
|
||||
m_Units->Append(m_Unit1);
|
||||
m_Units->Append(m_Unit2);
|
||||
m_Units->Append(ref new UnitViewModel("Hours", "HRs"));
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value1);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value2);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, Categories);
|
||||
OBSERVABLE_PROPERTY_RW(CategoryViewModel^, CurrentCategory);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, Units);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit1);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit2);
|
||||
OBSERVABLE_PROPERTY_RW(bool, Value1Active);
|
||||
OBSERVABLE_PROPERTY_RW(bool, Value2Active);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, SupplementaryResults);
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user