using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmDiameterQuery : Office2007Form { GSOGlobeControl globeControl1; List<string> layerNames = new List<string>(); int value; static FrmDiameterQuery frm; DataTable table = new DataTable(); string strLable = ""; private MainFrm.DataGridViewDelegate m_InitDataGridViewX1; public static void ShowForm(GSOGlobeControl _ctl, List<string> _list, MainFrm.DataGridViewDelegate InitDataGridViewX1) { if (frm == null) { frm = new FrmDiameterQuery(_ctl, _list, InitDataGridViewX1); frm.Show(_ctl.Parent); } else { if (frm.WindowState == FormWindowState.Minimized) { frm.WindowState = FormWindowState.Normal; } } } public FrmDiameterQuery(GSOGlobeControl _ctl, List<string> _list, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); globeControl1 = _ctl; layerNames = _list; m_InitDataGridViewX1 = InitDataGridViewX1; } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmDiameterSel_Load(object sender, EventArgs e) { for (int i = 0; i < layerNames.Count; i++) { comboBoxEx1.Items.Add(layerNames[i]); } value = comboBoxEx2.Location.X - textBoxX2.Location.X; textBoxX2.Visible = false; textBoxX2.Text = ""; labelX4.Visible = false; if (!isBetween) { textBoxX1.Location = new Point(textBoxX1.Location.X - value, textBoxX1.Location.Y); labelX3.Location = new Point(labelX3.Location.X - value, textBoxX1.Location.Y); comboBoxEx2.Location = new Point(comboBoxEx2.Location.X - value, comboBoxEx2.Location.Y); isBetween = true; } comboBoxEx2.Items.Clear(); comboBoxEx2.Items.Add(">"); comboBoxEx2.Items.Add("<"); comboBoxEx2.Items.Add("="); comboBoxEx2.Items.Add("区间"); } /// <summary> /// 键盘按键按下事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxX1_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8) { e.Handled = true;//屏蔽 } } bool isBetween; /// <summary> /// 下拉框选中项改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxEx2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEx2.SelectedIndex == 3) { textBoxX2.Visible = true; labelX4.Visible = true; if (isBetween) { textBoxX1.Location = new Point(textBoxX1.Location.X + value, textBoxX1.Location.Y); labelX3.Location = new Point(labelX3.Location.X + value, textBoxX1.Location.Y); comboBoxEx2.Location = new Point(comboBoxEx2.Location.X + value, comboBoxEx2.Location.Y); isBetween = false; } } else { textBoxX2.Visible = false; textBoxX2.Text = ""; labelX4.Visible = false; if (!isBetween) { textBoxX1.Location = new Point(textBoxX1.Location.X - value, textBoxX1.Location.Y); labelX3.Location = new Point(labelX3.Location.X - value, textBoxX1.Location.Y); comboBoxEx2.Location = new Point(comboBoxEx2.Location.X - value, comboBoxEx2.Location.Y); isBetween = true; } } } /// <summary> /// 确定按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX1_Click(object sender, EventArgs e) { if (comboBoxEx1.SelectedIndex == -1) { MessageBox.Show("请选择管线图层!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); return; } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.Text.Trim()); if (layer == null || textBoxX1.Text == "" || (textBoxX2.Visible && textBoxX2.Text == "")) { MessageBox.Show("请输入管径范围!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (textBoxX2.Visible && textBoxX2.Text != "") { try { if (Convert.ToInt32(textBoxX2.Text) > Convert.ToInt32(textBoxX1.Text)) { MessageBox.Show("管径范围最小值大于最大值,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { //LogError.PublishError(ex); // LogHelper.WriteLog(typeof(FrmDiameterQuery), ex.Message); LogHelper.Error(ex.Message); MessageBox.Show("请输入正确的管径范围!"); return; } } string mathT = comboBoxEx2.SelectedItem.ToString(); ClassSearchAnalysis.ResultDataTable(out table, globeControl1, comboBoxEx1.Text, "管径_毫米", mathT, textBoxX2.Text, textBoxX1.Text); if (table!=null && table.Rows.Count>0) { strLable=comboBoxEx1.Text+" 共有:" + table.Rows.Count + "条"; m_InitDataGridViewX1(table,strLable,comboBoxEx1.Text,true); } else { MessageBox.Show("没有查到符合条件的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// <summary> /// 取消按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX3_Click(object sender, EventArgs e) { Close(); } /// <summary> /// 窗体关闭事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmDiameterQuery_FormClosing(object sender, FormClosingEventArgs e) { m_InitDataGridViewX1(table, strLable, "", false); frm = null; } } }