lixiaojun
2024-12-20 a7c780692ab2d8072ad4cae0fecbf851c27231d9
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
using DevExpress.XtraLayout.Utils;
 
namespace HStation.WinFrmUI
{
    public partial class CreateXhsSchemeDlg : DevExpress.XtraEditors.XtraForm
    {
        public CreateXhsSchemeDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
 
        }
 
        private readonly CreateXhsSchemeViewModel _vm = new();
        private CreateXhsSchemeManager _wizard;
 
        private Dictionary<int, bool> _page_visible_dict = null;
 
 
 
        /// <summary>
        ///
        /// </summary>
        public CreateXhsSchemeViewModel ViewModel
        {
            get { return _vm; }
        }
 
 
        /// <summary>
        ///
        /// </summary>
        public async void SetBindingData
             (
                HStation.Vmo.XhsProjectVmo project,
                HStation.Vmo.XhsProjectSiteVmo project_site,
                Yw.Model.HydroModelInfo hydro_info
            )
        { 
            if (project == null)
            {
                return;
            }
            _vm.Project = project;
            _vm.ProjectSite = project_site;
            _vm.HydroInfo = hydro_info;
            _vm.ProjectSite ??= await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_vm.Project.ID);
            if (_vm.HydroInfo == null)
            {
                var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
                    .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _vm.ProjectSite.ID, HStation.Xhs.Purpose.Simulation);
                _vm.HydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
            }
            _vm.AllSchemeList = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetBySiteID(_vm.ProjectSite.ID);
 
            _wizard = new CreateXhsSchemeManager(_vm);
            _wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
            _wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; 
            _wizard.InitialManager(new IWizardPage<CreateXhsSchemeViewModel>[] {
                this.createXhsSchemeInfoPage1,
                this.createXhsSchemePumpChangePage1,
            });
            _page_visible_dict.Add(0,false);
 
            this.createXhsSchemeInfoPage1.ChangeTypeChangedEvent += CreateXhsSchemeInfoPage1_ChangeTypeChangedEvent; 
        }
 
 
        //变更类型变换
        private void CreateXhsSchemeInfoPage1_ChangeTypeChangedEvent(List<string> change_type_list)
        {
            for (int i = this.stepProgressBar1.Items.Count; i > 0; i--)
            {
                if (this.stepProgressBar1.Items.Count < 2)
                    break;
                this.stepProgressBar1.Items.RemoveAt(1);
            }
            if (change_type_list == null || !change_type_list.Any())
            {
              
            }
            else
            {
                foreach (var change_type in change_type_list)
                {
                    var name = HydroParterCatalogHelper.GetName(change_type);
                    Add(name);
                }
                Add("变更记录");
            }
        }
 
        private void Add(string caption)
        {
            var step_pb_item = new StepProgressBarItem();
            step_pb_item.ContentBlock2.Caption = caption; 
            step_pb_item.Options.Indicator.ActiveStateDrawMode = IndicatorDrawMode.Full;
            step_pb_item.Options.Indicator.ActiveStateImageOptions.SvgImage = null;
            step_pb_item.Options.Indicator.InactiveStateImageOptions.SvgImage = null;
            step_pb_item.State = StepProgressBarItemState.Inactive;
            this.stepProgressBar1.Items.Add(step_pb_item);
        }
 
 
        //选择页面改变
        private void _wizard_SelectedPageChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
        {
            this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.navigationFrame1.SelectedPageIndex = index;
            this.stepProgressBar1.SelectedItemIndex = index;
        }
 
        //选择页面状态改变
        private void _wizard_SelectedPageStateChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
        {
            this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never;
        }
 
        //上一步
        private void btnPrev_Click(object sender, EventArgs e)
        {
            if (_wizard != null)
            {
                _wizard.Prev();
            }
 
        }
 
        //下一步
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (_wizard != null)
            {
                _wizard.Next();
            }
 
        }
 
        //取消
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (_wizard != null)
            {
                var bol = _wizard.Cancel();
                if (bol)
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                }
            }
 
        }
 
        //完成
        private void btnComplete_Click(object sender, EventArgs e)
        {
            if (_wizard != null)
            {
                var bol = _wizard.Complete();
                if (bol)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
 
        }
 
        //正在关闭
        private void CreateXhsSchemeDlg_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_wizard != null)
            {
                if (this.DialogResult == DialogResult.OK)
                {
                    /*  if (!_wizard.Complete())
                      {
                          e.Cancel = true;
                      }*/
                }
                else if (this.DialogResult == DialogResult.Cancel)
                {
                    if (!_wizard.Cancel())
                    {
                        e.Cancel = true;
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
 
        }
 
 
 
    }
}