123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- using SuperMap.UI;
- using System;
- using System.IO;
- using System.Windows.Forms;
- namespace WWPipeLine.MapBasic.Conditions
- {
- public class BasicToolBar : ConditionPanel
- {
- /// <summary>
- /// 工具条关闭按钮
- /// </summary>
- private Sunny.UI.UISymbolButton uiSymbolButtonClose;
- /// <summary>
- /// 操作说明
- /// </summary>
- public ToolStripLabel toolStripLB;
- private ToolStripSeparator toolStripSeparator1;
- /// <summary>
- /// 工具条ToolStrip对象
- /// </summary>
- private ToolStrip m_ToolStrip;
- /// <summary>
- /// 工具条ToolStrip对象
- /// </summary>
- protected ToolStrip ToolStrip { get => m_ToolStrip; }
- /// <summary>
- /// 释放资源时统一释放对应的MapOperInterface对象
- /// </summary>
- /// <param name="disposing"></param>
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- }
- /// <summary>
- /// 默认的漫游按钮
- /// </summary>
- private ToolStripButton toolStripButtonPan;
- /// <summary>
- /// 默认的选择按钮
- /// </summary>
- private ToolStripButton toolStripButtonSelect;
- /// <summary>
- /// 默认的清除按钮
- /// </summary>
- private ToolStripButton toolStripButtonClear;
- /// <summary>
- /// 默认的图层选择框
- /// </summary>
- public ToolStripComboBox toolStripComboBoxLayer;
- public bool IsShowToolStripComboBox = false;
- /// <summary>
- /// 构造函数
- /// </summary>
- 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();
- }
- }
- /// <summary>
- /// 关闭父窗口时关闭对应的结果窗口
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BasicToolBar_ParentChanged(object sender, EventArgs e)
- {
- if (this.Parent == null)
- {
- if (this.m_ResultWindow != null)
- {
- this.m_ResultWindow.Close();
- }
- }
- }
- /// <summary>
- /// 点击关闭按钮关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void UiSymbolButtonClose_Click(object sender, EventArgs e)
- {
- CloseToolBar();
- }
- protected void CloseToolBar()
- {
- this.Parent.Controls.Remove(this);
- AfterClose();
- this.m_ResultWindow?.Close();
- }
- /// <summary>
- /// 给当前ToolStrip增加“保存标注”按钮及其单击事件
- /// </summary>
- 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();
- }
- }
- }
|