mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Merge pull request #73 from nventive/dev/yogu/currency.fix.missing.issues
Add decimal button on NumPad for all platform + Add workaround for WASM Currency API calls
This commit is contained in:
commit
8b449d6a15
8 changed files with 976 additions and 960 deletions
|
@ -17,8 +17,8 @@ namespace CalculatorApp.DataLoaders
|
|||
string m_responseLanguage;
|
||||
string m_sourceCurrencyCode;
|
||||
|
||||
static string sc_MetadataUriLocalizeFor = "https://go.microsoft.com/fwlink/?linkid=2041093&localizeFor=";
|
||||
static string sc_RatiosUriRelativeTo = "https://go.microsoft.com/fwlink/?linkid=2041339&localCurrency=";
|
||||
static string sc_MetadataUriLocalizeFor = "https://cors-anywhere.herokuapp.com/https://go.microsoft.com/fwlink/?linkid=2041093&localizeFor=";
|
||||
static string sc_RatiosUriRelativeTo = "https://cors-anywhere.herokuapp.com/https://go.microsoft.com/fwlink/?linkid=2041339&localCurrency=";
|
||||
|
||||
public CurrencyHttpClient()
|
||||
{
|
||||
|
@ -26,30 +26,20 @@ namespace CalculatorApp.DataLoaders
|
|||
m_responseLanguage = "en-US";
|
||||
}
|
||||
|
||||
public void SetSourceCurrencyCode(String sourceCurrencyCode)
|
||||
public void SetSourceCurrencyCode(string sourceCurrencyCode)
|
||||
{
|
||||
m_sourceCurrencyCode = sourceCurrencyCode;
|
||||
}
|
||||
|
||||
public void SetResponseLanguage(String responseLanguage)
|
||||
public void SetResponseLanguage(string responseLanguage)
|
||||
{
|
||||
m_responseLanguage = responseLanguage;
|
||||
}
|
||||
|
||||
public Task<String> GetCurrencyMetadata()
|
||||
{
|
||||
string uri = sc_MetadataUriLocalizeFor + m_responseLanguage;
|
||||
var metadataUri = new Uri(uri);
|
||||
public async Task<string> GetCurrencyMetadata() => await ExecuteRequestAsync(sc_MetadataUriLocalizeFor + m_responseLanguage);
|
||||
|
||||
return m_client.GetStringAsync(metadataUri);
|
||||
}
|
||||
public async Task<string> GetCurrencyRatios() => await ExecuteRequestAsync(sc_RatiosUriRelativeTo + m_sourceCurrencyCode);
|
||||
|
||||
public Task<String> GetCurrencyRatios()
|
||||
{
|
||||
string uri = sc_RatiosUriRelativeTo + m_sourceCurrencyCode;
|
||||
var ratiosUri = new Uri(uri);
|
||||
|
||||
return m_client.GetStringAsync(ratiosUri);
|
||||
}
|
||||
private async Task<string> ExecuteRequestAsync(string url) => await m_client.GetStringAsync(new Uri(url));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -480,6 +480,15 @@
|
|||
Value="{StaticResource CalcOperatorCaptionSize}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DecimalButtonStyle"
|
||||
BasedOn="{StaticResource OperatorButtonStyle}"
|
||||
TargetType="Controls:CalculatorButton">
|
||||
<Setter Property="FontWeight"
|
||||
Value="Bold" />
|
||||
<Setter Property="FontSize"
|
||||
Value="24" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SymbolOperatorButtonStyle"
|
||||
BasedOn="{StaticResource OperatorButtonStyle}"
|
||||
TargetType="Controls:CalculatorButton">
|
||||
|
|
|
@ -424,7 +424,8 @@
|
|||
Grid.RowSpan="4"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle18}" />
|
||||
ButtonStyle="{StaticResource NumericButtonStyle18}"
|
||||
DecimalButtonStyle="{StaticResource DecimalButtonStyle}" />
|
||||
|
||||
<controls:CalculatorButton x:Name="aButton"
|
||||
x:Uid="aButton"
|
||||
|
|
|
@ -1034,6 +1034,7 @@
|
|||
Grid.Column="6"
|
||||
Grid.ColumnSpan="3"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}" />
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}"
|
||||
DecimalButtonStyle="{StaticResource DecimalButtonStyle}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -605,7 +605,8 @@
|
|||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}" />
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}"
|
||||
DecimalButtonStyle="{StaticResource DecimalButtonStyle}" />
|
||||
|
||||
<controls:CalculatorButton x:Name="negateButton"
|
||||
x:Uid="negateButton"
|
||||
|
|
|
@ -118,10 +118,9 @@
|
|||
-->
|
||||
<controls:CalculatorButton x:Name="decimalSeparatorButton"
|
||||
x:Uid="decimalSeparatorButton"
|
||||
Grid.Row="4"
|
||||
Grid.Row="3"
|
||||
Grid.Column="2"
|
||||
Style="{Binding ElementName=ControlRoot, Path=ButtonStyle}"
|
||||
Background="{ThemeResource AppBackgroundAltMediumLowBrush}"
|
||||
Style="{x:Bind Path=DecimalButtonStyle, Mode=OneWay}"
|
||||
AutomationProperties.AutomationId="decimalSeparatorButton"
|
||||
ButtonId="Decimal"
|
||||
IsEnabled="{Binding IsDecimalEnabled}" />
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace CalculatorApp
|
|||
{
|
||||
public sealed partial class NumberPad : UserControl
|
||||
{
|
||||
#region ButtonStyle
|
||||
public Style ButtonStyle
|
||||
{
|
||||
get { return (Style)GetValue(ButtonStyleProperty); }
|
||||
|
@ -30,7 +31,20 @@ namespace CalculatorApp
|
|||
|
||||
// Using a DependencyProperty as the backing store for ButtonStyle. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty ButtonStyleProperty =
|
||||
DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(NumberPad), new PropertyMetadata(null));
|
||||
DependencyProperty.Register(nameof(ButtonStyle), typeof(Style), typeof(NumberPad), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region DecimalButtonStyle
|
||||
public Style DecimalButtonStyle
|
||||
{
|
||||
get { return (Style)GetValue(DecimalButtonStyleProperty); }
|
||||
set { SetValue(DecimalButtonStyleProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DecimalButtonStyleProperty =
|
||||
DependencyProperty.Register(nameof(DecimalButtonStyle), typeof(Style), typeof(NumberPad), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
private bool m_isErrorVisualState;
|
||||
|
||||
public NumberPad()
|
||||
|
|
|
@ -857,6 +857,7 @@
|
|||
VerticalAlignment="Stretch"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}"
|
||||
DecimalButtonStyle="{StaticResource DecimalButtonStyle}"
|
||||
TabIndex="10"
|
||||
TabNavigation="Local"/>
|
||||
<controls:CalculatorButton x:Name="ConverterNegateButton"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue