Polish
Adding polish to the outputs, such as icons and better alignment.
This commit is contained in:
parent
d24a7b400a
commit
07c8ed8460
7 changed files with 63 additions and 57 deletions
|
@ -33,6 +33,9 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="csmic, Version=1.1.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\csmic.1.1.4\lib\net40\csmic.dll</HintPath>
|
||||
|
@ -105,5 +108,11 @@
|
|||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="calculator-variant-black.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AdvancedCalculator
|
||||
{
|
||||
|
@ -14,29 +10,31 @@ namespace AdvancedCalculator
|
|||
|
||||
public string FunctionDescription { get; private set; }
|
||||
|
||||
public string Icon { get; private set; }
|
||||
|
||||
public IEnumerable<KeyValuePair<string, string>> FunctionArguments { get; private set; }
|
||||
|
||||
public static IEnumerable<FunctionDefinitonItem> DefinedFunctions
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "sin", FunctionDescription = "Returns the sine value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "cos", FunctionDescription = "Returns the cosine value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "tan", FunctionDescription = "Returns the tangent value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "round", FunctionDescription = "Rounds an expression to the nearest whole number.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "sqrt", FunctionDescription = "Returns the square root of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "abs", FunctionDescription = "Returns the absolute value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "exp", FunctionDescription = "Returns the constant e to a given power.", FunctionArguments = new[] { new KeyValuePair<string, string>("power", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "log", FunctionDescription = "Returns the log of the first expression to the base of the second expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("value", "An expression to compute."), new KeyValuePair<string, string>("base", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "precision", FunctionDescription = "Returns the value of expression1 to a given precision. For example, precision(12.3456789, 4) will return 12.3456.", FunctionArguments = new[] { new KeyValuePair<string, string>("value", "An expression to compute."), new KeyValuePair<string, string>("precision", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "sin", Icon = IconFont.SineWave, FunctionDescription = "Returns the sine value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "cos", Icon = IconFont.CosineWave, FunctionDescription = "Returns the cosine value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "tan", Icon = IconFont.MathTan, FunctionDescription = "Returns the tangent value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "round", Icon = IconFont.RoundedCorner, FunctionDescription = "Rounds an expression to the nearest whole number.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "sqrt", Icon = IconFont.SquareRoot, FunctionDescription = "Returns the square root of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "abs", Icon = IconFont.PlusCircle, FunctionDescription = "Returns the absolute value of a given expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("expression", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "exp", Icon = IconFont.AlphaECircle, FunctionDescription = "Returns the constant e to a given power.", FunctionArguments = new[] { new KeyValuePair<string, string>("power", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "log", Icon = IconFont.MathLog, FunctionDescription = "Returns the log of the first expression to the base of the second expression.", FunctionArguments = new[] { new KeyValuePair<string, string>("value", "An expression to compute."), new KeyValuePair<string, string>("base", "An expression to compute.") } };
|
||||
yield return new FunctionDefinitonItem() { FunctionName = "precision", Icon = IconFont.DecimalIncrease, FunctionDescription = "Returns the value of expression1 to a given precision. For example, precision(12.3456789, 4) will return 12.3456.", FunctionArguments = new[] { new KeyValuePair<string, string>("value", "An expression to compute."), new KeyValuePair<string, string>("precision", "An expression to compute.") } };
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Properties
|
||||
|
||||
private FunctionDefinitonItem()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:AdvancedCalculator"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
Title="Advanced Calculator" Height="450" Width="800" Icon="calculator-variant-black.png">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
|
@ -19,19 +19,19 @@
|
|||
<ListView Grid.Row="0" x:Name="lvVariableList" HorizontalContentAlignment="Stretch">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding VariableName}" FontWeight="Bold" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
<TextBlock Visibility="{Binding ExpressionVisibility}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Path=ActualHeight, RelativeSource={RelativeSource AncestorType=Grid}}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" FontFamily="{StaticResource MDI}" FontSize="24" Text="{Binding Icon}" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding VariableName}" FontWeight="Bold" />
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
<TextBlock Visibility="{Binding ExpressionVisibility}" Text="{Binding ExpressionComputation}" FontStyle="Italic" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
@ -51,7 +51,10 @@
|
|||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding FunctionName}" FontWeight="Bold" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{Binding Icon}" Margin="5,0" />
|
||||
<TextBlock Text="{Binding FunctionName}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding FunctionDescription}" FontStyle="Italic" />
|
||||
<ListView Margin="5,0" ItemsSource="{Binding FunctionArguments}" BorderThickness="0">
|
||||
<ListView.ItemContainerStyle>
|
||||
|
@ -80,7 +83,7 @@
|
|||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
<GridSplitter Grid.Column="0" HorizontalAlignment="Right" Height="100" VerticalAlignment="Center" Width="5"/>
|
||||
<GridSplitter Grid.Column="0" HorizontalAlignment="Right" Height="100" VerticalAlignment="Center" Width="5" />
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
|
@ -89,15 +92,22 @@
|
|||
<ListView Grid.Row="0" x:Name="lvHistory">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel VerticalAlignment="Bottom"/>
|
||||
<VirtualizingStackPanel VerticalAlignment="Bottom" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Input}" />
|
||||
<TextBlock Text="{Binding Output}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Path=ActualHeight, RelativeSource={RelativeSource AncestorType=Grid}}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontFamily="{StaticResource MDI}" Text="{x:Static local:IconFont.ArrowRightDropCircle}" FontSize="24" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Text="{Binding Input}" />
|
||||
<TextBlock Text="{Binding Output}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
@ -113,4 +123,4 @@
|
|||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
|
@ -1,18 +1,9 @@
|
|||
using csmic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AdvancedCalculator
|
||||
{
|
||||
|
@ -42,11 +33,12 @@ namespace AdvancedCalculator
|
|||
{
|
||||
this.interpreter.Interpret(input);
|
||||
this.historyItems.Add(new HistoryItem() { Input = input, Output = this.interpreter.Output });
|
||||
this.variableItems = this.interpreter.Variables.Select(kp => new VariableItem() { VariableName = kp.Key, Value = kp.Value.Value.ToString(), ExpressionVisibility = kp.Value.Type == VariableType.Equation ? Visibility.Visible : Visibility.Hidden, ExpressionComputation = "" }).ToList();
|
||||
this.variableItems = this.interpreter.Variables.Select(kp => new VariableItem() { VariableName = kp.Key, Value = kp.Value.Value.ToString(), ExpressionVisibility = kp.Value.Type == VariableType.Equation ? Visibility.Visible : Visibility.Hidden, ExpressionComputation = "", Icon = IconFont.Variable }).ToList();
|
||||
foreach(var expressionVariable in this.variableItems.Where(v => v.ExpressionVisibility == Visibility.Visible))
|
||||
{
|
||||
this.interpreter.Interpret(expressionVariable.Value);
|
||||
expressionVariable.ExpressionComputation = this.interpreter.Output;
|
||||
expressionVariable.Icon = IconFont.Function;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -75,4 +67,4 @@ namespace AdvancedCalculator
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace AdvancedCalculator
|
||||
{
|
||||
|
@ -13,12 +8,14 @@ namespace AdvancedCalculator
|
|||
|
||||
public string VariableName { get; set; }
|
||||
|
||||
public string Icon { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
public Visibility ExpressionVisibility { get; set; }
|
||||
|
||||
public string ExpressionComputation { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion Properties
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/calculator-variant-black.png
Normal file
BIN
src/calculator-variant-black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 629 B |
BIN
src/icon.ico
Normal file
BIN
src/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
Loading…
Add table
Add a link
Reference in a new issue