123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using IntelligentControlForsx.ChildForms;
- using IntelligentControlForsx.MyControls;
- using IntelligentControlForsx.Template;
- namespace IntelligentControlForsx.Service
- {
- public class NavService
- {
- private TemplateForm currentForm;
- //原标题
- //public static Title title = null;
- //仅风机控制页标题
- public static Title title = null;
- public static Bottom projectBottom = null;
- public static Bottom2 projectBottom2 = null;
- public Dictionary<String, TemplateForm> dictForm;
- private static MainWindow projectMDIParentForm = null;
- private NavService()
- {
- dictForm = new Dictionary<string, TemplateForm>();
- dictForm.Add("pictureBoxStatistics", null);
- dictForm.Add("pictureBoxMainParam", null);
- dictForm.Add("pictureBoxHome", null);
- dictForm.Add("pictureBoxMatrix", null);
- dictForm.Add("pictureBoxControl", null);
- dictForm.Add("pictureBoxParamters", null);
- dictForm.Add("pictureBoxElectrical", null);
- dictForm.Add("pictureBoxFault", null);
- dictForm.Add("pictureBoxAGC", null);
- dictForm.Add("pictureBoxSYZ", null);
- dictForm.Add("ZMForm", null);
- dictForm.Add("MapForm", null);
- }
- public static NavService Instance
- {
- get { return SingletonCreator.instance; }
- }
- class SingletonCreator
- {
- internal static readonly NavService instance = new NavService();
- }
- public List<TemplateForm> GetAllForm()
- {
- return new List<TemplateForm>();
- }
- public void Nav(String formName, MainWindow mdiParentForm)
- {
- if (String.IsNullOrWhiteSpace(formName))
- return;
- if (projectMDIParentForm == null)
- projectMDIParentForm = mdiParentForm;
- if (dictForm.ContainsKey(formName))
- {
- TemplateForm form = dictForm[formName];
- if (form == null)
- {
- form = CreateForm(formName, mdiParentForm);
- dictForm[formName] = form;
- }
- Nav(form, mdiParentForm);
- }
- }
- private string stationId = "SBQ_FDC";
- public string StationId
- {
- get
- {
- return stationId;
- }
- set
- {
- stationId = value;
- }
- }
- public void StationSelectedChanged(String stationId)
- {
- this.stationId = stationId;
- if (currentForm != null)
- currentForm.SelectedStationChanged(stationId);
- }
- private TemplateForm CreateForm(String formName, MainWindow mdiParentForm)
- {
- if (projectMDIParentForm == null)
- projectMDIParentForm = mdiParentForm;
- TemplateForm form = null;
- switch (formName)
- {
- case "pictureBoxHome":
- form = new HomeForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxMatrix":
- form = new MatrixForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxStatistics":
- form = new StatForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxMainParam":
- form = new ParamsForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxParamters":
- form = new WindturbineForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- //case "pictureBoxControl":
- // //form = new ControlForm2();
- // //form.MdiParent = mdiParentForm;
- // //form.Parent = mdiParentForm.panel1;
- // //form.Dock = DockStyle.Fill;
- // form = new CleverControlForm();
- // form.MdiParent = mdiParentForm;
- // form.Parent = mdiParentForm.panel1;
- // form.Dock = DockStyle.Fill;
- // break;
- case "pictureBoxSYZ":
- form = new ElectricalForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxFault":
- form = new AlarmForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "pictureBoxAGC":
- form = new AGCForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- break;
- case "ZMForm":
- {
- form = new ZMForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- //form = new ZMForm();
- //form.MdiParent = mdiParentForm;
- //form.Parent = mdiParentForm.panel1;
- //form.Dock = DockStyle.Fill;
- }
- break;
- case "MapForm":
- {
- form = new MapForm();
- //form = new MapForm();
- form.MdiParent = mdiParentForm;
- form.Parent = mdiParentForm.panel1;
- form.Dock = DockStyle.Fill;
- }
- break;
- default:
- break;
- }
- return form;
- }
- private void Nav(TemplateForm form, MainWindow mdiParent)
- {
- if (currentForm != null)
- currentForm.DeActive();
- form.Active();
- currentForm = form;
- }
- //提供从风场总貌图 风机跳转到风机参数页面
- public void NavForWindturbine(String formName, string windturbineId, string stationId)
- {
- this.stationId = stationId;
- if (projectBottom != null)
- projectBottom.StationChange(stationId);
- if (String.IsNullOrWhiteSpace(formName))
- return;
- if (dictForm.ContainsKey(formName))
- {
- TemplateForm form = dictForm[formName];
- if (form == null)
- {
- if (projectMDIParentForm != null)
- {
- form = CreateForm(formName, projectMDIParentForm);
- dictForm[formName] = form;
- }
- }
- WindturbineForm fm = (WindturbineForm)form;
- fm.SetNowWindturbineId(windturbineId, stationId);
- Nav(form, projectMDIParentForm);
- if (title != null)
- {
- title.StyleImgChange("pictureBoxParamters");
- }
- }
- }
- public void NavForMap(string formName, string stationId)
- {
- if (String.IsNullOrWhiteSpace(formName))
- return;
- if (dictForm.ContainsKey(formName))
- {
- TemplateForm form = dictForm[formName];
- if (form == null)
- {
- if (projectMDIParentForm != null)
- {
- form = CreateForm(formName, projectMDIParentForm);
- dictForm[formName] = form;
- }
- }
- NavService.Instance.StationId = stationId;
- MapForm fm = form as MapForm;
- Nav(form, projectMDIParentForm);
- }
- }
- public void NavForElectrical(string formName, string StationId)
- {
- if (title != null)
- title.StyleImgChange("pictureBoxSYZ");
- if (String.IsNullOrWhiteSpace(formName))
- return;
- if (dictForm.ContainsKey(formName))
- {
- TemplateForm form = dictForm[formName];
- if (form == null)
- {
- if (projectMDIParentForm != null)
- {
- form = CreateForm(formName, projectMDIParentForm);
- dictForm[formName] = form;
- }
- }
- try
- {
- ElectricalForm eForm = (ElectricalForm)form;
- eForm.StationId = stationId;
- }
- catch (Exception ex)
- {
- throw;
- }
- finally
- {
- Nav(form, projectMDIParentForm);
- }
- }
- }
- }
- }
|