Example #1
0
        public static T9Dictionary CreateFrom(Dictionary <char, int[]> dict)
        {
            var t9Dictionary = new T9Dictionary();

            foreach (var item in dict)
            {
                t9Dictionary.Add(item.Key, T9ButtonCombination.CreateFromDigits(item.Value));
            }

            return(t9Dictionary);
        }
Example #2
0
        public string GetValue(char c)
        {
            T9ButtonCombination combination;

            if (dictionary.TryGetValue(c, out combination))
            {
                string result = string.Empty;

                if (previousChar != null && previousChar.ShouldWaitPause(combination))
                {
                    result += pauseSymbol;
                }
                result += combination.ToString();

                previousChar = combination;
                return(result);
            }
            else
            {
                throw new ConvertionDictionaryException($"Dictionary doesn't contain char '{c}'");
            }
        }
Example #3
0
 public bool ShouldWaitPause(T9ButtonCombination other)
 {
     return(this.Buttons[0] == other.Buttons[0]);
 }
Example #4
0
 public void Reset()
 {
     previousChar = null;
 }
Example #5
0
 public void Add(char c, T9ButtonCombination buttons)
 {
     dictionary.Add(c, buttons);
 }