yangyin
2024-10-14 ec8fa5f0c4105d26956ecf30f12a0324c030c2ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
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)
        {
 
        }
    }
}