예제 #1
0
        private void AddAndRefreshVariableToVariableList()
        {
            selections.Add(CreateCurrentSelectionVariable());
            lastSelectionVariable = selections.Last();
            DisplayTextList.Add(selections.Last().ToString(inputText));

            RefreshItemDataSource(DisplayListBox, DisplayTextList);

            SetOutputText(inputText, 10);
        }
예제 #2
0
        private void InputTextBox_TextChanged(object sender, EventArgs e)
        {
            if (inputText == InputTextBox.Text)
            {
                return;
            }

            inputText = InputTextBox.Text;
            // Reset the DisplayTextList here
            // Add code for auto detecting variables here
            GenerateListOfInputVariables();
            DisplayTextList.Clear();
            return;

            RefreshItemDataSource(DisplayListBox, DisplayTextList);
            // Generate auto guess in Output Box here
        }
예제 #3
0
        /// <summary>
        /// Event for double clicking on the display list box.
        /// </summary>
        private void DisplayListBox_DoubleClick(object sender, MouseEventArgs e)
        {
            var removeIndex = DisplayListBox.SelectedIndex;

            if (removeIndex < 0 || removeIndex >= DisplayTextList.Count)
            {
                return;
            }

            try {
                DisplayTextList.RemoveAt(removeIndex);
                RefreshItemDataSource(DisplayListBox, DisplayTextList);
            }
            catch {
                throw new IndexOutOfRangeException();
            }
        }
예제 #4
0
        public NumberInputWindow(Variable randomVariable)
        {
            this.DisplayTextList      = new List <char>();
            this.ListMemberCollection = new List <string>();
            this.IsNegative           = false;
            this.type   = randomVariable.Type;
            this.IsList = randomVariable.IsList;
            if (randomVariable.Value != "")
            {
                if (randomVariable.IsList)
                {
                    ListMemberCollection.AddRange(randomVariable.Value.Replace(", ", ",").Split(','));
                }
                else
                {
                    DisplayTextList.AddRange(randomVariable.Value.ToCharArray());
                }
            }

            InitializeComponent();
            UpdateDisplay();
            this.CenterToParent();

            if (!randomVariable.IsList)
            {
                IsList = false;
                this.addButton.Dispose();
                this.listLabel.Dispose();
                this.listMemberLabel.Dispose();
                this.listDeleteButton.Dispose();
                this.listClearButton.Dispose();
                this.flowLayoutPanel1.Dispose();
                this.displayLabel.Height  += 24;
                this.displayLabel.Location = new Point(this.displayLabel.Location.X,
                                                       this.displayLabel.Location.Y - 24);
            }
            if (this.type == DataType.Integer)
            {
                this.periodButton.Dispose();
            }
        }
예제 #5
0
        internal string GenerateListOfInputVariables()
        {
            // Get Text in input box
            // Find all matches for
            // regex string (" " || "(" || "." || "{" || "[")  + \w+\d
            // e.g starts with space, left bracket, full stop, left curly brace, or left square bracket
            // Contains any number of non numeric letters, and ends with a digits
            string regexPattern          = "[\\s \\( \\. \\{ \\[ ]([A-Za-z]+\\d+)";
            var    collectionOfVariables = Regex.Matches(inputText, regexPattern);


            // foreach match, place in variables list if not already in list
            foreach (Match match in collectionOfVariables)
            {
                DisplayTextList.Add(new SelectionVariable(match.Index + 1, match.Length - 1).ToString(inputText));
            }

            RefreshItemDataSource(DisplayListBox, DisplayTextList);

            return(string.Empty);
        }