Example #1
0
        /// <summary>
        /// This method permits, on user click, to perform two type of actions.
        /// <list type="On click">
        ///     <item> The user can iterate with a combo list full of all possible value for this tag.</item>
        ///     <item> It appears a open dialog form where you can specify which path you want indicate.</item>
        ///     <item> It appears an input box where you can insert custom value</item>
        /// </list>
        /// </summary>
        /// <param name="sender">Object that is a dataGridView type</param>
        /// <param name="e">This contains event info about data cell</param>
        private void dgvConfig_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Boolean validClick = (e.RowIndex != -1 && e.ColumnIndex != -1); //Make sure the clicked row/column is valid.
            // Check to make sure the cell clicked is the cell containing the combobox
            //if ((e.ColumnIndex == kColumnActions) && validClick) {
            String myTag         = dgvConfig.Rows[e.RowIndex].Cells[Constants.K_ColumnTag].Value.ToString();
            String myValue       = dgvConfig.Rows[e.RowIndex].Cells[Constants.K_ColumnValue].Value.ToString();
            String myDescription = dgvConfig.Rows[e.RowIndex].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString();

            if ((e.ColumnIndex == Constants.K_ColumnValue) && validClick)
            {
                if (dgvConfig.CurrentCell is DataGridViewComboBoxCell)
                {
                    dgvConfig.ReadOnly = false;
                    dgvConfig.EditMode = DataGridViewEditMode.EditOnEnter;
                }
                else
                {
                    String prompt = "TAG --> " + myTag;
                    if (Trivia.IterateOverList(ListOpenDialog, myTag))
                    {
                        String  Path = String.Empty;
                        Boolean f    = FileUtils.OpenFolder(out Path);

                        if (!f)
                        {
                            return;
                        }

                        if (myValue != Path)
                        {
                            DictionaryUtils.UpdateCustomValue(myTag, Path, myDescription, ref DictionaryAllRows);
                            dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value = Path;
                        }
                    }
                    else if (Trivia.IterateOverList(ListOpenTextBox, myTag))
                    {
                        String         title   = String.Empty;
                        String         content = dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value.ToString();
                        String         tip     = String.Empty;
                        InputBoxResult result  = InputBox.Show(prompt, title, content, tip, new InputBoxValidatingHandler(inputBox_Validating));
                        if ((result.OK) && (content != result.Text))
                        {
                            DictionaryUtils.UpdateCustomValue(myTag, result.Text, myDescription, ref DictionaryAllRows);
                            dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value = result.Text;
                        }
                    }
                    else if (Trivia.IterateOverList(ListOpenCheckBoxList, myTag))
                    {
                        ChkListBox frm = new ChkListBox();

                        //add new prefixes here
                        //String[] defaultValues = new String[46]{ "*.c", "*.cc", "*.cxx", "*.cpp", "*.cs", "*.c++", "*.java", "*.ii", "*.ixx",
                        //                                         "*.ipp", "*.i++", "*.inl", "*.idl", "*.ddl", "*.odl", "*.h", "*.hh",
                        //                                         "*.hxx", "*.hpp", "*.h++", "*.cs", "*.d", "*.php", "*.php4", "*.php5",
                        //                                         "*.phtml", "*.inc", "*.m", "*.markdown", "*.md", "*.mm", "*.dox", "*.py",
                        //                                         "*.pyw", "*.f90", "*.f95", "*.f03", "*.f08", "*.f", "*.for", "*.tcl",
                        //                                         "*.vhd", "*.vhdl", "*.ucf", "*.qsf", "*.ice"};
                        String   content         = dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value.ToString().Trim();
                        String[] checkedElements = content.Split(new Char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

                        ////remove all spaces in a String array
                        //checkedElements = (from t in checkedElements
                        //                   select t.Trim()).ToArray();

                        frm.prompt        = prompt;
                        frm.checkedValues = checkedElements;
                        //frm.values = defaultValues;
                        frm.ShowDialog();

                        if (!String.IsNullOrEmpty(frm.strRet))
                        {
                            dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value = frm.strRet;
                        }
                    }
                    dgvConfig.ReadOnly = true;
                }
            }
            else
            {
                dgvConfig.ReadOnly = true;
            }

            if (e.ColumnIndex < 2)
            {
                txtDescription.Text = dgvConfig.Rows[e.RowIndex].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString().Replace("\r\n", "");
            }
        }