From d4ba21c443ab350b2178b9c986012cb0dec0929c Mon Sep 17 00:00:00 2001 From: Volker Wollmann <64246526+VolkerWollmann@users.noreply.github.com> Date: Fri, 24 Jul 2020 08:09:01 +0200 Subject: [PATCH] String Constant Mapping unecessary --- .../Commands/SelectColorCommand.cs | 2 +- .../MyMasterMind/Controls/CodeField.xaml | 13 ++++---- .../Interfaces/MasterMindEnums.cs | 31 ------------------- 3 files changed, 8 insertions(+), 38 deletions(-) diff --git a/MyMasterMind/MyMasterMind/Commands/SelectColorCommand.cs b/MyMasterMind/MyMasterMind/Commands/SelectColorCommand.cs index f87f189..9ded1ba 100644 --- a/MyMasterMind/MyMasterMind/Commands/SelectColorCommand.cs +++ b/MyMasterMind/MyMasterMind/Commands/SelectColorCommand.cs @@ -21,7 +21,7 @@ public bool CanExecute(object parameter) public void Execute(object parameter) { - CodeField.SetColor(MyMasterMindConstants.GetCodeColor((string)parameter)); + CodeField.SetColor((MyMasterMindCodeColors)parameter); } public SelectColorCommand(CodeField codeField ) diff --git a/MyMasterMind/MyMasterMind/Controls/CodeField.xaml b/MyMasterMind/MyMasterMind/Controls/CodeField.xaml index 76bf13e..32778e7 100644 --- a/MyMasterMind/MyMasterMind/Controls/CodeField.xaml +++ b/MyMasterMind/MyMasterMind/Controls/CodeField.xaml @@ -4,17 +4,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:MyMasterMind.Controls" + xmlns:constants="clr-namespace:MyMasterMind.Interfaces" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - - - - - - + + + + + + > mapping = - new List>() - { - new Tuple( RED, MyMasterMindCodeColors.Red ), - new Tuple( GREEN, MyMasterMindCodeColors.Green ), - new Tuple( BLUE, MyMasterMindCodeColors.Blue ), - new Tuple( YELLOW, MyMasterMindCodeColors.Yellow ), - new Tuple( MAGENTA, MyMasterMindCodeColors.Magenta ), - new Tuple( CYAN, MyMasterMindCodeColors.Cyan ), - - }; - - if (mapping.Any(m => (m.Item1 == color))) - { - return mapping.First(m => (m.Item1 == color)).Item2; - } - - return MyMasterMindCodeColors.None; - } } }