Commit Graph

524 Commits

Author SHA1 Message Date
Daniel Belcher
5ffe1bc858
Add Pan/Zoom support for the graph surface (#458)
Description of the changes:
Add Pan/Zoom support for the graph surface.
Currently only supports Mouse/Pen/Touch interactions. Keyboard support will be added separately.

How changes were validated:
Manual
2019-04-22 14:29:57 -07:00
cheezwhines
fab21191e2 Clicking on the same element in the hamburger view should re-open that view, like the menu items do (#447)
Fixes #437.
Clicking on the same element in the hamburger view should re-open that view, like the menu items do

Description of the changes:
-Fixed the bug that was listed

How changes were validated:
-manual
2019-04-19 18:59:10 -07:00
Rudy Huyn
bd04c92c1c Simplify title bar (#442)
Fixes #407 (partially) and #441

Description of the changes:
Remove TitleBarHelper and all <Border x:Name="CustomTitleBar" />
Let the system defines the draggable region
Centralize all events and functions associated to the title bar in a single control TitleBar instead of code splitted between MainPage/TitleBar/HistoryList/Memory.
Use the standard title bar when high contrast is activated instead of the custom one.
Modify the color of the title when the window doesn't have focus
Fix the right padding of the title bar with high contrast

How changes were validated:
Manually tested with LtR and RtL languages
Manually tested with high contrast
Tested when History and Memory flyout are opened
2019-04-19 18:49:08 -07:00
Rudy Huyn
0d31d5a5a2 Fix UI issues with UnitConverter in RtL (#410)
Fix #409 - Some content in Currency Converter not right-aligned properly in RtL
Fix #59 Currency symbol precedence is opposite of system setting in RTL languages

Description of the changes:
Add a property FlowDirectionHorizontalAlignment in UnitConverter to align some controls to the right (without modifying the FlowDirection of their parent items)
Force FlowDirection of Value1Container and Value2Container to LeftToRight (but align panels to the right)

How changes were validated:
Tested with LtR and RtL languages and with currency symbols on the left and on the right.
2019-04-19 18:37:50 -07:00
Eric Wong
43b2d4e536 Fix test code that never executes (#465)
Fixes #175.
Fixes loop in test code to verify that commands not supported by the unit converter viewmodel result in no-op.

Description of the changes:
Removed loop of range of enums with a being tested for no-ops since it added no intrinsic value (and the way that the range was handled was incorrect).  Considered adding an iterator over a static list of commands to validate against, but determined it didn't add any notable value.

How changes were validated:
Ran modified test to ensure it passes
2019-04-18 17:05:44 -07:00
Lance McCarthy
8520d3fc74 Refactored XAML x:Names (#433)
Description of the changes:
-Refactored all x:Names to use the generally accepted Pascal-Casing

How changes were validated:
Unit Tests
Manual Tests
2019-04-18 16:01:47 -07:00
Rudy Huyn
de65db6197 Decrease CPU usage of OverflowTextBlock + optimization (#403)
Fixes #402 and #414
Divide by 4 the CPU usage of OverflowTextBlock when buttons are pressed very quickly.

Description of the changes:

Xaml-side:
OverflowTextBlock has some performance issues:
double scrollviewer: the listview was in a scrollviewer, while the control already containing one -> it breaks the virtualization of the listview and impacts on UI performance.
The listview used a StackPanel, this panel doesn't support virtualization of ListViewItems contrary to ItemsStackPanel

No ListView-specific features were used, an ItemsControl is more efficient and lighter.
refactor how we manage the visibility of the left/right buttons in OverflowTextBlock, the new version is more reactive and will not display the right arrow when not necessary (see GIF below).
remove the ItemContainerSelector ExpressionItemContainerStyle, not really used by OverflowTextBlock

remove UI glitches generated by ChangeView when users type fast (control partially hidden and scrolling issues, see the GIF below).
only modify the accessibility view when it's necessary

ViewModel-side:
stop fully refreshing ExpressionTokens in StandardCalculatorViewModel when a new command were sent, instead, use a IObservableVector to only send new tokens to the UI (in average only 1 or 2 UI items are refreshed while the full expression was refreshed before)

How changes were validated:
Manually
2019-04-18 15:21:33 -07:00
Daniel Belcher
d21a47d5a1
Compile CalcManager project with or without precompiled headers (#436)
Fixes #324 .

Description of the changes:
In an effort to support other compilers (#109), this change reworks how precompiled headers are handled. For toolchains where precompiled headers are not used, there is unnecessary compilation cost because each source file explicity includes the pch, meaning all system headers in the pch were recompiled for each translation unit. This change modifies the project's files so that each translation unit includes a minimal set of dependent headers. For MSVC users, the precompiled headers option is still enabled and the precompiled header is added to each translation unit using the compiler's Forced Includes option. The end result is that MSVC users still see the same build times, but other toolchains are free to use or not use precompiled headers.

Risks introduced
Given that our CI build uses MSVC, this change introduces the risk that a system header is added to the pch and the CalcManager project builds correctly, but builds could be broken for other toolsets that don't use pch. We know we want to add support for Clang in our CI build (#211). It seems reasonable to also compile without precompiled headers there so that we can regression test this setup.

How changes were validated:
Rebuild CalcManager project. Compile time: ~4.5s.
Disable precompiled headers, keeping explicit include for pch in each source file. Compile time: ~13s.
Remove explicit pch inclusion and add the appropriate headers to each translation unit to allow the project to compile. Compile time: ~8s.
Re-enable pch and include it using the Forced Includes compiler option. MSVC compile time: ~4.5s.
Minor changes
Delete 'targetver.h'. I found this while looking around for system headers in the project. It's unused and unreferenced so let's remove it.
2019-04-17 17:28:45 -07:00
Seulgi Kim
853704c1c2 Add support for Pyeong, a Korean floorspace unit. (#444)
Fixes #382
Description of the changes:
Add Pyeong as an Area conversion unit.
Pyeong shows up only if the user's current region is Korea ( i.e. region is either KP or KR ).
Added Korean translation for Pyeong (평). For other locales, we default to English ( Pyeong ).
How changes were validated:
Manually tested the below

For non-Korean regions, Pyeong does not show up.

Korean region with Korean locale => Pyeong shows up and Pyeong is correctly translated.
pyeong_Korean

Korean region with English locale => Pyeong shows up and Pyeong is in English.
pyeong_English

Korean region with simplified Chinese locale => Pyeong shows up and Pyeong is in English.
pyeong_Chinese
2019-04-16 17:53:08 -07:00
jatinkumar
c150cd4ece Removed AppBar, OperatorTextBox and OperandTextBox controls (#440)
Fixes #407 
Removed AppBar, OperatorTextBox and OperandTextBox controls
2019-04-16 17:46:07 -07:00
Rudy Huyn
7a7ceb5888 Modify how modulo is calculated in Normal and Scientific mode. (#412)
## Fixes #111

> The modulo operator on this calculator gives the result that is different to the most used calculators.

The current `modrate` function is the equivalent of rem(...)/remainder(...), not mod(...)/modulo(...) available in some popular Math apps. 

### Description of the changes:
- rename `modrate` in `remrate` to be more accurate.
- add `modrate`, calculating modulo similarly to Matlab, Bing, Google calculator, Maxima, Wolfram Alpha and Microsoft Excel 
- Add `RationalMath::Mod` using `modrate` as an alternative to `Rational::operator%` using `remrate`
- Add a helper `SIGN` to retrieve the sign of a `Rational`.
- modify `CalcEngine` to use `modrate` in Normal and Scientific mode and `remrate` in Programmer mode.

### How changes were validated:
- manually and unit tests added
2019-04-16 17:17:24 -07:00
Rudy Huyn
ad25feda6b Keep input when users refresh currency rates (#369)
Fixes #260

Description of the changes:
prevent UnitConverterViewModel to reset values when users click on update rates.
recompute UnitConverter's caches (m_ratioMap and m_categoryToUnits) once rates are updated (but check first if the user did/didn't change the category)

How changes were validated:
Manually tested with fake currency rates (HTTP responses modified on the fly via FiddlerCore)
Verified that it works no matter the selected field (From or To)
Verified that the currencies selected are kept after a refresh
2019-04-16 11:29:43 -07:00
Rudy Huyn
5a6c6f4274 Prevent the application to crash when the current page is Date Calculation and users paste a text (#391)
Fix the else condition in ApplicationViewModel::OnPaste

How changes were validated:
Manually

Fixes #389
2019-04-15 09:51:06 -07:00
Rudy Huyn
109326508f Improve the support of Narrator with parenthesis (#368)
* Modify how we manage Narrator with parenthesis and refactor right parenthesis

* Optimization

* remove extra spaces

* take feedback into account
2019-04-15 09:31:02 -07:00
Michał Janiszewski
afdda581a4 Drop unneeded const-qualifier on return type (#396) 2019-04-12 13:40:02 -07:00
Pepe Rivera
f6f10444f7 Simplify some of the calc engine string logic (#449)
Description of the changes:
Currently Calculator handles strings by defining integers for each type of function that can be performed, this integer will eventually correspond with an index in s_engineStrings which holds the corresponding display string for each function. Some functions such as Sin can have multiple strings (degrees, rads, grads, inverse). Functions like Sin are mapped to another array called "rgUfne" where a new integer is given depending on the output string which will then be given to s_engineStrings. The new integer returned by the "rgUfne" array runs the risk of overlapping with any new functions that may be added in CCommand.h. Furthermore, it is expected that the strings in s_engineStrings and rgUfne are defined in a particular order (not necessarily sequential), otherwise the logic will break. This makes adding new strings for new functions confusing and difficult, since a lot of the logic is not clearly defined.

This PR attempts to make this a bit simpler by changing the s_engineStrings and rgUfne arrays to be unordered_maps instead of arrays. For s_engineStrings the keys will now be strings, allowing the existing logic for indexing to be used by simply converting the number into a string to access the value. This will also allow us to create keys in the future that are not limited to integers but to strings that hold more meaning.

The rgUfne array will also be updated to be a map that will take in an integer and give you the corresponding string that can be passed to s_engineStrings. The UFNE object in the rgUfne array will also be updated to hold all the possible string keys for a function, instead of indexing them on other numbers that may overlap with existing definitions.

Now to add a new string for a new IDC_FOO function, we would just need to add the "FooString" resource keys to the g_sids array and use the updated rgUfne map to link the IDC_FOO value to the corresponding "FooString" resource key. This way the resource key can be a meaningful string, and not an integer that must be in any particular order.

How changes were validated:
Tested each function manually in standard, scientific, and programmer modes.
2019-04-11 15:20:01 -07:00
Daniel Belcher
091732aa94
Feature/GraphingCalculator initial commit (#450)
Initial PR for the feature/GraphingCalculator feature branch, part of #338.

The feature incorporates a proprietary Microsoft-owned graphing engine to drive graphing experiences in the Windows Calculator app. Due to the private nature of the graphing engine, the source available in the public repo will make use of a mock graphing engine. See README.md for more details.

This PR simply serves as a base for future feature development. As such, the PR will be immediately merged. Feedback on the content of this PR, and on the feature in general, is encouraged. If there is feedback related to the content of this specific PR, please leave comments on the PR page. We will address the comments in future PRs to the feature branch.
2019-04-10 18:15:10 -07:00
Daniel Belcher
7ac750f7e5
Fix invalid check of m_precedenceOpCount (#298)
The conditional m_precedenceOpCount >= 0 was always true because m_precendenceOpCount is an unsigned type. Update the conditional to simply be true and rely on a break statement in the loop. Although this member variable used to be a signed type, in practice, the value was never less than 0.

How changes were validated:
Manual. Unit tests pass locally.
2019-04-09 14:12:28 -07:00
Rudy Huyn
af41a183a7 Optimize and simplify CalculationResult to be able to update the FontSize and the DisplayMargin without fully updating the Style. (#217)
- Merge the 3 CalculationResultStyle(S|M|L) in App.xaml
- Only modify CalculationResult::*FontSize in Calculator.xaml instead of fully updating the style of the control.
- Create a new property MaxFontSize in order to be able to update it without being forced to fully update the Style (because m_startingFontSize was set in OnApplyTemplate)
- Modify how DisplayMargin is managed to prevent the textblock Margin to shift when we update its value (without fully updating the Style).
2019-04-05 13:04:39 -07:00
Matt Cooley
e7eace57f8
Update localized strings 2019-04-04 (#438) 2019-04-05 08:39:29 -07:00
Rudy Huyn
6f49b17bf0 Add Reveal Highlight on AccentCalcButtonStyle + fix accessibility iss… (#374)
Add Reveal Highlight effect on the 4 basic operator buttons + Equal button (effect more visible with purple and all grey-ish accent colors). Also fixes a high contrast issue when the operator buttons were pressed.
2019-04-04 16:55:12 -07:00
Michał Janiszewski
f6a6aae6e6 Add additional defines for MSVC ARM and ARM64 to conv.cpp (#399)
Fixes ARM(64) regression introduced with #212
2019-03-28 11:17:06 -07:00
Michał Janiszewski
7a48f66807 Replace custom types with standard ones (#212)
Replace custom types with standard ones
2019-03-26 14:30:46 -07:00
Rudy Huyn
ef3f5e9cbb Improve performance of SupplementaryResult + Modify the height of RowDltrUnits when UnitConverter is in Landscape (#249)
* Modify the height of RowDltrUnits when UnitConverter  is in LandscapeLayout mode

* clean

* Use the same layout than the existing one while fixing the issue

* Refactor SupplementaryItemsControl to improve performance, not rely on parents and not force the parent element to be HorizonAlignment="stretch"

* take feedback into account

* add HorizontalNoOverflowStackPanel to vcproj.filters

* format conditionals

* replace max by std::max
2019-03-26 11:24:36 -07:00
Rudy Huyn
e9aea9237d Fix padding of unit converter when the current locale displays symbols on the left (#373) 2019-03-26 10:54:14 -07:00
Rudy Huyn
176718211a Accept plus/minus sign before a parenthesis in ClipboardManager (#346)
Modify scientificModePatterns regexes to support minus sign before parenthesis.
2019-03-25 19:09:05 -07:00
Daniel Belcher
19e61e2b53 Disable use of min/max macros defined by Windows headers. (#363)
Description of the changes:
  Disable Windows-provided min/max macros using the NOMINMAX flag. Add the flag to each project's pch to disable the macros across the solution.

How changes were validated:
  Project builds.
  Unit tests pass.
  Smoke tests.

Fixes #362.
2019-03-25 11:28:29 -07:00
Matt Cooley
e55ffe5b8d [Build] Remove conditional inclusion of resw files (#360)
The .resw files for all languages are expected to be checked into the repo (this used to not the the case). Let's remove the conditions in the project file which ignore them if they don't exist.

Additionally removes pseudo-loc resource references from the build as pseudo-loc resources aren't currently being generated.
2019-03-25 11:16:15 -07:00
Rudy Huyn
65045e9375 Update the year in the Copyright string (#320)
Templatize the copyright string and use a build variable to set the year for use across the entire app.

How changes were validated:
Tested with English and French and with different dates.
2019-03-25 11:11:24 -07:00
Matt Cooley
c4361e2bdf
Update localized strings (#357) 2019-03-22 12:29:18 -07:00
Matt Cooley
2a7c53a27d
Add TemporaryKey.pfx (#354) 2019-03-21 17:03:42 -07:00
Shamkhal Maharramov
fd317f5623 Simplify multiple "or" operators (#341)
Use implicit enum to int conversion to simplify some value checking against the Command enum.
2019-03-21 10:43:59 -07:00
Michał Janiszewski
80a5fa01b0 Make CalculatorManager final rather than sealed (#331)
I have no idea if it is required to be `sealed`, I have seen no `^`
operator which makes me think it could be a regular C++ code, barring
the concurrency stuff.
2019-03-20 17:23:09 -07:00
Michał Janiszewski
597caf9c6b Fix order of initialization list in CalculatorManager, COpndCommand (#332)
This ensures the initialization order matches the layout of member
fields in class declaration
2019-03-20 16:45:30 -07:00
Michał Janiszewski
426a6c058d Remove expression with no effects from CalculatorManager (#337) 2019-03-20 16:43:51 -07:00
Shamkhal Maharramov
251ffffc50 Propose code-cleanups#2 (#253)
Description of the changes:

Remove redundancy
Simplify if statements
2019-03-20 14:28:30 -07:00
Michał Janiszewski
683b91aeec Remove redundant type qualifiers on function return type (#329) 2019-03-20 14:22:31 -07:00
Michał Janiszewski
94f0e8b320 Replace fallthrough comment with C++17's attribute (#334) 2019-03-20 14:19:30 -07:00
Michał Janiszewski
462694dcef Remove unused member field from CalculatorHistory (#330) 2019-03-20 10:58:32 -07:00
Daniel Belcher
3bff99b323 ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
Rudy Huyn
4b6b8fa8fa Fix auto-scaling of CalculationResult when the current locale displays currency symbols on the right (#246)
* Fix auto-scaling of CalculationResult when the current locale displays symbols at the right

* Formatting

* add padding

* modify padding of ValueContainer
2019-03-20 09:54:02 -07:00
Rudy Huyn
21e15c426e hide history button in programmer mode (#327)
Description of the changes:
  Hide the History button when in Programmer mode via VisualState

How changes were validated:
  Open Standard mode
  Switch to Programmer mode
  Verify that the History button isn't visible

Fixes #326
2019-03-18 14:22:44 -07:00
Rudy Huyn
62b2fafdd0 Fix formatting issues with CurrencyConverter and some locales (#242)
The ViewModel wrongly assumed that non-breaking spaces were only used between the value and the symbol. It's not the case of all locales using non-breaking spaces as a thousand delimiter (French for example).

When it was the case, the function only replaced the first thousand delimiter found and kept the extra space at the end of the string, generating 2 issues:

Extra space at the end: #240
Bad formatting of the number: #232

Description of the changes:
   Replace currencyResult.find(L'\u00a0') by a regex only removing spaces at the end of the string.

Fixes #240 and #232
2019-03-18 14:09:13 -07:00
Michał Janiszewski
3d18dd38c2 Add explicit [[fallthrough]] attributes in Ratpack (#323) 2019-03-18 14:02:02 -07:00
Shamkhal Maharramov
965e36cc5d Propose minor code-cleanups (#241)
Description of the changes:
Remove unnecessary 'else', 'continue' statements

How changes were validated:
Manual.
2019-03-18 13:38:04 -07:00
Cyril
b8b0fdf86b Improving code style : verbosity, indentation levels (#200)
Fixing some nested if() statements and reducing indentation levels.

Making some sections less verbose, e.g:

if (a == 1)
{
    b = true;
}
else
{
    b = false;
}
↓

b = (a == 1)
2019-03-18 12:31:04 -07:00
Rudy Huyn
cd7c266a6b Fix issue with Date diff when it includes a Daylight Saving Time (#193)
The application uses local time to calculate the number of days between 2 dates. If a Daylight Saving Time takes place during this period of time (only Clocks Forward 2am->3am), the application will miss 1 day and fail to calculate the number of days/weeks/months between the 2 dates.
image

Description of the changes:
DateCalculationEngine uses local time to modify dates, however, AddDays, AddWeeks,... won't add 24 hours or 7 days if DST happens between the 2 dates, but instead add ~23.9/24.1 hours or ~6.9/7.1 days (depends if it's the DST clock backward or clock forward). When the DST is clock forward, DateCalculationEngine will miss one day.

Solution
use UTC dates to calculate date difference.

Extra Fix:
use calendar->FirstPeriodInThisDay and calendar->FirstHourInThisPeriod in ClipTime (else it will set the time to 12PM (noon) in some regions.
replace OBSERVABLE_PROPERTY_RW by OBSERVABLE_PROPERTY_R when possible.
remove the definition of CheckClipTimeSameDay (implementation missing)

How changes were validated:
Tested manually with different regions (FR, US, ES, JP).

Fixes #178
2019-03-18 11:22:32 -07:00
Rudy Huyn
e40791d7ad Fix compilation issues due to unsigned/signed warnings treated as errors (#317) 2019-03-15 21:21:30 -07:00
Brandon Williams
4a41e37c87 Added support for pasting of monetary values (#176)
Fixes #52

Description of the changes:
Added support for pasting of prefix currency symbols supported by the Windows keyboard.
yen or yuan (¥)
unspecified currency sign (¤)
Ghanaian cedi (₵)
dollar or peso ($)
colón (₡)
won (₩)
shekel (₪)
naira (₦)
Indian rupee (₹)
pound (£)
euro (€)

How changes were validated:
Manually tested each prefix currency symbol supported by the Windows keyboard and ran unit tests.
2019-03-15 17:45:49 -07:00
Rudy Huyn
ca15f05227 DateDiff: Optimize how we build the string used when we calculate the difference between 2 dates (#195)
Optimize how we build the result of GetDateDiffString and GetDateDiffStringInDays, using std::wstring (mutuable) instead of Platform::String (immutable)
2019-03-15 17:20:33 -07:00
Nikita Potapenko
244fd8deee Fix grid.Row (#279)
Fixes #265
Fixes invalid grid.Row assignment for decimalSeparatorButton
2019-03-15 02:06:10 -07:00
Will
1113ff4b86 Updating comments per the C++ core guidelines and removing trailing whitespace (#194)
Fixed comments that were inconsistent with the style guidelines described in C++ core guidelines and the modern C++/WinRT language projections and removed trailing whitespace.

Inserted a space after the beginning of the comment so the text wasn't touching the // on all occurrences.

Removed all occurrences of trailing whitespace
2019-03-14 23:30:07 -07:00
Rudy Huyn
62317fd63b Activate TextSelection on all interesting values/results (#213)
If we allow users to select texts, the application will feel more like a "Desktop app", will be easier to use on a tablet and users will be more prompt to use Ctrl+C to use the result in another app.
2019-03-14 22:35:55 -07:00
Satya
7cad778cc0 Fix memory leak (#300)
Free memory allocated to temp before returning from the function.
2019-03-14 21:21:17 -07:00
Michał Janiszewski
a5e07418df Replace custom ARRAYSIZE macro with std::size (#208)
* Replace custom ARRAYSIZE macro with std::size
2019-03-14 21:06:12 -07:00
Stephanie Anderl
d37c75fec2
Fixes #282 Narrator does not convey error information when no more Right Parenthesis can be added in expression. (#284)
* Added narrator announcements when right parenthesis is clicked
2019-03-14 16:20:05 -07:00
Guillaume Rischard
ac5292cf88 Optimised images losslessly. (#229)
Saved 301 KB out of 9.2 MB. 15.8% per file on average (up to 82.2%)
Fixes #.
Saves 301 KB (although not all files are included in the build)
Description of the changes:
For PNG files: used a combination of Pngcrush, OxiPNG, AdvPNG, PNGOUT and Zopfli
For GIF files: used Gifsicle
How changes were validated:
No changes to behaviour or source code.
Previewed the changed files to make sure they still work
2019-03-13 16:37:50 -07:00
Rudy Huyn
6f4ecf35b3 Remove RenderTransform that is never used (#247) 2019-03-13 15:08:51 -07:00
Michał Janiszewski
be31288187 Fix declarations of functions (#186)
Move file-scope functions to anonymous namespaces.
Drop #pragma once from .cpp files
2019-03-13 13:15:08 -07:00
Jeff Genovy
251578047f Make 73 numeric constants const, moving them into .rdata (#234)
This change makes the 73 variables in ratconst.h actually
inline const, which allows them to move from the mutable .data
section of the executable, and into the read-only .rdata
section instead.

Moving data to the .rdata section has a number of benefits,
such as preventing possible corruption due to stray writes,
or other memory corruption.

Additionally, the initialization at run-time start-up is no
longer needed, so there is also a reduction in the .text
(code) section as well.

As a result the overall size of the Calculator.exe binary
(on x64 Release builds) decreases by 1,536 bytes (or ~1.5 KB)
with no change in behavior other than a small performance benefit.
2019-03-13 13:10:14 -07:00
Rudy Huyn
7663c0d5f2 Remove .editorconfig from sln (#290)
#225 accidentally added a duplicate .editorconfig to the repo as well as to the solution.
#257 removed the duplicate .editorconfig, but not its entry in the solution.
This update removes the extra .editorconfig reference to a version that #257 already removed from the repo.
2019-03-13 12:50:23 -07:00
Howard Wolosky
29c362657b
Remove logging of invalid pasted text (#286)
Addressing community feedback for removal of diagnostic data
2019-03-13 03:34:06 -07:00
Jeff Genovy
e6bd36ec2a Eliminate redundant copies of EMPTY_UNIT object, saving 2.5 KB. (#235)
### Description of the changes:

There are currently 11 copies of the `EMPTY_UNIT` object in the
`Calculator.exe` binary, which not only wastes space/footprint in the
binary itself, but also means that each copy must be separately
initialized, which effects performance.

The reason for this is that the object is defined in a shared header
file, which then is included by multiple .cpp files, causing each
translation unit (.obj) to get a full complete copy of the object.

By marking the object as `inline` we can
instruct the linker to define the object once, as we do
not need to have 11 unique versions of the EMPTY_UNIT object,
we only need 1.

The net result is that the `Calculator.exe` binary size is reduced by
2,560 bytes (or 2.5 KB) with no change in behavior, other than
the small performance benefit of not initializing 10 redundant copies
of the object.

### How changes were validated:
- Manually tested.
2019-03-12 19:24:37 -07:00
Rudy Huyn
a80d082242 CopyPasteManagerTest fails to test all values (#269)
CopyPasteManager unit tests were not fully run, the first item of arrays were never tested. (Luckily, the not-tested values were ok).

Updated from using a pre-decrement while loop to using a standard for loop with an iterator.
2019-03-12 14:58:47 -07:00
Johan Laanstra
67fa2286eb Remove duplicate .editorconfig. (#257)
* Remove duplicate .editorconfig
* Update .editorconfig to remove forcing crlf as discussed in #225.
2019-03-11 17:04:17 -07:00
Rudy Huyn
0f615faff9 Remove end-of-line from .editorconfig (#239)
* Add Editor config

* reset sln

* remove end-of-line setting
2019-03-09 15:46:32 -08:00
Shamkhal Maharramov
a98cb50a70 fix: redundant semicolons (#230)
### Description of the changes:
- Remove redundant semicolons in:
  - [x] UnitConverter.cpp
  - [x] DateCalculator.xaml.cpp
  - [x] CopyPasteManagerTest.cpp

### How changes were validated:
-  Manual
2019-03-09 08:16:05 -08:00
Rudy Huyn
140a5b3b21 add .editorconfig to set some basic coding styles (#225)
To maintain consistent code style between contributors and simplify merging, the solution should provide a .editorconfig to set some basic rules (already used by the current code source).

- use `UTF-8` with BOM (some files are without)
- use CR-LF
- use <kbd>Space</kbd> to indent (sorry #teamTab)
- trim trailing whitespace 
- be sure to add a new line at the end of files.

[Documentation](https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017)
2019-03-09 08:09:51 -08:00
Petr Sedláček
248b762b80 Fix indentation and extra newline (#198) 2019-03-08 23:47:40 -08:00
Brett Waldbaum
64c6493312
Build with /W4 (#197)
All projects are built with warning level 4 (/W4) and treat warnings as errors (/WX).
Fixed build errors resulting from enabling these compiler flags.
2019-03-08 23:15:28 -08:00
marcellogianola
e0f70e8c37 fixed typo (#171) 2019-03-08 13:46:36 -08:00
Michał Janiszewski
c85d7ec454 Compare locale strings, not their pointers (#183)
Change the stored locale type to wstring to make the comparison operator
work.
2019-03-08 13:45:39 -08:00
Michał Janiszewski
0197bf18c1 Add override keyword where applicable (#188) 2019-03-08 11:18:01 -08:00
Michał Janiszewski
c6b770eec8 Fix usage of temporary string (#185) 2019-03-07 22:10:20 -08:00
Michał Janiszewski
c325cb1b3a Remove duplicated condition checks (#187) 2019-03-07 22:09:37 -08:00
Michał Janiszewski
13ba479a0c Remove unused variable (#184) 2019-03-07 21:38:40 -08:00
Michał Janiszewski
e2c7db644d Mark classes as final where applicable (#189) 2019-03-07 19:46:53 -08:00
Michał Janiszewski
0166daf5c7 Replace escape sequences with path separators in include paths 2019-03-07 15:51:00 -08:00
Josh Soref
84941c698e Spelling (#135) 2019-03-07 10:27:13 -08:00
Michał Janiszewski
2320697562 Catch polymorphic types by const-ref (#125) 2019-03-07 09:45:51 -08:00
Rudy Huyn
20afac5572 Modify how default units are selected for conversions (#126) 2019-03-07 09:24:34 -08:00
Josh Soref
8a75dcd09d Switch urls from http: to https: (#137) 2019-03-07 08:56:25 -08:00
Karan Nandwani
dc00380d0f updating nuget.org source to point to V3 (#129) 2019-03-07 07:33:22 -08:00
Jared Fuchs
8fa9a691cc Fix comment on IsEven
Looks like the comment on IsEven should read this way instead of "The assumption here is its numerator is 1 and we are testing the numerator is even or not"
2019-03-06 17:14:50 -08:00
Michał Janiszewski
6c0e4e81e7 Remove unused values 2019-03-06 16:47:02 -08:00
Michał Janiszewski
ca01a7e444 Add explicit [[fallthrough]] attribute 2019-03-06 16:44:28 -08:00
Edward Betts
0197fa41da Correct spelling mistakes 2019-03-06 16:10:14 -08:00
Michał Janiszewski
07ff1c372f Fix initialization order in CEngine (#118)
The order of initialization of fields is required to match the one in
class member fields declaration.
2019-03-06 14:51:21 -08:00
Daniel Belcher
057401f5f2 Suppress conversion warning in Ratpack/conv.cpp.
When building for x64, the compiler complains:
    warning C4267: 'argument': conversion from 'size_t' to 'ULONG', possible loss of data

In practice, the number string will not exceed a ULONG in length.
2019-03-05 21:42:24 -08:00
Stephanie Anderl
b865b1b2aa
Add Checked Event Handler to Add/Subtract Radio Buttons to enable Narrator (#91)
* added bug report and feature request issue tempaltes

* copied pull_request_template.md to .github folder

* Updated the DateCalculation narrator logic to use PropertyChangedCallbacks for the DateResultLabel and DateDiffAllUnitsResultLabel TextBlocks.

* Reverted textblock callback changes and added an event handler for when the radio buttons are checked.

* Revert NarratorAnnouncement.h changes and removed unused code from DataCalculator.xaml.h. Updated comments in RaiseNotification method in DateCalculator.xaml.cpp

* Reverted changes in NarratorAnnouncement.h and NarratorAnnouncement.cpp

* Added SAL annotation to AddSubtractOption_Checked

* Remove namespaces from input types on AddSubtractOption_Checked
2019-03-05 20:26:37 -08:00
Stephanie Anderl
b0e24c6f4c Updated UnitConvert ComboBox and Programmer Mode Radio Button Styles to Enable IsTextScaleFactorEnabled (#92) 2019-03-05 17:27:07 -08:00
Howard Wolosky
a0e2dacd98 Updating all icons/images to latest version of the "developer build" icons
All Calculator app iconography uses the "developer version" icon from Design,
to help differentiate a developer build of Calculator from the official version.

Assets have been run through the image compression tools to ensure all unnecessary
metadata has been removed.
2019-03-04 12:30:30 -08:00
Stephanie Anderl
321672995d
Update Rates Hyperlink changed to a HyperlinkButton (#29)
* update currency hyperlink changed to a hyperlink button

* added bug report and feature request issue tempaltes

* copied pull_request_template.md to .github folder

* update currency hyperlink changed to a hyperlink button

* Updated hyperlink button to move text that should not be linked outside the hyperlink button

* Updated hyperlink button to move CurrencySecondaryStatus text out of the hyperlinkbutton control.

* Updated the HyperlinkButton to set the content without using a TextBlock and fixed the AutomationTree issue where the HyperlinkButton wasn't being seen
2019-03-01 13:11:05 -08:00
Lance McCarthy
060139f493 Readability Improvements to Calculator.xaml (#85)
* Calculator.xaml - Simple Readability Adjustments

Improved readability of the XAML document by inserting newline where they were missing and removed rextra newlines from others.

* Added comments and organized resources for superior readability

Using comments and grouping DataTemplates, Styles and other resources significantly increases the readability and discovery of resources.
2019-03-01 11:40:02 -08:00
Daniel Belcher
dd79d6fcd3 Move the CalculatorManager instance to be direct member data of the StandardCalculatorViewModel class.
Previously, the CalculatorManager was managed with a unique_ptr that was instantiated in the ViewModel's constructor and was never re-assigned.  Objects with long lifetime and larger memory footprint should live in dynamic memory, but the ViewModel itself lives in dynamic memory so that goal is still satisfied by storing the CalculatorManager directly in the class. The change allows the compiler to write a more efficient memory footprint for the same data.

- Verified by testing basic app functionality and running unit tests locally.
2019-02-28 16:26:19 -08:00
Matt Cooley
28f982a6e1
Apply spell check (#41) 2019-02-26 20:41:04 -08:00
Matt Cooley
654f09f544
Fix spelling in some comments (#38) 2019-02-25 15:41:16 -08:00
Josh Koon
ddc470949c
Rename scimath.h/cpp to RationalMath.h/cpp (#36) 2019-02-25 14:04:38 -08:00
Josh Koon
0cb5e9bae0
CalcEngine: Manage precision internally to Rational and convert functions to operator overrides (#35)
* Convert Rational::Negate to an operator override
* Convert Rational::Add to + and += operator overrides.
* Convert Rational::Sub to - and -= operator overrides.
* Convert Rational::Div and ::Mul to use /, /=, *, *= operator overrides.
* Convert Rational::Mod to use %= and % operator overrides
* Convert Rational::Rsh and ::Lsh to use >>=, >>, <<=, << operator overrides
* Convert Rational::And, ::Or, ::Xor to use &=, &, |=, |, ^=, ^ operator overrides
* Convert Rational relational functions to operator overrides
* Remove unnecessary precision arguments from Rational class and remove use of explicit Rational constructors in favor of implicit conversions for value types
* Remove unnecessary precision variable from RationalMath operations
* Replace unnecessary Rational::Not with Xor operation
* Remove unnecessary Rational::IsZero() in favor of == 0 comparisons
* Fix rounding issues in ratpak that result from using large precisions.
* Move assignment stmt out of IsCurrentTooBigForTrig
2019-02-25 11:41:32 -08:00
Josh Koon
73372283a0
CalcEngine: Remove the need to specify base/radix when working with Rational values (#31)
- Separates values from the representation (base/radix) of those values.
- Uses a single base for all values represented as Rationals.
- Rationals are converted to/from a specific base when they are converted to/from strings.
2019-02-22 10:00:19 -08:00
Josh Koon
5a530c4bed
Change m_nPrecNum from int to size_t and rename to m_precedenceOpCount (#33) 2019-02-21 16:36:54 -08:00
Josh Koon
32fb8500cb
Fix Log10 function (#27) 2019-02-21 10:50:32 -08:00
Josh Koon
2e18f6f477
Move RADIX_TYPE enum into its own header (#25)
This change moves the RADIX_TYPE enum into its own header. This resolves a compilation error and reduces the dependency graph by allowing RadixToStringConverter to include just the enum header rather than the entire CalcEngine header.

Change verified by ensuring Calculator build locally.
2019-02-20 11:07:32 -08:00
Josh Koon
995f077127
CalcEngine: Convert NumObj* functions to use Rationals and move under CalcEngine::RationalMath namespace (#12)
* Converts NumObj* functions to use Rationals. Places new functions under CalcEngine::RationalMath namespace
* Moves functions that correspond to an operator to the Rational class with intent to convert to operators in the future
* Consolidates use of RatPack's NUMBER and RAT data types to Number/Rational classes and RationalMath namespace.
2019-02-19 07:46:17 -08:00
Daniel Belcher
f210290ddc - Avoid referencing project headers from precompiled headers.
Before this change, the pchs for CalcViewModel and Calculator project referenced project headers.  If those project headers (or any of their dependencies) were to change, then the pch would be recompiled, slowing local build times.

  By removing references to project headers, the pch will be compiled once and is resilient to changes in the project.  Now that project headers are explicit about their dependencies, when there is a change to a project header only the translation units referencing the modified header will need to be rebuilt.

- Manually tested by ensuring Calculator project builds locally.

@Microsoft/calculator-team
2019-02-14 18:20:25 -08:00
Pepe Rivera
362b4f9d1e
Merge pull request #16 from joseartrivera/joriv/OnLaunchSize
Resize app to appropriate dimensions on first launch
2019-02-13 09:56:01 -08:00
Matt Cooley
2ab114a71f
Update WinUI to 2.0.181018004 (#18)
Update the Microsoft.UI.Xaml NuGet package to a new version. The ARM64 framework package in 2.0.181018003.1 had entries missing from its manifest, so the classes in the package couldn't be activated.
2019-02-13 09:44:02 -08:00
Pepe Rivera
531a8a1b7b Use TryResizeView to resize calc on first launch 2019-02-12 13:50:09 -08:00
Stephanie Anderl
cb8775926a
Merge pull request #13 from Microsoft/sanderl/JapaneseEra
Date Calculation: Updated AdjustCalendarDate() to ensure we always add 365 when adding 1 year for Japanese calendar
2019-02-08 15:51:28 -08:00
Stephanie Anderl
2fc8196104 Moved all the Japanese Era logic inside the Year case of the switch statement 2019-02-08 15:42:28 -08:00
Stephanie Anderl
1bd4f1870c Updated calendar strings to use the CalendarIdentifiers object 2019-02-08 15:33:00 -08:00
Stephanie Anderl
f8029942d4 Updated the AdjustCalendarDate() to account for the transition year quirk in the Japanese calendar. 2019-02-08 12:30:16 -08:00
Matt Cooley
a2739b8de2
Don't send AppLifecycle telemetry unless SEND_TELEMETRY is defined (#10)
The app currently logs diagnostic events to ETW in various places. If we add certain flags to those events, the data is eligible to be sent as telemetry. (Whether it actually gets sent is controlled outside of Calculator--for example, there are lots of checks at the system level to ensure privacy settings are honored.)

Currently we set the "eligible for telemetry" flags only in official builds, so no telemetry gets uploaded while the app is in development. We already have this set up for the main TraceLogging provider, but we also need to do this for the AppLifecycle performance logging.
2019-02-04 12:06:02 -08:00
Matt Cooley
ac63c1e1c2
Remove calcmanager ref (#9)
Calculator (the main app project) depends on CalcManager, but only transitively: Calculator -> CalcViewModel -> CalcManager.

However, Calculator's project file currently has a direct dependency on CalcManager. Let's remove this to make it harder to accidentally introduce new dependencies between the layers.

Also cleaning up some commented-out directives in the CalcManager MSBuild file.
2019-02-04 11:53:02 -08:00
Matt Cooley
177a606012
Clean up project structure in Visual Studio (#8)
A few small changes to improve the view of the code in Solution Explorer:
* Delete folders from solution explorer which don't appear on disk (Resource Files, PerfTrack)
* Delete files on disk which aren't compiled into the project (Type.xaml)
* Rename CalculatorHistory.Cpp to CalculatorHistory.cpp, for consistency with other files
2019-02-04 11:52:28 -08:00
Matt Cooley
4cadfb204d
Remove unused PLM code (#7)
Remove LayoutAwarePage, SuspensionManager, and other suspend-resume handling code. SuspensionManager::SaveAsync and related methods weren't actually called anywhere. I didn't attempt to remove the serialize/deserialize code at the ViewModel layer, although much of that is likely not needed either.

We may decide we want to persist more state through a suspend-terminate-resume cycle (as the app might have done a long time ago). But if we decide we want that, we should not use a persistence mechanism that's closely coupled to frame navigation.
2019-02-01 15:15:48 -08:00
Matt Cooley
8df88c7106
Fix file path in CalculatorUnitTests.vcxproj.filters (#6) 2019-01-31 13:05:10 -08:00
Matt Cooley
278a1e714e
Remove MSBuild directives which were used only in the internal build system (#5)
Remove some properties which were only used when XefOutputRoot was set in the previous internal-only build environment.
2019-01-29 19:39:20 -08:00
Matt Cooley
1c7187f632
Clean up unit test projects (#4)
* Rename CalculatorUnitTests_VS to CalculatorUnitTests, fix gitignore

* Delete internal unit tests

* Update pipeline paths
2019-01-29 19:37:37 -08:00
Josh Koon
ebfce5a8cd Remove empty COpndCommand destructor. Cleanup constructor declaration. 2019-01-29 14:28:03 -08:00
Josh Koon
b70a12c6cf Add clarifying comment to call to CHistoryCollector::AddOpndToHistory 2019-01-29 14:27:24 -08:00
Josh Koon
db4a6eb9ea Return to initialization pattern in ExpressionCommand 2019-01-28 19:34:36 -08:00
Josh Koon
4883fab7f7 Convert ExpressionCommand and History collector to use Rational instead of PRAT 2019-01-28 19:14:15 -08:00
Howard Wolosky
c13b8a099e Hello GitHub 2019-01-28 16:24:37 -08:00