private void menuitemCopyRegExp_Click(object sender, EventArgs e) { try { if (regExpDataGridView.CurrentCell != null) { DataGridViewCell cell = regExpDataGridView.CurrentCell; if (cell.ColumnIndex == regExpDataGridViewTextBoxColumn.Index) { regExpDataGridView.EndEdit(DataGridViewDataErrorContexts.Commit); if (cell.Value != DBNull.Value) { DataRowView rowview = (DataRowView)cell.OwningRow.DataBoundItem; var regExp = RegExpFactory.Create_RegExp(rowview, true); Clipboard.SetText(regExp.BuiltExpression); } } } } catch { } }
private void AddSelectionToExceptions() { if (textBox.SelectionLength == 0) { return; } var text = textBox.SelectedText.Trim(); if (!String.IsNullOrEmpty(text)) { var rowView = _views.MainForm.sourceColRegExp.Current as DataRowView; var regExp = RegExpFactory.Create_ColRegExp(rowView, new [] { _selectedColumnID }, false); if (regExp != null) { regExp.Exceptions.Items.Add(new RegExpCriteria { Enabled = true, Expression = text }); regExp.SafeSave(rowView, true); _views.UpdateViews(); } } }
public ColRegExpProcessor(string regExpDatabasePath, string password, int regExpID, bool ignoreCase = true, bool compiled = false) : this(null) { _password = password; using (var connection = DatabaseHelper.CreateConnection(regExpDatabasePath, password)) { var options = RegExpOptions.CreateOptions(ignoreCase, compiled); /////////////////////////////////////////////////////////////////////////////// var query = "SELECT ID, ColumnID, RegExp, [Extract], [RegExpColor], [lookahead], [lookbehind], [neg lookahead], [neg lookbehind], [exceptions] FROM ColRegExp WHERE ID = " + regExpID; var regExpRows = DatabaseHelper.GetDataRows(connection, query).ToList(); if (!regExpRows.Any()) { throw new Exception("Invalid RegExpID"); } var regExp = RegExpFactory.Create_ColRegExp(regExpRows.First(), null, true, options); _listRegExps.Add(regExp); /////////////////////////////////////////////////////////////////////////////// _hasEmptyItems = Sanitize(); } }
public RegExpProcessor(Logger logger, string regExpDatabasePath, string password, bool ignoreCase = true, bool compiled = false) : this(logger) { using (var connection = DatabaseHelper.CreateConnection(regExpDatabasePath, password)) { var options = RegExpOptions.CreateOptions(ignoreCase, compiled); /////////////////////////////////////////////////////////////////////////////// var query = "SELECT ID, RegExp, score, [Arithmetic factor], [prefix match], [suffix match], [RegExpColor], [lookahead], [lookbehind], [neg lookahead], [neg lookbehind], [exceptions], [categoryID] FROM RegExp"; var regExpRows = DatabaseHelper.GetDataRows(connection, query); foreach (var row in regExpRows) { try { var regExp = RegExpFactory.Create_RegExp(row, true, options); if (regExp != null) { _listRegExps.Add(regExp); } } catch { this.Logger.HandleRegExpException(row); } } _hasEmptyItems = Sanitize(); } }
protected void AddToExceptions(MainDataSet.RegExpRow rowRegExp, RegExpStatisticsProcessingResult wordcount) { var regExp = RegExpFactory.Create_RegExp(rowRegExp, false); regExp.AddException(wordcount.Word); regExp.SafeSave(rowRegExp, true); }
public ColRegExpProcessor(DataRow row, IEnumerable <int> columnIDs, bool ignoreCase = true, bool compiled = false) : this(null) { var regExp = RegExpFactory.Create_ColRegExp(row, columnIDs, true, RegExpOptions.CreateOptions(ignoreCase, compiled)); if (regExp == null) { throw new DataException("Row is deleted or detached"); } _listRegExps.Add(regExp); _hasEmptyItems = Sanitize(); }
private void btnEdit_Click(object sender, EventArgs e) { if (grid.SelectedRows.Count == 1) { var rowView = (DataRowView)grid.SelectedRows[0].DataBoundItem; var regExp = RegExpFactory.Create_RegExp(rowView, false); if (regExp != null) { FormEditPrefixSuffix formEditPrefixSuffix = new FormEditPrefixSuffix(regExp); if (formEditPrefixSuffix.ShowDialog() == DialogResult.OK) { regExp.SafeSave(rowView, true); } } } }
public RegExpProcessor(IEnumerable <DataRow> regExpRows, bool ignoreCase = true, bool compiled = false) : this(null) { var options = RegExpOptions.CreateOptions(ignoreCase, compiled); /////////////////////////////////////////////////////////////////////////////// foreach (var row in regExpRows) { var regExp = RegExpFactory.Create_RegExp(row, true, options); if (regExp != null) { _listRegExps.Add(regExp); } } _hasEmptyItems = Sanitize(); }
public ColRegExpProcessor(IEnumerable <DataRow> enumerable, IEnumerable <int> columnIDs, bool ignoreCase = true, bool compiled = false) : this(null) { var options = RegExpOptions.CreateOptions(ignoreCase, compiled); /////////////////////////////////////////////////////////////////////////////// foreach (var row in enumerable) { var regExp = RegExpFactory.Create_ColRegExp(row, columnIDs, true, options); if (regExp != null) { _listRegExps.Add(regExp); } } _listRegExps = _listRegExps.OrderBy(x => x.ExtractOptions != null ? x.ExtractOptions.Order : 0) .ToList(); _hasEmptyItems = Sanitize(); }
public ColRegExpProcessor(Logger logger, string regExpDatabasePath, string password, IEnumerable <int> columnIDs, bool ignoreCase = true, bool compiled = false) : this(logger) { using (var connection = DatabaseHelper.CreateConnection(regExpDatabasePath, password)) { var options = RegExpOptions.CreateOptions(ignoreCase, compiled); /////////////////////////////////////////////////////////////////////////////// var query = "SELECT ID, ColumnID, RegExp, [Extract], [RegExpColor], [lookahead], [lookbehind], [neg lookahead], [neg lookbehind], [exceptions] FROM ColRegExp"; var regExpRows = DatabaseHelper.GetDataRows(connection, query); foreach (var row in regExpRows) { try { var regExp = RegExpFactory.Create_ColRegExp(row, columnIDs, true, options); if (regExp != null) { _listRegExps.Add(regExp); } } catch { this.Logger.HandleRegExpException(row); } } /////////////////////////////////////////////////////////////////////////////// _listRegExps = _listRegExps.OrderBy(x => x.ExtractOptions != null ? x.ExtractOptions.Order : 0) .ToList(); _hasEmptyItems = Sanitize(); } }
protected void InitializeRegExpEditor(bool enableNavigation) { _editor = new FormRegularExpressionEditor(_views, _views.MainForm.sourceRegExp, x => RegExpFactory.Create_RegExp(x, false)) { Dock = DockStyle.Fill, TopLevel = false, Parent = splitter.Panel2 }; _editor.Modified += (sender, args) => RaiseDataModifiedEvent(); /////////////////////////////////////////////////////////////////////////////// var panel = new Panel { Dock = DockStyle.Fill, BorderStyle = BorderStyle.None, Visible = true }; panel.Controls.Add(_editor); splitter.Panel2.Controls.Add(panel); _editor.Show(); }
protected void AppendRegExpCriteria(RegExpMatchResult match, RegExpCriteriaType criteriaType, string strPrefix, string strSuffix) { try { string strSelectedText = (string)textBox.Tag; if (criteriaType != RegExpCriteriaType.Exception) { if (strSelectedText.IndexOf(" ", StringComparison.InvariantCulture) == -1 && strSelectedText.Trim() == strSelectedText) { strSelectedText = strPrefix + @"\b" + Regex.Escape(strSelectedText) + @"\b" + strSuffix; } else { strSelectedText = strPrefix + Regex.Escape(strSelectedText) + strSuffix; } } else { strSelectedText = strPrefix + strSelectedText + strSuffix; } var rowRegExp = _views.MainForm.datasetMain.ColRegExp.FirstOrDefault(x => x.ID == match.RegExp.ID); if (rowRegExp != null) { var regExp = RegExpFactory.Create_ColRegExp(rowRegExp, null, false); regExp.AddCriteria(criteriaType, strSelectedText); regExp.SafeSave(rowRegExp, true); ////////////////////////////////////////////////////////////////////////// if (this.RefreshHighlights != null) { this.RefreshHighlights(this, EventArgs.Empty); } ////////////////////////////////////////////////////////////////////////// if (this.CalcScores != null) { if (_views.AutoCalc > 0) { _nChanges++; if (_nChanges >= _views.AutoCalc) { _nChanges = 0; DialogResult dlgres = MessageBox.Show("Do you wish to calculate scores?", MainForm.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgres == DialogResult.Yes) { this.CalcScores(this, EventArgs.Empty); } } } } //ClearHighlights(); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }