123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- 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;
- using IntelligentControlForsx.Service;
- using IntelligentControlForsx.Template;
- using log4net;
- using IntelligentControlForsx.MyControls.zm.map;
- namespace IntelligentControlForsx.ChildForms
- {
- public partial class MapForm : TemplateForm
- {
- public MapForm()
- {
- InitializeComponent();
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
- SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.UpdateStyles();
- // 动态添加控件和关联事件
- // 自定义label title
- this.lbTitle.AutoSize = true;
- this.lbTitle.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.lbTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(184)))), ((int)(((byte)(250)))));
- this.lbTitle.Location = new System.Drawing.Point(3, 11);
- this.lbTitle.Name = "lbTitle";
- this.lbTitle.Size = new System.Drawing.Size(138, 22);
- this.lbTitle.TabIndex = 1;
- this.lbTitle.Text = "风机排布图";
- Init();
- }
- Label lbTitle = new Label();// title
- Dictionary<int, MapControl> dicProjectMap = new Dictionary<int, MapControl>();
- int currentIndex = 1;//第几期工程图
- string currentStationID = "";
- private static ILog logger = LogManager.GetLogger("AppInfoLog");
- private Label cashLabel = null;
- private void Init()
- {
- if (dicProjectMap.ContainsKey(currentIndex))
- {
- dicProjectMap[currentIndex].DeActive();
- }
- flowLayout.Controls.Clear();// TOP
- dicProjectMap.Clear();
- plCenter.Controls.Clear();//Center
-
- flowLayout.Controls.Add(lbTitle);
- currentStationID = NavService.Instance.StationId;
- // 自定义项目数量项目一...
- switch (NavService.Instance.StationId)
- {
- #region 根据风机站的ID动态创建对应的控件
- case "NSS_FDC"://牛首山
- {
- #region 牛首山相关控件
- this.Text = "牛首山风机排布图";
- this.lbTitle.Text = "牛首山风机排布图";
- flowLayout.Controls.Add(this.lbTitle);
- NSS_Project1 p1 = new NSS_Project1();
- NSS_Project2 p2 = new NSS_Project2();
- NSS_Project3 p3 = new NSS_Project3();
- dicProjectMap.Add(1, p1);
- dicProjectMap.Add(2, p2);
- dicProjectMap.Add(3, p3);
- Panel pal1 = new Panel();
- Panel pal2 = new Panel();
- Panel pal3 = new Panel();
- Label lb1 = new Label();
- Label lb2 = new Label();
- Label lb3 = new Label();
- lb1.Text = "一 期";
- lb1.Tag = 1;
- lb2.Text = "二 期";
- lb2.Tag = 2;
- lb3.Text = "三 期";
- lb3.Tag = 3;
- pal1.Controls.Add(lb1);
- pal2.Controls.Add(lb2);
- pal3.Controls.Add(lb3);
- flowLayout.Controls.Add(pal1);
- flowLayout.Controls.Add(pal2);
- flowLayout.Controls.Add(pal3);
- #endregion
- }
- break;
- case "SBQ_FDC"://石板泉
- {
- #region
- this.Text = "石板泉风机排布图";
- this.lbTitle.Text = "石板泉风机排布图";
- flowLayout.Controls.Add(this.lbTitle);
- SBQ_Project1 p1 = new SBQ_Project1();
- SBQ_Project2 p2 = new SBQ_Project2();
- SBQ_Project3 p3 = new SBQ_Project3();
- SBQ_Project4 p4 = new SBQ_Project4();
- dicProjectMap.Add(1, p1);
- dicProjectMap.Add(2, p2);
- dicProjectMap.Add(3, p3);
- dicProjectMap.Add(4, p4);
- Panel pal1 = new Panel();
- Panel pal2 = new Panel();
- Panel pal3 = new Panel();
- Panel pal4 = new Panel();
- Label lb1 = new Label();
- Label lb2 = new Label();
- Label lb3 = new Label();
- Label lb4 = new Label();
- lb1.Text = "一 期";
- lb1.Tag = 1;
- lb2.Text = "二 期";
- lb2.Tag = 2;
- lb3.Text = "三 期";
- lb3.Tag = 3;
- lb4.Text = "四 期";
- lb4.Tag = 4;
- pal1.Controls.Add(lb1);
- pal2.Controls.Add(lb2);
- pal3.Controls.Add(lb3);
- pal4.Controls.Add(lb4);
- flowLayout.Controls.Add(pal1);
- flowLayout.Controls.Add(pal2);
- flowLayout.Controls.Add(pal3);
- flowLayout.Controls.Add(pal4);
- #endregion
- }
- break;
- case "MHS_FDC"://麻黄山
- {
- #region
- this.Text = "麻黄山风机排布图";
- this.lbTitle.Text = "麻黄山风机排布图";
- flowLayout.Controls.Add(this.lbTitle);
- MHS_Project1 p1 = new MHS_Project1();
- MHS_Project2 p2 = new MHS_Project2();
- dicProjectMap.Add(1, p1);
- dicProjectMap.Add(2, p2);
- Panel pal1 = new Panel();
- Panel pal2 = new Panel();
- Label lb1 = new Label();
- Label lb2 = new Label();
- lb1.Text = "一 期";
- lb1.Tag = 1;
- lb2.Text = "二 期";
- lb2.Tag = 2;
- pal1.Controls.Add(lb1);
- pal2.Controls.Add(lb2);
- flowLayout.Controls.Add(pal1);
- flowLayout.Controls.Add(pal2);
- #endregion
- }
- break;
- case "QS_FDC"://青山
- {
- #region
- this.Text = "青山风机排布图";
- this.lbTitle.Text = "青山风机排布图";
- flowLayout.Controls.Add(this.lbTitle);
- QS_Project1 p1 = new QS_Project1();
- QS_Project2 p2 = new QS_Project2();
- dicProjectMap.Add(1, p1);
- dicProjectMap.Add(2, p2);
- Panel pal1 = new Panel();
- Panel pal2 = new Panel();
- Label lb1 = new Label();
- Label lb2 = new Label();
- lb1.Text = "一 期";
- lb1.Tag = 1;
- lb2.Text = "二 期";
- lb2.Tag = 2;
- pal1.Controls.Add(lb1);
- pal2.Controls.Add(lb2);
- flowLayout.Controls.Add(pal1);
- flowLayout.Controls.Add(pal2);
- #endregion
- }
- break;
- case "XS_FDC"://香山
- {
- #region
- this.Text = "青山风机排布图";
- this.lbTitle.Text = "青山风机排布图";
- flowLayout.Controls.Add(this.lbTitle);
- XS_Project1 p1 = new XS_Project1();
- XS_Project2 p2 = new XS_Project2();
- dicProjectMap.Add(1, p1);
- dicProjectMap.Add(2, p2);
- Panel pal1 = new Panel();
- Panel pal2 = new Panel();
- Label lb1 = new Label();
- Label lb2 = new Label();
- lb1.Text = "一 期";
- lb1.Tag = 1;
- lb2.Text = "二 期";
- lb2.Tag = 2;
- pal1.Controls.Add(lb1);
- pal2.Controls.Add(lb2);
- flowLayout.Controls.Add(pal1);
- flowLayout.Controls.Add(pal2);
- #endregion
- }
- break;
- default:
- {
- currentIndex = 1;
- return;
- }
- #endregion
- }
- currentIndex = 1;
- #region 顶部标题样式设置
- foreach (var c in flowLayout.Controls)
- {
- if (c is Panel)
- {
- Panel panel = c as Panel;
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(184)))), ((int)(((byte)(250)))));
- panel.Location = new System.Drawing.Point(260, 1);
- panel.Name = "panel4";
- panel.Size = new System.Drawing.Size(80, 36);
- #region 多期工程标题样式设置
- foreach (var l in panel.Controls)
- {
- if (l is Label)
- {
- Label la = l as Label;
- la.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- if ((int)la.Tag == currentIndex)
- {
- la.ForeColor = Color.FromArgb(15, 45, 74);
- la.BackColor = Color.FromArgb(48, 184, 250);
- cashLabel = la;
- }
- else
- {
- la.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(184)))), ((int)(((byte)(250)))));
- la.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(45)))), ((int)(((byte)(74)))));
- }
- la.Location = new System.Drawing.Point(1, 1);
- la.Size = new System.Drawing.Size(78, 34);
-
- la.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- la.Click += new System.EventHandler(this.lblProject_Click);
- la.MouseEnter += new System.EventHandler(this.lblProject_MouseEnter);
- la.MouseLeave += new System.EventHandler(this.lblProject_MouseLeave);
- }
- }
- #endregion
- }
- }
- #endregion
- #region 中间地图模块的样式设置
- foreach (MapControl c in dicProjectMap.Values)// 设置map控件的属性
- {
- c.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- c.Location = new System.Drawing.Point(1, 1);
- c.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- c.Size = new System.Drawing.Size(1918, 926);
- }
- #endregion
- // 将项目一展示出来
- if (dicProjectMap.Count>0&&dicProjectMap[currentIndex] !=null)//
- {
- plCenter.Hide();
- plCenter.Controls.Add(dicProjectMap[currentIndex]);
- dicProjectMap[currentIndex].Active();
- plCenter.Show();
- }
- }
- public override void Active()
- {
- // 此处切换
- if (NavService.Instance.StationId == currentStationID)
- {
- this.Show();
- }
- else
- {
- Init();
- this.Show();
- }
- }
- public override void DeActive()
- {
- foreach (MapControl c in dicProjectMap.Values)
- {
- c.DeActive();
- }
- this.Hide();
- }
- private void lblProject_Click(object sender, EventArgs e)
- {
- Label currentLabel = (Label)sender;
- int pointIndex =(int) currentLabel.Tag;
- if(pointIndex== currentIndex)
- {
- return;
- }
- cashLabel.BackColor = Color.FromArgb(15, 45, 74);
- cashLabel.ForeColor = Color.FromArgb(48, 184, 250);
- cashLabel = currentLabel;
- if (dicProjectMap.ContainsKey(currentIndex))
- {
- plCenter.Hide();
- dicProjectMap[currentIndex].DeActive();
- plCenter.Controls.Clear();
- plCenter.Controls.Add(dicProjectMap[pointIndex]);
- currentIndex = pointIndex;
- dicProjectMap[pointIndex].Active();
- plCenter.Show();
- }
- }
- private void lblProject_MouseEnter(object sender, EventArgs e)
- {
- if (!this.DesignMode)
- {
- Label currentLabel = (Label)sender;
- int pointIndex = (int)currentLabel.Tag;
- if (pointIndex != currentIndex)
- {
- currentLabel.ForeColor = Color.FromArgb(15, 45, 74);
- currentLabel.BackColor = Color.FromArgb(48, 184, 250);
- }
- }
- }
- private void lblProject_MouseLeave(object sender, EventArgs e)
- {
- if (!this.DesignMode)
- {
- Label currentLabel = (Label)sender;
- int pointIndex = (int)currentLabel.Tag;
- if (pointIndex != currentIndex)
- {
- currentLabel.BackColor = Color.FromArgb(15, 45, 74);
- currentLabel.ForeColor = Color.FromArgb(48, 184, 250);
- }
- }
- }
- private void btnReturn_Click(object sender, EventArgs e)
- {
- NavService.Instance.StationId = currentStationID;
- NavService.Instance.Nav("ZMForm", (MainWindow)this.Parent.Parent);
-
- }
- public override void SelectedStationChanged(string stationId)
- {
- NavService.Instance.StationId = stationId;
- if (currentStationID == NavService.Instance.StationId)
- {
- this.Show();
- return;
- }
- else
- {
- Init();
- this.Show();
- }
- }
- }
- }
|