123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using DevExpress.XtraBars;
- 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 DevExpress.XtraBars.Docking2010.Views;
- using XdCxRhDW.App.UserControl;
- using DevExpress.XtraBars.Ribbon;
- using System.Threading;
- using XdCxRhDw.CpuCgTools;
- using DevExpress.XtraEditors;
- using ExtensionsDev;
- using DevExpress.XtraBars.Forms;
- using XdCxRhDW.App.CorTools;
- using XdCxRhDW.App.EFContext;
- using System.Data.Entity;
- namespace XdCxRhDW
- {
- public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
- {
- Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
- public MainForm()
- {
- InitializeComponent();
- ribbon.UseDefault();
- tabbedView1.UseDefault();
- ctrlTypes.Add("任务管理", typeof(CtrlHome));
- ctrlTypes.Add("参估结果", typeof(CtrlCgRes));
- ctrlTypes.Add("测向结果", typeof(CtrlCxRes));
- ctrlTypes.Add("定位结果", typeof(CtrlPosRes));
- ctrlTypes.Add("星历管理", typeof(CtrlXl));
- ctrlTypes.Add("天线管理", typeof(CtrlTx));
- ctrlTypes.Add("卫星管理", typeof(CtrlSat));
- ctrlTypes.Add("系统设置", typeof(CtrlSysSettings));
- ctrlTypes.Add("参估工具", typeof(CorToolForm));
- btn_ItemClick(null, null);
- }
- private void btn_ItemClick(object sender, ItemClickEventArgs e)
- {
- var btnTxt = e?.Item?.Caption ?? "任务管理";
- BaseDocument doc = null;
- doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
- if (doc == null)
- {
- doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
- if (doc.Control is Form form)
- {
- form.Text = "";
- doc.Caption = btnTxt;
- }
- if (btnTxt == "任务管理")
- doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False;
- else
- doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True;
- }
- tabbedView1.ActivateDocument(doc.Control);
- }
- protected override void OnFormClosing(FormClosingEventArgs e)
- {
- if (e.CloseReason == CloseReason.UserClosing)
- {
- if (!DxHelper.MsgBoxHelper.ShowConfirm("确定要退出当前系统吗?"))
- {
- e.Cancel = true;
- return;
- }
- }
- Application.Exit();
- }
- private async void btnOpenApi_ItemClick(object sender, ItemClickEventArgs e)
- {
- using (RHDWContext db = new RHDWContext())
- {
- var settings = await db.SysSetings.FirstOrDefaultAsync();
- if (settings == null)
- {
- DxHelper.MsgBoxHelper.ShowWarning($"请在系统设置中配置IP地址和Http端口");
- return;
- }
- if (string.IsNullOrEmpty(settings.ServerIp))
- {
- DxHelper.MsgBoxHelper.ShowWarning($"请在系统设置中配置IP地址和Http端口");
- return;
- }
- if (settings.HttpPort<1)
- {
- DxHelper.MsgBoxHelper.ShowWarning($"请在系统设置中配置IP地址和Http端口");
- return;
- }
- string addr = $"http://{settings.ServerIp}:{settings.HttpPort}/swagger";
- try
- {
- System.Diagnostics.Process.Start(addr);
- }
- catch
- {
- db.Dispose();
- DxHelper.MsgBoxHelper.ShowError($"无法打开默认浏览器,请手动查看接口文档.地址{addr}");
- }
- }
- }
- }
- }
|