using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace Hydro.MapUI
|
{
|
public partial class InputBox : Form
|
{
|
DialogResult _DialogResult;
|
|
void initPosition()
|
{
|
this.StartPosition = FormStartPosition.Manual;
|
int offsetX = -1 * this.Width / 2; // 距离鼠标左侧的间距
|
int offsetY = -1 * this.Height / 2; // 距离鼠标顶部的间距
|
int newWindowWidth = this.Width; // 新窗口的宽度
|
int newWindowHeight = this.Height; // 新窗口的高度
|
Point mousePosition = MousePosition; // 获取鼠标位置
|
|
this.Location = new Point(mousePosition.X + offsetX, mousePosition.Y + offsetY); // 计算新窗口的位置
|
}
|
public InputBox()
|
{
|
InitializeComponent();
|
initPosition();
|
|
}
|
public InputBox(string txt,string content="")
|
{
|
|
InitializeComponent();
|
initPosition();
|
this.Text = txt;
|
this.textBox1.Text = content;
|
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
_DialogResult = DialogResult.OK;
|
this.Close();
|
|
}
|
private void button2_Click(object sender, EventArgs e)
|
{
|
_DialogResult = DialogResult.Cancel;
|
this.Close();
|
}
|
public new string ShowDialog()
|
{
|
|
base.ShowDialog();
|
if (_DialogResult == DialogResult.OK)
|
return textBox1.Text;
|
else
|
return null;
|
|
}
|
|
|
}
|
}
|