ningshuxia
2025-03-21 7af1565cf5af77397453a3ea6ad516ac9be371f8
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
using DevExpress.Drawing.Internal.Fonts.Interop;
using DevExpress.XtraPrinting.Native;
using Hydro;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Taskbar;
 
namespace PBS.WinFrmUI.Hydro
{
    public partial class ModelEditPage : DocumentPage, IWizardPageAsync<QuickModelingViewModel>
    {
        public ModelEditPage()
        {
            InitializeComponent();
            //this.modelTemplateTreeListCtrl1.SelectModelTemplateEvent += ModelTemplateTreeListCtrl1_SelectModelTemplateEvent;
            //this.modelTemplateTreeListCtrl1.RefreshDataEvent += () => { RefreshData(); };
        }
 
 
        private FacilityVmo _facility = null; 
        private Template _template = null;
        private MapViewer _mapView;
        private PropertyForm _propertyForm;
 
        /// <summary>
        /// 初始化数据源
        /// </summary>
        public override void InitialDataSource()
        {
            base.InitialDataSource();
            InitialMapViewer();
        }
 
 
        /// <summary>
        /// 初始化数据
        /// </summary> 
        public void InitialData(FacilityVmo obj)
        { 
            if (obj == null)
            {
                _facility = null;
                _template = null;
                _mapView.Clear();
                return;
            }
 
            if (string.IsNullOrEmpty(obj.ModelPath))
            { 
                var fullPath = Path.Combine(Directory.GetCurrentDirectory(), "Data\\Inp\\" + obj.ID + ".inp"); 
                var directoryPath = Path.GetDirectoryName(fullPath);
                if (!Directory.Exists(directoryPath))
                    Directory.CreateDirectory(directoryPath);
                if (!File.Exists(fullPath))
                {
                    fullPath = Path.Combine(Directory.GetCurrentDirectory(), "Data\\Inp\\temp.inp"); 
                }
                File.Create(fullPath).Close();
 
                obj.ModelPath = fullPath;
            }
 
 
            if (string.IsNullOrEmpty(obj.ModelInfo))
            {
                var templateTemp = new Template()
                {
                    ID = obj.ID.ToString(),
                    Name = obj.Name,
                    Type = eModelTemplateType.Custom,
                    filePath = obj.ModelPath,
                };
                if (_vm != null)
                {
                    templateTemp.BackGroundImg_FullPath = _vm.tempBackgroundImageUrl;
                    templateTemp.BackGroundImgWidth = (float)_vm.BackgroundWidth;
                    templateTemp.BackGroundImgHeight = (float)_vm.BackgroundHeight;
                    templateTemp.BackGroundImgRotaAngle = 0;
                    templateTemp.BackGroundPoint1 = new PointF(0, 0);
                }
                obj.ModelInfo = Yw.JsonHelper.Object2Json(templateTemp); 
                
            }
 
            _facility = obj;
            _template = Yw.JsonHelper.Json2Object<Template>(obj.ModelInfo);
 
 
            var template = _template;
            template.network = new MapViewNetWork();
            template.network.BuildFromInp(Path.Combine(Directory.GetCurrentDirectory(), _template.filePath));
            _mapView.SetData(template);
        }
 
        
 
 
 
 
        //初始化视图
        private void InitialMapViewer()
        {
            _mapView = new MapViewer();
            //_mapView.Lock2DView = true;
            _mapView.ShowPropertyForm = false;
            //_mapView.Location = new System.Drawing.Point(0, 0);
            _mapView.Dock = DockStyle.Fill;
            _mapView.mapOption.isShowPic = true;
            _mapView.mapOption.IsOrtho = false;
            this.panelControl1.Controls.Add(_mapView);
 
            _propertyForm = new PropertyForm();
            _propertyForm.Dock = DockStyle.Fill;
            this.dockPanelModelProperty.Controls.Add(_propertyForm);
 
            GlobalObject.PropertyForm = _propertyForm;
            GlobalObject.map = _mapView;
        }
 
 
        public override void RefreshData()
        {
            base.RefreshData();
        }
 
        private void SetMapBackground(string backgroundUrl, float width, float height)
        {
            _mapView.mapOption.isShowPic = true;
            _mapView.mapOption.isAutoBackgroundImage = true;
            var img = Image.FromFile(backgroundUrl);
            var imgWidth = img.Width;
            var imgHeight = img.Height;
 
            var w = imgWidth / width;
            var h = imgHeight / height;
            var zoom = w > h ? w : h;
 
            _mapView.MapCenter = _mapView.mapOption.Center = new PointF(width / 2, height / 2);
            _mapView.zoom = _mapView.mapOption.zoom = zoom;
 
            var temp = _mapView._Template;
            var directory = Path.GetDirectoryName(temp.BackGroundImg_FullPath);
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            File.Copy(backgroundUrl, temp.BackGroundImg_FullPath, true);
            temp.BackGroundImg_FullPath = temp.BackGroundImg_FullPath;
            temp.BackGroundImgWidth = width;
            temp.BackGroundImgHeight = height;
            temp.BackGroundImgRotaAngle = 0;
            temp.BackGroundPoint1 = new PointF(0, 0);
            _mapView._Template = temp;
            _mapView.SetMapInvalidate();
 
        }
 
        #region Event
 
        #region Draw
 
        private void toolboxControlDraw_ItemClick(object sender, DevExpress.XtraToolbox.ToolboxItemClickEventArgs e)
        {
            if (e.Item.Tag is not string tag)
                return;
            switch (tag)
            {
                case "Select":
                    {
                        _mapView.toolStripButton_普通_Click(1, new EventArgs());
                    }
                    break;
                case "AddNode":
                    {
                        _mapView.toolStripButton_新建节点_Click(1, new EventArgs());
                    }
                    break;
                case "AddVerticalPipe":
                    {
                        _mapView.toolStripButton_新建立管_Click(1, new EventArgs());
                    }
                    break;
                case "AddHorizontalPipe":
                    {
                        _mapView.toolStripButton_新建管线_Click(1, new EventArgs());
                    }
                    break;
                case "AddValve":
                    {
                        _mapView.toolStripButton_添加阀门_Click(1, new EventArgs());
                    }
                    break;
                case "AddPump":
                    {
                        _mapView.toolStripButton_添加水泵_Click(1, new EventArgs());
                    }
                    break;
                case "AddWaterMeter":
                    {
                        _mapView.toolStripButton_添加水表_Click(1, new EventArgs());
                    }
                    break;
                case "AddTank":
                    {
                        _mapView.toolStripButton_添加水池_Click(1, new EventArgs());
                    }
                    break;
                case "AddReservoir":
                    {
                        _mapView.toolStripButton_添加水库_Click(1, new EventArgs());
                    }
                    break;
                case "Copy":
                    {
                        _mapView.复制ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
                case "Paste":
                    {
                        _mapView.粘贴ToolStripMenuItem1_Click(1, new EventArgs());
                    }
                    break;
                case "Delete":
                    {
                        _mapView.删除ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
 
                case "Undo":
                    {
                        _mapView.buttonUndo_Click(1, new EventArgs());
                    }
                    break;
                case "Redo":
                    {
                        _mapView.buttonRedo_Click(1, new EventArgs());
                    }
                    break;
                case "HorizontalAlign":
                    {
                        _mapView.东西对齐ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
                case "VerticalAlign":
                    {
                        _mapView.南北对齐ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
                case "TopBottomAlign":
                    {
                        _mapView.竖直对齐ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
                case "AutoAlign":
                    {
                        _mapView.自动对齐ToolStripMenuItem_Click(1, new EventArgs());
                    }
                    break;
                default:
                    break;
            }
 
 
        }
 
 
 
        private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            var hi = this.toolboxControlDraw.CalcHitInfo(e.ControlMousePosition);
            if (hi.IsInItem)
            {
                var toolItem = hi.ItemInfo.Item;
                this.toolTipController1.ShowHint(toolItem.Caption, MousePosition);
            }
            else
            {
                this.toolTipController1.HideHint();
            }
        }
 
        #endregion
 
        #region QuickModeling
 
        private EditFloors dlg = new EditFloors();
        private void barBtnModelTemplate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        { 
            if (dlg.ShowDialog() == DialogResult.OK)
            {
            }
        }
 
        private void barBtnConnectivityCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.关阀搜索ToolStripMenuItem_Click(1, new EventArgs());
        }
 
        private void barBtnVerticalPipeDiameter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        { 
            var dlg = new InputDlg();
            dlg.SetBindingData("输入口径");
            dlg.ReloadDataEvent += (value) =>
            {
                _mapView._Template.network.Links.ForEach(l =>
                {
                    if (l.StartNode != null && l.EndNode != null)
                    {
                        if (l.StartNode.Position == l.EndNode.Position)
                        {
                            l.Diameter = (float)value;
                        }
                    }
                });
            };
        }
 
        private void barBtnHorizontalPipeDiameter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new InputDlg();
            dlg.SetBindingData("输入口径");
            dlg.ReloadDataEvent += (value) =>
            { 
                _mapView._Template.network.Links.ForEach(l =>
                {
                    if (l.StartNode.Elev == 0 && l.EndNode.Elev == 0)
                    {
                        l.Diameter = (float)value;
                    }
                });
            }; 
 
        }
 
        private void barBtnElevationTranslation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new InputDlg();
            dlg.SetBindingData("输入标高偏移量");
            dlg.ReloadDataEvent += (value) =>
            {
                _mapView._Template.network.Nodes.ForEach(n =>
                {
                    if (n.Elev > 0)
                    {
                        n.Elev = n.Elev + (float)value;
                    }
                });
            };
            dlg.ShowDialog();
           
        }
 
 
        /// <summary>
        /// 保存
        /// </summary> 
        private void SaveModelTemplate()
        {
            if (_facility == null)
            {
                TipFormHelper.ShowWarn("请选择模板");
                return;
            }
            if (_template == null)
            {
                TipFormHelper.ShowWarn("请选择模板");
                return;
            }
            SaveView();
            SetZoom();
 
            _facility.ModelInfo = Yw.JsonHelper.Object2Json(_template);
            this._mapView.toolStripButton_save_ButtonClick(1, new EventArgs());
 
        } 
 
 
 
        private void barBtnSaveModelTemplate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SaveModelTemplate();
        }
 
        #endregion
 
        #region Import
 
        private void ImportInp()
        {
            if (_facility == null)
            {
                return;
            }
            if (_template == null)
            {
                return;
            }
            var openFileDlg = new OpenFileDialog();
            openFileDlg.Filter = "INP文件|*.inp";
            if (openFileDlg.ShowDialog() != DialogResult.OK)
                return;
 
            _mapView.Clear();
 
            var inpFilePath = openFileDlg.FileName;
            var templateFilePath = _template.FullPath;
 
            Global.ClearFileReadOnly(templateFilePath);
            File.Copy(inpFilePath, templateFilePath, true);
            _template.network.BuildFromInp(templateFilePath);
 
            _mapView.SetData(_template);
 
        }
 
 
        private void barBtnImportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ImportInp();
        }
 
        #endregion
 
        #region BaseMap
 
        private void SetBaseMap()
        {
            var dlg = new SetMapBaseMapDlg();
            dlg.ReloadDataEvent += (filePath, widht, height) =>
            {
                SetMapBackground(filePath, (float)widht, (float)height);
            };
            dlg.ShowDialog();
        }
 
        private void barBtnAddBaseMap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SetBaseMap();
        }
 
        private void barBtnSetBaseMap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.设置底图ToolStripMenuItem_Click(1, null);
        }
 
        private void barBtnClearBaseMap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.清除底图ToolStripMenuItem_Click(1, null);
        }
 
        private void barCekBaseMapVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.显示隐藏底图ToolStripMenuItem_Click(1, null);
        }
 
 
        #endregion
 
        #region View
 
        private void SetDefaultView()
        {
            var mapOption0 = _mapView.mapOption.Copy();
            var p = PointF.Empty;
            float x0 = 99999999999f, y0 = 99999999999f, x1 = -99999999999f, y1 = -99999999999f;
 
            foreach (NodeViewModel junction in _mapView._Nodes)
            {
                p.X += (float)junction.X;
                p.Y += (float)junction.Y;
                if (x0 > junction.X) x0 = junction.X;
                if (y0 > junction.Y) y0 = junction.Y;
                if (x1 < junction.X) x1 = junction.X;
                if (y1 < junction.Y) y1 = junction.Y;
            }
 
            float x_span = x1 - x0, y_span = y1 - y0;
 
            _mapView.zoom = Math.Min(this._mapView.Width / x_span, this._mapView.Height / y_span);
            _mapView.zoom = Math.Max(_mapView.zoom, 0.1f);
            _mapView.zoom = Math.Min(_mapView.zoom, 1000.0f);
 
            _mapView.Rotation = 0;
            _mapView.RotationF = 90;
 
 
            if (_mapView._Nodes.Count > 0)
            {
                p.X /= _mapView._Nodes.Count;
                p.Y /= _mapView._Nodes.Count;
            }
            _mapView.MapCenter = p;
            _mapView.RotationF = 45;
            _mapView.Rotation = -45;
            MapObjectExtensions.AddCommand(_mapView.mapOption, "Map", mapOption0, _mapView.mapOption);
 
            _mapView.SetMapInvalidate();
        }
 
        private void barBtnDefaultView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SetDefaultView();
        }
 
        private void barBtnFullView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.重置视角ToolStripMenuItem_Click(1, new EventArgs());
        }
 
        private void SetTopView()
        {
            var mapOption0 = _mapView.mapOption.Copy();
            _mapView.RotationF = 90;
            MapObjectExtensions.AddCommand(_mapView.mapOption, "Map", mapOption0, _mapView.mapOption);
 
            _mapView.SetMapInvalidate();
        }
 
        private void barBtnTopView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SetTopView();
        }
 
        private void SetFrontView()
        {
            var mapOption0 = _mapView.mapOption.Copy();
            _mapView.RotationF = 0;
            MapObjectExtensions.AddCommand(_mapView.mapOption, "Map", mapOption0, _mapView.mapOption);
 
            _mapView.SetMapInvalidate();
        }
 
        private void barBtnFrontView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SetFrontView();
        }
 
        private void barBtnResetView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _mapView.重置视角ToolStripMenuItem_Click(1, new EventArgs());
        }
 
 
        public void SetMapCenterAndZoom()
        {
            _mapView.MapCenter = _mapView.mapOption.Center = new PointF((float)_vm.BackgroundWidth / 2, (float)_vm.BackgroundHeight / 2);
            _mapView.zoom = _mapView.mapOption.zoom = (float)_vm.Zoom;
            _mapView.RotationF = 90;
            _mapView.mapOption.isAutoBackgroundImage = true;
            _mapView._Template.Colours = null;
            _mapView.SetMapInvalidate();
        }
 
 
 
        private void SetZoom()
        {
            if (_template == null) return;
            _template.view ??= new MapDimensions();
            _template.view.Center = _mapView.MapCenter;
            _template.view.zoom = _mapView.zoom;
            _template.view.rotation = _mapView.Rotation;
            _template.view.rotationF = _mapView.RotationF;
 
        }
 
        private void SaveView()
        {
            if (_template == null) return;
            _template.view ??= new MapDimensions();
            _template.view.Center = _mapView.MapCenter;
            _template.view.zoom = _mapView.zoom;
            _template.view.rotation = _mapView.Rotation;
            _template.view.rotationF = _mapView.RotationF;
 
        }
 
 
        private void barBtnSaveView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SaveView();
        }
        #endregion
 
        #endregion
 
 
        /// <summary>
        /// 状态改变事件
        /// </summary>
        public event Action PageStateChangedEvent;
 
        private QuickModelingViewModel _vm = null;//操作对象
        private bool _isCompleted = false;//是否创建完成  
        private bool _isInitialMapViewer = false;//是否初始化地图
 
 
        /// <summary>
        /// 初始化页面
        /// </summary>
        public void InitialPage(QuickModelingViewModel vm)
        {
            if (vm == null)
            {
                return;
            }
            _vm = vm;
            _isCompleted = false;
            if (!_isInitialMapViewer)
            {
                InitialMapViewer();
            }
 
 
            InitialData(_vm.Facility);
            SetMapCenterAndZoom();
            _isCompleted = true;
            this.PageStateChangedEvent?.Invoke();
        }
 
 
        //验证
        public bool Verify()
        {
            return this.Invoke(() =>
            {
                bool isExist = true;
 
                if (_mapView==null)
                {
                    isExist = false;
                }
                if (_template==null)
                {
                    isExist = false;
                }
        
                return isExist;
            });
        }
 
        //保存
        private bool Save()
        {
            if (!Verify())
            {
                return false;
            }
 
            _vm.Facility.ModelInfo = Yw.JsonHelper.Object2Json(_template);
 
 
            return true;
        }
 
        //保存
        private async Task<bool> Complete()
        {
            if (!Verify())
            {
                return false;
            }
 
            var place = _vm.Place;
            var facility = _vm.Facility;
 
            place.ID = await BLLFactory<BLL.Place>.Instance.Insert(place);
            if (place.ID < 1)
            {
                TipFormHelper.ShowError("新增场所失败!");
                return false;
            }
            facility.PlaceID = place.ID;
            facility.ID = await BLLFactory<BLL.Facility>.Instance.Insert(facility);
            if (facility.ID < 1)
            {
                TipFormHelper.ShowError("新增设施失败!");
                return false;
            }
 
            facility = await BLLFactory<BLL.Facility>.Instance.GetByID(facility.ID);
 
            var tempInpFile = facility.ModelPath;  
 
            var fullPath = Path.Combine(Directory.GetCurrentDirectory(), "Data\\Inp\\" + facility.ID + ".inp");
            File.Copy(tempInpFile, fullPath, true);
            var bgFile = tempInpFile.Replace(".inp", ".png");
            if (File.Exists(bgFile))
            {
                File.Copy(bgFile, fullPath.Replace(".inp", ".png"), true);
                File.Delete(bgFile);
            }
            if (File.Exists(tempInpFile))
                File.Delete(tempInpFile);
            _template.filePath = fullPath;
            _template.BackGroundImg_FullPath = fullPath.Replace(".inp", ".png");
 
            facility.ModelInfo = Yw.JsonHelper.Object2Json(_template);
            facility.ModelPath = fullPath;
 
            if (!await BLLFactory<BLL.Facility>.Instance.Update(facility))
            {
                TipFormHelper.ShowError("新增模型信息失败!");
                return false;
            }
 
            return true;
        }
 
 
        /// <summary>
        /// 允许上一步
        /// </summary>
        public bool AllowPrev
        {
            get
            {
                if (!_isCompleted)
                {
                    return false;
                }
                return true;
            }
        }
 
        /// <summary>
        /// 允许下一步
        /// </summary>
        public bool AllowNext
        {
            get
            {
                return false;
            }
        }
 
        /// <summary>
        /// 允许取消
        /// </summary>
        public bool AllowCancel
        {
            get
            { 
                return false;
            }
        }
 
        /// <summary>
        /// 允许完成
        /// </summary>
        public bool AllowComplete
        {
            get
            {
                return true;
            }
        }
 
        /// <summary>
        /// 能否上一步
        /// </summary>
        /// <returns></returns>
        public Task<bool> CanPrev()
        {
            return Task.Run(() =>
            {
                Save();
                return this.AllowPrev;
            });
        }
 
        /// <summary>
        /// 能否下一步
        /// </summary>
        public Task<bool> CanNext()
        {
            return Task.Run(() => this.AllowNext);
        }
 
        /// <summary>
        /// 能否取消
        /// </summary>
        public Task<bool> CanCancel()
        {
            return Task.Run(() => this.AllowCancel);
        }
 
        /// <summary>
        /// 能否完成
        /// </summary>
        public Task<bool> CanComplete()
        {
            return Task.Run(() => Complete());
        }
 
 
 
    }
 
}