From 4a3f827c258aeb7e230ec6ccd6a698c5f2dfddfc Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Wed, 2 Mar 2022 13:31:42 +0530 Subject: [PATCH 01/25] Created dotnet core project for expression evaluator --- ExpressionEvaluator.sln | 8 +++++- ExpressionEvaluatorUi/App.xaml | 9 ++++++ ExpressionEvaluatorUi/App.xaml.cs | 17 +++++++++++ ExpressionEvaluatorUi/AssemblyInfo.cs | 10 +++++++ .../ExpressionEvaluatorUi.csproj | 9 ++++++ ExpressionEvaluatorUi/MainWindow.xaml | 12 ++++++++ ExpressionEvaluatorUi/MainWindow.xaml.cs | 28 +++++++++++++++++++ .../View/FormulaEditorView.xaml | 12 ++++++++ .../View/FormulaEditorView.xaml.cs | 26 +++++++++++++++++ .../ViewModels/FormulaEditorViewModel.cs | 10 +++++++ 10 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 ExpressionEvaluatorUi/App.xaml create mode 100644 ExpressionEvaluatorUi/App.xaml.cs create mode 100644 ExpressionEvaluatorUi/AssemblyInfo.cs create mode 100644 ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj create mode 100644 ExpressionEvaluatorUi/MainWindow.xaml create mode 100644 ExpressionEvaluatorUi/MainWindow.xaml.cs create mode 100644 ExpressionEvaluatorUi/View/FormulaEditorView.xaml create mode 100644 ExpressionEvaluatorUi/View/FormulaEditorView.xaml.cs create mode 100644 ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs diff --git a/ExpressionEvaluator.sln b/ExpressionEvaluator.sln index 92b4760..b7a3559 100644 --- a/ExpressionEvaluator.sln +++ b/ExpressionEvaluator.sln @@ -5,7 +5,9 @@ VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluator", "ExpressionEvaluator\ExpressionEvaluator.csproj", "{8CE7CD5B-C847-4CC3-B173-D85B74D356C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExpressionEvaluatorTests", "ExpressionEvaluatorTests\ExpressionEvaluatorTests.csproj", "{F10EECC5-380C-4A7C-8345-EE49F44C7C3D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorTests", "ExpressionEvaluatorTests\ExpressionEvaluatorTests.csproj", "{F10EECC5-380C-4A7C-8345-EE49F44C7C3D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExpressionEvaluatorUi", "ExpressionEvaluatorUi\ExpressionEvaluatorUi.csproj", "{77C9678B-6B41-445A-B032-CB8E59046A7B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,10 @@ Global {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Release|Any CPU.Build.0 = Release|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ExpressionEvaluatorUi/App.xaml b/ExpressionEvaluatorUi/App.xaml new file mode 100644 index 0000000..56fce7b --- /dev/null +++ b/ExpressionEvaluatorUi/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ExpressionEvaluatorUi/App.xaml.cs b/ExpressionEvaluatorUi/App.xaml.cs new file mode 100644 index 0000000..8d41109 --- /dev/null +++ b/ExpressionEvaluatorUi/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ExpressionEvaluatorUi +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/ExpressionEvaluatorUi/AssemblyInfo.cs b/ExpressionEvaluatorUi/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/ExpressionEvaluatorUi/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj new file mode 100644 index 0000000..6c68d0e --- /dev/null +++ b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj @@ -0,0 +1,9 @@ + + + + WinExe + netcoreapp3.1 + true + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/MainWindow.xaml b/ExpressionEvaluatorUi/MainWindow.xaml new file mode 100644 index 0000000..fbcd5fe --- /dev/null +++ b/ExpressionEvaluatorUi/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/ExpressionEvaluatorUi/MainWindow.xaml.cs b/ExpressionEvaluatorUi/MainWindow.xaml.cs new file mode 100644 index 0000000..dfcb6a3 --- /dev/null +++ b/ExpressionEvaluatorUi/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +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 ExpressionEvaluatorUi +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml new file mode 100644 index 0000000..01d8a50 --- /dev/null +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml.cs b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml.cs new file mode 100644 index 0000000..c9b0e6e --- /dev/null +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; +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 ExpressionEvaluatorUi.View +{ + /// + /// Interaction logic for FormulaEditorView.xaml + /// + public partial class FormulaEditorView : UserControl + { + public FormulaEditorView() + { + InitializeComponent(); + } + } +} diff --git a/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs b/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs new file mode 100644 index 0000000..fce232f --- /dev/null +++ b/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ExpressionEvaluatorUi.ViewModels +{ + class FormulaEditorViewModel + { + } +} From b20bb1b358fdef03e17acb62534597368beba5f1 Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Wed, 2 Mar 2022 17:48:42 +0530 Subject: [PATCH 02/25] Stiching up the view model viewmodel --- ExpressionEvaluatorUi/App.xaml | 9 +- .../ExpressionEvaluatorUi.csproj | 4 + ExpressionEvaluatorUi/Model/Operator.cs | 13 ++ ExpressionEvaluatorUi/Model/Step.cs | 13 ++ .../ButtonDictionary.xaml | 12 ++ .../OperatorListViewDictionary.xaml | 21 +++ .../View/FormulaEditorView.xaml | 152 +++++++++++++++++- .../View/FormulaEditorView.xaml.cs | 4 +- .../ViewModels/FormulaEditorViewModel.cs | 93 ++++++++++- .../ViewModels/Helpers/ListViewHelper.cs | 98 +++++++++++ 10 files changed, 412 insertions(+), 7 deletions(-) create mode 100644 ExpressionEvaluatorUi/Model/Operator.cs create mode 100644 ExpressionEvaluatorUi/Model/Step.cs create mode 100644 ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml create mode 100644 ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml create mode 100644 ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs diff --git a/ExpressionEvaluatorUi/App.xaml b/ExpressionEvaluatorUi/App.xaml index 56fce7b..18b232c 100644 --- a/ExpressionEvaluatorUi/App.xaml +++ b/ExpressionEvaluatorUi/App.xaml @@ -2,8 +2,13 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ExpressionEvaluatorUi" - StartupUri="MainWindow.xaml"> + StartupUri="View/FormulaEditorView.xaml"> - + + + + + + diff --git a/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj index 6c68d0e..81e35b7 100644 --- a/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj +++ b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj @@ -6,4 +6,8 @@ true + + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/Model/Operator.cs b/ExpressionEvaluatorUi/Model/Operator.cs new file mode 100644 index 0000000..4deb695 --- /dev/null +++ b/ExpressionEvaluatorUi/Model/Operator.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ExpressionEvaluatorUi.Model +{ + public class Operator + { + public string Category { get; set; } + public string Type { get; set; } + public string Description { get; set; } + } +} diff --git a/ExpressionEvaluatorUi/Model/Step.cs b/ExpressionEvaluatorUi/Model/Step.cs new file mode 100644 index 0000000..cd75c9f --- /dev/null +++ b/ExpressionEvaluatorUi/Model/Step.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ExpressionEvaluatorUi.Model +{ + public class Step + { + public string Name { get; set; } + public string Type { get; set; } + public string Description { get; set; } + } +} diff --git a/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml b/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml new file mode 100644 index 0000000..8e18c27 --- /dev/null +++ b/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml b/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml new file mode 100644 index 0000000..833202d --- /dev/null +++ b/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml index 01d8a50..db731e4 100644 --- a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml @@ -5,8 +5,156 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:ExpressionEvaluatorUi.View" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="800" d:DesignWidth="1000"> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -93,18 +97,18 @@ SelectedValue="{Binding SelectedVariable, Mode=TwoWay}" FontWeight="Normal"> - - - - - + + + + + - - + + @@ -182,11 +186,31 @@ - + + + + + + + + + @@ -204,9 +228,13 @@ Grid.Row="3" HorizontalAlignment="Left"> diff --git a/ExpressionEvaluatorUi/ViewModels/Commands/ClearVariableCommand.cs b/ExpressionEvaluatorUi/ViewModels/Commands/ClearVariableCommand.cs new file mode 100644 index 0000000..7c10b09 --- /dev/null +++ b/ExpressionEvaluatorUi/ViewModels/Commands/ClearVariableCommand.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Input; + +namespace ExpressionEvaluatorUi.ViewModels.Commands +{ + public class ClearVariableCommand : ICommand + { + public VariableInputViewModel _variableInputViewModel; + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + public ClearVariableCommand(VariableInputViewModel variableInputViewModel) + { + _variableInputViewModel = variableInputViewModel; + } + + public bool CanExecute(object parameter) + { + return !string.IsNullOrEmpty((string)parameter); + } + + public void Execute(object parameter) + { + _variableInputViewModel.VariableInput = null; + + + } + } +} diff --git a/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs b/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs index 4548e68..10d80bc 100644 --- a/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs +++ b/ExpressionEvaluatorUi/ViewModels/FormulaEditorViewModel.cs @@ -6,10 +6,14 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; using System.Text; using System.Windows; using System.Windows.Data; using exp=Vanderbilt.Biostatistics.Wfccm2; +using ExpressionEvaluator.Procedures.Operators; namespace ExpressionEvaluatorUi.ViewModels { @@ -19,9 +23,13 @@ public class FormulaEditorViewModel:INotifyPropertyChanged public static Variable selectedVariableTemp; public HashSet UsedVariables; - private exp.Expression _func; + public exp.Expression _func; private bool isSelected; + public static FormulaEditorViewModel FormulaEditorVM { get; set; } + public ListViewHelper ListViewHelper; + public bool InputNull { get; set; } + public bool IsSelected { get { return isSelected; } @@ -54,8 +62,6 @@ public bool CanRunTest } } - - private string formula; public string Formula @@ -66,6 +72,7 @@ public string Formula formula = value; OnPropertyChanged(nameof(Formula)); CanRunTest = false; + TestOutput = null; } } @@ -101,7 +108,6 @@ public string SelectedOutputType { selectedOutputType = value; OnPropertyChanged(nameof(SelectedOutputType)); - //CanValidate = true & !string.IsNullOrEmpty(Formula); CanValidate = true; } @@ -141,10 +147,12 @@ public string TestOutput public FormulaEditorViewModel() { + FormulaEditorVM = this; Variables = new ObservableCollection(); VariableInputViewModels = new ObservableCollection(); OutputTypes = new ObservableCollection(); UsedVariables = new HashSet(); + ListViewHelper = new ListViewHelper(); LoadOperators(); LoadOutputTypes(); AddVariableCommand = new AddVariableCommand(); @@ -155,8 +163,7 @@ public FormulaEditorViewModel() } public static void AddNewVariableToList(Variable Variable) { - Variables.Add(Variable); - + Variables.Add(Variable); } public void UpdateVariable(Variable NewVariable) { @@ -168,13 +175,13 @@ public void UpdateVariable(Variable NewVariable) NewVariable.Value = variable.VariableInput; VariableInputViewModels.Remove(variable); - UsedVariables.Remove(variable.VariableName); // + UsedVariables.Remove(variable.VariableName); VariableInputViewModels.Add(new VariableInputViewModel() { VariableName = NewVariable.Name, VariableInput = NewVariable.Value }); - UsedVariables.Add(NewVariable.Name); // + UsedVariables.Add(NewVariable.Name); break; } } @@ -202,7 +209,6 @@ private void AddVariableToFormula() } private void LoadOperators() { - List operatorlist = ListViewHelper.getOperatorList(); operatorcollectionView = new ListCollectionView(operatorlist); operatorcollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category")); @@ -226,16 +232,6 @@ private void SelectedVariableFunctionality() if (SelectedVariable != null) { - //bool isPresent = false; - //foreach (var variable in VariableInputViewModels) - //{ - // if (variable.VariableName == SelectedVariable.Name) - // { - // isPresent = true; - // break; - // } - //} - //if (!isPresent) if(!UsedVariables.Contains(SelectedVariable.Name)) { VariableInputViewModels.Add(new VariableInputViewModel() @@ -279,12 +275,24 @@ public void ValidatingForumla() } public void RunTest() { + if (InputNull) + { + _func.Function = Formula; + InputNull = false; + } + StringBuilder msg = new StringBuilder(""); foreach (var variable in Variables) { + if (!UsedVariables.Contains(variable.Name)) continue; + if (variable.Value == null || string.IsNullOrEmpty(variable.Value.ToString())) + { + continue; + } + try { switch (variable.Type) @@ -338,10 +346,16 @@ public void RunTest() } else if (SelectedOutputType == "boolean") { - TestOutput = _func.EvaluateBoolean().ToString(); + TestOutput = _func.EvaluateBoolean().ToString(); } + + } + catch(exp.ExpressionException e) + { + MessageBox.Show(e.Message, "Expected Output Type Error", + MessageBoxButton.OK, MessageBoxImage.Error); } - catch(Exception e) + catch(InvalidCastException e) { MessageBox.Show(e.Message, "Expected Output Type Error", MessageBoxButton.OK, MessageBoxImage.Error); diff --git a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs index 5ef99a7..d46a950 100644 --- a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs +++ b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs @@ -1,7 +1,11 @@ using ExpressionEvaluatorUi.Model; using System; using System.Collections.Generic; +using System.Linq; +using System.Reflection; using System.Text; +using System.Windows; +using exp = Vanderbilt.Biostatistics.Wfccm2; namespace ExpressionEvaluatorUi.ViewModels.Helpers { @@ -9,26 +13,55 @@ public class ListViewHelper { public static List getOperatorList() { + + //Type[] types= Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "ExpressionEvaluator.Procedures.Operators", StringComparison.Ordinal)).ToArray(); + //foreach (var type in types) + //{ + // Console.WriteLine(type.Name); + //} List operators = new List(); operators.Add(new Operator() { Category = "Arithmetic", Type = "+", - Description = "Used to add two operands." + Description = "Add two operands." }); operators.Add(new Operator() { Category = "Arithmetic", Type = "-", - Description = "Used to subtract two operands." + Description = "Subtract two operands." }); + operators.Add(new Operator() + { + Category = "Arithmetic", + Type = "*", + Description = "Multiply two operands." + + }); + operators.Add(new Operator() + { + Category = "Arithmetic", + Type = "/", + Description = "Divide two operands and gives the quotient as the answer." + + }); + operators.Add(new Operator() + { + Category = "Arithmetic", + Type = "%", + Description = " Find the remains of two integers and gives the remainder after the division." + + }); + + operators.Add(new Operator() { Category = "Relational", Type = "==", - Description = "Used to check if both operands are equal." + Description = "Check if both operands are equal." }); @@ -36,64 +69,67 @@ public static List getOperatorList() { Category = "Relational", Type = "!=", - Description = "Can check if both operands are not equal." + Description = "Check if both operands are not equal." }); - operators.Add(new Operator() { - Category = "Logical", - Type = "&&", - Description = "Used to check if both the operands are true." + Category = "Relational", + Type = ">", + Description = "Check if the first operand is greater than the second." }); operators.Add(new Operator() { - Category = "Logical", - Type = "||", - Description = "Used to check if at least one of the operand is true." + Category = "Relational", + Type = "<", + Description = "Check if the first operand is lesser than the second." }); - - return operators; - } - public static List getVariableList() - { - List variables = new List(); - variables.Add(new Variable() + operators.Add(new Operator() { - Name = "Variable1Name", - Type = "Variable1Type", - Description = "Variable1Description" - + Category = "Relational", + Type = ">=", + Description = "Check if the first operand is greater than or equal to the second." }); - variables.Add(new Variable() + operators.Add(new Operator() { - Name = "Variable2Name", - Type = "Variable2Type", - Description = "Variable2Description" - + Category = "Relational", + Type = "<=", + Description = "Check if the first operand is lesser than or equal to the second." }); - variables.Add(new Variable() - { - Name = "Variable3Name", - Type = "Variable3Type", - Description = "Variable3Description" + operators.Add(new Operator() + { + Category = "Logical", + Type = "&&", + Description = "Check if both the operands are true." }); - variables.Add(new Variable() + operators.Add(new Operator() { - Name = "Variable4Name", - Type = "Variable4Type", - Description = "Variable4Description" + Category = "Logical", + Type = "||", + Description = "Check if at least one of the operand is true." + }); + operators.Add(new Operator() + { + Category = "Logical", + Type = "!", + Description = "Check if the operand is false" }); - return variables; + + return operators; } + //public Type[] GetOperators() + //{ + + // return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "ExpressionEvaluator.Procedures.Operators", StringComparison.Ordinal)).ToArray(); + //} public static List getVariableTypeList() { List VariableTypes = new List() {"int","float","double","char","string","bool","object" }; diff --git a/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs b/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs index 8abd201..4c5cfec 100644 --- a/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs +++ b/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs @@ -1,4 +1,5 @@ -using System; +using ExpressionEvaluatorUi.ViewModels.Commands; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; @@ -8,6 +9,7 @@ namespace ExpressionEvaluatorUi.ViewModels { public class VariableInputViewModel : INotifyPropertyChanged { + public ClearVariableCommand ClearVariableCommand { get; set; } private string variableName; public string VariableName @@ -36,8 +38,17 @@ public object VariableInput break; } } + if(VariableInput==null || string.IsNullOrEmpty(VariableInput.ToString())) + { + FormulaEditorViewModel.FormulaEditorVM.InputNull = true; + } + } } + public VariableInputViewModel() + { + ClearVariableCommand = new ClearVariableCommand(this); + } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { From 040d3354d0d4dfa8de9a8a4883848c51d4299819 Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Tue, 12 Apr 2022 14:24:09 +0530 Subject: [PATCH 09/25] Operator category and description added and extracted from expression evaluator --- ExpressionEvaluator/Keywords/Procedure.cs | 3 +- .../Procedures/Functions/Absolute.cs | 2 + .../Procedures/Functions/Avg.cs | 2 + .../Procedures/Functions/Ceiling.cs | 2 + .../Procedures/Functions/Concatenate.cs | 2 + .../Procedures/Functions/Contains.cs | 2 + .../Procedures/Functions/Days.cs | 1 + .../Procedures/Functions/DaysComponent.cs | 2 + .../Procedures/Functions/Floor.cs | 2 + .../Procedures/Functions/Hours.cs | 1 + .../Procedures/Functions/HoursComponent.cs | 2 + .../Procedures/Functions/IsNumber.cs | 2 + .../Procedures/Functions/Length.cs | 2 + .../Procedures/Functions/Max.cs | 2 + .../Procedures/Functions/Min.cs | 2 + .../Procedures/Functions/Minutes.cs | 1 + .../Procedures/Functions/MinutesComponent.cs | 2 + .../Procedures/Functions/NaturalLog.cs | 2 + .../Procedures/Functions/Negate.cs | 2 + .../Procedures/Functions/Now.cs | 1 + .../Procedures/Functions/Round.cs | 2 + .../Procedures/Functions/Seconds.cs | 1 + .../Procedures/Functions/SecondsComponent.cs | 2 + .../Procedures/Functions/Sign.cs | 2 + .../Procedures/Functions/StdDev.cs | 2 + .../Procedures/Functions/Substring.cs | 2 + .../Procedures/Functions/Sum.cs | 2 + .../Procedures/Functions/ToNumber.cs | 2 + .../Procedures/Functions/ToString.cs | 2 + .../Procedures/Functions/ToStringFormat.cs | 1 + .../Procedures/Functions/TotalDays.cs | 1 + .../Procedures/Functions/TotalHours.cs | 1 + .../Procedures/Functions/TotalMinutes.cs | 1 + .../Procedures/Functions/TotalSeconds.cs | 1 + .../Procedures/Operators/Addition.cs | 2 + .../Procedures/Operators/And.cs | 2 + .../Procedures/Operators/Division.cs | 3 +- .../Procedures/Operators/Equal.cs | 2 + .../Procedures/Operators/GreaterEqual.cs | 2 + .../Procedures/Operators/GreaterThan.cs | 2 + .../Procedures/Operators/LesserEqual.cs | 2 + .../Procedures/Operators/LesserThan.cs | 2 + .../Procedures/Operators/Modulo.cs | 2 + .../Procedures/Operators/Multiplication.cs | 2 + .../Procedures/Operators/NotEqual.cs | 2 + .../Procedures/Operators/Or.cs | 2 + .../Procedures/Operators/Power.cs | 2 + .../Procedures/Operators/Subtraction.cs | 2 + ExpressionEvaluatorTests/DateTimeTests.cs | 6 + ExpressionEvaluatorTests/LengthTests.cs | 7 + .../ToStringFormatTests.cs | 1 + .../ViewModels/Helpers/ListViewHelper.cs | 138 +++--------------- 52 files changed, 124 insertions(+), 116 deletions(-) diff --git a/ExpressionEvaluator/Keywords/Procedure.cs b/ExpressionEvaluator/Keywords/Procedure.cs index 6ce447f..637b089 100644 --- a/ExpressionEvaluator/Keywords/Procedure.cs +++ b/ExpressionEvaluator/Keywords/Procedure.cs @@ -59,7 +59,8 @@ public Procedure(string name, int precedance, int numParams, bool alwaysReturnsV public bool AlwaysReturnsValue { get; private set; } public int NumParameters { get; set; } public bool VariableOperandsCount { get; private set; } - + public string Category { get; set; } + public string Description { get; set; } public IOperand Evaluate() diff --git a/ExpressionEvaluator/Procedures/Functions/Absolute.cs b/ExpressionEvaluator/Procedures/Functions/Absolute.cs index 38c458c..8dd465e 100644 --- a/ExpressionEvaluator/Procedures/Functions/Absolute.cs +++ b/ExpressionEvaluator/Procedures/Functions/Absolute.cs @@ -10,6 +10,8 @@ public Absolute(int precedance) : base("abs", precedance, 1, false) { _name2 = "Absolute"; + Category = "Mathematical Function"; + Description = "Return the absolute value of a specified number"; DecimalDecimal = x => { double dblResult = Math.Abs((double)x); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Functions/Avg.cs b/ExpressionEvaluator/Procedures/Functions/Avg.cs index 7b0bb2c..8413e39 100644 --- a/ExpressionEvaluator/Procedures/Functions/Avg.cs +++ b/ExpressionEvaluator/Procedures/Functions/Avg.cs @@ -9,6 +9,8 @@ public Avg(int precedance) : base("avg", precedance, 1, true) { _name2 = "Avg"; + Category = "Mathematical Function"; + Description = "Calculates the average of the values."; DecimalDecimalOperandList = x => x.Average(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Ceiling.cs b/ExpressionEvaluator/Procedures/Functions/Ceiling.cs index 45b805a..25661f8 100644 --- a/ExpressionEvaluator/Procedures/Functions/Ceiling.cs +++ b/ExpressionEvaluator/Procedures/Functions/Ceiling.cs @@ -9,6 +9,8 @@ public Ceiling(int precedance) : base("ceiling", precedance, 2, true) { _name2 = "Ceiling"; + Category = "Mathematical Function"; + Description = "Return the smallest integral value greater than or equal to the specified number"; DecimalDecimalOperandList = x => { if (x.Count > 2) throw new ExpressionException("Ceiling only takes one or two paramters."); diff --git a/ExpressionEvaluator/Procedures/Functions/Concatenate.cs b/ExpressionEvaluator/Procedures/Functions/Concatenate.cs index 08ab153..fe05a6e 100644 --- a/ExpressionEvaluator/Procedures/Functions/Concatenate.cs +++ b/ExpressionEvaluator/Procedures/Functions/Concatenate.cs @@ -9,6 +9,8 @@ public Concatenate(int precedance) : base("concatenate", precedance, 1, true) { _name2 = "Concatenate"; + Category = "String"; + Description = "Appending one string to the end of another string"; ObjectStringOperandList = x => x.Aggregate("", (current, i) => current + i); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Contains.cs b/ExpressionEvaluator/Procedures/Functions/Contains.cs index 931a233..7464b04 100644 --- a/ExpressionEvaluator/Procedures/Functions/Contains.cs +++ b/ExpressionEvaluator/Procedures/Functions/Contains.cs @@ -8,6 +8,8 @@ public Contains(int precedance) : base("contains", precedance, 2, false) { _name2 = "Contains"; + Category = "String"; + Description = "Check if the string contains the given substring"; StringStringBool = (x, y) => x.ToLower() .Contains(y.ToLower()); } diff --git a/ExpressionEvaluator/Procedures/Functions/Days.cs b/ExpressionEvaluator/Procedures/Functions/Days.cs index 8ab01a0..7e938fe 100644 --- a/ExpressionEvaluator/Procedures/Functions/Days.cs +++ b/ExpressionEvaluator/Procedures/Functions/Days.cs @@ -9,6 +9,7 @@ public Days(int precedance) : base("days", precedance, 1, false) { _name2 = "Days"; + Category = "Date/Time"; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerDay)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs b/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs index 4b900dc..85eadf3 100644 --- a/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs @@ -8,6 +8,8 @@ public DaysComponent(int precedance) : base("dayscomponent", precedance, 1, false) { _name2 = "DaysComponent"; + Category = "Date/Time"; + Description = "Returns the no. of days between two given dates"; TimespanDecimal = x => (decimal)x.Days; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Floor.cs b/ExpressionEvaluator/Procedures/Functions/Floor.cs index 9a9c636..52d26d0 100644 --- a/ExpressionEvaluator/Procedures/Functions/Floor.cs +++ b/ExpressionEvaluator/Procedures/Functions/Floor.cs @@ -9,6 +9,8 @@ public Floor(int precedance) : base("floor", precedance, 2, true) { _name2 = "Floor"; + Category = "Mathematical Function"; + Description = "Return the largest integer, which is less than or equal to the passed argument"; DecimalDecimalOperandList = x => { if (x.Count > 2) throw new ExpressionException("Floor only takes one or two paramters."); diff --git a/ExpressionEvaluator/Procedures/Functions/Hours.cs b/ExpressionEvaluator/Procedures/Functions/Hours.cs index 896c5fd..614fdec 100644 --- a/ExpressionEvaluator/Procedures/Functions/Hours.cs +++ b/ExpressionEvaluator/Procedures/Functions/Hours.cs @@ -9,6 +9,7 @@ public Hours(int precedance) : base("hours", precedance, 1, false) { _name2 = "Hours"; + Category = "Date/Time"; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerHour)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs b/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs index e7dfc8b..11bc9fb 100644 --- a/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs @@ -8,6 +8,8 @@ public HoursComponent(int precedance) : base("hourscomponent", precedance, 1, false) { _name2 = "HoursComponent"; + Category = "Date/Time"; + Description = "Returns the no. of hours between two given dates"; TimespanDecimal = x => (decimal)x.Hours; } } diff --git a/ExpressionEvaluator/Procedures/Functions/IsNumber.cs b/ExpressionEvaluator/Procedures/Functions/IsNumber.cs index fc60f59..02c23d3 100644 --- a/ExpressionEvaluator/Procedures/Functions/IsNumber.cs +++ b/ExpressionEvaluator/Procedures/Functions/IsNumber.cs @@ -9,6 +9,8 @@ public IsNumber(int precedance) : base("isnumber", precedance, 1, false) { _name2 = "IsNumber"; + Category = "Mathematical Function"; + Description = "Check if the given argument is a number or not"; AnyBool = x => x != null && StringBool(x.ToString()); StringBool = x => { try { diff --git a/ExpressionEvaluator/Procedures/Functions/Length.cs b/ExpressionEvaluator/Procedures/Functions/Length.cs index 6fba5aa..f50e012 100644 --- a/ExpressionEvaluator/Procedures/Functions/Length.cs +++ b/ExpressionEvaluator/Procedures/Functions/Length.cs @@ -8,6 +8,8 @@ public Length(int precedance) : base("length", precedance, 1, false) { _name2 = "Length"; + Category = "String"; + Description = "Returns the length of given string"; StringDecimal = x => x.Length; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Max.cs b/ExpressionEvaluator/Procedures/Functions/Max.cs index 2236502..1955ffc 100644 --- a/ExpressionEvaluator/Procedures/Functions/Max.cs +++ b/ExpressionEvaluator/Procedures/Functions/Max.cs @@ -9,6 +9,8 @@ public Max(int precedance) : base("max", precedance, 1, true) { _name2 = "Max"; + Category = "Mathematical Function"; + Description = "Returns the larger of the specified numbers."; DecimalDecimalOperandList = x => x.Max(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Min.cs b/ExpressionEvaluator/Procedures/Functions/Min.cs index 50a07e4..d67b1b2 100644 --- a/ExpressionEvaluator/Procedures/Functions/Min.cs +++ b/ExpressionEvaluator/Procedures/Functions/Min.cs @@ -9,6 +9,8 @@ public Min(int precedance) : base("min", precedance, 1, true) { _name2 = "Min"; + Category = "Mathematical Function"; + Description = "Returns the minimum of the specified numbers"; DecimalDecimalOperandList = x => x.Min(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Minutes.cs b/ExpressionEvaluator/Procedures/Functions/Minutes.cs index 8d667dc..2595f40 100644 --- a/ExpressionEvaluator/Procedures/Functions/Minutes.cs +++ b/ExpressionEvaluator/Procedures/Functions/Minutes.cs @@ -9,6 +9,7 @@ public Minutes(int precedance) : base("minutes", precedance, 1, false) { _name2 = "Minutes"; + Category = "Date/Time"; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerMinute)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs b/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs index 22d58c7..88bfaeb 100644 --- a/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs @@ -8,6 +8,8 @@ public MinutesComponent(int precedance) : base("minutescomponent", precedance, 1, false) { _name2 = "MinutesComponent"; + Category = "Date/Time"; + Description = "Returns the no. of minutes between two given dates"; TimespanDecimal = x => (decimal)x.Minutes; } } diff --git a/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs b/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs index a94e741..fa3a235 100644 --- a/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs +++ b/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs @@ -10,6 +10,8 @@ public NaturalLog(int precedance) : base("ln", precedance, 1, false) { _name2 = "NaturalLog"; + Category = "Mathematical Function"; + Description = "Returns the natural (base e) logarithm of a specified number."; DecimalDecimal = x => { double dblResult = Math.Log((double)x); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Functions/Negate.cs b/ExpressionEvaluator/Procedures/Functions/Negate.cs index 4ae266f..7a7bf5b 100644 --- a/ExpressionEvaluator/Procedures/Functions/Negate.cs +++ b/ExpressionEvaluator/Procedures/Functions/Negate.cs @@ -8,6 +8,8 @@ public Negate(int precedance) : base("neg", precedance, 1, false) { _name2 = "Negate"; + Category = "Mathematical Function"; + Description = "Returns the result of multiplying the specified value by negative one"; DecimalDecimal = x => -1 * x; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Now.cs b/ExpressionEvaluator/Procedures/Functions/Now.cs index 67c7479..352c19f 100644 --- a/ExpressionEvaluator/Procedures/Functions/Now.cs +++ b/ExpressionEvaluator/Procedures/Functions/Now.cs @@ -9,6 +9,7 @@ public Now(int precedance) : base("now", precedance, 0, false) { _name2 = "Now"; + Category = "Date/Time"; Datetime = () => DateTime.Now; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Round.cs b/ExpressionEvaluator/Procedures/Functions/Round.cs index 88290b0..360adcc 100644 --- a/ExpressionEvaluator/Procedures/Functions/Round.cs +++ b/ExpressionEvaluator/Procedures/Functions/Round.cs @@ -9,6 +9,8 @@ public Round(int precedance) : base("round", precedance, 2, false) { _name2 = "Round"; + Category = "Mathematical Function"; + Description = "Rounds the number to a specified number of digits"; DecimalDecimalDecimal = (x, y) => Math.Round(x, (int)y, MidpointRounding.AwayFromZero); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Seconds.cs b/ExpressionEvaluator/Procedures/Functions/Seconds.cs index 226be6e..a794d5d 100644 --- a/ExpressionEvaluator/Procedures/Functions/Seconds.cs +++ b/ExpressionEvaluator/Procedures/Functions/Seconds.cs @@ -9,6 +9,7 @@ public Seconds(int precedance) : base("seconds", precedance, 1, false) { _name2 = "Seconds"; + Category = "Date/Time"; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerSecond)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs b/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs index f343dfd..820cb06 100644 --- a/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs @@ -8,6 +8,8 @@ public SecondsComponent(int precedance) : base("secondscomponent", precedance, 1, false) { _name2 = "SecondsComponent"; + Category = "Date/Time"; + Description = "Returns the no. of seconds between two given dates"; TimespanDecimal = x => (decimal)x.Seconds; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Sign.cs b/ExpressionEvaluator/Procedures/Functions/Sign.cs index 3b40407..e8bc322 100644 --- a/ExpressionEvaluator/Procedures/Functions/Sign.cs +++ b/ExpressionEvaluator/Procedures/Functions/Sign.cs @@ -8,6 +8,8 @@ public Sign(int precedance) : base("sign", precedance, 1, false) { _name2 = "Sign"; + Category = "Mathematical Function"; + Description = "Returns an integer that specify the sign of the number"; DecimalDecimal = x => x >= 0 ? 1 : -1; } } diff --git a/ExpressionEvaluator/Procedures/Functions/StdDev.cs b/ExpressionEvaluator/Procedures/Functions/StdDev.cs index e6f759f..1708aca 100644 --- a/ExpressionEvaluator/Procedures/Functions/StdDev.cs +++ b/ExpressionEvaluator/Procedures/Functions/StdDev.cs @@ -10,6 +10,8 @@ public StdDev(int precedance) : base("stddev", precedance, 1, true) { _name2 = "StdDev"; + Category = "Mathematical Function"; + Description = "Returns the standard deviation of the given numbers"; DecimalDecimalOperandList = x => { var avg = (double)x.Average(); return (decimal)Math.Sqrt(x.Average(v => Math.Pow((double)v - avg, 2))); diff --git a/ExpressionEvaluator/Procedures/Functions/Substring.cs b/ExpressionEvaluator/Procedures/Functions/Substring.cs index d4dc5e3..bf7771d 100644 --- a/ExpressionEvaluator/Procedures/Functions/Substring.cs +++ b/ExpressionEvaluator/Procedures/Functions/Substring.cs @@ -8,6 +8,8 @@ public Substring(int precedance) : base("substring", precedance, 3, false) { _name2 = "Substring"; + Category = "String"; + Description = "Extracts the substring of the string with the specified start and end position"; StringDecimalDecimalString = (x, y, z) => x.Substring((int)y, (int)z); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Sum.cs b/ExpressionEvaluator/Procedures/Functions/Sum.cs index ef4c5f8..846e7cd 100644 --- a/ExpressionEvaluator/Procedures/Functions/Sum.cs +++ b/ExpressionEvaluator/Procedures/Functions/Sum.cs @@ -8,6 +8,8 @@ public Sum(int precedance) : base("sum", precedance, 1, true) { _name2 = "Sum"; + Category = "Mathematical Function"; + Description = "Returns the sum of the given numbers"; DecimalDecimalOperandList = x => { decimal sum = 0; foreach (var i in x) { diff --git a/ExpressionEvaluator/Procedures/Functions/ToNumber.cs b/ExpressionEvaluator/Procedures/Functions/ToNumber.cs index 52061bb..3864cc3 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToNumber.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToNumber.cs @@ -9,6 +9,8 @@ public ToNumber(int precedance) : base("tonumber", precedance, 1, false) { _name2 = "ToNumber"; + Category = "String"; + Description = "Returns the number equivalent of the given string"; StringDecimal = x => { try { return decimal.Parse(x); diff --git a/ExpressionEvaluator/Procedures/Functions/ToString.cs b/ExpressionEvaluator/Procedures/Functions/ToString.cs index d315488..1c3afc0 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToString.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToString.cs @@ -8,6 +8,8 @@ public ToString(int precedance) : base("tostring", precedance, 1, false) { _name2 = "ToString"; + Category = "String"; + Description = "Returns the string equivalent of the given number"; DecimalString = x => x.ToString(); DateTimeString = x => x.ToString(); BoolString = x => x.ToString(); diff --git a/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs b/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs index 5246d00..aa53c8b 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs @@ -8,6 +8,7 @@ public ToStringFormat(int precedance) : base("tostringformat", precedance, 2, false) { _name2 = "ToStringFormat"; + Category = "String"; DecimalStringString = (x, y) => x.ToString(y); } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalDays.cs b/ExpressionEvaluator/Procedures/Functions/TotalDays.cs index dceec40..f3f71ad 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalDays.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalDays.cs @@ -8,6 +8,7 @@ public TotalDays(int precedance) : base("totaldays", precedance, 1, false) { _name2 = "TotalDays"; + Category = "Date/Time"; TimespanDecimal = x => (decimal)x.TotalDays; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalHours.cs b/ExpressionEvaluator/Procedures/Functions/TotalHours.cs index e95a00d..15d1abf 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalHours.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalHours.cs @@ -8,6 +8,7 @@ public TotalHours(int precedance) : base("totalhours", precedance, 1, false) { _name2 = "TotalHours"; + Category = "Date/Time"; TimespanDecimal = x => (decimal)x.TotalHours; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs b/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs index 960f4b4..17f840a 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs @@ -8,6 +8,7 @@ public TotalMinutes(int precedance) : base("totalminutes", precedance, 1, false) { _name2 = "TotalMinutes"; + Category = "Date/Time"; TimespanDecimal = x => (decimal)x.TotalMinutes; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs b/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs index 6908019..a72e2da 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs @@ -8,6 +8,7 @@ public TotalSeconds(int precedance) : base("totalseconds", precedance, 1, false) { _name2 = "TotalSeconds"; + Category = "Date/Time"; TimespanDecimal = x => (decimal)x.TotalSeconds; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Addition.cs b/ExpressionEvaluator/Procedures/Operators/Addition.cs index 12d7e6a..a5926bc 100644 --- a/ExpressionEvaluator/Procedures/Operators/Addition.cs +++ b/ExpressionEvaluator/Procedures/Operators/Addition.cs @@ -9,6 +9,8 @@ public Addition(int precedance) : base("+", precedance, 2, false) { _name2 = "Addition"; + Category = "Arithmetic"; + Description = "Add two operands."; DecimalDecimalDecimal = (x, y) => x+y; DatetimeTimespanDatetime = (x, y) => x + y; TimespanDatetimeDatetime = (x, y) => y + x; diff --git a/ExpressionEvaluator/Procedures/Operators/And.cs b/ExpressionEvaluator/Procedures/Operators/And.cs index 00218c0..abb497d 100644 --- a/ExpressionEvaluator/Procedures/Operators/And.cs +++ b/ExpressionEvaluator/Procedures/Operators/And.cs @@ -8,6 +8,8 @@ public And(int precedance) : base("&&", precedance, 2, false) { _name2 = "And"; + Category = "Logical"; + Description = "Check if at least one of the operand is true."; BoolBoolBool = (x, y) => x && y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Division.cs b/ExpressionEvaluator/Procedures/Operators/Division.cs index ea805bb..5cdee1f 100644 --- a/ExpressionEvaluator/Procedures/Operators/Division.cs +++ b/ExpressionEvaluator/Procedures/Operators/Division.cs @@ -10,7 +10,8 @@ public Division(int precedance) : base("/", precedance, 2, false) { _name2 = "Division"; - + Category = "Arithmetic"; + Description = "Divide two operands and gives the quotient as the answer."; DecimalDecimalDecimal = (x, y) => { if (y == 0) { throw new DivideByZeroException(); diff --git a/ExpressionEvaluator/Procedures/Operators/Equal.cs b/ExpressionEvaluator/Procedures/Operators/Equal.cs index 89ff933..29a1061 100644 --- a/ExpressionEvaluator/Procedures/Operators/Equal.cs +++ b/ExpressionEvaluator/Procedures/Operators/Equal.cs @@ -8,6 +8,8 @@ public Equal(int precedance) : base("==", precedance, 2, false) { _name2 = "Equal"; + Category = "Relational"; + Description = "Check if both operands are equal."; DecimalDecimalBool = (x, y) => x == y; BoolBoolBool = (x, y) => x == y; StringStringBool = (x, y) => x.ToLower() == y.ToLower(); diff --git a/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs b/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs index 2ed5763..dec1d38 100644 --- a/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs @@ -8,6 +8,8 @@ public GreaterEqual(int precedance) : base(">=", precedance, 2, false) { _name2 = "GreaterEqual"; + Category = "Relational"; + Description = "Check if the first operand is greater than or equal to the second."; DecimalDecimalBool = (x, y) => x >= y; TimespanTimespanBool = (x, y) => x >= y; DatetimeDatetimeBool = (x, y) => x >= y; diff --git a/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs b/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs index f13d007..6ef3a82 100644 --- a/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs +++ b/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs @@ -8,6 +8,8 @@ public GreaterThan(int precedance) : base(">", precedance, 2, false) { _name2 = "GreaterThan"; + Category = "Relational"; + Description = "Check if the first operand is greater than the second."; DecimalDecimalBool = (x, y) => x > y; TimespanTimespanBool = (x, y) => x > y; DatetimeDatetimeBool = (x, y) => x > y; diff --git a/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs b/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs index 0443525..4ee0f74 100644 --- a/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs @@ -8,6 +8,8 @@ public LesserEqual(int precedance) : base("<=", precedance, 2, false) { _name2 = "LesserEqual"; + Category = "Relational"; + Description = "Check if the first operand is lesser than or equal to the second."; DecimalDecimalBool = (x, y) => x <= y; TimespanTimespanBool = (x, y) => x <= y; DatetimeDatetimeBool = (x, y) => x <= y; diff --git a/ExpressionEvaluator/Procedures/Operators/LesserThan.cs b/ExpressionEvaluator/Procedures/Operators/LesserThan.cs index 9d4312a..6ad342b 100644 --- a/ExpressionEvaluator/Procedures/Operators/LesserThan.cs +++ b/ExpressionEvaluator/Procedures/Operators/LesserThan.cs @@ -8,6 +8,8 @@ public LesserThan(int precedance) : base("<", precedance, 2, false) { _name2 = "LessThan"; + Category = "Relational"; + Description = "Check if the first operand is lesser than the second."; DecimalDecimalBool = (x, y) => x < y; TimespanTimespanBool = (x, y) => x < y; DatetimeDatetimeBool = (x, y) => x < y; diff --git a/ExpressionEvaluator/Procedures/Operators/Modulo.cs b/ExpressionEvaluator/Procedures/Operators/Modulo.cs index 81b8425..17e11c5 100644 --- a/ExpressionEvaluator/Procedures/Operators/Modulo.cs +++ b/ExpressionEvaluator/Procedures/Operators/Modulo.cs @@ -8,6 +8,8 @@ public Modulo(int precedance) : base("%", precedance, 2, false) { _name2 = "Modulo"; + Category = "Arithmetic"; + Description = " Find the remains of two integers and gives the remainder after the division."; DecimalDecimalDecimal = (x, y) => x % y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Multiplication.cs b/ExpressionEvaluator/Procedures/Operators/Multiplication.cs index fb7e748..684d088 100644 --- a/ExpressionEvaluator/Procedures/Operators/Multiplication.cs +++ b/ExpressionEvaluator/Procedures/Operators/Multiplication.cs @@ -8,6 +8,8 @@ public Multiplication(int precedance) : base("*", precedance, 2, false) { _name2 = "Multiplication"; + Category = "Arithmetic"; + Description = "Multiply two operands."; DecimalDecimalDecimal = (x, y) =>x*y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/NotEqual.cs b/ExpressionEvaluator/Procedures/Operators/NotEqual.cs index e5298ed..3f813b9 100644 --- a/ExpressionEvaluator/Procedures/Operators/NotEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/NotEqual.cs @@ -8,6 +8,8 @@ public NotEqual(int precedance) : base("!=", precedance, 2, false) { _name2 = "NotEqual"; + Category = "Relational"; + Description = "Check if both operands are not equal."; DecimalDecimalBool = (x, y) => x != y; BoolBoolBool = (x, y) => x != y; StringStringBool = (x, y) => x != y; diff --git a/ExpressionEvaluator/Procedures/Operators/Or.cs b/ExpressionEvaluator/Procedures/Operators/Or.cs index 3b9fb95..83e19ca 100644 --- a/ExpressionEvaluator/Procedures/Operators/Or.cs +++ b/ExpressionEvaluator/Procedures/Operators/Or.cs @@ -8,6 +8,8 @@ public Or(int precedance) : base("||", precedance, 2, false) { _name2 = "Or"; + Category = "Logical"; + Description = "Check if at least one of the operand is true."; BoolBoolBool = (x, y) => x || y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Power.cs b/ExpressionEvaluator/Procedures/Operators/Power.cs index 5217b7c..e4a1817 100644 --- a/ExpressionEvaluator/Procedures/Operators/Power.cs +++ b/ExpressionEvaluator/Procedures/Operators/Power.cs @@ -10,6 +10,8 @@ public Power(int precedance) : base("^", precedance, 2, false) { _name2 = "Power"; + Category = "Arithmetic"; + Description = "Raise the number on the left to the power of the exponent of the right."; DecimalDecimalDecimal = (x, y) => { double dblResult = Math.Pow((double)x, (double)y); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Operators/Subtraction.cs b/ExpressionEvaluator/Procedures/Operators/Subtraction.cs index a4ce044..4d5ccdc 100644 --- a/ExpressionEvaluator/Procedures/Operators/Subtraction.cs +++ b/ExpressionEvaluator/Procedures/Operators/Subtraction.cs @@ -8,6 +8,8 @@ public Subtraction(int precedance) : base("-", precedance, 2, false) { _name2 = "Subtraction"; + Category = "Arithmetic"; + Description = "Subtract two operands."; DecimalDecimalDecimal = (x, y) => x - y; TimespanTimespanTimespan = (x, y) => x - y; DatetimeTimespanDatetime = (x, y) => x - y; diff --git a/ExpressionEvaluatorTests/DateTimeTests.cs b/ExpressionEvaluatorTests/DateTimeTests.cs index 21d0deb..cc9d4d4 100644 --- a/ExpressionEvaluatorTests/DateTimeTests.cs +++ b/ExpressionEvaluatorTests/DateTimeTests.cs @@ -495,5 +495,11 @@ public void Subtraction_TimeSpanTimeSpan_IsCorrect() _func.AddSetVariable("a", _now); Assert.AreEqual(new TimeSpan(1, 0, 0, 0), _func.Evaluate()); } + [Test] + public void Now_test() { + _func.Function = "a"; + _func.AddSetVariable("a", _now); + Assert.AreEqual(_now, _func.Evaluate()); + } } } diff --git a/ExpressionEvaluatorTests/LengthTests.cs b/ExpressionEvaluatorTests/LengthTests.cs index cd5a503..90c2afe 100644 --- a/ExpressionEvaluatorTests/LengthTests.cs +++ b/ExpressionEvaluatorTests/LengthTests.cs @@ -28,5 +28,12 @@ public void Length_ValidSTring_IsCorrect() _func.Function = @"Length('abcd')"; Assert.AreEqual(4, _func.EvaluateNumeric()); } + + [Test] + public void Length_EmptyString() + { + _func.Function = @"Length('')"; + Assert.AreEqual(0, _func.EvaluateNumeric()); + } } } diff --git a/ExpressionEvaluatorTests/ToStringFormatTests.cs b/ExpressionEvaluatorTests/ToStringFormatTests.cs index 72ba55c..8c35aaa 100644 --- a/ExpressionEvaluatorTests/ToStringFormatTests.cs +++ b/ExpressionEvaluatorTests/ToStringFormatTests.cs @@ -34,5 +34,6 @@ public void ToStringFormat_TrailingZero_CorrectValue() func.Function = @"ToStringFormat(10.1, '0.00')"; Assert.AreEqual("10.10", func.Evaluate()); } + } } diff --git a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs index d46a950..f8711f6 100644 --- a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs +++ b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs @@ -13,123 +13,33 @@ public class ListViewHelper { public static List getOperatorList() { - - //Type[] types= Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "ExpressionEvaluator.Procedures.Operators", StringComparison.Ordinal)).ToArray(); - //foreach (var type in types) - //{ - // Console.WriteLine(type.Name); - //} List operators = new List(); - operators.Add(new Operator() - { - Category = "Arithmetic", - Type = "+", - Description = "Add two operands." - - }); - operators.Add(new Operator() - { - Category = "Arithmetic", - Type = "-", - Description = "Subtract two operands." - - }); - operators.Add(new Operator() - { - Category = "Arithmetic", - Type = "*", - Description = "Multiply two operands." - - }); - operators.Add(new Operator() - { - Category = "Arithmetic", - Type = "/", - Description = "Divide two operands and gives the quotient as the answer." - - }); - operators.Add(new Operator() - { - Category = "Arithmetic", - Type = "%", - Description = " Find the remains of two integers and gives the remainder after the division." - - }); - - - operators.Add(new Operator() - { - Category = "Relational", - Type = "==", - Description = "Check if both operands are equal." - - }); - - operators.Add(new Operator() - { - Category = "Relational", - Type = "!=", - Description = "Check if both operands are not equal." - - }); - operators.Add(new Operator() - { - Category = "Relational", - Type = ">", - Description = "Check if the first operand is greater than the second." - - }); - operators.Add(new Operator() - { - Category = "Relational", - Type = "<", - Description = "Check if the first operand is lesser than the second." - - }); - operators.Add(new Operator() - { - Category = "Relational", - Type = ">=", - Description = "Check if the first operand is greater than or equal to the second." - - }); - operators.Add(new Operator() - { - Category = "Relational", - Type = "<=", - Description = "Check if the first operand is lesser than or equal to the second." - - }); - - operators.Add(new Operator() - { - Category = "Logical", - Type = "&&", - Description = "Check if both the operands are true." - - }); - operators.Add(new Operator() - { - Category = "Logical", - Type = "||", - Description = "Check if at least one of the operand is true." - - }); - operators.Add(new Operator() - { - Category = "Logical", - Type = "!", - Description = "Check if the operand is false" - - }); - + var _operators = from t in exp.ExpressionKeywords.Keywords.OfType() + select t; + foreach(var opr in _operators) + { + var new_operator = new Operator() + { + Category = opr.Category, + Type=opr.Name, + Description=opr.Description + }; + operators.Add(new_operator); + } + var _functions = from t in exp.ExpressionKeywords.Keywords.OfType() + select t; + foreach (var func in _functions) + { + var new_operator = new Operator() + { + Category = func.Category, + Type = func.Name, + Description = func.Description + }; + operators.Add(new_operator); + } return operators; } - //public Type[] GetOperators() - //{ - - // return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "ExpressionEvaluator.Procedures.Operators", StringComparison.Ordinal)).ToArray(); - //} public static List getVariableTypeList() { List VariableTypes = new List() {"int","float","double","char","string","bool","object" }; From 27c917c47b8ab1b1cf5c9fd8075d5fc450155bf8 Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Thu, 14 Apr 2022 00:18:48 +0530 Subject: [PATCH 10/25] Date time support added --- .../Procedures/Functions/Now.cs | 1 + ExpressionEvaluatorTests/ConcatenateTests.cs | 1 + .../View/FormulaEditorView.xaml | 5 +-- .../ViewModels/FormulaEditorViewModel.cs | 42 ++++++++++++++----- .../ViewModels/Helpers/ListViewHelper.cs | 4 +- .../ViewModels/VariableInputViewModel.cs | 5 ++- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/ExpressionEvaluator/Procedures/Functions/Now.cs b/ExpressionEvaluator/Procedures/Functions/Now.cs index 352c19f..07bd7a5 100644 --- a/ExpressionEvaluator/Procedures/Functions/Now.cs +++ b/ExpressionEvaluator/Procedures/Functions/Now.cs @@ -10,6 +10,7 @@ public Now(int precedance) { _name2 = "Now"; Category = "Date/Time"; + Description = "Gets the current Date and Time."; Datetime = () => DateTime.Now; } } diff --git a/ExpressionEvaluatorTests/ConcatenateTests.cs b/ExpressionEvaluatorTests/ConcatenateTests.cs index 7656215..3332dd1 100644 --- a/ExpressionEvaluatorTests/ConcatenateTests.cs +++ b/ExpressionEvaluatorTests/ConcatenateTests.cs @@ -63,5 +63,6 @@ public void Concatenate_WithVariables_CorrectValue() func.AddSetVariable("a", "word"); Assert.AreEqual("a1word", func.Evaluate()); } + } } diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml index 85e11e7..7d99f1e 100644 --- a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml @@ -126,8 +126,8 @@ SelectedValue="{Binding SelectedOperator}"> - - + + @@ -136,7 +136,6 @@ - ().ToString(); + } + else if (SelectedOutputType == "TimeSpan") + { + TestOutput = _func.Evaluate().ToString(); + } + + } catch(exp.ExpressionException e) { - MessageBox.Show(e.Message, "Expected Output Type Error", + MessageBox.Show(e.Message, "Output Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch(InvalidCastException e) { - MessageBox.Show(e.Message, "Expected Output Type Error", + MessageBox.Show(e.Message, "Output Error", MessageBoxButton.OK, MessageBoxImage.Error); } } diff --git a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs index f8711f6..d64cacb 100644 --- a/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs +++ b/ExpressionEvaluatorUi/ViewModels/Helpers/ListViewHelper.cs @@ -42,12 +42,12 @@ public static List getOperatorList() } public static List getVariableTypeList() { - List VariableTypes = new List() {"int","float","double","char","string","bool","object" }; + List VariableTypes = new List() {"int","float","double","char","string","bool","object","DateTime","TimeSpan" }; return VariableTypes; } public static List getOutputTypeList() { - List OutputTypes = new List() {"numeric","string","boolean" }; + List OutputTypes = new List() {"numeric","string","boolean","DateTime","TimeSpan" }; return OutputTypes; } } diff --git a/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs b/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs index 4c5cfec..548caaa 100644 --- a/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs +++ b/ExpressionEvaluatorUi/ViewModels/VariableInputViewModel.cs @@ -38,7 +38,10 @@ public object VariableInput break; } } - if(VariableInput==null || string.IsNullOrEmpty(VariableInput.ToString())) + //handle case of string empty or Null + + //if(VariableInput==null || string.IsNullOrEmpty(VariableInput.ToString())) + if (VariableInput == null || (VariableInput.ToString()).Length==0) { FormulaEditorViewModel.FormulaEditorVM.InputNull = true; } From 33d2d93b5d8803c5d2332e5ed6e26122cea5559f Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Mon, 18 Apr 2022 16:34:58 +0530 Subject: [PATCH 11/25] Removed static members by implementing singleton helper class --- ExpressionEvaluatorTests/ContainsTests.cs | 1 + .../View/AddVariableView.xaml.cs | 4 +- .../View/EditVariableView.xaml.cs | 4 +- .../View/FormulaEditorView.xaml | 23 +++++--- .../View/FormulaEditorView.xaml.cs | 2 +- .../ViewModels/AddVariableViewModel.cs | 14 ++--- .../ViewModels/Commands/CloseWindowCommand.cs | 10 ++-- .../Commands/EditVariableCommand.cs | 5 +- .../ViewModels/EditVariableViewModel.cs | 17 +++--- .../ViewModels/FormulaEditorViewModel.cs | 53 +++++++++---------- .../ViewModels/Helpers/FormulaEditorHelper.cs | 38 +++++++++++++ .../Helpers/IFormulaEditorHelper.cs | 18 +++++++ .../ViewModels/Helpers/ListViewHelper.cs | 9 +--- .../ViewModels/VariableInputViewModel.cs | 6 ++- 14 files changed, 138 insertions(+), 66 deletions(-) create mode 100644 ExpressionEvaluatorUi/ViewModels/Helpers/FormulaEditorHelper.cs create mode 100644 ExpressionEvaluatorUi/ViewModels/Helpers/IFormulaEditorHelper.cs diff --git a/ExpressionEvaluatorTests/ContainsTests.cs b/ExpressionEvaluatorTests/ContainsTests.cs index 50bf755..f70b198 100644 --- a/ExpressionEvaluatorTests/ContainsTests.cs +++ b/ExpressionEvaluatorTests/ContainsTests.cs @@ -65,5 +65,6 @@ public void Contains_StringIsASubstring_True() _func.Function = @"Contains('abcd','bc')"; Assert.AreEqual(true, _func.EvaluateBoolean()); } + } } diff --git a/ExpressionEvaluatorUi/View/AddVariableView.xaml.cs b/ExpressionEvaluatorUi/View/AddVariableView.xaml.cs index 8df847f..cea2fa3 100644 --- a/ExpressionEvaluatorUi/View/AddVariableView.xaml.cs +++ b/ExpressionEvaluatorUi/View/AddVariableView.xaml.cs @@ -1,4 +1,5 @@ using ExpressionEvaluatorUi.ViewModels; +using ExpressionEvaluatorUi.ViewModels.Helpers; using System; using System.Collections.Generic; using System.Text; @@ -22,7 +23,8 @@ public AddVariableView() { InitializeComponent(); this.DataContext = new AddVariableViewModel(); - AddVariableViewModel.CloseWindow = Close; + //AddVariableViewModel.CloseWindow = Close; + FormulaEditorHelper.Instance.AddVariable_CloseWindow = Close; } } diff --git a/ExpressionEvaluatorUi/View/EditVariableView.xaml.cs b/ExpressionEvaluatorUi/View/EditVariableView.xaml.cs index e1f6a67..db5a830 100644 --- a/ExpressionEvaluatorUi/View/EditVariableView.xaml.cs +++ b/ExpressionEvaluatorUi/View/EditVariableView.xaml.cs @@ -1,4 +1,5 @@ using ExpressionEvaluatorUi.ViewModels; +using ExpressionEvaluatorUi.ViewModels.Helpers; using System; using System.Collections.Generic; using System.Text; @@ -22,7 +23,8 @@ public EditVariableView() { InitializeComponent(); this.DataContext = new EditVariableViewModel(); - EditVariableViewModel.CloseWindow = Close; + //EditVariableViewModel.CloseWindow = Close; + FormulaEditorHelper.Instance.EditVariable_CloseWindow = Close; } } } diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml index 7d99f1e..c5937a3 100644 --- a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml @@ -5,11 +5,17 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:local="clr-namespace:ExpressionEvaluatorUi.View" + xmlns:vm="clr-namespace:ExpressionEvaluatorUi.ViewModels" + xmlns:h="clr-namespace:ExpressionEvaluatorUi.ViewModels.Helpers" mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="1000" MinHeight="500" MinWidth="700"> - - + + + + + @@ -35,7 +41,8 @@ Margin="1" FontWeight="Light" VerticalScrollBarVisibility="Visible" - HorizontalScrollBarVisibility="Auto"> + HorizontalScrollBarVisibility="Auto" + AcceptsReturn="True"> From b913ebc0b9e0382781d2de8331ad0090d626136b Mon Sep 17 00:00:00 2001 From: Aprajit Katiyar Date: Wed, 20 Apr 2022 16:01:05 +0530 Subject: [PATCH 13/25] Added watermark to indicate null variable input --- .../View/FormulaEditorView.xaml | 13 +++++++++++-- .../ViewModels/AddVariableViewModel.cs | 3 ++- .../ViewModels/VariableInputViewModel.cs | 18 +++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml index 8685906..c83da15 100644 --- a/ExpressionEvaluatorUi/View/FormulaEditorView.xaml +++ b/ExpressionEvaluatorUi/View/FormulaEditorView.xaml @@ -13,6 +13,7 @@ + @@ -178,11 +179,19 @@ Width="100" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> - + + @@ -83,20 +89,13 @@ - + + + - + - @@ -126,7 +149,6 @@ Background="LightGray" Margin="1" FontWeight="Bold"> - - +