public void NotifyNewInput(string newInput, CommandConsoleWindow window)
        {
            if (newInput.IsNullOrEmpty())
            {
                CurrentTextEntered = "";
                CurrentAutoComplete?.InitializeAutoComplete();
            }
            else
            {
                AddNewArraySlotIfNeeded();
            }

            CurrentTextEntered = newInput;

            RegenerateAutoComplete();

            if (CurrentAutoComplete != null &&
                (CurrentAutoCompleteID > CurrentAutoComplete.Count ||
                 CurrentAutoCompleteID == -1))
            {
                if (!newInput.IsNullOrEmpty() && CurrentAutoComplete.Count > 0 &&
                    Info.CommandParameterInfo[CurrentParameterID].ForceAutoCompleteUsage)
                {
                    CurrentAutoCompleteID = 0;
                    window.SelectedIndex  = CurrentAutoCompleteID;
                }
                else
                {
                    CurrentAutoCompleteID = -1;
                    window.SelectedIndex  = CurrentAutoCompleteID;
                }
            }
            window.Repaint();
        }
        private void ComputeCurrentArrayVariable(CommandConsoleWindow window)
        {
            if (currentArrayIDEdited < 0 || currentArrayIDEdited >= CurrentArrayTextEntered.Count)
            {
                return;
            }

            //TODO refactor this condition mess

            CurrentArrayTextEntered[CurrentArrayIDEdited] = CurrentTextEntered;

            object outputObj = null;

            if (!Info.CommandParameterInfo[CurrentParameterID].ForceAutoCompleteUsage &&
                !CurrentTextEntered.IsNullOrEmpty())
            {
                currentInterpreter.TryParse(CurrentTextEntered, out outputObj);
            }

            if ((!CurrentTextEntered.IsNullOrEmpty() || CurrentAutoCompleteID != -1) &&
                IsAutoCompleteSuggestions && outputObj == null &&
                (Info.CommandParameterInfo[CurrentParameterID].ForceAutoCompleteUsage || CurrentAutoCompleteID != -1))
            {
                if (CurrentAutoCompleteID == -1)
                {
                    CurrentAutoCompleteID = 0;
                }

                CurrentArrayValuesParsed[CurrentArrayIDEdited] =
                    (CurrentAutoComplete.GetValue(CurrentAutoCompleteID));
                CurrentArrayTextEntered[CurrentArrayIDEdited] =
                    CurrentAutoComplete.GetStringValue(CurrentAutoCompleteID);
                CurrentAutoComplete.InitializeAutoComplete();
            }
            else
            {
                CurrentArrayValuesParsed[CurrentArrayIDEdited] = outputObj;
            }

            CurrentAutoCompleteID = -1;

            CurrentAutoComplete?.InitializeAutoComplete();

            window.SelectedIndex       = -1;
            window.SearchTerms         = "";
            window.PreviousSearchTerms = "";

            window.Repaint();
            window.Focus();
        }
        private void PrepareParameterEdition()
        {
            CommandParameterInfo paramInfo = Info.CommandParameterInfo[CurrentParameterID];

            currentInterpreter = CommandParameterInterpreter.
                                 GetInterpreter(paramInfo.ParameterType);
            CurrentTextEntered = TextEntered[CurrentParameterID];

            CurrentAutoComplete = paramInfo.HasAutoComplete
                ? paramInfo.AutoComplete
                : AutoCompleteManager.GetDefaultAutoComplete(IsArray ?
                                                             paramInfo.ParameterType.GetElementType() :
                                                             paramInfo.ParameterType);

            CurrentAutoComplete?.InitializeAutoComplete();

            CurrentAutoCompleteID = -1;

            if (!CurrentParameterInfo.PreventDefaultValueUsage && CurrentParameterInfo.HadDefaultValue && CurrentAutoComplete != null)
            {
                if (CurrentAutoComplete.Count == 0)
                {
                    CurrentAutoComplete.GenerateAndSortAutoComplete("");
                }

                for (int i = 0; i < CurrentAutoComplete.Count; i++)
                {
                    if (CurrentAutoComplete.GetValue(i).Equals(CurrentParameterInfo.DefaultValue))
                    //   if (CurrentAutoComplete.GetValue(i).ToString() == CurrentParameterInfo.DefaultValue.ToString())
                    {
                        CurrentAutoCompleteID = i;
                        break;
                    }
                }
            }

            if (IsArray)
            {
                CurrentArrayTextEntered  = arrayTextEntered[CurrentParameterID];
                CurrentArrayValuesParsed = arrayValuesParsed[CurrentParameterID];
                currentArrayIDEdited     = CurrentArrayTextEntered.Count - 1;
                if (CurrentArrayIDEdited >= 0)
                {
                    CurrentTextEntered = CurrentArrayTextEntered[CurrentArrayIDEdited];
                }
            }
            else
            {
                CurrentTextEntered = TextEntered[CurrentParameterID];
            }

            if (!CurrentTextEntered.IsNullOrEmpty())
            {
                RegenerateAutoComplete();
            }
            else
            {
                CurrentAutoComplete?.InitializeAutoComplete();
            }

            CommandConsoleWindow.CurrentPanel.SearchTerms         = CurrentTextEntered;
            CommandConsoleWindow.CurrentPanel.PreviousSearchTerms = CurrentTextEntered;
        }