⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gotolinenumberdialog.cs

📁 c#精彩编程百例(源代码)
💻 CS
字号:
//  GotoLineNumberDialog.cs 
//  Copyright (C) 2000 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.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;

using SharpDevelop.Gui.Window;
using SharpDevelop.Tool.Data;

namespace SharpDevelop.Gui.Dialogs {
    
    public class GotoLineNumberDialog : Form 
    {
		Container  components;
		Button     cancelButton;
		Button     okButton;
		TextBox    lineNumberTextBox;
		Label      label1;
		ContentWindow window;
		
		void cancelEvent(object sender, EventArgs e)
	    {
	    	Close();
	    }
	    
	    void closeEvent(object sender, EventArgs e)
	    {
	    	try {
	    		int   i      = Math.Min(window.TextArea.Buffer.Length, Math.Max(1, Int32.Parse(lineNumberTextBox.Text)));
				Point pos    = window.TextArea.Caret.CaretPos;
				Point newPos = new Point(0, i - 1);
				window.TextArea.Caret.CaretPos = newPos;
				window.TextArea.ScrollToCaret();
	    	} catch (Exception) {
	    		
	    	} finally {
	    		Close();
	    	}
	    }
		
        public GotoLineNumberDialog(ContentWindow window)
        {
        	this.window = window;
        	
            InitializeComponent();
        	
            AcceptButton = okButton;
            CancelButton = cancelButton;
            
			okButton.Click     += new EventHandler(closeEvent);
        	cancelButton.Click += new EventHandler(cancelEvent);
			
			MaximizeBox  = MinimizeBox = false;
			
			ShowInTaskbar = false;
			StartPosition = FormStartPosition.CenterParent;
			Icon = null;
        }
        
        public override void Dispose()
        {
            base.Dispose();
            components.Dispose();
        }
		
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.cancelButton = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.okButton = new System.Windows.Forms.Button();
			this.lineNumberTextBox = new System.Windows.Forms.TextBox();
			
			cancelButton.Location = new System.Drawing.Point(90, 40);
			cancelButton.Size = new System.Drawing.Size(74, 24);
			cancelButton.TabIndex = 3;
			cancelButton.Text = Resource.GetString("Global.CancelButtonText");
			
			label1.Location = new System.Drawing.Point(10, 10);
			label1.Text = Resource.GetString("Dialog.GotoLineNumber.label1Text");
			label1.Size = new System.Drawing.Size(72, 16);
			label1.TabIndex = 0;
			
			okButton.Location = new System.Drawing.Point(8, 40);
			okButton.Size = new System.Drawing.Size(74, 24);
			okButton.TabIndex = 2;
			okButton.Text = Resource.GetString("Global.OKButtonText");
			
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.Text = Resource.GetString("Dialog.GotoLineNumber.DialogName");
			this.ClientSize = new System.Drawing.Size(200, 69);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			
			lineNumberTextBox.Location = new System.Drawing.Point(80, 8);
			lineNumberTextBox.Text = "";
			lineNumberTextBox.TabIndex = 1;
			lineNumberTextBox.Size = new System.Drawing.Size(112, 20);
			
			this.Controls.Add(cancelButton);
			this.Controls.Add(okButton);
			this.Controls.Add(lineNumberTextBox);
			this.Controls.Add(label1);
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -