Exemplo n.º 1
0
		public TextEditorControl()
		{
			this.SetStyle(ControlStyles.ContainerControl, true);
			this.SetStyle(ControlStyles.Selectable, true);
			this.ResizeRedraw = true;

			Document = (new DocumentFactory()).CreateDefaultDocument();
			Document.HighlightingStrategy = HighlightingManager.Manager.HighlightingDefinitions["Default"] as DefaultHighlightingStrategy;
			textAreaControl  = new TextAreaControl(this);
			textAreaControl.Dock = DockStyle.Fill;
			InitializeTextAreaControl(textAreaControl);
			this.Controls.Add(textAreaControl);
			//注意:下面为Document.UpdateCommited事件添加了处理程序,
			//所以当Document.OnUpdateCommited()方法被调用到时,会调用这里注册的处理程序.
			//而Document.OnUpdateCommited()方法应该由这个类中的EndUpdate()方法来调用到。
			Document.UpdateCommited += new EventHandler(CommitUpdateRequested);

			TextEditorProperties = new DefaultTextEditorProperties();
			OptionsChanged();
		}
Exemplo n.º 2
0
		//以上全部为一些简单的属性.
		
		//构造函数
		public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
		{
			this.motherTextAreaControl      = motherTextAreaControl;
			this.motherTextEditorControl    = motherTextEditorControl;
			
			caret            = new Caret(this);//附加插入符.
			selectionManager = new SelectionManager(Document);//附加选择管理器.
						
			ResizeRedraw = true;
			
			SetStyle(ControlStyles.DoubleBuffer, false);
			SetStyle(ControlStyles.Opaque, false);
			SetStyle(ControlStyles.ResizeRedraw, true);
			SetStyle(ControlStyles.Selectable, true);
			
			textViewMargin = new TextViewMargin(this);//附加主要的文本区域。
			gutterMargin = new GutterMargin(this);//附加装订线区域.
			foldMargin   = new FoldMargin(this);//附加折叠区域.
			iconBarMargin = new IconBarMargin(this);//附加图标栏区域.
			leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin });
			
			OptionsChanged();
			
			textAreaClipboardHandler = new TextAreaClipboardHandler(this);//附加剪切办处理程序.
			new TextAreaMouseHandler(this).Attach();
			new TextAreaDragDropHandler().Attach(this);
			
			bracketshemes.Add(new BracketHighlightingScheme('{', '}'));
			bracketshemes.Add(new BracketHighlightingScheme('(', ')'));
			bracketshemes.Add(new BracketHighlightingScheme('[', ']'));
			
			caret.PositionChanged += new EventHandler(SearchMatchingBracket);
			Document.TextContentChanged += new EventHandler(TextContentChanged);
			Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged);
		}
Exemplo n.º 3
0
		//这个方法以后可以被继承自这个类的文本编辑器重写.
		protected virtual void InitializeTextAreaControl(TextAreaControl newControl)
		{
		}
 //这个方法以后可以被继承自这个类的文本编辑器重写.
 protected virtual void InitializeTextAreaControl(TextAreaControl newControl)
 {
 }