lixiaojun
2024-07-11 8d8cd298ab46aee191baf53ff320fd3290d1ec9a
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
using System;
using System.Collections.Generic;
 
namespace IStation.WinFrmUI
{
    public partial class DocumentPage : DevExpress.XtraEditors.XtraUserControl
    {
        public DocumentPage()
        {    
            this.PageTitle = new PageTitle();
        }
 
        public DocumentPage(SurfaceGuid surfaceGuid)
        { 
            this.PageTitle = new PageTitle();
            this.SurfaceGuid = surfaceGuid;
        }
 
        /// <summary>
        /// 加载菜单事件
        /// </summary>
        public event Action<SurfaceGuid, List<PageMenu>> LoadPageMenuEvent;
        protected void LoadPageMenu(SurfaceGuid sguid, List<PageMenu> menus)
        {
            this.LoadPageMenuEvent?.Invoke(sguid, menus);
        }
 
        /// <summary>
        /// 根据字符串判断Document是否存在,
        /// 第一个参数为SurfaceGuid参数类
        /// 第二个参数如果页面存在是否激活页面
        /// 第三个参数 存在则激活并返回TRUE,不存在返回FALSE
        /// </summary>
        public event Func<SurfaceGuid, bool, bool> IsExistPageEvent;
        protected bool IsExistPage(SurfaceGuid sguid, bool isActivateDoc)
        {
            if (this.IsExistPageEvent != null)
                return this.IsExistPageEvent(sguid, isActivateDoc);
            return false;
        }
 
        /// <summary>
        /// 查找Page
        /// </summary>
        public event Func<SurfaceGuid, bool, DocumentPage> FindPageEvent;
        protected DocumentPage FindPage(SurfaceGuid sguid, bool isActivateDoc)
        {
            if (this.FindPageEvent != null)
                return this.FindPageEvent(sguid, isActivateDoc);
            return null;
        }
 
        /// <summary>
        /// 创建Page
        /// </summary>
        public event Func<DocumentPage, SurfaceGuid, bool> CreatePageEvent;
        protected bool CreatePage(DocumentPage page, SurfaceGuid sguid)
        {
            if (this.CreatePageEvent != null)
                return CreatePageEvent(page, sguid);
            return false;
        }
 
        /// <summary>
        /// 更新数据事件
        /// 第一个参数为SurfaceGuid
        /// </summary>
        public event Action<SurfaceGuid> RefreshPageDataEvent;
        protected void RefreshPageData(SurfaceGuid sguid)
        {
            this.RefreshPageDataEvent?.Invoke(sguid);
        }
 
        /// <summary>
        /// 更新PageTitle事件
        /// </summary>
        public event Action<SurfaceGuid, PageTitle> UpdatePageTitleEvent;
        protected void UpdatePageTitle(SurfaceGuid sguid, PageTitle title)
        {
            this.UpdatePageTitleEvent?.Invoke(sguid, title);
        }
 
        /// <summary>
        /// 关闭Page事件
        /// </summary>
        public event Action<SurfaceGuid> ClosePageEvent;
        protected void ClosePage(SurfaceGuid sguid)
        {
            this.ClosePageEvent?.Invoke(sguid);
        }
 
        /// <summary>
        /// 重置所有页面事件
        /// </summary>
        public event Action ResetAllPagesEvent;
        protected void ResetAllPages()
        {
            this.ResetAllPagesEvent?.Invoke();
        }
 
        /// <summary>
        /// 在脚部提示的命令名
        /// </summary>
        protected string strPageBottomCapture = null;
        public string GetPageBottomCapture()
        { 
            if (!string.IsNullOrEmpty(strPageBottomCapture))
                return strPageBottomCapture;
            if (PageTitle != null)
                return PageTitle.Caption;
            return "";
        }
        /// <summary>
        /// 软件操作提示
        /// </summary>
        protected string _pageOperateInfo = "";
        public virtual string GetPageOperateInfo()
        {
            return _pageOperateInfo;
        }
        /// <summary>
        /// 头部部分
        /// </summary>
        public PageTitle PageTitle { get; set; }
 
        /// <summary>
        /// 自身标识
        /// </summary>
        public SurfaceGuid SurfaceGuid { get; set; }
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public virtual void InitialDataSource()
        {
 
        }
 
        /// <summary>
        /// 刷新数据
        /// </summary>
        public virtual void RefreshDataSource()
        {
 
        }
 
        /// <summary>
        /// 关闭时调用
        /// </summary>
        public virtual void Close()
        {
 
        }
 
        /// <summary>
        /// 是否可以关闭
        /// </summary>
        public virtual bool CanClose()
        {
            return true;
        }
 
        /// <summary>
        /// 注册事件
        /// </summary>
        public virtual void RegistEvents()
        {
 
        }
 
        /// <summary>
        /// 取消注册事件
        /// </summary>
        public virtual void UnRegistEvents()
        {
 
        }
 
        /// <summary>
        /// 操作提示
        /// </summary>
        public event Action<string, int> OnShowCmdOperateInfo = null;
        public virtual void ShowCmdOperateInfo(string content, int type = 0)
        {
            if (OnShowCmdOperateInfo != null)
            {
                OnShowCmdOperateInfo(content, type);
            }
        }
 
        /// <summary>
        /// 打开一个新的页面
        /// </summary>
        public event Action<DocumentPage, SurfaceGuid,bool > OnOpenNewPage = null;
        public virtual void OpenNewPageInMain(DocumentPage page, SurfaceGuid guid)
        {
            if (OnOpenNewPage != null)
            {
                OnOpenNewPage(page, guid, true);
            }
        }
        /// <summary>
        /// 打开时出现等待框
        /// </summary>
        public bool IsShowWatingFrm { get; set; } = false;
    }
}