/// <summary> /// Initializes a new code editor. /// </summary> public CodeEditorViewModel(AbstractFoldingStrategy foldingStrategy, IHighlightingDefinition highlightingDefinition, IEnumerable <MenuViewModel> snippets, IClipboard clipboard) { _clipboard = clipboard; FoldingStrategy = foldingStrategy; HighlightingDefinition = highlightingDefinition; Snippets = snippets; Options = new EditorOptions(); _contentIndex = Property.New(this, p => p.ContentIndex, OnPropertyChanged); _contentIndex.Value = 0; _selectionStart = Property.New(this, p => p.SelectionStart, OnPropertyChanged); _selectionLength = Property.New(this, p => p.SelectionLength, OnPropertyChanged); _document = Property.New(this, p => p.Document, OnPropertyChanged); _scrollOffset = Property.New(this, p => p.ScrollOffset, OnPropertyChanged); _isModified = Property.New(this, p => IsModified, OnPropertyChanged); UndoCommand = new RelayCommand(() => Document.UndoStack.Undo(), () => Document.UndoStack.CanUndo); RedoCommand = new RelayCommand(() => Document.UndoStack.Redo(), () => Document.UndoStack.CanRedo); CopyCommand = new RelayCommand(Copy); CutCommand = new RelayCommand(Cut); PasteCommand = new RelayCommand(Paste, () => _clipboard.ContainsText); }
internal void InitFolding() { foldingUpdateTimer.Stop(); if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BraceFoldingStrategy(); foldingUpdateTimer.Start(); } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { switch (textEditor.SyntaxHighlighting) { case "XML": foldingStrategy = new XmlFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); foldingStrategy = new BraceFoldingStrategy(); break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; break; } } if (foldingStrategy != null) { if (foldingManager == null) foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
void installFoldingManager() { _foldingStrategy = new XmlFoldingStrategy(); _textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); _foldingStrategy.UpdateFoldings(_foldingManager, _textEditor.Document); }
void InitFolding() { if (txtResult.SyntaxHighlighting == null) { foldingStrategyA = null; } else { foldingStrategyA = new BraceFoldingStrategy(); } if (foldingStrategyA != null) { if (foldingManagerA == null) { foldingManagerA = FoldingManager.Install(txtResult.TextArea); } foldingStrategyA.UpdateFoldings(foldingManagerA, textEditorA.Document); } else { if (foldingManagerA != null) { FoldingManager.Uninstall(foldingManagerA); foldingManagerA = null; } } }
void initFolding() { foldingStrategy = new BraceFoldingStrategy(); if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); }
/// <summary> /// Update the folding in the text editor when requested per call on this method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void foldingUpdateTimer_Tick(object sender, EventArgs e) { if (this.IsVisible == true) { if (mInstallFoldingManager == true) { if (this.Document != null) { if (mFoldingManager == null) { this.mFoldingManager = FoldingManager.Install(this.TextArea); mInstallFoldingManager = false; } } else { return; } } if (mFoldingStrategy != null) { if (this.mFoldingStrategy is AbstractFoldingStrategy) { AbstractFoldingStrategy abstractFolder = this.mFoldingStrategy as AbstractFoldingStrategy; abstractFolder.UpdateFoldings(mFoldingManager, this.Document); } } } }
public Xsd2XmlGenerator(string currentFileName) { InitializeComponent(); _currentFileName = currentFileName; try { SchemaParser schema = new SchemaParser(currentFileName, false); IEnumerable <IXsdNode> nodes = schema.GetVirtualRoot().GetChildren(); foreach (IXsdNode xsdNode in nodes) { XsdElement ele = xsdNode as XsdElement; if (ele != null) { cboRoot.Items.Add(ele.Name); } } } catch { //do nothing } _foldingManager = FoldingManager.Install(edtResult.TextArea); _foldingStrategy = new XmlFoldingStrategy(); }
public CustomLexter(TextEditor textEditor, AbstractFoldingStrategy foldingStrategy, IIndentationStrategy indentationStrategy, CodeCompletionList codeCompletionList) : base(textEditor) { FoldingStrategy = foldingStrategy; IndentationStrategy = indentationStrategy; CodeCompletionList = codeCompletionList; }
public MainWindow() { IHighlightingDefinition coolHighlighting; using (System.IO.Stream s = typeof(MainWindow).Assembly.GetManifestResourceStream("CoolCompiler.CoolHighlighting.xshd")) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { coolHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } HighlightingManager.Instance.RegisterHighlighting("Cool Highlighting", new string[] { ".cool" }, coolHighlighting); InitializeComponent(); foldingStrategy = new CoolFoldingStrategy(); foldingManager = FoldingManager.Install(tbEditor.TextArea); tbEditor.ShowLineNumbers = true; tbEditor.TextArea.TextEntering += tbEditor_TextArea_TextEntering; tbEditor.TextArea.TextEntered += tbEditor_TextArea_TextEntered; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); if (Settings.Default.WindowLeft != 0) { Left = Settings.Default.WindowLeft; } if (Settings.Default.WindowTop != 0) { Top = Settings.Default.WindowTop; } if (Settings.Default.WindowWidth != 0) { Width = Settings.Default.WindowWidth; } if (Settings.Default.WindowTop != 0) { Height = Settings.Default.WindowHeight; } if (!string.IsNullOrEmpty(Settings.Default.FileName)) { LoadFile(Settings.Default.FileName); } Log = new StringBuilder(); CoolTokens.Load("../../output/CoolGrammar.tokens"); }
private void InstallFoldingStrategy() { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); AddFoldingStrategyTimer(); }
public void SetFolding(IHighlightingDefinition SyntaxHighlighting) { if (SyntaxHighlighting == null) { foldingStrategy = null; } else { switch (SyntaxHighlighting.Name) { case "XML": foldingStrategy = new XmlFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); foldingStrategy = new BraceFoldingStrategy(); break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; break; } } if (foldingStrategy != null) { if (textEditor.Document != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { _InstallFoldingManager = true; } } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
public Editor() { InitializeComponent(); editor.TextArea.Caret.PositionChanged += Caret_PositionChanged; editor.Document.UndoStack.PropertyChanged += UndoStack_PropertyChanged; foldingManager = FoldingManager.Install(editor.TextArea); foldingStrategy = new AsmFoldingStrategy(); documentService = ServiceFactory.Instance.GetServiceInstance <DocumentService>(); dockingService = ServiceFactory.Instance.GetServiceInstance <DockingService>(); }
static public void GetStrategyFromName2(this TextEditor editor, IEditorContext control) { FoldingManager.Uninstall(control.FoldingManager); AbstractFoldingStrategy NewFoldingStrategy = null; IIndentationStrategy NewIndentationStrategy = null; if (editor.SyntaxHighlighting == null) { } //control.FoldingStrategy = null; else { switch (editor.SyntaxHighlighting.Name) { case "XML": NewFoldingStrategy = new XmlFoldingStrategy(); NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": NewFoldingStrategy = new CSharpPragmaRegionFoldingStrategy(); NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(); break; default: NewFoldingStrategy = new CSharpPragmaRegionFoldingStrategy(); NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; } } //control.FoldingStrategy is not assigned //control.FoldingStrategy,editor.TextArea.IndentationStrategy if (NewFoldingStrategy != null) { control.FoldingStrategy = NewFoldingStrategy; if (control.FoldingManager == null) { control.FoldingManager = FoldingManager.Install(editor.TextArea); } control.FoldingStrategy.UpdateFoldings(control.FoldingManager, editor.Document); } else { if (control.FoldingManager != null) { FoldingManager.Uninstall(control.FoldingManager); control.FoldingManager = null; } } }
private void Fold() { if (this.txtEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BeginEndFoldingStrategy(); txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); if (false) { switch (txtEditor.SyntaxHighlighting.Name) { case "XML": foldingStrategy = new XmlFoldingStrategy(); txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(txtEditor.Options); foldingStrategy = new BraceFoldingStrategy(); break; default: txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; break; } } } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(txtEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, txtEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
/// <summary> /// 初始化构造函数 /// </summary> /// <param name="name">函数块名称</param> public FuncBlockViewModel(string name, ProjectModel _pmodel) { InitializeComponent(); parent = _pmodel; ProgramName = name; model = new FuncBlockModel(String.Empty); IHighlightingDefinition customHighlighting; Assembly assembly = Assembly.GetExecutingAssembly(); Console.WriteLine(assembly.GetManifestResourceNames()); using (Stream s = assembly.GetManifestResourceStream("SamSoarII.AppMain.Project.CustomHighlighting.xshd")) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance); } } HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting); CodeTextBox.TextArea.TextEntering += textEditor_TextArea_TextEntering; CodeTextBox.TextArea.TextEntered += textEditer_TextArea_TextEntered; CodeTextBox.TextArea.CodeCompleteKeyDown += textEditer_TextArea_CodeCompleteKeyDown; CodeTextBox.TextArea.CodeCompleteKeyUp += textEditer_TextArea_CodeCompleteKeyUp; CodeTextBox.CaretChanged += textEditer_CaretChanged; CodeTextBox.DocumentChanged_Detail += textEditer_DocumentChanged; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(0.5); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); foldingManager = FoldingManager.Install(CodeTextBox.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, CodeTextBox.Document); CodeTextBox.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(CodeTextBox.Options); //completionWindow = new CompletionWindow(CodeTextBox.TextArea); completionWindow = null; CCSProfix = String.Empty; ccstblocks = new TextBlock[9]; for (int i = 0; i < 9; i++) { ccstblocks[i] = new TextBlock(); ccstblocks[i].FontFamily = new FontFamily("Consolas"); ccstblocks[i].FontSize = 16; Grid.SetRow(ccstblocks[i], i + 1); Grid.SetColumn(ccstblocks[i], 0); CodeCompletePanel.Children.Add(ccstblocks[i]); } CodeTextBox.TextArea.Caret.VisibleChanged += Caret_VisibleChanged; }
void HighlightingComboBox_SelectionChanged() { if (Editor.SyntaxHighlighting == null) { _folding_strategy = null; } else { switch (Editor.SyntaxHighlighting.Name) { case "XML": _folding_strategy = new ICSharpCode.AvalonEdit.Folding.XmlFoldingStrategy(); Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "ACS": case "C++": case "PHP": case "Java": Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(Editor.Options); _folding_strategy = new BraceFoldingStrategy(); break; default: Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); _folding_strategy = null; break; } } if (_folding_strategy != null) { if (folding_manager == null) { folding_manager = FoldingManager.Install(Editor.TextArea); } _folding_strategy.UpdateFoldings(folding_manager, Editor.Document); } else { if (folding_manager != null) { FoldingManager.Uninstall(folding_manager); folding_manager = null; } } }
void HighlightingComboBox() { if (textEditor.SyntaxHighlighting == null) { _foldingStrategy = null; } else { switch (textEditor.SyntaxHighlighting.Name) { case "XML": _foldingStrategy = new XmlFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); _foldingStrategy = new BraceFoldingStrategy(); break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); _foldingStrategy = null; break; } } if (_foldingStrategy != null) { if (_foldingManager == null) { _foldingManager = new FoldingManager(textEditor.Document); _foldingManager = FoldingManager.Install(textEditor.TextArea); } _foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document); } else { if (_foldingManager != null) { FoldingManager.Uninstall(_foldingManager); _foldingManager = null; } } }
private void SetupFolding() { textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); foldingStrategy = new BraceFoldingStrategy(); textfoldingManager = FoldingManager.Install(textEditor.TextArea); outputfoldingManager = FoldingManager.Install(output.TextArea); var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += FoldingUpdateTimerTick; foldingUpdateTimer.Start(); }
/// <summary> /// Обработчик меняет стратегию разбиения текста на части. Подсветка синтаксиса меняется автоматом. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void HighlightingComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { // SyntaxHighlighting - это свойство, определяющее текущее правило подсветки синтаксиса if (textEditor.SyntaxHighlighting == null) { _foldingStrategy = null; } else { switch (textEditor.SyntaxHighlighting.Name) { case "XML": _foldingStrategy = new XmlFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); _foldingStrategy = null; break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); _foldingStrategy = null; break; } } if (_foldingStrategy != null) { if (_foldingManager == null) { _foldingManager = FoldingManager.Install(textEditor.TextArea); } _foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document); } else { if (_foldingManager != null) { FoldingManager.Uninstall(_foldingManager); _foldingManager = null; } } }
private void SetUpTextEditor() { _editor = new TextEditor { SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"), ShowLineNumbers = true, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto }; _editor.SetValue(AutomationProperties.AutomationIdProperty, "UI_XMLEditor_AutoID"); _foldingStrategy = new XmlFoldingStrategy(); _foldingManager = FoldingManager.Install(_editor.TextArea); _editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); _foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; _foldingUpdateTimer.Tick += OnFoldingUpdateTimerOnTick; _foldingUpdateTimer.Start(); }
/// <summary> /// /// </summary> void SetFoldingStrategy() { if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { // switch (textEditor.SyntaxHighlighting.Name) // { // case "XML": // foldingStrategy = new XmlFoldingStrategy(); // textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); // break; // case "C#": // case "C++": // case "PHP": // case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); foldingStrategy = new BraceFoldingStrategy(); // break; // default: // textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); // foldingStrategy = null; // break; // } } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
public Details() { InitializeComponent(); this.Reset(); this.treeviewTargets.ItemsSource = this.TargetsToBuild; DispatcherTimer foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += this.foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); this.foldingStrategy = new XmlFoldingStrategy(); this.textBoxXml.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); this.foldingManager = FoldingManager.Install(this.textBoxXml.TextArea); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.textBoxXml.Document); }
private void SetObject() { if (this.GridValue != null) { string text = (string)this.GridValue.Value; if (text != null && text.Trim().StartsWith("<")) { this.Editor.Text = Serializer.FormatXml(text); this.Editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); this.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); this.foldingStrategy = new XmlFoldingStrategy(); } else { this.Editor.Text = text; this.Editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("TXT"); this.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(this.Editor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, this.Editor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } } }
protected internal void InitializeFolding(AbstractFoldingStrategy foldingStrategy) { if (_foldingManager != null) { FoldingManager.Uninstall(_foldingManager); } var foldingManager = FoldingManager.Install(Editor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += (o, args) => foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); foldingUpdateTimer.Start(); _foldingManager = foldingManager; }
public SqlInput() { InitializeComponent(); textEditor.Options.ShowTabs = true; textEditor.Options.ShowSpaces = true; textEditor.Options.ConvertTabsToSpaces = true; textEditor.Options.HighlightCurrentLine = true; textEditor.ShowLineNumbers = true; foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering; textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); }
public BuildPad() { this.InitializeComponent(); this.TextBoxPreExecute.Text = Settings.Default.DefaultBootStrapper; this.TextBoxParameters.Text = Settings.Default.DefaultParameters; DispatcherTimer foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += this.foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); this.foldingStrategy = new XmlFoldingStrategy(); this.textBoxXml.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); this.foldingManager = FoldingManager.Install(this.textBoxXml.TextArea); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.textBoxXml.Document); if (string.IsNullOrWhiteSpace(this.textBoxXml.Text)) { this.textBoxXml.Text = Settings.Default.DefaultBuildPad; } }
public GeneratedCodeView() { // Load our custom highlighting definition IHighlightingDefinition customHighlighting; using (Stream s = typeof(GeneratedCodeView).Assembly.GetManifestResourceStream("CinchCodeGen.UserControls.CustomHighlighting.xshd")) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } // and register it in the HighlightingManager HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting); InitializeComponent(); txtCode.SyntaxHighlighting = customHighlighting; if (txtCode.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BraceFoldingStrategy(); } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(txtCode.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, txtCode.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); this.DataContextChanged += GeneratedCodeView_DataContextChanged; }
public FragmentView() { InitializeComponent(); _foldingStrategy = new XmlFoldingStrategy(); _foldingManager = FoldingManager.Install(_edtFragment.TextArea); }
/// <summary> /// Determine whether or not highlighting can be /// suppported by a particular folding strategy. /// </summary> /// <param name="syntaxHighlighting"></param> public void SetFolding(IHighlightingDefinition syntaxHighlighting) { if (syntaxHighlighting == null) { this.mFoldingStrategy = null; } else { switch (syntaxHighlighting.Name) { case "XML": case "HTML": mFoldingStrategy = new XmlFoldingStrategy() { ShowAttributesWhenFolded = true }; this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new CSharpBraceFoldingStrategy(); break; case "C++": case "PHP": case "Java": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new CSharpBraceFoldingStrategy(); break; case "VBNET": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new VBNetFoldingStrategy(); break; default: this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); mFoldingStrategy = null; break; } if (mFoldingStrategy != null) { if (this.Document != null) { if (mFoldingManager == null) { mFoldingManager = FoldingManager.Install(this.TextArea); } this.mFoldingStrategy.UpdateFoldings(mFoldingManager, this.Document); } else { this.mInstallFoldingManager = true; } } else { if (mFoldingManager != null) { FoldingManager.Uninstall(mFoldingManager); mFoldingManager = null; } } } }