コード例 #1
0
        /// <summary>
        /// This method restore the original value stored in a dedicate DefinitionTag class property.
        /// Remember these original values is all about the first reading of config file.
        /// </summary>
        /// <param name="sender">Object that is an object type</param>
        /// <param name="e">This contains event info about data grid view errors</param>
        private void btRestore_Click(object sender, EventArgs e)
        {
            //progress bar...
            gbProgressBar.Visible = true;
            gbProgressBar.Maximum = dgvConfig.Rows.Count;
            gbProgressBar.Step    = 1;
            gbProgressBar.Value   = 0;

            this.Refresh();
            Int32 q = 0;

            for (Int32 x = 0; x < dgvConfig.Rows.Count; x++)
            {
                String myTag         = dgvConfig.Rows[x].Cells[Constants.K_ColumnTag].Value.ToString();
                String originalValue = dgvConfig[Constants.K_ColumnOriginalValue, x].Value.ToString();
                String myDescription = dgvConfig.Rows[x].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString();

                DictionaryUtils.UpdateCustomValue(myTag, originalValue, myDescription, ref DictionaryAllRows);
                dgvConfig[Constants.K_ColumnValue, x].Value = originalValue;

                q += 1;
                gbProgressBar.Value = q;
            }


            gbProgressBar.Value   = 0;
            gbProgressBar.Visible = false;
            this.Refresh();
        }
コード例 #2
0
        /// <summary>
        /// This methods (with btSave_Click) permits to choice
        /// the path and the name of file you want to create.
        /// </summary>
        /// <param name="sender">Object that is an object type</param>
        /// <param name="e">This contains event info about object</param>
        private void saveFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Get file name.

            for (Int32 x = 0; x < dgvConfig.Rows.Count; x++)
            {
                String myTag         = dgvConfig.Rows[x].Cells[Constants.K_ColumnTag].Value.ToString();
                String originalValue = dgvConfig[Constants.K_ColumnValue, x].Value.ToString();
                String myDescription = dgvConfig.Rows[x].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString();

                DictionaryUtils.UpdateCustomValue(myTag, originalValue, myDescription, ref DictionaryAllRows);
            }

            String name = saveFileDialog1.FileName;

            FileUtils.SavingConfFile(name, ref DictionaryAllRows);
        }
コード例 #3
0
        /// <summary>
        /// Determines if a cell change its value, through calling Trivia.CheckDataIntegrity() method,
        /// in order to determine if this value is congruent or not.
        /// </summary>
        /// <param name="sender">Object that is a dataGridView cell type</param>
        /// <param name="e">This contains event info about object</param>
        private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            //Make sure the clicked row/column is valid.
            Boolean validClick = (e.RowIndex != -1 && e.ColumnIndex != -1);

            if ((validClick) && (e.ColumnIndex == Constants.K_ColumnValue) && (Trivia.VerifyTypeCellCombo(dgvConfig[Constants.K_ColumnTag, e.RowIndex].Value.ToString(), ref ListCombo)))
            {
                dgvConfig.Refresh();

                String myTag         = dgvConfig[Constants.K_ColumnTag, e.RowIndex].Value.ToString();
                String myValue       = dgvConfig[Constants.K_ColumnValue, e.RowIndex].Value.ToString();
                String myDescription = dgvConfig[Constants.K_ColumnDescriptionHidden, e.RowIndex].Value.ToString();

                //TODO: determine cases
                if (!DictionaryUtils.CheckDataIntegrity(ref DictionaryAllRows, myTag, myValue))
                {
                    return;
                }
                DictionaryUtils.UpdateCustomValue(myTag, myValue, myDescription, ref DictionaryAllRows);
            }
        }
コード例 #4
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", "");
            }
        }