📄 textareatabpage.cs
字号:
// DINAMIC XML Editor
//
// Copyright (c) 2002-2003 Dusan Hlavaty
// mailto: duddo@atlas.cz
//
// This software is licensed under the terms of
// GNU General Public license
//
using System;
using XML_editor.Common;
namespace XML_editor.TabPages
{
/// <summary>
/// <see cref="TextAreaTabPage"/> zdruzuje textovy editor (<see cref="DLTextEditor.TextAreaControl"/>)
/// do komponenty <see cref="Crownwood.Magic.Controls.TabPage"/>
/// </summary>
public class TextAreaTabPage : Crownwood.Magic.Controls.TabPage
{
/// <summary>
/// true = ak v dokumente boli vykonane nejake zmeny
/// </summary>
private bool textareaHasChanges = false;
/// <summary>
/// true = ak tento subor je novy a nebol este nikdy ulozeny na disk
/// </summary>
private bool isNewFile = true;
// -------------------------------------------------------------------------
/// <summary>
/// true = ak tento subor je novy a nebol este nikdy ulozeny na disk
/// </summary>
public bool IsNewFile
{
get
{
return this.isNewFile;
}
set
{
this.isNewFile = value;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Titulok tohoto (<see cref="TextAreaTabPage"/>) okna
/// </summary>
public string TitleToShow
{
get
{
return this.Title.TrimEnd('*');
}
}
// -------------------------------------------------------------------------
/// <summary>
/// true = ak v dokumente boli vykonane nejake zmeny
/// </summary>
public bool TextAreaHasChanges
{
get
{
return this.textareaHasChanges;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Textovy editor (<see cref="TextAreaControl"/>), ktory je 'zabaleny'
/// v tomto TabPage
/// </summary>
public DLTextEditor.TextAreaControl TextAreaControl
{
get
{
return (this.Control as DLTextEditor.TextAreaControl);
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Inicializuje instanciu <see cref="TextAreaTabPage"/>. Vytvori
/// vnutri tohoto objektu instanciu <see cref="DLTextEditor.TextAreaControl"/>.
/// </summary>
/// <param name="title">Titulok, ktory sa ma vypisat do zalozky</param>
/// <param name="icon">Ikonka, ktora sa ma vykreslit na zalozku</param>
public TextAreaTabPage(string title, System.Drawing.Icon icon) : base(title)
{
this.Icon = icon;
DLTextEditor.TextAreaControl txt = new DLTextEditor.TextAreaControl();
txt.FileName = title;
this.Control = txt;
txt.Document.DocumentChanged += new DLTextEditor.Document.DocumentAggregatorEventHandler(DocumentChanged);
txt.DocumentSaved += new EventHandler(DocumentHasBeenSaved);
}
// -------------------------------------------------------------------------
/// <summary>
/// Inicializuje instanciu <see cref="TextAreaTabPage"/>.
/// </summary>
/// <param name="title">Titulok, ktory sa ma vypisat do zalozky</param>
/// <param name="icon">Ikonka, ktora sa ma vykreslit na zalozku</param>
/// <param name="textAreaControl">instancia <see cref="DLTextEditor.TextAreaControl"/>,
/// ktoru ma tento <see cref="TextAreaTabPage"/> obsahovat</param>
public TextAreaTabPage(string title, System.Drawing.Icon icon, DLTextEditor.TextAreaControl textAreaControl) : base(title)
{
this.Icon = icon;
this.Control = textAreaControl;
textAreaControl.Document.DocumentChanged += new DLTextEditor.Document.DocumentAggregatorEventHandler(DocumentChanged);
textAreaControl.DocumentSaved += new EventHandler(DocumentHasBeenSaved);
}
// -------------------------------------------------------------------------
/// <summary>
/// Obsluha udalosti. Vyvola sa po zmene v dokumente
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DocumentChanged(object sender, DLTextEditor.Document.DocumentAggregatorEventArgs e)
{
if (this.textareaHasChanges != true)
{
this.textareaHasChanges = true;
this.Title = this.TitleToShow + "*";
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Oznami tejto <see cref="TextAreaTabPage"/>, ze obsah dokumentu bol ulozeny na disk.
/// </summary>
public void DocumentHasBeenSaved(object sender, EventArgs e)
{
this.textareaHasChanges = false;
this.IsNewFile = false;
System.IO.FileInfo fileInfo = new System.IO.FileInfo(TextAreaControl.FileName);
this.Title = fileInfo.Name;
this.Icon = IconProvider.GetIconForFileName(this, TextAreaControl.FileName);
}
} // public class TextAreaTabPage : ...
} // namespace XML_editor.TabPages
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -