using SuperMap.UI;
using System;
using System.IO;
using System.Windows.Forms;
namespace WWPipeLine.MapBasic.Conditions
{
public class BasicToolBar : ConditionPanel
{
///
/// 工具条关闭按钮
///
private Sunny.UI.UISymbolButton uiSymbolButtonClose;
///
/// 操作说明
///
public ToolStripLabel toolStripLB;
private ToolStripSeparator toolStripSeparator1;
///
/// 工具条ToolStrip对象
///
private ToolStrip m_ToolStrip;
///
/// 工具条ToolStrip对象
///
protected ToolStrip ToolStrip { get => m_ToolStrip; }
///
/// 释放资源时统一释放对应的MapOperInterface对象
///
///
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
///
/// 默认的漫游按钮
///
private ToolStripButton toolStripButtonPan;
///
/// 默认的选择按钮
///
private ToolStripButton toolStripButtonSelect;
///
/// 默认的清除按钮
///
private ToolStripButton toolStripButtonClear;
///
/// 默认的图层选择框
///
public ToolStripComboBox toolStripComboBoxLayer;
public bool IsShowToolStripComboBox = false;
///
/// 构造函数
///
protected BasicToolBar()
{
InitializeComponent();
this.ParentChanged += BasicToolBar_ParentChanged;
string img1 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\漫游.png";
string img2 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\选择.png";
string img3 = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\清除.png";
if (System.IO.File.Exists(img1))
this.toolStripButtonPan.Image = System.Drawing.Image.FromFile(img1);
if (System.IO.File.Exists(img2))
this.toolStripButtonSelect.Image = System.Drawing.Image.FromFile(img2);
if (System.IO.File.Exists(img3))
this.toolStripButtonClear.Image = System.Drawing.Image.FromFile(img3);
this.toolStripButtonPan.Click += ToolStripButtonPan_Click;
this.toolStripButtonSelect.Click += ToolStripButtonSelect_Click;
this.toolStripButtonClear.Click += ToolStripButtonClear_Click;
this.uiSymbolButtonClose.Click += UiSymbolButtonClose_Click;
}
protected override void OnLoad(EventArgs e)
{
if (IsShowToolStripComboBox)
{
this.toolStripComboBoxLayer.Visible = true;
toolStripComboBoxLayer.ComboBox.ValueMember = "LayerDatasetName";
toolStripComboBoxLayer.ComboBox.DisplayMember = "LayerCaption";
toolStripComboBoxLayer.ComboBox.DataSource = ComsStatic.getLayers();
}
}
///
/// 关闭父窗口时关闭对应的结果窗口
///
///
///
private void BasicToolBar_ParentChanged(object sender, EventArgs e)
{
if (this.Parent == null)
{
if (this.m_ResultWindow != null)
{
this.m_ResultWindow.Close();
}
}
}
///
/// 点击关闭按钮关闭
///
///
///
private void UiSymbolButtonClose_Click(object sender, EventArgs e)
{
CloseToolBar();
}
protected void CloseToolBar()
{
this.Parent.Controls.Remove(this);
AfterClose();
this.m_ResultWindow?.Close();
}
///
/// 给当前ToolStrip增加“保存标注”按钮及其单击事件
///
protected void Item_add_BiaoZhuSave()
{
var bzSave = new ToolStripButton()
{
DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
Text = "保存标注",
Name = "StartDraw",
AutoToolTip = false
};
var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\保存标注.png";
if (System.IO.File.Exists(img))
bzSave.Image = System.Drawing.Image.FromFile(img);
m_ToolStrip.Items.Add(bzSave);
bzSave.Click += BzSave_Click;
}
private void BzSave_Click(object sender, EventArgs e)
{
Sunny.UI.UIMessageTip.ShowError("未实现功能");
}
private void ToolStripButtonSelect_Click(object sender, EventArgs e)
{
MapControl.Action = SuperMap.UI.Action.Pan;
MapControl.Action = SuperMap.UI.Action.Select;
}
private void ToolStripButtonPan_Click(object sender, EventArgs e)
{
MapControl.Action = SuperMap.UI.Action.Pan;
}
private void ToolStripButtonClear_Click(object sender, EventArgs e)
{
MapControl.Map.TrackingLayer.Clear();
MapControl.Action = SuperMap.UI.Action.Pan;
MapControl.Map.Refresh();
}
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BasicToolBar));
this.m_ToolStrip = new System.Windows.Forms.ToolStrip();
this.toolStripButtonPan = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonSelect = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonClear = new System.Windows.Forms.ToolStripButton();
this.toolStripLB = new System.Windows.Forms.ToolStripLabel();
this.toolStripComboBoxLayer = new System.Windows.Forms.ToolStripComboBox();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.uiSymbolButtonClose = new Sunny.UI.UISymbolButton();
this.m_ToolStrip.SuspendLayout();
this.SuspendLayout();
//
// m_ToolStrip
//
this.m_ToolStrip.Dock = System.Windows.Forms.DockStyle.Fill;
this.m_ToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButtonPan,
this.toolStripButtonSelect,
this.toolStripButtonClear,
this.toolStripLB,
this.toolStripComboBoxLayer,
this.toolStripSeparator1});
this.m_ToolStrip.Location = new System.Drawing.Point(0, 0);
this.m_ToolStrip.Name = "m_ToolStrip";
this.m_ToolStrip.Padding = new System.Windows.Forms.Padding(0);
this.m_ToolStrip.Size = new System.Drawing.Size(591, 28);
this.m_ToolStrip.TabIndex = 0;
this.m_ToolStrip.Text = "toolStrip";
//
// toolStripButtonPan
//
this.toolStripButtonPan.AutoToolTip = false;
this.toolStripButtonPan.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonPan.Image")));
this.toolStripButtonPan.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonPan.Name = "toolStripButtonPan";
this.toolStripButtonPan.Size = new System.Drawing.Size(52, 25);
this.toolStripButtonPan.Text = "漫游";
this.toolStripButtonPan.ToolTipText = "漫游";
//
// toolStripButtonSelect
//
this.toolStripButtonSelect.AutoToolTip = false;
this.toolStripButtonSelect.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSelect.Image")));
this.toolStripButtonSelect.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonSelect.Name = "toolStripButtonSelect";
this.toolStripButtonSelect.Size = new System.Drawing.Size(52, 25);
this.toolStripButtonSelect.Text = "选择";
//
// toolStripButtonClear
//
this.toolStripButtonClear.AutoToolTip = false;
this.toolStripButtonClear.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonClear.Image")));
this.toolStripButtonClear.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonClear.Name = "toolStripButtonClear";
this.toolStripButtonClear.Size = new System.Drawing.Size(52, 25);
this.toolStripButtonClear.Text = "清除";
//
// toolStripLB
//
this.toolStripLB.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripLB.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.toolStripLB.Name = "toolStripLB";
this.toolStripLB.Size = new System.Drawing.Size(24, 25);
this.toolStripLB.Text = " ";
//
// toolStripComboBoxLayer
//
this.toolStripComboBoxLayer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.toolStripComboBoxLayer.Name = "toolStripComboBoxLayer";
this.toolStripComboBoxLayer.Size = new System.Drawing.Size(121, 28);
this.toolStripComboBoxLayer.Visible = false;
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 28);
//
// uiSymbolButtonClose
//
this.uiSymbolButtonClose.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiSymbolButtonClose.Dock = System.Windows.Forms.DockStyle.Right;
this.uiSymbolButtonClose.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
this.uiSymbolButtonClose.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165)))));
this.uiSymbolButtonClose.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
this.uiSymbolButtonClose.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
this.uiSymbolButtonClose.Font = new System.Drawing.Font("微软雅黑 Light", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButtonClose.Location = new System.Drawing.Point(563, 0);
this.uiSymbolButtonClose.Margin = new System.Windows.Forms.Padding(5);
this.uiSymbolButtonClose.MinimumSize = new System.Drawing.Size(1, 1);
this.uiSymbolButtonClose.Name = "uiSymbolButtonClose";
this.uiSymbolButtonClose.Radius = 10;
this.uiSymbolButtonClose.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
this.uiSymbolButtonClose.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(160)))), ((int)(((byte)(165)))));
this.uiSymbolButtonClose.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
this.uiSymbolButtonClose.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(121)))), ((int)(((byte)(123)))), ((int)(((byte)(129)))));
this.uiSymbolButtonClose.Size = new System.Drawing.Size(28, 28);
this.uiSymbolButtonClose.Style = Sunny.UI.UIStyle.Gray;
this.uiSymbolButtonClose.Symbol = 61453;
this.uiSymbolButtonClose.SymbolSize = 16;
this.uiSymbolButtonClose.TabIndex = 1;
this.uiSymbolButtonClose.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BasicToolBar
//
this.Controls.Add(this.uiSymbolButtonClose);
this.Controls.Add(this.m_ToolStrip);
this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
this.Name = "BasicToolBar";
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
this.Size = new System.Drawing.Size(591, 28);
this.Style = Sunny.UI.UIStyle.Gray;
this.m_ToolStrip.ResumeLayout(false);
this.m_ToolStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
}
}