本文整理汇总了C#中ICSharpCode.AvalonEdit.Folding.FoldingManager类的典型用法代码示例。如果您正苦于以下问题:C# FoldingManager类的具体用法?C# FoldingManager怎么用?C# FoldingManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FoldingManager类属于ICSharpCode.AvalonEdit.Folding命名空间,在下文中一共展示了FoldingManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallFoldingManager
public void InstallFoldingManager()
{
var textEditorAdapter = textEditor as AvalonEditTextEditorAdapter;
if (textEditorAdapter != null) {
foldingManager = FoldingManager.Install(textEditorAdapter.TextEditor.TextArea);
}
}
示例2: MWindow
public MWindow()
{
try
{
InitializeComponent();
Closing += new CancelEventHandler(MWindow_Closing);
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
dt.Interval = TimeSpan.FromSeconds(1);
dt.Tick += new EventHandler(dt_Tick);
foldingManager = FoldingManager.Install(textEditor.TextArea);
foldingStrategy = new XmlFoldingStrategy();
textEditor.TextChanged += new EventHandler(textEditor_TextChanged);
if (App.StartUpCommand != "" && App.StartUpCommand != null)
{
openFile(App.StartUpCommand);
}
KeyGesture renderKeyGesture = new KeyGesture(Key.F5);
KeyBinding renderCmdKeybinding = new KeyBinding(Commands.Render, renderKeyGesture);
this.InputBindings.Add(renderCmdKeybinding);
status.Text = "Ready!";
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
示例3: XamlPage
public XamlPage()
{
InitializeComponent();
textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML");
TextEditorOptions options = textEditor.Options;
if (options != null)
{
//options.AllowScrollBelowDocument = true;
options.EnableHyperlinks = true;
options.EnableEmailHyperlinks = true;
//options.ShowSpaces = true;
//options.ShowTabs = true;
//options.ShowEndOfLine = true;
}
textEditor.ShowLineNumbers = true;
_foldingManager = FoldingManager.Install(textEditor.TextArea);
_foldingStrategy = new XmlFoldingStrategy();
textEditor.CommandBindings.Add(new CommandBinding(
ApplicationCommands.Print, OnPrint, OnCanExecuteTextEditorCommand));
textEditor.CommandBindings.Add(new CommandBinding(
ApplicationCommands.PrintPreview, OnPrintPreview, OnCanExecuteTextEditorCommand));
_searchHandler = new SearchInputHandler(textEditor.TextArea);
textEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(_searchHandler);
}
示例4: MainForm
public MainForm() {
InitializeComponent();
// 初始化编辑器。
codeEditor = new ICSharpCode.AvalonEdit.TextEditor();
codeEditorHost.Child = codeEditor;
codeEditor.FontFamily = new System.Windows.Media.FontFamily("Consolas");
codeEditor.FontSize = 14;
codeEditor.ShowLineNumbers = true;
codeEditor.SyntaxHighlighting = syntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".js");
codeEditor.WordWrap = true;
foldingManager = FoldingManager.Install(codeEditor.TextArea);
codeEditor.TextChanged += codeEditor_TextChanged;
//codeEditor.TextArea.AddHandler(System.Windows.DataObject.PastingEvent, new System.Windows.DataObjectPastingEventHandler(codeEditor_Paste));
textMarkerService = new TextMarkerService(codeEditor);
TextView textView = codeEditor.TextArea.TextView;
textView.BackgroundRenderers.Add(textMarkerService);
textView.LineTransformers.Add(textMarkerService);
textView.Services.AddService(typeof(TextMarkerService), textMarkerService);
textView.MouseHover += MouseHover;
textView.MouseHoverStopped += codeEditorMouseHoverStopped;
textView.MouseHover += MouseHover;
textView.MouseHoverStopped += codeEditorMouseHoverStopped;
textView.VisualLinesChanged += VisualLinesChanged;
}
示例5: AvalonEditor
/// <summary>
/// Initializes a new instance of the <see cref="AvalonEditor"/> class.
/// </summary>
/// <exception cref="System.InvalidOperationException">Failed to load syntax definition</exception>
public AvalonEditor()
{
_foldingManager = FoldingManager.Install(TextArea);
_folding = new XmlFoldingStrategy();
_htmlIndent = new HtmlIndentationStrategy();
_defaultIndent = new DefaultIndentationStrategy();
AutoIndent = true;
AutoIndentAmount = 1;
ShowLineNumbers = true;
// Load our HTML highlighting
using (var s = typeof(AvalonEditor).Assembly.GetManifestResourceStream(typeof(AvalonEditor), "HtmlHighlighting.xml"))
{
if (s == null)
throw new InvalidOperationException("Failed to load syntax definition");
using (var r = XmlReader.Create(s))
{
var highlightingDefinition = HighlightingLoader.Load(r, HighlightingManager.Instance);
SyntaxHighlighting = highlightingDefinition;
}
}
IsDirty = false;
Task.Factory.StartNew(FoldingUpdateLoop);
}
示例6: FoldingManagerAdapter
public FoldingManagerAdapter(ITextEditor textEditor)
{
AvalonEditTextEditorAdapter adaptor = textEditor as AvalonEditTextEditorAdapter;
if (adaptor != null) {
this.foldingManager = FoldingManager.Install(adaptor.TextEditor.TextArea);
}
}
示例7: Dispose
public void Dispose()
{
if (foldingManager != null) {
FoldingManager.Uninstall(foldingManager);
foldingManager = null;
}
}
示例8: ResetFoldingManager
public void ResetFoldingManager()
{
if (_foldingManager != null)
FoldingManager.Uninstall(_foldingManager);
_foldingManager = FoldingManager.Install(this.editor.TextArea);
UpdateFoldings();
}
示例9: FoldingSection
internal FoldingSection(FoldingManager manager, int startOffset, int endOffset)
{
Debug.Assert(manager != null);
this.manager = manager;
this.StartOffset = startOffset;
this.Length = endOffset - startOffset;
}
示例10: XmlMessageView
public XmlMessageView()
{
InitializeComponent();
foldingManager = FoldingManager.Install(document.TextArea);
foldingStrategy = new XmlFoldingStrategy();
SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
document.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
}
示例11: JsonMessageView
public JsonMessageView()
{
InitializeComponent();
foldingManager = FoldingManager.Install(document.TextArea);
foldingStrategy = new BraceFoldingStrategy();
SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
document.TextArea.IndentationStrategy = new DefaultIndentationStrategy();
}
示例12: DocumentDialog
public DocumentDialog(string value)
{
InitializeComponent();
this.jsonEditor.Text = value;
this.jsonEditor.TextChanged += Te_TextChanged;
foldingManager = FoldingManager.Install(this.jsonEditor.TextArea);
foldingStrategy = new BraceFoldingStrategy();
foldingStrategy.UpdateFoldings(foldingManager, jsonEditor.Document);
}
示例13: APITestDialog
public APITestDialog()
{
InitializeComponent();
foldingManager = FoldingManager.Install(xmlViewer.TextArea);
foldingStrategy = new XmlFoldingStrategy();
LoadAPICalls();
}
示例14: SetFolding
/// <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;
}
}
}
}
示例15: TextEditorControl
public TextEditorControl(string name, int index)
{
InitializeComponent();
FileName = name;
FileIndex = index;
var foldingUpdateTimer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)};
foldingUpdateTimer.Tick += FoldingUpdateTimerTick;
foldingUpdateTimer.Start();
if (File.Exists(@"Highlighter\CustomHighlighting.xshd"))
{
var fileStream = new FileStream(@"Highlighter\CustomHighlighting.xshd", FileMode.Open, FileAccess.Read);
using (var reader = new XmlTextReader(fileStream))
{
textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
fileStream.Close();
}
textEditor.TextArea.IndentationStrategy =
new CSharpIndentationStrategy(textEditor.Options);
_foldingStrategy = new BEFoldingStrategy();
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;
}
}
textEditor.Text = "# Welcome to lpSolver (Linear Programming Solver)!" + Environment.NewLine;
textEditor.Text += "lpmodel ModelName" + FileIndex.ToString() + " \n{" + Environment.NewLine;
textEditor.Text += string.Format("\t# TODO : Objectives {0}{0}", Environment.NewLine + "\t");
textEditor.Text += "min 10*x + 20*y" + Environment.NewLine;
textEditor.Text += "\tsubject to:" + Environment.NewLine;
textEditor.Text += "\tx + y > 10;" + Environment.NewLine;
textEditor.Text += "\t0<x;" + Environment.NewLine;
textEditor.Text += "\t0<y;" + Environment.NewLine;
textEditor.Text += Environment.NewLine + "\t";
textEditor.Text += Environment.NewLine;
textEditor.Text += "};" + Environment.NewLine;
textEditor.Text += "# __EOF" + Environment.NewLine;
textEditor.ShowLineNumbers = true;
FileUrl = string.Empty;
}