calculator/src
Seulgi Kim af8322617f Restore user preferences (#456)
### Description of the changes:
**1) Do not set units to default values if they already have valid values** 
This fixes the actual issue. `UnitConverter::InitializeSelectedUnits()` ( this function resets all units to their default units if available for the current category ) gets called after `UnitConverterViewModel::RestoreUserPreferences()` ( this function restores user preferences ).
So Calculator has been restoring saved values, and then overriding the restored values with default values.
I modified `InitializeSelectedUnits()` so that we only initialize units only when they are not already set to valid units for the current category.

**2) Removed `m_isFirstTime`** 
I noticed that we are calling `RestoreUserPreferences()`  twice when Calculator starts up, and the function is restoring the same value both times

The below happens when Calculator starts up
1) On startup, in `UnitConverterViewModel::InitializeView()`, `RestoreUserPreferences()` is called.
2) `RestoreUserPreferences()` in turn triggers `OnUnitChanged()`
3) During the first call to `OnUnitChanged()`, m_IsFirstTime is `True`, so we call `RestoreUserPreferences()` again while also setting `m_IsFirstTime` to `False`. 
4) `RestoreUserPreference()` again triggers `OnUnitChanged()`
5) During the second call to `OnUnitChanged()`,  m_IsFirstTime is `False`, so we call `SaveUserPreferences()`

I think we should only call `SaveUserPreferences()` inside `OnUnitChanged()` since we already restored user preferences during view initialization. I can't really think of a reason to restore units after view has been initialized. This led me to just delete `m_isFirstTime`.


### How changes were validated:
Manually tested that units and the current category are properly selected when you quit and start Calculator.

![GifMaker_20190414182150911](https://user-images.githubusercontent.com/3166423/56102706-88f73400-5ee3-11e9-8bbf-7a0c8e051a5c.gif)

![GifMaker_20190414183403644](https://user-images.githubusercontent.com/3166423/56102763-f0ad7f00-5ee3-11e9-99ef-3b932f587393.gif)

## Fixes #445.
2019-07-29 09:39:19 -07:00
..
build Hello GitHub 2019-01-28 16:24:37 -08:00
CalcManager Restore user preferences (#456) 2019-07-29 09:39:19 -07:00
Calculator Fixed issue where UI Responsive events were not fired (#603) 2019-07-26 11:51:01 -07:00
CalculatorUITestFramework UI tests should be able to test both dev and store-released builds (#567) 2019-06-25 11:29:32 -07:00
CalculatorUITests UI tests should be able to test both dev and store-released builds (#567) 2019-06-25 11:29:32 -07:00
CalculatorUnitTests Updated Calculator diagnostic data collection per the specification (#572) 2019-07-17 18:09:39 -07:00
CalcViewModel Restore user preferences (#456) 2019-07-29 09:39:19 -07:00
Calculator.sln Update to v142 build tools for Visual Studio 2019 (#548) 2019-06-24 16:38:45 -07:00
CMakeLists.txt Add CMake project, GCC support (#540) 2019-06-06 14:08:31 -07:00
nuget.config updating nuget.org source to point to V3 (#129) 2019-03-07 07:33:22 -08:00
Settings.XamlStyler Hello GitHub 2019-01-28 16:24:37 -08:00