Implement migration plan: models, service, MVVM, XAML layout, icons\n\n- Add Models: HistoryItem, VariableItem, FunctionDefinitionItem, IconFont\n- Add Services: ICalculatorService, CalculatorService wrapping interpreter\n- Update MainViewModel: properties and Submit/ToggleFunctions commands\n- Rebuild Views/MainView.axaml with variables, history, input, functions panel\n- Add BoolToGridLengthConverter for panel toggle\n- Wire Material Design Icons font as Avalonia resource in App.axaml/csproj
This commit is contained in:
parent
22f9043e50
commit
7b1912579f
11 changed files with 342 additions and 9 deletions
28
src/AdvancedCalculator/Models/FunctionDefinitionItem.cs
Normal file
28
src/AdvancedCalculator/Models/FunctionDefinitionItem.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace AdvancedCalculator.Models;
|
||||
|
||||
public class FunctionDefinitionItem
|
||||
{
|
||||
public string FunctionName { get; private set; } = string.Empty;
|
||||
public string FunctionDescription { get; private set; } = string.Empty;
|
||||
public string Icon { get; private set; } = string.Empty;
|
||||
public IEnumerable<KeyValuePair<string, string>> FunctionArguments { get; private set; } = new List<KeyValuePair<string, string>>();
|
||||
|
||||
public static IEnumerable<FunctionDefinitionItem> DefinedFunctions
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { 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 FunctionDefinitionItem { FunctionName = "precision", Icon = IconFont.DecimalIncrease, FunctionDescription = "Returns the value of expression1 to a given precision.", FunctionArguments = new[] { new KeyValuePair<string, string>("value", "An expression to compute."), new KeyValuePair<string, string>("precision", "An expression to compute.") } };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
src/AdvancedCalculator/Models/HistoryItem.cs
Normal file
8
src/AdvancedCalculator/Models/HistoryItem.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace AdvancedCalculator.Models;
|
||||
|
||||
public class HistoryItem
|
||||
{
|
||||
public string Input { get; set; } = string.Empty;
|
||||
public string Output { get; set; } = string.Empty;
|
||||
}
|
||||
|
19
src/AdvancedCalculator/Models/IconFont.cs
Normal file
19
src/AdvancedCalculator/Models/IconFont.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace AdvancedCalculator.Models;
|
||||
|
||||
// Slimmed icon font mapping for required glyphs only
|
||||
public static class IconFont
|
||||
{
|
||||
public const string ArrowRightDropCircle = "\U000f0059";
|
||||
public const string DecimalIncrease = "\U000f01b5";
|
||||
public const string Function = "\U000f0295";
|
||||
public const string PlusCircle = "\U000f0417";
|
||||
public const string RoundedCorner = "\U000f0607";
|
||||
public const string SquareRoot = "\U000f0784";
|
||||
public const string SineWave = "\U000f095b";
|
||||
public const string Variable = "\U000f0ae7";
|
||||
public const string AlphaECircle = "\U000f0bf8";
|
||||
public const string MathTan = "\U000f0c98";
|
||||
public const string MathLog = "\U000f1085";
|
||||
public const string CosineWave = "\U000f1479";
|
||||
}
|
||||
|
15
src/AdvancedCalculator/Models/VariableItem.cs
Normal file
15
src/AdvancedCalculator/Models/VariableItem.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
namespace AdvancedCalculator.Models;
|
||||
|
||||
public class VariableItem
|
||||
{
|
||||
public string VariableName { get; set; } = string.Empty;
|
||||
public string Icon { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
// True when this variable is defined by an equation/expression
|
||||
public bool IsExpression { get; set; }
|
||||
|
||||
// Computed value for an expression variable (pretty-printed)
|
||||
public string? ExpressionComputation { get; set; }
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue