📄 textlib.cs
字号:
// TextLib.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.IO;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.Resources;
using System.Xml;
using SharpDevelop.Gui.Edit.Text;
using SharpDevelop.Internal.Templates;
namespace SharpDevelop.Gui.Navigation {
public class TextLib : UserControl
{
MainWindow mainwindow;
ComboBox libraryselector = new ComboBox();
ListBox entrylist = new ListBox();
public TextLib(MainWindow mainwindow)
{
this.mainwindow = mainwindow;
Dock = DockStyle.Fill;
libraryselector.Size = new System.Drawing.Size(184, 21);
libraryselector.Dock = DockStyle.Top;
libraryselector.TabIndex = 0;
libraryselector.DropDownStyle = ComboBoxStyle.DropDownList;
foreach (TextTemplate template in TextTemplate.TextTemplates) {
libraryselector.Items.Add(template.Name);
}
libraryselector.SelectedIndexChanged += new EventHandler(LibrarySelectionChange);
libraryselector.SelectedIndex = 0;
entrylist.Dock = DockStyle.Fill;
entrylist.BorderStyle = BorderStyle.Fixed3D;
entrylist.Location = new System.Drawing.Point(0, 22);
entrylist.Size = new System.Drawing.Size(184, 157);
entrylist.TabIndex = 1;
/* entrylist.Alignment = ListViewAlignment.Left;
entrylist.View = View.Details;
entrylist.Columns.Add(new ColumnHeader());
entrylist.HeaderStyle = ColumnHeaderStyle.None;*/
entrylist.DoubleClick += new EventHandler(InsertItem);
Controls.Add(entrylist);
Controls.Add(libraryselector);
}
void InsertItem(object sender, EventArgs e)
{
if (mainwindow.ActiveContentWindow == null || !mainwindow.ActiveContentWindow.HasTextArea)
return;
TextAreaControl textarea = mainwindow.ActiveContentWindow.TextArea;
string text = ((TextTemplate.Entry)entrylist.SelectedItem).Value;
if (!text.Equals("")) {
textarea.ClipboardHandler.Delete(sender, e);
int y = textarea.Caret.CaretPos.Y;
textarea.Caret.CaretPos = textarea.Buffer.Insert(textarea.Caret.CaretPos, text);
if (y != textarea.Caret.CaretPos.Y) {
textarea.UpdateToEnd(y);
} else {
textarea.UpdateLines(y, y);
}
}
}
void LibrarySelectionChange(object sender, EventArgs e)
{
TextTemplate template = (TextTemplate)TextTemplate.TextTemplates[libraryselector.SelectedIndex];
entrylist.Items.Clear();
foreach (TextTemplate.Entry entry in template.Entries)
entrylist.Items.Add(entry);
// entrylist.Items.Add(new ListViewItem(entry.Display ));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -