0:   //  TextLib.cs
1:   //  Copyright (C) 2001 Mike Krueger
2:   //
3:   //  This program is free software; you can redistribute it and/or modify
4:   //  it under the terms of the GNU General Public License as published by
5:   //  the Free Software Foundation; either version 2 of the License, or
6:   //  (at your option) any later version.
7:   //
8:   //  This program is distributed in the hope that it will be useful,
9:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11:   //  GNU General Public License for more details.
12:   //
13:   //  You should have received a copy of the GNU General Public License
14:   //  along with this program; if not, write to the Free Software
15:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16:   /*
17:   using System;
18:   using System.IO;
19:   using System.ComponentModel;
20:   using System.Windows.Forms;
21:   using System.Drawing;
22:   using System.Collections;
23:   using System.Resources;
24:   using System.Xml;
25:  
26:   using SharpDevelop.Gui.Edit.Text;
27:   using SharpDevelop.Internal.Templates;
28:  
29:   namespace SharpDevelop.Gui.Navigation {
30:       
31:       public class TextLib : UserControl
32:       {
33:           MainWindow mainwindow;
34:           ComboBox libraryselector = new ComboBox();
35:           ListBox  entrylist       = new ListBox();
36:           
37:           public TextLib(MainWindow mainwindow)
38:           {
39:               this.mainwindow = mainwindow;
40:               Dock = DockStyle.Fill;
41:               
42:               libraryselector.Size = new System.Drawing.Size(184, 21);
43:               libraryselector.Dock = DockStyle.Top;
44:               libraryselector.TabIndex = 0;
45:               libraryselector.DropDownStyle = ComboBoxStyle.DropDownList;
46:               
47:               foreach (TextTemplate template in TextTemplate.TextTemplates) {
48:                   libraryselector.Items.Add(template.Name);
49:               }
50:               libraryselector.SelectedIndexChanged += new EventHandler(LibrarySelectionChange);
51:               libraryselector.SelectedIndex = 0;
52:               entrylist.Dock = DockStyle.Fill;
53:               entrylist.BorderStyle = BorderStyle.Fixed3D;
54:               entrylist.Location = new System.Drawing.Point(0, 22);
55:               entrylist.Size = new System.Drawing.Size(184, 157);
56:               entrylist.TabIndex = 1;
57:               
58:               entrylist.DoubleClick += new EventHandler(InsertItem);
59:               Controls.Add(entrylist);
60:               Controls.Add(libraryselector);
61:           }
62:           
63:           void InsertItem(object sender, EventArgs e)
64:           {
65:               if (mainwindow.ActiveContentWindow == null || !mainwindow.ActiveContentWindow.HasTextArea)
66:                   return;
67:               
68:               TextAreaControl textarea = mainwindow.ActiveContentWindow.TextArea;
69:               string text = ((TextTemplate.Entry)entrylist.SelectedItem).Value;
70:               if (!text.Equals("")) {
71:                   textarea.ClipboardHandler.Delete(sender, e);
72:                   int y = textarea.Caret.CaretPos.Y;
73:                   
74:                   textarea.Caret.CaretPos = textarea.Buffer.Insert(textarea.Caret.CaretPos, text);
75:                   
76:                   if (y != textarea.Caret.CaretPos.Y) {
77:                       textarea.UpdateToEnd(y);
78:                   } else {
79:                       textarea.UpdateLines(y, y);
80:                   }
81:               }
82:           }
83:           
84:           void LibrarySelectionChange(object sender, EventArgs e)
85:           {
86:               TextTemplate template = (TextTemplate)TextTemplate.TextTemplates[libraryselector.SelectedIndex];
87:               
88:               entrylist.Items.Clear();
89:               foreach (TextTemplate.Entry entry in template.Entries) 
90:                   entrylist.Items.Add(entry);
91:   //                entrylist.Items.Add(new ListViewItem(entry.Display ));
92:               
93:               
94:           }
95:           
96:       }
97:   }*/

This page was automatically generated by SharpDevelop.