using SuperMap.Mapping;
using SuperMap.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
namespace WWPipeLine.MapBasic.Results
{
public partial class ResultWindow : ToolWindowExtend
{
/////
///// 存储参数
/////
//private SortedDictionary m_BaseParams = new SortedDictionary();
/////
///// 设置参数
/////
///// 参数名
///// 参数值
//public void SetParams(string key, object value)
//{
// if (m_BaseParams.ContainsKey(key))
// {
// return;
// }
// m_BaseParams.Add(key, value);
//}
//protected string SelectLayerNamelResultWindow
//{
// get
// {
// if (m_BaseParams.ContainsKey("SelectLayerNamelResultWindow"))
// return m_BaseParams["SelectLayerNamelResultWindow"] as string;
// return null;
// }
//}
//public string FindLayerName { get; set; }
///
/// 构造并初始化查询结果ResultWindow窗体
///
public ResultWindow()
{
InitializeComponent();
///关闭按钮可见、可用
this.CloseButtonVisible = true;
this.CloseButton = true;
this.DockAreas = DockAreas.DockLeft
| DockAreas.DockRight
| DockAreas.DockTop
| DockAreas.DockBottom
| DockAreas.Document
| DockAreas.Float;
}
///
/// 将DataGridView的数据导出至Excel
///
///
public void ExportToExcel(System.Windows.Forms.DataGridView dg)
{
if (dg == null) return;
var errMsg = Commons.ExportDgvToExcel.ExportExcel(string.Empty, dg, "雅黑", 14);
if (!string.IsNullOrEmpty(errMsg))
{
if (errMsg == Commons.ExportDgvToExcel.CANCELRESULTSTRING)
return;
else
Sunny.UI.UINotifier.Show(errMsg, Sunny.UI.UINotifierType.ERROR, "错误", false, 1000);
}
else
{
Sunny.UI.UINotifier.Show("导出成功", Sunny.UI.UINotifierType.OK, "消息", false, 1000);
}
}
///
/// 将Control导出至Image
///
///
public void ExportToImage(Control ctrl)
{
SaveFileDialog saveFileDialog = new SaveFileDialog
{
DefaultExt = "jpg",
Filter = "图片文件(*.jpg)|*.jpg",
RestoreDirectory = true,
Title = "图片文件保存路径"
};
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
Bitmap bmp = new Bitmap(ctrl.Width, ctrl.Height);
ctrl.DrawToBitmap(bmp, ctrl.ClientRectangle);
bmp.Save(saveFileDialog.FileName);
}
}
///
/// 显示数据非BasicToolBar 必须实现此方法
///
///
public virtual void ShowData(object data)
{
throw new Exception("未实现WWPipeLine.MapTools.Results.ResultWindow.ShowData");
}
///
/// 导出Excel按钮
///
protected Sunny.UI.UISymbolButton uiSymbolButtonExportToExcel;
///
/// 导出图片按钮
///
protected Sunny.UI.UISymbolButton uiSymbolButtonExportToImage;
///
/// 创建并添加,“导出到Excel”按钮
///
protected void CreateExportExcelButton()
{
this.uiSymbolButtonExportToExcel = new Sunny.UI.UISymbolButton
{
Cursor = System.Windows.Forms.Cursors.Hand,
Dock = System.Windows.Forms.DockStyle.Bottom,
Font = new System.Drawing.Font("微软雅黑", 12F),
Location = new System.Drawing.Point(0, 415),
MinimumSize = new System.Drawing.Size(1, 1),
Name = "uiSymbolButtonExportToExcel",
Size = new System.Drawing.Size(800, 20),
Symbol = 61582,
TabIndex = 0,
Style = Sunny.UI.UIStyle.Gray,
Text = "导出到Excel"
};
this.Controls.Add(this.uiSymbolButtonExportToExcel);
}
///
/// 创建并添加,“导出图片”和“导出到Excel”按钮
///
protected void CreateExportImageAndExcelButton()
{
Sunny.UI.UIPanel panel = new Sunny.UI.UIPanel
{
Dock = System.Windows.Forms.DockStyle.Bottom,
Height = 20
};
this.Controls.Add(panel);
this.uiSymbolButtonExportToExcel = new Sunny.UI.UISymbolButton
{
Dock = System.Windows.Forms.DockStyle.Fill,
Cursor = System.Windows.Forms.Cursors.Hand,
Font = new System.Drawing.Font("微软雅黑", 12F),
Location = new System.Drawing.Point(0, 415),
MinimumSize = new System.Drawing.Size(1, 1),
Name = "uiSymbolButtonExportToExcel",
Size = new System.Drawing.Size(800, 20),
Symbol = 61582,
TabIndex = 0,
Style = Sunny.UI.UIStyle.Gray,
Text = "导出到Excel",
RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None,
RadiusSides = Sunny.UI.UICornerRadiusSides.None
};
panel.Controls.Add(this.uiSymbolButtonExportToExcel);
this.uiSymbolButtonExportToImage = new Sunny.UI.UISymbolButton
{
Dock = System.Windows.Forms.DockStyle.Left,
Cursor = System.Windows.Forms.Cursors.Hand,
Font = new System.Drawing.Font("微软雅黑", 12F),
Location = new System.Drawing.Point(0, 415),
MinimumSize = new System.Drawing.Size(1, 1),
Name = "uiSymbolButtonExportToImage",
Size = new System.Drawing.Size(800, 20),
Symbol = 61893,
TabIndex = 1,
Style = Sunny.UI.UIStyle.Gray,
Text = "导出图片",
RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None,
RadiusSides = Sunny.UI.UICornerRadiusSides.None
};
panel.Controls.Add(this.uiSymbolButtonExportToImage);
this.SizeChanged += ResultWindow_SizeChanged;
}
///
/// 窗体发生变化时候按钮自动缩放
///
///
///
private void ResultWindow_SizeChanged(object sender, EventArgs e)
{
uiSymbolButtonExportToExcel.Width = this.Width / 2;
uiSymbolButtonExportToImage.Width = this.Width / 2;
}
private void ResultWindow_FormClosing(object sender, FormClosingEventArgs e)
{
ComsStatic.MapControl.Map.TrackingLayer.Clear();
ComsStatic.MapControl.Map.Refresh();
//this.MapControlResultWindow.Map.TrackingLayer.Clear();
//this.MapControlResultWindow.Map.Refresh();
}
}
}