using System;
|
using System.IO;
|
using System.Drawing;
|
using System.Reflection;
|
using System.Text;
|
using System.Linq;
|
using System.Collections.Generic;
|
using System.Diagnostics;
|
using System.Windows.Forms;
|
using System.Threading;
|
|
|
|
|
namespace DPumpHydr.DesktopMain
|
{
|
public partial class MainWindow : Form
|
{
|
private bool _isMaxWindowStatus = true;//最大化窗体覆盖任务栏
|
|
#region 构造与加载
|
public MainWindow()
|
{
|
InitializeComponent();
|
|
//DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(null, typeof(DPumpHydr.DesktopMain.SplashFrmStart), true, true, false);
|
|
|
//this.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);//保证可以拖动缩放
|
this.Load += new System.EventHandler(this.OnFrmMainLoad);
|
this.Shown += new System.EventHandler(this.OnMainFormShown);
|
|
|
|
|
|
|
}
|
|
|
private void OnFrmMainLoad(object sender, EventArgs e)
|
{
|
////DPumpHydr.WinFrmUI.GlobeParas.MainForm = this;
|
|
|
////初始化权限
|
////InitialCmdBtnAuthor();
|
|
|
|
//////检查更新程序是否需要覆盖更新
|
////UpgradeHelper.CheckAutoUpdateExeCover();
|
////UpgradeHelper.CheckClientExeUpdateCover();
|
|
//
|
InitialSoftwareIcon();
|
|
//最小化到托盘控件
|
CreateNotify();
|
|
//设置flyoutPanel
|
SetFlyoutPanel();
|
|
|
//初始化窗体尺寸
|
InitialDialogSizeStatus();
|
|
|
|
|
|
|
CreateImpellerPage();
|
|
//帮助
|
HelpRequested += (sh, eh) =>
|
{
|
//ForegroundWindow.OpenHelp();
|
};
|
|
|
//软件更新
|
//DPumpHydr.DesktopMain.UpgradeHelper.Check((type, title, content, second) =>
|
//{//-1 表示文件下载失败 1开始下载 2结束下载 3 开始前台遮挡下载 4 结束前台遮挡下载 , 99 表示不用更新
|
// if (type == 3)
|
// {
|
// DPumpHydr.DesktopMain.UpgradeWaitForm.ShowWaitForm(this);
|
// }
|
// else if (type == 4)
|
// {
|
// DPumpHydr.DesktopMain.UpgradeWaitForm.HideWaitForm();
|
// }
|
// else if (type == 99)
|
// {
|
// //不用更新
|
// }
|
// else
|
// {
|
// DispUpgradeInfo(title, content, second);
|
// }
|
//});
|
}
|
|
|
|
protected string GetTranslateString(string text)
|
{
|
return text;
|
}
|
//初始化窗体尺寸
|
private void InitialDialogSizeStatus()
|
{
|
//设置窗体最大化,全屏
|
this.WindowState = FormWindowState.Normal;
|
this.StartPosition = FormStartPosition.Manual;
|
//this.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.None;
|
// this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
|
}
|
|
public void InitialForm()
|
{
|
|
}
|
|
|
//
|
public void DispTipWindowInfo(string title, string content, int second)
|
{
|
DispUpgradeInfo(title, content, second);
|
}
|
//显示升级提示
|
private void DispUpgradeInfo(string title, string content, int second)
|
{
|
if (this.InvokeRequired)
|
{
|
Action<string, string, int> d = new Action<string, string, int>(DispUpgradeInfo);
|
this.Invoke(d, new object[] { title, content, second });
|
}
|
else
|
{
|
// DevExpress.XtraBars.Alerter.AlertControl alertControl_UpgradeInfo = new DevExpress.XtraBars.Alerter.AlertControl();
|
// alertControl_UpgradeInfo.AutoHeight = true;
|
// alertControl_UpgradeInfo.FormLocation = DevExpress.XtraBars.Alerter.AlertFormLocation.BottomRight;
|
// //alertControl1.AlertClick += new DevExpress.XtraBars.Alerter.AlertClickEventHandler(alertMsgFrm_AlertClick);
|
// alertControl_UpgradeInfo.AutoFormDelay = second * 1000;
|
|
// alertControl_UpgradeInfo.Show(
|
//DPumpHydr.WinFrmUI.GlobeParas.MainForm,//.FindForm(),
|
//title,
|
//content, "", DPumpHydr.DesktopMain.Properties.Resources.AlertInfo);
|
}
|
|
return;
|
}
|
|
//
|
private void OnMainFormShown(object sender, EventArgs e)
|
{
|
//DPumpHydr.WinFrmUI.WaitFrmHelper.HideWaitForm();
|
}
|
|
//初始化软件图标
|
protected void InitialSoftwareIcon()
|
{
|
|
|
|
}
|
|
|
|
|
|
#region 可拖动缩放
|
const int WM_NCHITTEST = 0x0084;
|
const int HTLEFT = 10; //左边界
|
const int HTRIGHT = 11; //右边界
|
const int HTTOP = 12; //上边界
|
const int HTTOPLEFT = 13; //左上角
|
const int HTTOPRIGHT = 14; //右上角
|
const int HTBOTTOM = 15; //下边界
|
const int HTBOTTOMLEFT = 0x10; //左下角
|
const int HTBOTTOMRIGHT = 17; //右下角
|
|
protected override void WndProc(ref System.Windows.Forms.Message m)
|
{
|
base.WndProc(ref m);
|
switch (m.Msg)
|
{
|
case WM_NCHITTEST:
|
{
|
Point vPoint = new Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF);
|
vPoint = PointToClient(vPoint);
|
//判断:仅当当前窗体状态不是最大化时,相关鼠标事件生效
|
if (!_isMaxWindowStatus)
|
{
|
if (vPoint.X < 10)
|
{
|
if (vPoint.Y < 10)
|
{
|
m.Result = (IntPtr)HTTOPLEFT;
|
}
|
else if (vPoint.Y > this.Height - 10)
|
{
|
m.Result = (IntPtr)HTBOTTOMLEFT;
|
}
|
else
|
{
|
m.Result = (IntPtr)HTLEFT;
|
}
|
}
|
else if (vPoint.X > this.Width - 10)
|
{
|
if (vPoint.Y < 10)
|
{
|
m.Result = (IntPtr)HTTOPRIGHT;
|
}
|
else if (vPoint.Y > this.Height - 10)
|
{
|
m.Result = (IntPtr)HTBOTTOMRIGHT;
|
}
|
else
|
{
|
m.Result = (IntPtr)HTRIGHT;
|
}
|
}
|
else if (10 < vPoint.X && vPoint.X < this.Width - 10)
|
{
|
if (vPoint.Y < 10)
|
{
|
m.Result = (IntPtr)HTTOP;
|
}
|
else if (vPoint.Y > this.Height - 10)
|
{
|
m.Result = (IntPtr)HTBOTTOM;
|
}
|
}
|
}
|
break;
|
}
|
}
|
}
|
#endregion
|
|
#endregion
|
|
|
#region 鼠标操作
|
private Point _titleMouserDownPosition; //记录鼠标按下时的坐标
|
private bool _isTitleMouseDown = false;//判断鼠标是状态 True:按下 False:抬起
|
private bool _isMoveDiaglogPosiAble = true;
|
private void tileNavPane_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (_isMaxWindowStatus)
|
return;
|
if (!_isMoveDiaglogPosiAble)
|
return;
|
//if(e.X < navBtnSave.)
|
_titleMouserDownPosition = new Point(e.X, e.Y);
|
_isTitleMouseDown = true;
|
}
|
|
private void tileNavPane_MouseMove(object sender, MouseEventArgs e)
|
{
|
if (_isTitleMouseDown && e.Button == System.Windows.Forms.MouseButtons.Left)
|
{
|
if (_isMaxWindowStatus)
|
return; //此处还需要更多的考虑,这一句是为了当窗体最大化时拖拽标题栏可以切换到Normal状态,但是效果不是很理想
|
Point currentPosition = Control.MousePosition;
|
currentPosition.Offset(-_titleMouserDownPosition.X, -_titleMouserDownPosition.Y);
|
this.Location = currentPosition;
|
}
|
}
|
|
private void tileNavPane_MouseUp(object sender, MouseEventArgs e)
|
{
|
_isTitleMouseDown = false;
|
}
|
|
|
|
#endregion
|
|
|
DPumpHydr.WinFrmUI.Volute.MainViewPage _activeVolutePage;
|
private void CreateImpellerPage()
|
{
|
_activeVolutePage = new DPumpHydr.WinFrmUI.Volute.MainViewPage();
|
|
_activeVolutePage.InitWindow();
|
|
//_activeVolutePage.MdiFromPageLogo = SPump.Client.Properties.Resources.PrjList24;
|
|
_activeVolutePage.WindowState = FormWindowState.Maximized;
|
_activeVolutePage.MdiParent = this;//放在设置MdiFromPageLogo后面
|
_activeVolutePage.Text = "蜗壳设计";
|
_activeVolutePage.Name = "VoluteMainViewPage";
|
_activeVolutePage.Show();
|
}
|
|
#region 关闭
|
System.Windows.Forms.NotifyIcon notifyIcon1 = null;
|
private void CreateNotify()
|
{
|
//Icon main_icon;
|
//var icon_path = System.IO.Path.Combine(HydrCAD.GlobeParas.DataFolder, "AppIcon.ico");
|
//if (System.IO.File.Exists(icon_path))
|
// main_icon = new Icon(icon_path);
|
//else
|
// main_icon = DPumpHydr.DesktopMain.Properties.Resources.AppIcon96;
|
|
//if (this.components == null)
|
// this.notifyIcon1 = new System.Windows.Forms.NotifyIcon();
|
//else
|
// this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
|
//this.notifyIcon1.Icon = main_icon;
|
//this.notifyIcon1.Text = DPumpHydr.WinFrmUI.Localization.TranslateHelper.GetString("选型软件");
|
//this.notifyIcon1.Visible = true;
|
//this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
|
//this.Icon = main_icon;
|
//this.ShowInTaskbar = false;
|
}
|
|
private void notifyIcon1_Click(object sender, EventArgs e)
|
{
|
if (notifyIcon1 == null)
|
return;
|
|
this.Visible = true;
|
|
this.notifyIcon1.Visible = false;
|
}
|
|
#endregion
|
|
|
#region 操作提示
|
|
protected void SetFlyoutPanel() //设置flyoutPanel
|
{
|
//this.flyoutPanel.OptionsBeakPanel.CloseOnOuterClick = false;
|
////this._flyoutPanel.Options.CloseOnOuterClick = false;
|
//this.flyoutPanelHintLabel.Text = DPumpHydr.WinFrmUI.Localization.TranslateHelper.GetString("点击此处可调出其他命令");
|
//this.flyoutPanel.HideBeakForm();
|
}
|
|
// bool isFlyoutPanelShow = false;
|
void ShowHitInfoFrm()
|
{
|
//if (DPumpHydr.DesktopMain.Properties.Settings.Default.IsShowMainHit)
|
// return;
|
|
//if (flyoutPanel.FlyoutPanelState.IsActive) return;
|
//isFlyoutPanelShow = true;
|
|
//Point row = new Point(this.tileNavPane.Width * 24 / 40, this.tileNavPane.Height - 1);
|
//row = this.tileNavPane.PointToScreen(row);
|
//flyoutPanel.ShowBeakForm(row);
|
|
//DPumpHydr.DesktopMain.Properties.Settings.Default.IsShowMainHit = false;
|
//DPumpHydr.DesktopMain.Properties.Settings.Default.Save();
|
}
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void bsiSoftVersion_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
public void DispCommandName(string CommmandName, object refInfo)
|
{
|
|
}
|
|
private void MainWindow_Load(object sender, EventArgs e)
|
{
|
|
}
|
}
|
}
|