/
n-dimens
/
pascalabcnet
Обзор
Документация
Войти
/
n-dimens
/
pascalabcnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ICSharpCode.TextEditorLinux/Src/Document/BookmarkManager/Bookmark.cs
137 строк
3 KB
Mikhalkovich Stanislav
Для Linux-версии исправлен DockContent, редактор (показ всплывающего окна)
30 июн 2022, 09:47
30 июн 2022, 09:47
3072383
Код
Авторство
О чём код?
// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/> // <version>$Revision: 2691 $</version> // </file> using System; using System.Drawing; using SWF = System.Windows.Forms; namespace ICSharpCode.TextEditor.Document { /// <summary> /// Description of Bookmark. /// </summary> public class Bookmark { IDocument document; LineSegment line; int lineNumber; bool isEnabled = true; public IDocument Document { get { return document; } set { if (document != value) { if (line != null) { lineNumber = line.LineNumber; line = null; } document = value; if (document != null) { line = document.GetLineSegment(Math.Min(lineNumber, document.TotalNumberOfLines-1)); } OnDocumentChanged(EventArgs.Empty); } } } public event EventHandler DocumentChanged; protected virtual void OnDocumentChanged(EventArgs e) { if (DocumentChanged != null) { DocumentChanged(this, e); } } public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { isEnabled = value; if (document != null) { document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber)); document.CommitUpdate(); } OnIsEnabledChanged(EventArgs.Empty); } } } public event EventHandler IsEnabledChanged; protected virtual void OnIsEnabledChanged(EventArgs e) { if (IsEnabledChanged != null) { IsEnabledChanged(this, e); } } /// <summary> /// Gets the line the bookmark belongs to. /// Is null if the bookmark is not connected to a document. /// </summary> public LineSegment Line { get { return line; } } public int LineNumber { get { if (line != null) return line.LineNumber; else return lineNumber; } set { if (value < 0) throw new ArgumentOutOfRangeException("value", value, "line number must be >= 0"); if (document == null) { lineNumber = value; } else { line = document.GetLineSegment(value); } } } /// <summary> /// Gets if the bookmark can be toggled off using the 'set/unset bookmark' command. /// </summary> public virtual bool CanToggle { get { return true; } } public Bookmark(IDocument document, int lineNumber) : this(document, lineNumber, true) { } public Bookmark(IDocument document, int lineNumber, bool isEnabled) { this.document = document; this.isEnabled = isEnabled; this.LineNumber = lineNumber; } public virtual bool Click(SWF.Control parent, SWF.MouseEventArgs e) { if (e.Button == SWF.MouseButtons.Left && CanToggle) { document.BookmarkManager.RemoveMark(this); return true; } return false; } public virtual void Draw(IconBarMargin margin, Graphics g, Point p) { margin.DrawBookmark(g, p.Y, isEnabled); } } }