Example #1
0
        /// <summary>
        /// Call Trivia.SetListsInForm(), that is a static method which load elements (strings here) in
        /// public lists.
        /// Then set txtSearch to modify all in put character into UPPER char and subscribe an event handler
        /// which controls if Enter key is pressed.
        /// </summary>
        private void SetElementsInForm()
        {
            Trivia.SetListsInForm(ref ListButton, ref ListCombo, ref ListOpenDialog, ref ListOpenTextBox, ref ListOpenCheckBoxList);

            gbConfFile.Text       = "No Configuration file opened";
            gbConfFile.ForeColor  = Color.DarkRed;
            lbPath.Text           = "Please select a config file or create a new one!";
            gbProgressBar.Visible = false;

            txtSearch.CharacterCasing = CharacterCasing.Upper;
            txtSearch.KeyPress       += new KeyPressEventHandler(CheckEnter);
        }
Example #2
0
 /// <summary>
 /// This method set a DataGridViewComboBoxCell object, based on its tag.
 /// </summary>
 /// <param name="cb">Represents a DataGridViewComboBoxCell object.</param>
 /// <param name="tag">Represents a particular tag to test.</param>
 /// <param name="value">Represents the tag value.</param>
 public static void FillCombo(ref DataGridViewComboBoxCell cb, String tag)
 {
     cb.ReadOnly = false;
     if (Trivia.TestingYesNoCombo(tag))
     {
         cb.DataSource = new String[] { "YES", "NO" };
     }
     else
     {
         cb.DataSource = Trivia.Combo_Other(tag);
     }
 }
        /// <summary>
        /// This method represents a "custom mode" of writing a text file
        /// according to the doxygen config file schema.
        /// </summary>
        /// <param name="path">The path where this text file will write.</param>
        /// <param name="dict">Represents a public Dictionary<String, DefinitionTag>
        ///                    which Represents every read row
        /// </param>
        public static void SavingConfFile(String path, ref Dictionary <String, DefinitionTag> dict)
        {
            //TODO: save file -- move these statement rows
            //String s = General.GetTextResource("ConfigDoxygen.header.txt");
            StringBuilder sb = new StringBuilder();
            Boolean       f  = false;

            sb = sb.AppendLine("#This configuration file is modified with ");
            sb = sb.Append("#");
            sb = sb.Append(AppDomain.CurrentDomain.FriendlyName);
            sb = sb.Append(" (v. ");
            sb = sb.Append(Assembly.GetExecutingAssembly().GetName().Version.ToString());
            sb = sb.AppendLine(")");
            sb = sb.AppendLine();

            foreach (KeyValuePair <String, DefinitionTag> entry in dict)
            {
                String[] stringSeparators = new String[] { "\r\n" };
                String   paddedParam      = entry.Value.Description.PadLeft(entry.Value.Description.Length + 1);;
                paddedParam = paddedParam.PadLeft(10);

                String[] lines = paddedParam.Split(stringSeparators, StringSplitOptions.None);

                foreach (String s in lines)
                {
                    sb = sb.Append("#");
                    sb = sb.Append(s);
                    sb = sb.Append(Environment.NewLine);
                }

                f  = Trivia.TestingQuoteValue(entry.Key);
                sb = sb.Append(Environment.NewLine);
                sb = sb.Append(entry.Key);
                sb = sb.Append(" = ");
                if (f)
                {
                    sb = sb.Append("\"");
                }
                sb = sb.Append(entry.Value.Value);
                if (f)
                {
                    sb = sb.Append("\"");
                }
                sb = sb.Append(Environment.NewLine);
                sb = sb.Append(Environment.NewLine);
            }

            File.WriteAllText(path, sb.ToString());
        }
Example #4
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);
            }
        }
Example #5
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", "");
            }
        }
Example #6
0
        /// <summary>
        /// This method create a DataTable object which is loaded with a filtered dictionary.
        /// Then it creates two column.
        /// <list type="Column">
        ///     <item> It contains values and (depending on type of key/tag) it is modified into combo or button (invisible).</item>
        ///     <item> A column where store the original value read of config file (remember this method is called by ReadConfigFile()!).</item>
        /// </list>
        /// </summary>
        /// Finally set datagridview.
        /// <param name="DictionaryDataSource">This parameter is a dictionary (filtered if it is possible) as datagridview datasource.</param>
        private void SetDataGridView(Dictionary <String, DefinitionTag> DictionaryDataSource)
        {
            CloseConnection();

            dgvConfig.ColumnHeadersDefaultCellStyle.ForeColor = Color.Chocolate;
            dgvConfig.ColumnHeadersDefaultCellStyle.BackColor = Color.Lavender;
            dgvConfig.EnableHeadersVisualStyles = false;

            dgvConfig.Visible = false;

            gbConfFile.Text = "Reading Configuration file...";

            dgvConfig.AutoGenerateColumns = true;

            var filteredValues = DictionaryUtils.GetQuery(txtSearch.Text.Trim(), DictionaryAllRows);

            DataTable dt = new DataTable();

            dt.Columns.Add("TAG", typeof(String));
            dt.Columns.Add("Value", typeof(String));
            dt.Columns.Add("Description", typeof(String));
            dt.Columns.Add("OriginalValue", typeof(String));

            //http://robertgreiner.com/2010/05/iterating-through-a-dictionary-in-csharp/
            foreach (KeyValuePair <String, DefinitionTag> x in filteredValues)
            {
                dt.Rows.Add(x.Key, x.Value.Value, x.Value.Description);
            }

            dgvConfig.DataSource = dt;

            dgvConfig.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
            dgvConfig.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            dgvConfig.AllowUserToResizeRows = false;

            //progress bar...
            gbProgressBar.Visible = true;
            gbProgressBar.Maximum = dgvConfig.Rows.Count * 2;
            gbProgressBar.Step    = 1;
            gbProgressBar.Value   = 0;

            this.Refresh();
            Int32 q = 0;

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

                if (Trivia.VerifyTypeCellButton(myTag, ref ListButton))
                {
                    //DEPRECATED
                    //DataGridViewButtonCell bt = new DataGridViewButtonCell();
                    //bt.Value = kButtonText;
                    //dgvConfig[kColumnActions, x] = bt;
                    //DEPRECATED -- END

                    String tmp = dgvConfig[Constants.K_ColumnValue, x].Value.ToString().Replace("\"", "");
                    dgvConfig[Constants.K_ColumnValue, x].Value         = tmp;
                    dgvConfig[Constants.K_ColumnOriginalValue, x].Value = tmp;
                    //if (txtSearch.Text.Length == 0) UpdateCustomValue(myTag, tmp);
                }
                else if (Trivia.VerifyTypeCellCombo(myTag, ref ListCombo))
                {
                    DataGridViewComboBoxCell cb = new DataGridViewComboBoxCell();
                    cb.FlatStyle = FlatStyle.Flat;
                    Trivia.FillCombo(ref cb, myTag);
                    dgvConfig[Constants.K_ColumnValue, x] = cb;
                    dgvConfig.Refresh();

                    dgvConfig.Rows[x].Cells[Constants.K_ColumnValue].Value = myValue;
                    dgvConfig[Constants.K_ColumnOriginalValue, x].Value    = myValue;
                    //if (txtSearch.Text.Length == 0) UpdateCustomValue(myTag, myValue);
                }
                else
                {
                    if (Trivia.TestingDotLineDescription(myTag))
                    {
                        //TODO: regex...
                        //(.*) etc
                        //####myValue= myValue.Replace(
                    }


                    //UpdateCustomValue(myTag, myValue);
                }
                q += 1;
                gbProgressBar.Value = q;
            }
            this.Refresh();

            dgvConfig.Columns[Constants.K_ColumnOriginalValue].Visible     = false;
            dgvConfig.Columns[Constants.K_ColumnDescriptionHidden].Visible = true;

            //set autosize mode
            dgvConfig.Columns[Constants.K_ColumnTag].AutoSizeMode   = DataGridViewAutoSizeColumnMode.None;
            dgvConfig.Columns[Constants.K_ColumnValue].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            dgvConfig.Columns[Constants.K_ColumnTag].Width          = Constants.K_ColWidthTag;
            dgvConfig.Columns[Constants.K_ColumnValue].Width        = dgvConfig.Width - dgvConfig.Columns[Constants.K_ColumnTag].Width - Constants.K_ColWidthFillUp;


            dgvConfig.Visible          = true;
            dgvConfig.Rows[0].Selected = true;
            txtDescription.Text        = dgvConfig.Rows[0].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString().Replace("\r\n", "");;

            gbConfFile.Text      = "Configuration file: nr " + dgvConfig.Rows.Count.ToString() + " rows";
            gbConfFile.ForeColor = Color.GreenYellow;
            dgvConfig.Refresh();

            gbProgressBar.Value   = 0;
            gbProgressBar.Visible = false;
        }