How to use Document_DocumentChanged method of NBi.UI.Genbi.View.TestSuiteGenerator.NbiTextEditor class

Best NBi code snippet using NBi.UI.Genbi.View.TestSuiteGenerator.NbiTextEditor.Document_DocumentChanged

NbiTextEditor.cs

Source:NbiTextEditor.cs Github

copy

Full Screen

...5051 // Methods52 public NbiTextEditor()53 {54 base.Document.DocumentChanged += this.Document_DocumentChanged;5556 this.UndoCommand = new DelegateCommand(CanUndo, Undo);57 this.RedoCommand = new DelegateCommand(CanRedo, Redo);5859 this.CutCommand = new DelegateCommand(CanCut, DoCut);60 this.CopyCommand = new DelegateCommand(CanCopy, DoCopy);61 this.PasteCommand = new DelegateCommand(CanPaste, DoPaste);6263 this.SelectAllCommand = new DelegateCommand(CanSelectAll, DoSelectAll);64 this.FindAndReplaceCommand = new FindAndReplaceCommand(this);65 this.ToggleFoldingsCommand = new DelegateCommand(() => true, this.DoToggleFoldings);6667 this.CreateContextMenu();6869 Application.Idle += RefreshCommands;7071 //base.Document.FoldingManager.UpdateFoldings(string.Empty, null);72 }7374 private void RefreshCommands(object sender, EventArgs e)75 {76 this.UndoCommand.Refresh();77 this.RedoCommand.Refresh();7879 this.CutCommand.Refresh();80 this.CopyCommand.Refresh();81 this.PasteCommand.Refresh();8283 this.SelectAllCommand.Refresh();84 this.FindAndReplaceCommand.Refresh();85 this.ToggleFoldingsCommand.Refresh();86 }8788 8990 #region Commands definitions9192 public ICommand UndoCommand { get; private set; }93 public ICommand RedoCommand { get; private set; }9495 public ICommand CutCommand { get; private set; }96 public ICommand CopyCommand { get; private set; }97 public ICommand PasteCommand { get; private set; }9899 public ICommand SelectAllCommand { get; private set; }100 public ICommand ToggleFoldingsCommand { get; private set; }101 public ICommand FindAndReplaceCommand { get; private set; }102103 #endregion104105 #region Commands implementations106107 private bool CanUndo()108 {109 return this.Presenter != null && base.Document.UndoStack.CanUndo;110 }111112 private bool CanRedo()113 {114 return this.Presenter != null && base.Document.UndoStack.CanRedo;115 }116117 private bool CanCopy()118 {119 return this.Presenter != null && base.ActiveTextAreaControl.SelectionManager.HasSomethingSelected;120 }121122 private bool CanCut()123 {124 return this.Presenter != null && base.ActiveTextAreaControl.SelectionManager.HasSomethingSelected;125 }126127 private bool CanPaste()128 {129 return this.Presenter != null && base.ActiveTextAreaControl.TextArea.ClipboardHandler.EnablePaste;130 }131132 private bool CanSelectAll()133 {134 if (this.Presenter == null) return false;135 if (base.Document.TextContent == null) return false;136 return !base.Document.TextContent.Trim().Equals(String.Empty);137 }138139140141142 private void DoCut()143 {144 new Cut().Execute(base.ActiveTextAreaControl.TextArea);145 base.ActiveTextAreaControl.Focus();146 }147148 private void DoCopy()149 {150 new Copy().Execute(base.ActiveTextAreaControl.TextArea);151 base.ActiveTextAreaControl.Focus();152 }153154 private void DoPaste()155 {156 new Paste().Execute(base.ActiveTextAreaControl.TextArea);157 base.ActiveTextAreaControl.Focus();158 }159160 private void DoSelectAll()161 {162 new SelectWholeDocument().Execute(base.ActiveTextAreaControl.TextArea);163 base.ActiveTextAreaControl.Focus();164 }165166 public void DoToggleFoldings()167 {168 new ToggleAllFoldings().Execute(base.ActiveTextAreaControl.TextArea);169 }170171 #endregion172173 # region Initialization174175 private void CreateContextMenu()176 {177 //contextmenu178 var mnu = new ContextMenuStrip();179 var mnuFind = new ToolStripMenuItem("Find/Replace");180 var mnuFold = new ToolStripMenuItem("Open/close all foldings");181182 CommandManager.Instance.Bindings.Add(this.FindAndReplaceCommand, mnuFind);183 CommandManager.Instance.Bindings.Add(this.ToggleFoldingsCommand, mnuFold);184185186 //Add to main context menu187 mnu.Items.AddRange(new ToolStripItem[] { mnuFind, mnuFold });188189 //Assign to datagridview190 base.ActiveTextAreaControl.ContextMenuStrip = mnu;191 }192193 #endregion194195 public void SelectText(int start, int length)196 {197 var textLength = base.Document.TextLength;198 if (textLength < (start + length))199 {200 length = (textLength - 1) - start;201 }202 base.ActiveTextAreaControl.Caret.Position = base.Document.OffsetToPosition(start + length);203 base.ActiveTextAreaControl.SelectionManager.ClearSelection();204 base.ActiveTextAreaControl.SelectionManager.SetSelection(new DefaultSelection(base.Document, base.Document.OffsetToPosition(start), base.Document.OffsetToPosition(start + length)));205 base.Refresh();206 }207208 public void Find(string search)209 {210 this.Find(search, false);211 }212213 public void Find(string search, bool caseSensitive)214 {215 var found = false;216217 var i = 0;218 var lines = this.Lines;219 foreach (var line in lines)220 {221 if (i > previousSearchLine)222 {223 int start;224 if (previousSearchWord > line.Length)225 {226 start = caseSensitive ?227 line.IndexOf(search) :228 line.ToLower().IndexOf(search.ToLower());229230 previousSearchWord = 0;231 }232 else233 {234 start = caseSensitive ?235 line.IndexOf(search, previousSearchWord) :236 line.ToLower().IndexOf(search.ToLower(), previousSearchWord);237 }238 var end = start + search.Length;239 if (start != -1)240 {241 var p1 = new Point(start, i);242 var p2 = new Point(end, i);243244 //TODO base.ActiveTextAreaControl.SelectionManager.SetSelection(p1, p2);245 base.ActiveTextAreaControl.ScrollTo(i);246 base.Refresh();247248 previousSearchWord = end;249 previousSearchLine = i - 1;250 found = true;251 break;252 }253254 previousSearchWord = 0;255 }256257 i += 1;258 if (i >= lines.Length - 1)259 {260 previousSearchLine = -1;261 }262 }263264 if (!found)265 {266 MessageBox.Show("The following specified text was not found: " + Environment.NewLine + Environment.NewLine + search);267 }268 }269270 public void Replace(string search, string replace, bool caseSensitive)271 {272 if (base.ActiveTextAreaControl.SelectionManager.HasSomethingSelected && base.ActiveTextAreaControl.SelectionManager.SelectedText == search)273 {274 var text = base.ActiveTextAreaControl.SelectionManager.SelectedText;275 base.ActiveTextAreaControl.Caret.Position = base.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].StartPosition;276 base.ActiveTextAreaControl.SelectionManager.ClearSelection();277 base.ActiveTextAreaControl.Document.Replace(base.ActiveTextAreaControl.Caret.Offset, text.Length, replace);278 }279 this.Find(search, caseSensitive);280 }281282 public void ReplaceAll(string search, string replace)283 {284 this.ReplaceAll(search, replace, false);285 }286287 public void ReplaceAll(string search, string replace, bool caseSensitive)288 {289 base.Text = Regex.Replace(base.Text, search, replace, caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);290 base.Refresh();291 }292293 public void ResetLastFound()294 {295 previousSearchLine = -1;296 previousSearchWord = 0;297 }298299 private void Document_DocumentChanged(object sender, DocumentEventArgs e)300 {301 //base.Document.FoldingManager.UpdateFoldings(string.Empty, null);302 bool isVisible = (base.Document.TotalNumberOfLines > this.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount);303 base.ActiveTextAreaControl.VScrollBar.Visible = isVisible; 304305 if (this.Presenter == null) return;306 if (this.Text == Environment.NewLine && string.IsNullOrEmpty(this.presenter.Text)) return;307308 this.Presenter.Text = this.Text;309 }310 }311} ...

Full Screen

Full Screen

Document_DocumentChanged

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using ICSharpCode.AvalonEdit.Document;7using ICSharpCode.AvalonEdit.Rendering;8using ICSharpCode.AvalonEdit.Editing;9using ICSharpCode.AvalonEdit;10using ICSharpCode.AvalonEdit.CodeCompletion;11using System.Windows.Media;12using System.Windows;13using System.Windows.Controls;14using System.Windows.Input;15using System.Windows.Media.Imaging;16using System.Windows.Shapes;17using System.Windows.Threading;18using System.IO;19using System.ComponentModel;20using System.Collections.ObjectModel;21us nImakpCs.rv lhlt thhi"Savg" bu.tsnds ald/dslwheni Sesmnnt nC SfhthpCvdilEr is dppets;22{23o {24 pulc ()25is {Windows.Data;26S IniyializeCsmponent();27t thim..ditor.indows.M.rkup;+=Dcum_DocmChang;28is }Collections;29 using System.Collections.Specialized;30Ih privatpCvoid ode.AvalonEdit.AddIn;(jc sd, EvnAg e)31iS {ode.AvalonEdit.AddIn.Options;32Ih if (thir.pditor.ode.Aval.Isnirdy)33 {34 tIis.SnviBugttnsEald = true;35 }36 {37 his.aveBnIsEnal =fae;38 }39 iS}ode.AvalonEdit.AddIn.Options.Highlighting;40 using ICSharpCode.AvalonEdit.AddIn.Options.Snippets;41 {42 {43 xdrtur thsedtorxt;44 }45 {46 hs.di =vaue;47 }48 iS}ode.AvalonEdit.AddIn.Options.TextEditor.Indentation;49 using ICSharpCode.AvalonEdit.AddIn.Options.TextEditor.Formatting;50 {51 {52 r.dur.is.ososdtorFl;53 }54 }55 pblic vod SavFil()56 {57 his.SaveFie();58 iS}ode.AvalonEdit.AddIn.Options.TextEditor.Search;59 using ICSharpCode.AvalonEdit.AddIn.Options.TextEditor.BracketHighlighting;60 publii vnig SaveFil As()61 {62 IhCdIis.ptistrdSavtFlA();63 }64 pblic vod OpFil()65 {66 his.OpenFie();67 iS}ode.AvalonEdit.AddIn.Options.TextEditor.Folding;68 using ICSharpCode.AvalonEdit.AddIn.Options.TextEditor.GotoDefinition;69 publii vnigIUndS()70 {71 hC lIis.ptisTrr.Cdo();72 }73 puolmc voed Rtdo()74 {75 thiso;dR();76iS }ode.AvalonEdit.AddIn.Options.TextEditor.Caret;77 publi viCu()78 {79 thi.dir.C();80 }81 public viCpy()82 {83 thsdCopy();84 }85 pulc void Past()86 {87 his.e.Pte();88= }89 public void SelectAll()90 {91 this.editor.SelectAll();92 }93 public void Find()94 {95 this.editor.Find();96 }97 public void Replace()98 {99 this.editor.Replace();100te } that the "Save" button is enabled/disabled when the content of the editor is changed101 publim veisaGeTo()102 . {103 iSis.eGirtroTo();104 }105 pulc vod SlcL()106 {107 his.SeletLine();108 }109 publi v i{ SelcWrd()110 {111 thi.dir.SlcWr();112 }113 pulc vod SlcAllLs()114 {115 his.SeletAlLine();116 p} NbiTextEditor()117  {118 p blicnvmiSelcAllWrs()119 {120 thsdtorSlctAllWord();121 }122 pblic vod SlcBlck()123 {124 this.SeletBock();125 }is.editor.Document.DocumentChanged += Document_DocumentChanged;126  }127 publi vi SelcNne()128 {129 thi.dir.SeleNo();130 }131 private void Document_DocumentChanged(object sender, EventArgs e)132 {133 if (this.editor.Document.IsDirty)134 {135 this.SaveButton.IsEnabled = true;136 }137 {138 this.SaveButton.IsEnabled = false;139 }140 }141 {142 {143 return this.editor.Text;144 }145 {146 this.editor.Text = value;147 }148 }149 {150 {151 return this.editor.File;152 }153 }154 public void SaveFile()155 {156 this.editor.SaveFile();157 }158 public void SaveFileAs()159 {160 this.editor.SaveFileAs();161 }162 public void OpenFile()163 {164 this.editor.OpenFile();165 }166 public void Undo()167 {168 this.editor.Undo();169 }170 public void Redo()171 {172 this.editor.Redo();173 }174 public void Cut()175 {176 this.editor.Cut();177 }178 public void Copy()179 {180 this.editor.Copy();181 }182 public void Paste()183 {184 this.editor.Paste();185 }186 public void SelectAll()187 {188 this.editor.SelectAll();189 }190 public void Find()191 {192 this.editor.Find();193 }194 public void Replace()195 {196 this.editor.Replace();197 }198 public void GoTo()199 {200 this.editor.GoTo();201 }202 public void SelectLine()203 {document.T

Full Screen

Full Screen

Document_DocumentChanged

Using AI Code Generation

copy

Full Screen

1protected virtual void OnDocumentChanged (object sender, EventArgs e)2{3 Document doc = (Document)sender;4 string docName = doc.FileName;5 if (doc.IsDirty) {6 UpdateTab (docName, false);7 } else {8 UpdateTab (docName, true);9 }10}11protected void UpdateTab (string docName, bool isSaved)12{13 TabPage page = (TabPage)DocumentTabs.TabPages[docName];14 string tabText = page.Text;15 if (isSaved) {16 if (tabText.Contains ("*")) {17 this.editor.SelectLine();18 }19 public void SelectWord()20 {21 this.editor.SelectWord();22 }23 public void SelectAllLines()24 {25 this.editor.SelectAllLines();26 }27 public void SelectAllWords()28 {29 this.editor.SelectAllWords();30 }31 public void SelectBlock()32 {33 this.editor.SelectBlock();34 }35 public void SelectNone()36 {37 this.editor.SelectNone();38 }

Full Screen

Full Screen

Document_DocumentChanged

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using ICSharpCode.AvalonEdit.Document;7using ICSharpCode.AvalonEdit;8using NBi.UI.Genbi.View.TestSuiteGenerator;9{10 {11 public TextDocument()12 {13 DocumentChanged += Document_DocumentChanged;14 }15 private void Document_DocumentChanged(object sender, EventArgs e)16 {17 var editor = sender as NbiTextEditor;18 editor.Document.Text = editor.Document.Text;19 }20 }21}22using ICSharpCode.AvalonEdit.Document;23{24 {25 public NbiTextEditor()26 {27 Document = new TextDocument();28 }29 }30}31using ICSharpCode.AvalonEdit.Document;32{33 {34 public TestSuiteGeneratorView()35 {36 InitializeComponent();37 var editor = new NbiTextEditor();38 editor.Document.Text = "This is a test";

Full Screen

Full Screen

Document_DocumentChanged

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using ICSharpCode.AvalonEdit.Document;7using ICSharpCode.AvalonEdit.Rendering;8using ICSharpCode.AvalonEdit;9using System.Windows.Media;10using System.Windows;11{12 {13 public NbiTextEditor()14 {15 var document = new TextDocument();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful