first commit

This commit is contained in:
2026-01-07 11:33:05 +08:00
commit fc54ffd43b
215 changed files with 31856 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
namespace ICSharpCode.TextEditor.UserControls
{
partial class ContextMenuStripEx
{
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
//DisposeEventsHandlers();
base.Dispose(disposing);
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Utils;
namespace ICSharpCode.TextEditor.UserControls
{
public partial class ContextMenuStripEx : ContextMenuStrip
{
public ToolStripMenuItem AddToolStripMenuItem(string text, Bitmap bitmap, EventHandler<EventArgs> clickEvent, Keys keys, Func<bool> enabled)
{
var menuItem = new ToolStripMenuItem(text);
if (bitmap != null)
{
menuItem.Image = bitmap;
}
if (keys != Keys.None)
{
menuItem.ShortcutKeys = keys;
}
if (clickEvent != null)
{
menuItem.Click += new WeakEventHandler<EventArgs>(clickEvent).Handler;
}
Items.Add(menuItem);
EventHandler<EventArgs> toolstripOpening = (sender, args) =>
{
menuItem.Enabled = enabled();
};
Opening += new WeakEventHandler<EventArgs>(toolstripOpening).Handler;
return menuItem;
}
public ToolStripSeparator AddToolStripSeparator()
{
var strip = new ToolStripSeparator();
Items.Add(strip);
return strip;
}
}
}

View File

@@ -0,0 +1,556 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.TextEditor.UserControls
{
public partial class FindAndReplaceForm : Form
{
public FindAndReplaceForm()
{
InitializeComponent();
_search = new TextEditorSearcher();
}
readonly TextEditorSearcher _search;
TextEditorControl _editor;
TextEditorControl Editor
{
set
{
_editor = value;
_search.Document = _editor.Document;
UpdateTitleBar();
}
}
private void UpdateTitleBar()
{
string text = ReplaceMode ? "Find & replace" : "Find";
if (_editor != null && _editor.FileName != null)
text += " - " + Path.GetFileName(_editor.FileName);
if (_search.HasScanRegion)
text += " (selection only)";
Text = text;
}
public void ShowFor(TextEditorControl editor, bool replaceMode)
{
Editor = editor;
_search.ClearScanRegion();
var sm = editor.ActiveTextAreaControl.SelectionManager;
if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1)
{
var sel = sm.SelectionCollection[0];
if (sel.StartPosition.Line == sel.EndPosition.Line)
txtLookFor.Text = sm.SelectedText;
else
_search.SetScanRegion(sel);
}
else
{
// Get the current word that the caret is on
Caret caret = editor.ActiveTextAreaControl.Caret;
int start = TextUtilities.FindWordStart(editor.Document, caret.Offset);
int endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);
txtLookFor.Text = editor.Document.GetText(start, endAt - start);
}
ReplaceMode = replaceMode;
Owner = (Form)editor.TopLevelControl;
Show();
txtLookFor.SelectAll();
txtLookFor.Focus();
}
public bool ReplaceMode
{
get { return txtReplaceWith.Visible; }
set
{
btnReplace.Visible = btnReplaceAll.Visible = value;
lblReplaceWith.Visible = txtReplaceWith.Visible = value;
btnHighlightAll.Visible = !value;
AcceptButton = value ? btnReplace : btnFindNext;
UpdateTitleBar();
}
}
private void btnFindPrevious_Click(object sender, EventArgs e)
{
FindNext(false, true, "Text not found");
}
private void btnFindNext_Click(object sender, EventArgs e)
{
FindNext(false, false, "Text not found");
}
public bool LastSearchWasBackward = false;
public bool LastSearchLoopedAround;
public TextRange FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)
{
if (string.IsNullOrEmpty(txtLookFor.Text))
{
MessageBox.Show("No string specified to look for!");
return null;
}
LastSearchWasBackward = searchBackward;
_search.LookFor = txtLookFor.Text;
_search.MatchCase = chkMatchCase.Checked;
_search.MatchWholeWordOnly = chkMatchWholeWord.Checked;
var caret = _editor.ActiveTextAreaControl.Caret;
if (viaF3 && _search.HasScanRegion && !caret.Offset.
IsInRange(_search.BeginOffset, _search.EndOffset))
{
// user moved outside of the originally selected region
_search.ClearScanRegion();
UpdateTitleBar();
}
int startFrom = caret.Offset - (searchBackward ? 1 : 0);
TextRange range = _search.FindNext(startFrom, searchBackward, out LastSearchLoopedAround);
if (range != null)
SelectResult(range);
else if (messageIfNotFound != null)
MessageBox.Show(messageIfNotFound);
return range;
}
private void SelectResult(TextRange range)
{
TextLocation p1 = _editor.Document.OffsetToPosition(range.Offset);
TextLocation p2 = _editor.Document.OffsetToPosition(range.Offset + range.Length);
_editor.ActiveTextAreaControl.SelectionManager.SetSelection(p1, p2);
_editor.ActiveTextAreaControl.ScrollTo(p1.Line, p1.Column);
// Also move the caret to the end of the selection, because when the user
// presses F3, the caret is where we start searching next time.
_editor.ActiveTextAreaControl.Caret.Position =
_editor.Document.OffsetToPosition(range.Offset + range.Length);
}
readonly Dictionary<TextEditorControl, HighlightGroup> _highlightGroups = new Dictionary<TextEditorControl, HighlightGroup>();
private void btnHighlightAll_Click(object sender, EventArgs e)
{
if (!_highlightGroups.ContainsKey(_editor))
_highlightGroups[_editor] = new HighlightGroup(_editor);
HighlightGroup group = _highlightGroups[_editor];
if (string.IsNullOrEmpty(LookFor))
// Clear highlights
group.ClearMarkers();
else
{
_search.LookFor = txtLookFor.Text;
_search.MatchCase = chkMatchCase.Checked;
_search.MatchWholeWordOnly = chkMatchWholeWord.Checked;
int offset = 0, count = 0;
for (; ; )
{
bool looped;
TextRange range = _search.FindNext(offset, false, out looped);
if (range == null || looped)
break;
offset = range.Offset + range.Length;
count++;
var m = new TextMarker(range.Offset, range.Length,
TextMarkerType.SolidBlock, Color.Yellow, Color.Black);
group.AddMarker(m);
}
if (count == 0)
MessageBox.Show("Search text not found.");
else
Close();
}
}
private void FindAndReplaceForm_FormClosing(object sender, FormClosingEventArgs e)
{ // Prevent dispose, as this form can be re-used
if (e.CloseReason != CloseReason.FormOwnerClosing)
{
if (Owner != null)
Owner.Select(); // prevent another app from being activated instead
e.Cancel = true;
Hide();
// Discard search region
_search.ClearScanRegion();
_editor.Refresh(); // must repaint manually
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
private void btnReplace_Click(object sender, EventArgs e)
{
var sm = _editor.ActiveTextAreaControl.SelectionManager;
if (string.Equals(sm.SelectedText, txtLookFor.Text, StringComparison.OrdinalIgnoreCase))
InsertText(txtReplaceWith.Text);
FindNext(false, LastSearchWasBackward, "Text not found.");
}
private void btnReplaceAll_Click(object sender, EventArgs e)
{
int count = 0;
// BUG FIX: if the replacement string contains the original search string
// (e.g. replace "red" with "very red") we must avoid looping around and
// replacing forever! To fix, start replacing at beginning of region (by
// moving the caret) and stop as soon as we loop around.
_editor.ActiveTextAreaControl.Caret.Position =
_editor.Document.OffsetToPosition(_search.BeginOffset);
_editor.Document.UndoStack.StartUndoGroup();
try
{
while (FindNext(false, false, null) != null)
{
if (LastSearchLoopedAround)
break;
// Replace
count++;
InsertText(txtReplaceWith.Text);
}
}
finally
{
_editor.Document.UndoStack.EndUndoGroup();
}
if (count == 0)
MessageBox.Show("No occurrances found.");
else
{
MessageBox.Show(string.Format("Replaced {0} occurrances.", count));
Close();
}
}
private void InsertText(string text)
{
var textArea = _editor.ActiveTextAreaControl.TextArea;
textArea.Document.UndoStack.StartUndoGroup();
try
{
if (textArea.SelectionManager.HasSomethingSelected)
{
textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
textArea.SelectionManager.RemoveSelectedText();
}
textArea.InsertString(text);
}
finally
{
textArea.Document.UndoStack.EndUndoGroup();
}
}
public string LookFor { get { return txtLookFor.Text; } }
}
public class TextRange : AbstractSegment
{
public TextRange(int offset, int length)
{
this.offset = offset;
this.length = length;
}
}
/// <summary>This class finds occurrances of a search string in a text
/// editor's IDocument... it's like Find box without a GUI.</summary>
public class TextEditorSearcher : IDisposable
{
IDocument _document;
public IDocument Document
{
get { return _document; }
set
{
if (_document != value)
{
ClearScanRegion();
_document = value;
}
}
}
// I would have used the TextAnchor class to represent the beginning and
// end of the region to scan while automatically adjusting to changes in
// the document--but for some reason it is sealed and its constructor is
// internal. Instead I use a TextMarker, which is perhaps even better as
// it gives me the opportunity to highlight the region. Note that all the
// markers and coloring information is associated with the text document,
// not the editor control, so TextEditorSearcher doesn't need a reference
// to the TextEditorControl. After adding the marker to the document, we
// must remember to remove it when it is no longer needed.
TextMarker _region;
/// <summary>Sets the region to search. The region is updated
/// automatically as the document changes.</summary>
public void SetScanRegion(ISelection sel)
{
SetScanRegion(sel.Offset, sel.Length);
}
/// <summary>Sets the region to search. The region is updated
/// automatically as the document changes.</summary>
public void SetScanRegion(int offset, int length)
{
var bkgColor = _document.HighlightingStrategy.GetColorFor("Default").BackgroundColor;
_region = new TextMarker(offset, length, TextMarkerType.SolidBlock,
bkgColor.HalfMix(Color.FromArgb(160, 160, 160)));
_document.MarkerStrategy.AddMarker(_region);
}
public bool HasScanRegion
{
get { return _region != null; }
}
public void ClearScanRegion()
{
if (_region != null)
{
_document.MarkerStrategy.RemoveMarker(_region);
_region = null;
}
}
public void Dispose()
{
ClearScanRegion();
GC.SuppressFinalize(this);
}
~TextEditorSearcher()
{
Dispose();
}
/// <summary>Begins the start offset for searching</summary>
public int BeginOffset
{
get
{
if (_region != null)
return _region.Offset;
return 0;
}
}
/// <summary>Begins the end offset for searching</summary>
public int EndOffset
{
get
{
if (_region != null)
return _region.EndOffset;
return _document.TextLength;
}
}
public bool MatchCase;
public bool MatchWholeWordOnly;
string _lookFor;
string _lookFor2; // uppercase in case-insensitive mode
public string LookFor
{
get { return _lookFor; }
set { _lookFor = value; }
}
/// <summary>Finds next instance of LookFor, according to the search rules
/// (MatchCase, MatchWholeWordOnly).</summary>
/// <param name="beginAtOffset">Offset in Document at which to begin the search</param>
/// <param name="searchBackward"></param>
/// <param name="loopedAround"></param>
/// <remarks>If there is a match at beginAtOffset precisely, it will be returned.</remarks>
/// <returns>Region of document that matches the search string</returns>
public TextRange FindNext(int beginAtOffset, bool searchBackward, out bool loopedAround)
{
Debug.Assert(!string.IsNullOrEmpty(_lookFor));
loopedAround = false;
int startAt = BeginOffset, endAt = EndOffset;
int curOffs = beginAtOffset.InRange(startAt, endAt);
_lookFor2 = MatchCase ? _lookFor : _lookFor.ToUpperInvariant();
TextRange result;
if (searchBackward)
{
result = FindNextIn(startAt, curOffs, true);
if (result == null)
{
loopedAround = true;
result = FindNextIn(curOffs, endAt, true);
}
}
else
{
result = FindNextIn(curOffs, endAt, false);
if (result == null)
{
loopedAround = true;
result = FindNextIn(startAt, curOffs, false);
}
}
return result;
}
private TextRange FindNextIn(int offset1, int offset2, bool searchBackward)
{
Debug.Assert(offset2 >= offset1);
offset2 -= _lookFor.Length;
// Make behavior decisions before starting search loop
Func<char, char, bool> matchFirstCh;
Func<int, bool> matchWord;
if (MatchCase)
matchFirstCh = (lookFor, c) => (lookFor == c);
else
matchFirstCh = (lookFor, c) => (lookFor == char.ToUpperInvariant(c));
if (MatchWholeWordOnly)
matchWord = IsWholeWordMatch;
else
matchWord = IsPartWordMatch;
// Search
char lookForCh = _lookFor2[0];
if (searchBackward)
{
for (int offset = offset2; offset >= offset1; offset--)
{
if (matchFirstCh(lookForCh, _document.GetCharAt(offset))
&& matchWord(offset))
return new TextRange(offset, _lookFor.Length);
}
}
else
{
for (int offset = offset1; offset <= offset2; offset++)
{
if (matchFirstCh(lookForCh, _document.GetCharAt(offset))
&& matchWord(offset))
return new TextRange(offset, _lookFor.Length);
}
}
return null;
}
private bool IsWholeWordMatch(int offset)
{
if (IsWordBoundary(offset) && IsWordBoundary(offset + _lookFor.Length))
return IsPartWordMatch(offset);
return false;
}
private bool IsWordBoundary(int offset)
{
return offset <= 0 || offset >= _document.TextLength ||
!IsAlphaNumeric(offset - 1) || !IsAlphaNumeric(offset);
}
private bool IsAlphaNumeric(int offset)
{
char c = _document.GetCharAt(offset);
return char.IsLetterOrDigit(c) || c == '_';
}
private bool IsPartWordMatch(int offset)
{
string substr = _document.GetText(offset, _lookFor.Length);
if (!MatchCase)
substr = substr.ToUpperInvariant();
return substr == _lookFor2;
}
}
/// <summary>Bundles a group of markers together so that they can be cleared together.</summary>
public class HighlightGroup : IDisposable
{
readonly List<TextMarker> _markers = new List<TextMarker>();
readonly TextEditorControl _editor;
readonly IDocument _document;
public HighlightGroup(TextEditorControl editor)
{
_editor = editor;
_document = editor.Document;
}
public void AddMarker(TextMarker marker)
{
_markers.Add(marker);
_document.MarkerStrategy.AddMarker(marker);
}
public void ClearMarkers()
{
foreach (TextMarker m in _markers)
_document.MarkerStrategy.RemoveMarker(m);
_markers.Clear();
_editor.Refresh();
}
public void Dispose()
{
ClearMarkers();
GC.SuppressFinalize(this);
}
~HighlightGroup()
{
Dispose();
}
public IList<TextMarker> Markers
{
get
{
return _markers.AsReadOnly();
}
}
}
public static class Extensions
{
public static int InRange(this int x, int lo, int hi)
{
Debug.Assert(lo <= hi);
return x < lo ? lo : (x > hi ? hi : x);
}
public static bool IsInRange(this int x, int lo, int hi)
{
return x >= lo && x <= hi;
}
public static Color HalfMix(this Color one, Color two)
{
return Color.FromArgb(
(one.A + two.A) >> 1,
(one.R + two.R) >> 1,
(one.G + two.G) >> 1,
(one.B + two.B) >> 1);
}
}
}

View File

@@ -0,0 +1,216 @@
namespace ICSharpCode.TextEditor.UserControls
{
partial class FindAndReplaceForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FindAndReplaceForm));
this.label1 = new System.Windows.Forms.Label();
this.lblReplaceWith = new System.Windows.Forms.Label();
this.txtLookFor = new System.Windows.Forms.TextBox();
this.txtReplaceWith = new System.Windows.Forms.TextBox();
this.btnFindNext = new System.Windows.Forms.Button();
this.btnReplace = new System.Windows.Forms.Button();
this.btnReplaceAll = new System.Windows.Forms.Button();
this.chkMatchWholeWord = new System.Windows.Forms.CheckBox();
this.chkMatchCase = new System.Windows.Forms.CheckBox();
this.btnHighlightAll = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnFindPrevious = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Fi&nd what:";
//
// lblReplaceWith
//
this.lblReplaceWith.AutoSize = true;
this.lblReplaceWith.Location = new System.Drawing.Point(12, 35);
this.lblReplaceWith.Name = "lblReplaceWith";
this.lblReplaceWith.Size = new System.Drawing.Size(72, 13);
this.lblReplaceWith.TabIndex = 2;
this.lblReplaceWith.Text = "Re&place with:";
//
// txtLookFor
//
this.txtLookFor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtLookFor.Location = new System.Drawing.Point(90, 6);
this.txtLookFor.Name = "txtLookFor";
this.txtLookFor.Size = new System.Drawing.Size(232, 20);
this.txtLookFor.TabIndex = 1;
//
// txtReplaceWith
//
this.txtReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtReplaceWith.Location = new System.Drawing.Point(90, 32);
this.txtReplaceWith.Name = "txtReplaceWith";
this.txtReplaceWith.Size = new System.Drawing.Size(232, 20);
this.txtReplaceWith.TabIndex = 3;
//
// btnFindNext
//
this.btnFindNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnFindNext.Location = new System.Drawing.Point(247, 81);
this.btnFindNext.Name = "btnFindNext";
this.btnFindNext.Size = new System.Drawing.Size(75, 23);
this.btnFindNext.TabIndex = 6;
this.btnFindNext.Text = "&Find next";
this.btnFindNext.UseVisualStyleBackColor = true;
this.btnFindNext.Click += new System.EventHandler(this.btnFindNext_Click);
//
// btnReplace
//
this.btnReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnReplace.Location = new System.Drawing.Point(85, 110);
this.btnReplace.Name = "btnReplace";
this.btnReplace.Size = new System.Drawing.Size(75, 23);
this.btnReplace.TabIndex = 7;
this.btnReplace.Text = "&Replace";
this.btnReplace.UseVisualStyleBackColor = true;
this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click);
//
// btnReplaceAll
//
this.btnReplaceAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnReplaceAll.Location = new System.Drawing.Point(166, 110);
this.btnReplaceAll.Name = "btnReplaceAll";
this.btnReplaceAll.Size = new System.Drawing.Size(75, 23);
this.btnReplaceAll.TabIndex = 9;
this.btnReplaceAll.Text = "Replace &All";
this.btnReplaceAll.UseVisualStyleBackColor = true;
this.btnReplaceAll.Click += new System.EventHandler(this.btnReplaceAll_Click);
//
// chkMatchWholeWord
//
this.chkMatchWholeWord.AutoSize = true;
this.chkMatchWholeWord.Location = new System.Drawing.Point(178, 58);
this.chkMatchWholeWord.Name = "chkMatchWholeWord";
this.chkMatchWholeWord.Size = new System.Drawing.Size(113, 17);
this.chkMatchWholeWord.TabIndex = 5;
this.chkMatchWholeWord.Text = "Match &whole word";
this.chkMatchWholeWord.UseVisualStyleBackColor = true;
//
// chkMatchCase
//
this.chkMatchCase.AutoSize = true;
this.chkMatchCase.Location = new System.Drawing.Point(90, 58);
this.chkMatchCase.Name = "chkMatchCase";
this.chkMatchCase.Size = new System.Drawing.Size(82, 17);
this.chkMatchCase.TabIndex = 4;
this.chkMatchCase.Text = "Match &case";
this.chkMatchCase.UseVisualStyleBackColor = true;
//
// btnHighlightAll
//
this.btnHighlightAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnHighlightAll.Location = new System.Drawing.Point(105, 110);
this.btnHighlightAll.Name = "btnHighlightAll";
this.btnHighlightAll.Size = new System.Drawing.Size(136, 23);
this.btnHighlightAll.TabIndex = 8;
this.btnHighlightAll.Text = "Find && highlight &all";
this.btnHighlightAll.UseVisualStyleBackColor = true;
this.btnHighlightAll.Visible = false;
this.btnHighlightAll.Click += new System.EventHandler(this.btnHighlightAll_Click);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(247, 110);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnFindPrevious
//
this.btnFindPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnFindPrevious.Location = new System.Drawing.Point(157, 81);
this.btnFindPrevious.Name = "btnFindPrevious";
this.btnFindPrevious.Size = new System.Drawing.Size(84, 23);
this.btnFindPrevious.TabIndex = 6;
this.btnFindPrevious.Text = "Find pre&vious";
this.btnFindPrevious.UseVisualStyleBackColor = true;
this.btnFindPrevious.Click += new System.EventHandler(this.btnFindPrevious_Click);
//
// FindAndReplaceForm
//
this.AcceptButton = this.btnReplace;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(334, 145);
this.Controls.Add(this.chkMatchCase);
this.Controls.Add(this.chkMatchWholeWord);
this.Controls.Add(this.btnReplaceAll);
this.Controls.Add(this.btnReplace);
this.Controls.Add(this.btnHighlightAll);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnFindPrevious);
this.Controls.Add(this.btnFindNext);
this.Controls.Add(this.txtReplaceWith);
this.Controls.Add(this.txtLookFor);
this.Controls.Add(this.lblReplaceWith);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FindAndReplaceForm";
this.Text = "Find and replace";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FindAndReplaceForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblReplaceWith;
private System.Windows.Forms.TextBox txtLookFor;
private System.Windows.Forms.TextBox txtReplaceWith;
private System.Windows.Forms.Button btnFindNext;
private System.Windows.Forms.Button btnReplace;
private System.Windows.Forms.Button btnReplaceAll;
private System.Windows.Forms.CheckBox chkMatchWholeWord;
private System.Windows.Forms.CheckBox chkMatchCase;
private System.Windows.Forms.Button btnHighlightAll;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnFindPrevious;
}
}

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAA
AAAAAAAnAAAAQQAAAEEAAABBAAAAQQAAAEEAAAAn////Af///wEAAAAnAAAAQQAAAEEAAABBAAAAQQAA
AEEAAAAnFRUVsxsbG/8bGxv/Gxsb/xsbG/8bGxv/FRUVs////wH///8BFRUVsxsbG/8bGxv/Gxsb/xsb
G/8bGxv/FRUVsxkZGf+ZmZn/bm5u/1BQUP9KSkr/Xl5e/xkZGf////8B////ARkZGf9eXl7/SkpK/1BQ
UP9ubm7/mZmZ/xkZGf8NDQ3/UlJS/zs7O/8rKyv/Jycn/zIyMv8NDQ3/////Af///wENDQ3/MjIy/ycn
J/8rKyv/Ozs7/1JSUv8NDQ3/GRkZ/6SkpP9+fn7/Y2Nj/15eXv9wcHD/GRkZ/////wH///8BGRkZ/3Bw
cP9eXl7/Y2Nj/35+fv+kpKT/GRkZ/xkZGf+ZmZn/bm5u/1BQUP9KSkr/Xl5e/xkZGf////8B////ARkZ
Gf9eXl7/SkpK/1BQUP9ubm7/mZmZ/xkZGf8ZGRn/mZmZ/25ubv9QUFD/SkpK/15eXv8ZGRn/////Af//
/wEZGRn/Xl5e/0pKSv9QUFD/bm5u/5mZmf8ZGRn/GRkZ/5mZmf9ubm7/UFBQ/0RERP88PDz/GRkZ/wAA
AEEAAABBGRkZ/zw8PP9ERET/UFBQ/25ubv+ZmZn/GRkZ/xgYGNO4uLj/i4uL/1BQUP87Ozv/GRkZ/woK
Cv8RERH/ERER/woKCv8ZGRn/Ozs7/1BQUP+Li4v/uLi4/xgYGNMZGRl7GRkZzRkZGf8TExP/BAQE/woK
Cv9gYGD/kZGR/5GRkf9gYGD/CgoK/wQEBP8EBAT/CQkJ/xkZGc0ZGRl7////Af///wEZGRn/jY2N/11d
Xf8EBAT/KCgo/0pKSv9KSkr/KCgo/wQEBP9fX1//jY2N/xkZGf////8B////Af///wH///8BGRkZ/42N
jf9dXV3/BgYG/2BgYP+RkZH/kZGR/2BgYP8GBgb/X19f/42Njf8ZGRn/////Af///wH///8B////ARkZ
Gf+1tbX/cHBw/1RUVP8ZGRn/MDAw/zAwMP8ZGRn/VFRU/ykpKf+1tbX/GRkZ/////wH///8B////Af//
/wEcHByHGRkZ/xkZGf8ZGRn/HBwch////wH///8BHBwchxkZGf8ZGRn/GRkZ/xwcHIf///8B////Af//
/wH///8B////ARYWFrukpKT/GRkZ/////wH///8B////Af///wEZGRn/pKSk/xYWFrv///8B////Af//
/wH///8B////Af///wEZGRn/GRkZ/xkZGf////8B////Af///wH///8BGRkZ/xkZGf8ZGRn/////Af//
/wH///8BAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
//8AAP//AAD//w==
</value>
</data>
</root>

View File

@@ -0,0 +1,115 @@
using System;
using System.Windows.Forms;
using ICSharpCode.TextEditorEx;
namespace ICSharpCode.TextEditor.UserControls
{
/// <summary>
/// http://minicsharplab.codeplex.com/
/// </summary>
public partial class FormatCodeHtml : Form
{
/// <summary>
/// Initializes a new instance of the <see cref="FormatCodeHtml"/> class.
/// </summary>
/// <param name="codeToFormat">The code to format.</param>
/// <param name="defaultLanguage">The default language.</param>
public FormatCodeHtml(string codeToFormat, string defaultLanguage)
{
CodeToFormat = codeToFormat;
InitializeComponent();
switch (defaultLanguage)
{
case SyntaxModes.CSharp:
rbCSharp.Checked = true;
break;
case SyntaxModes.VBNET:
rbVB.Checked = true;
break;
case SyntaxModes.XML:
rbHtml.Checked = true;
break;
case SyntaxModes.JavaScript:
rbJS.Checked = true;
break;
case SyntaxModes.Java:
rbJava.Checked = true;
break;
case SyntaxModes.SQL:
rbtsql.Checked = true;
break;
case SyntaxModes.CPPNET:
rbCSharp.Checked = true;
break;
default:
rbCSharp.Checked = true;
break;
}
}
/// <summary>
/// Handles the Click event of the btnCopy control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void btnCopy_Click(object sender, EventArgs e)
{
/*
SourceFormat sf = null;
if (rbCSharp.Checked)
{
sf = new CSharpFormat();
}
else if (rbVB.Checked)
{
sf = new VisualBasicFormat();
}
else if (rbtsql.Checked)
{
sf = new TsqlFormat();
}
else if (rbHtml.Checked)
{
sf = new HtmlFormat();
}
else if (rbJS.Checked)
{
sf = new JavaScriptFormat();
}
else if (rbJava.Checked)
{
sf = new MshFormat();
}
else { return; }
sf.TabSpaces = 4;
sf.LineNumbers = cbLineNumbers.Checked;
sf.EmbedStyleSheet = cbEmbedCss.Checked;
sf.Alternate = cbAlternate.Checked;
string formatedCode = sf.FormatCode(CodeToFormat);
//Clipboard.SetText(formatedCode, TextDataFormat.Html);
Clipboard.SetText(formatedCode);*/
}
/// <summary>
/// Handles the Click event of the btnClose control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void btnClose_Click(object sender, EventArgs e)
{
btnCopy_Click(sender, e);
this.Close();
}
/// <summary>
/// Gets or sets the code to format.
/// </summary>
/// <value>The code to format.</value>
public string CodeToFormat { get; set; }
}
}

View File

@@ -0,0 +1,261 @@
namespace ICSharpCode.TextEditor.UserControls
{
partial class FormatCodeHtml
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.btnClose = new System.Windows.Forms.Button();
this.btnCopy = new System.Windows.Forms.Button();
this.gbLanguage = new System.Windows.Forms.GroupBox();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
this.rbCSharp = new System.Windows.Forms.RadioButton();
this.rbVB = new System.Windows.Forms.RadioButton();
this.rbHtml = new System.Windows.Forms.RadioButton();
this.rbtsql = new System.Windows.Forms.RadioButton();
this.rbJS = new System.Windows.Forms.RadioButton();
this.gbSettings = new System.Windows.Forms.GroupBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.cbLineNumbers = new System.Windows.Forms.CheckBox();
this.cbEmbedCss = new System.Windows.Forms.CheckBox();
this.cbAlternate = new System.Windows.Forms.CheckBox();
this.rbJava = new System.Windows.Forms.RadioButton();
this.gbLanguage.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.gbSettings.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.Location = new System.Drawing.Point(261, 150);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(91, 23);
this.btnClose.TabIndex = 0;
this.btnClose.Text = "Copy && Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnCopy
//
this.btnCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCopy.Location = new System.Drawing.Point(180, 150);
this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(75, 23);
this.btnCopy.TabIndex = 1;
this.btnCopy.Text = "Copy";
this.btnCopy.UseVisualStyleBackColor = true;
this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click);
//
// gbLanguage
//
this.gbLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gbLanguage.Controls.Add(this.flowLayoutPanel2);
this.gbLanguage.Location = new System.Drawing.Point(12, 12);
this.gbLanguage.Name = "gbLanguage";
this.gbLanguage.Size = new System.Drawing.Size(340, 75);
this.gbLanguage.TabIndex = 2;
this.gbLanguage.TabStop = false;
this.gbLanguage.Text = "Language";
//
// flowLayoutPanel2
//
this.flowLayoutPanel2.Controls.Add(this.rbCSharp);
this.flowLayoutPanel2.Controls.Add(this.rbVB);
this.flowLayoutPanel2.Controls.Add(this.rbHtml);
this.flowLayoutPanel2.Controls.Add(this.rbtsql);
this.flowLayoutPanel2.Controls.Add(this.rbJS);
this.flowLayoutPanel2.Controls.Add(this.rbJava);
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel2.Location = new System.Drawing.Point(3, 16);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Padding = new System.Windows.Forms.Padding(5);
this.flowLayoutPanel2.Size = new System.Drawing.Size(334, 56);
this.flowLayoutPanel2.TabIndex = 12;
//
// rbCSharp
//
this.rbCSharp.AutoSize = true;
this.rbCSharp.Checked = true;
this.rbCSharp.Location = new System.Drawing.Point(8, 8);
this.rbCSharp.Name = "rbCSharp";
this.rbCSharp.Size = new System.Drawing.Size(39, 17);
this.rbCSharp.TabIndex = 5;
this.rbCSharp.TabStop = true;
this.rbCSharp.Text = "C#";
this.rbCSharp.UseVisualStyleBackColor = true;
//
// rbVB
//
this.rbVB.AutoSize = true;
this.rbVB.Location = new System.Drawing.Point(53, 8);
this.rbVB.Name = "rbVB";
this.rbVB.Size = new System.Drawing.Size(64, 17);
this.rbVB.TabIndex = 4;
this.rbVB.Text = "VB.NET";
this.rbVB.UseVisualStyleBackColor = true;
//
// rbHtml
//
this.rbHtml.AutoSize = true;
this.rbHtml.Location = new System.Drawing.Point(123, 8);
this.rbHtml.Name = "rbHtml";
this.rbHtml.Size = new System.Drawing.Size(73, 17);
this.rbHtml.TabIndex = 6;
this.rbHtml.Text = "Html/XML";
this.rbHtml.UseVisualStyleBackColor = true;
//
// rbtsql
//
this.rbtsql.AutoSize = true;
this.rbtsql.Location = new System.Drawing.Point(202, 8);
this.rbtsql.Name = "rbtsql";
this.rbtsql.Size = new System.Drawing.Size(56, 17);
this.rbtsql.TabIndex = 3;
this.rbtsql.Text = "T-SQL";
this.rbtsql.UseVisualStyleBackColor = true;
//
// rbJS
//
this.rbJS.AutoSize = true;
this.rbJS.Location = new System.Drawing.Point(8, 31);
this.rbJS.Name = "rbJS";
this.rbJS.Size = new System.Drawing.Size(75, 17);
this.rbJS.TabIndex = 7;
this.rbJS.Text = "JavaScript";
this.rbJS.UseVisualStyleBackColor = true;
//
// gbSettings
//
this.gbSettings.Controls.Add(this.flowLayoutPanel1);
this.gbSettings.Location = new System.Drawing.Point(12, 95);
this.gbSettings.Name = "gbSettings";
this.gbSettings.Size = new System.Drawing.Size(337, 51);
this.gbSettings.TabIndex = 3;
this.gbSettings.TabStop = false;
this.gbSettings.Text = "Settings";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.cbLineNumbers);
this.flowLayoutPanel1.Controls.Add(this.cbEmbedCss);
this.flowLayoutPanel1.Controls.Add(this.cbAlternate);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 16);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
this.flowLayoutPanel1.Size = new System.Drawing.Size(331, 32);
this.flowLayoutPanel1.TabIndex = 1;
//
// cbLineNumbers
//
this.cbLineNumbers.AutoSize = true;
this.cbLineNumbers.Location = new System.Drawing.Point(8, 8);
this.cbLineNumbers.Name = "cbLineNumbers";
this.cbLineNumbers.Size = new System.Drawing.Size(91, 17);
this.cbLineNumbers.TabIndex = 0;
this.cbLineNumbers.Text = "Line Numbers";
this.cbLineNumbers.UseVisualStyleBackColor = true;
//
// cbEmbedCss
//
this.cbEmbedCss.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbEmbedCss.AutoSize = true;
this.cbEmbedCss.Location = new System.Drawing.Point(105, 8);
this.cbEmbedCss.Name = "cbEmbedCss";
this.cbEmbedCss.Size = new System.Drawing.Size(79, 17);
this.cbEmbedCss.TabIndex = 1;
this.cbEmbedCss.Text = "Embed Css";
this.cbEmbedCss.UseVisualStyleBackColor = true;
//
// cbAlternate
//
this.cbAlternate.AutoSize = true;
this.cbAlternate.Location = new System.Drawing.Point(190, 8);
this.cbAlternate.Name = "cbAlternate";
this.cbAlternate.Size = new System.Drawing.Size(123, 17);
this.cbAlternate.TabIndex = 2;
this.cbAlternate.Text = "Alternate Line Colors";
this.cbAlternate.UseVisualStyleBackColor = true;
//
// rbJava
//
this.rbJava.AutoSize = true;
this.rbJava.Location = new System.Drawing.Point(89, 31);
this.rbJava.Name = "rbJava";
this.rbJava.Size = new System.Drawing.Size(48, 17);
this.rbJava.TabIndex = 8;
this.rbJava.Text = "Java";
this.rbJava.UseVisualStyleBackColor = true;
//
// FormatCodeHtml
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(364, 185);
this.Controls.Add(this.gbSettings);
this.Controls.Add(this.gbLanguage);
this.Controls.Add(this.btnCopy);
this.Controls.Add(this.btnClose);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormatCodeHtml";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Copy Code as Html";
this.gbLanguage.ResumeLayout(false);
this.flowLayoutPanel2.ResumeLayout(false);
this.flowLayoutPanel2.PerformLayout();
this.gbSettings.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnCopy;
private System.Windows.Forms.GroupBox gbLanguage;
private System.Windows.Forms.GroupBox gbSettings;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.RadioButton rbCSharp;
private System.Windows.Forms.RadioButton rbVB;
private System.Windows.Forms.RadioButton rbHtml;
private System.Windows.Forms.RadioButton rbtsql;
private System.Windows.Forms.RadioButton rbJS;
private System.Windows.Forms.CheckBox cbLineNumbers;
private System.Windows.Forms.CheckBox cbEmbedCss;
private System.Windows.Forms.CheckBox cbAlternate;
private System.Windows.Forms.RadioButton rbJava;
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,106 @@
namespace ICSharpCode.TextEditor.UserControls
{
partial class GotoForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GotoForm));
this.lblLineNumber = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtLineNumber = new ICSharpCode.TextEditor.UserControls.Int32TextBox();
this.SuspendLayout();
//
// lblLineNumber
//
this.lblLineNumber.AutoSize = true;
this.lblLineNumber.Location = new System.Drawing.Point(13, 13);
this.lblLineNumber.Name = "lblLineNumber";
this.lblLineNumber.Size = new System.Drawing.Size(110, 13);
this.lblLineNumber.TabIndex = 0;
this.lblLineNumber.Text = "Line number (1 - 999):";
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.Location = new System.Drawing.Point(114, 56);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 2;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(195, 56);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// txtLineNumber
//
this.txtLineNumber.Location = new System.Drawing.Point(16, 30);
this.txtLineNumber.Max = 2147483647;
this.txtLineNumber.Min = 1;
this.txtLineNumber.Name = "txtLineNumber";
this.txtLineNumber.Size = new System.Drawing.Size(254, 20);
this.txtLineNumber.TabIndex = 1;
this.txtLineNumber.Text = "1";
//
// GotoForm
//
this.AcceptButton = this.btnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(282, 87);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.txtLineNumber);
this.Controls.Add(this.lblLineNumber);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GotoForm";
this.Text = "Go To Line";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblLineNumber;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private Int32TextBox txtLineNumber;
}
}

View File

@@ -0,0 +1,67 @@
using System.Globalization;
using System.Windows.Forms;
namespace ICSharpCode.TextEditor.UserControls
{
public partial class GotoForm : Form
{
private int _firstLineNumber;
public int FirstLineNumber
{
get { return _firstLineNumber; }
set
{
_firstLineNumber = value;
UpdateLineNumberLabel();
}
}
private int _lastLineNumber;
public int LastLineNumber
{
get { return _lastLineNumber; }
set
{
_lastLineNumber = value;
UpdateLineNumberLabel();
}
}
public int SelectedLineNumber
{
get
{
int selectedLineNumber;
if (!string.IsNullOrEmpty(txtLineNumber.Text) && int.TryParse(txtLineNumber.Text, out selectedLineNumber))
{
return selectedLineNumber;
}
return 0;
}
set
{
txtLineNumber.Text = value.ToString(CultureInfo.InvariantCulture);
}
}
public GotoForm()
{
InitializeComponent();
}
public DialogResult ShowDialogEx()
{
txtLineNumber.Min = _firstLineNumber;
txtLineNumber.Max = _lastLineNumber;
return ShowDialog();
}
private void UpdateLineNumberLabel()
{
lblLineNumber.Text = string.Format("Line number ({0} - {1}):", _firstLineNumber, _lastLineNumber);
}
}
}

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAA
AAD///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////AWcsBBf///8B////Af//
/wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////AaZODyuYRxBtmEcOL///
/wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wGtWBtHl0oW/6NR
GW2eUBkv////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8BtGUqR6lW
HP+uXiD/r14jbaRcJi////8B////Af///wF3SiUXd0olF3dKJRd3SiUXd0olF3dKJRd3SiUXd0olF6xq
Ni+8dDtHu2Ii/8FrJv+8bC9tvHQ7K////wHFg00rx3k7bcd5O23HeTttx3k7bcd5O23HeTttx3k7bcd5
O23HeTttx3k7bch0M4nWfzD/yW0m/8WDTUfFg00rzpJfR9FyKf/YfC7/2Hwu/9h8Lv/YfC7/2Hwu/9h8
Lv/YfC7/2Hwu/9h8Lv/ehTP/7Zs+/+CINP/Rcin/zpJfR9eicCvXjVBt141QbdeNUG3XjVBt141QbdeN
UG3XjVBt141QbdeNUG3XjVBt1oRCieOKN//Wdiz/16JwR9eicCv///8B37CBD9+wgQ/fsIEP37CBD9+w
gQ/fsIEP37CBD9+wgQ/fsIEr37CBR9mCNv/gjT3/3Jpebd+wgSv///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B5ryQR9mRQ//gnkz/4Khsbea8kCv///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////AezHnEfRcin/359mbezHnCv///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////Af///wHwzqQr4aNqbfDOpCv///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////Af///wH///8B////AfDOpA////8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af//
/wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af//
/wH///8BAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
//8AAP//AAD//w==
</value>
</data>
</root>

View File

@@ -0,0 +1,58 @@
using System;
using System.Windows.Forms;
namespace ICSharpCode.TextEditor.UserControls
{
class Int32TextBox : TextBox
{
public int Min { get; set; }
public int Max { get; set; }
public Int32TextBox()
: this(1, int.MaxValue)
{
}
public Int32TextBox(int min, int max)
{
Min = min;
Max = max;
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
if (!IsValidNumber(Text))
{
Text = string.Empty;
}
}
protected override void WndProc(ref Message m)
{
const int WM_PASTE = 0x0302;
if (m.Msg == WM_PASTE)
{
string text = Clipboard.GetText();
if (!IsValidNumber(text))
return;
}
base.WndProc(ref m);
}
private bool IsValidNumber(string text)
{
int i;
if (int.TryParse(text, out i))
{
return i <= Max && i >= Min;
}
return false;
}
}
}