其他分享
首页 > 其他分享> > Edit Session 类

Edit Session 类

作者:互联网

 1 
 2     /// <summary>
 3     /// 编辑Session
 4     /// </summary>
 5     public class EditSession {
 6         private IWorkspaceEdit workspaceEdit;
 7         private IWorkspace workspace;
 8 
 9         /// <summary>
10         /// 设置编辑对象所在工作空间
11         /// </summary>
12         public IWorkspace Workspace {
13             get { return workspace; }
14             set {
15                 workspace = value;
16                 CheckValid();
17                 workspaceEdit = workspace as IWorkspaceEdit;
18             }
19         }
20         /// <summary>
21         /// 开启编辑Session,并设置是否启用回退功能
22         /// </summary>
23         /// <param name="withUndoRedo"></param>
24         public void StartEdit(bool withUndoRedo) {
25             if (workspaceEdit.IsBeingEdited()) 
26                 return;
27             workspaceEdit.StartEditing(withUndoRedo);
28             workspaceEdit.StartEditOperation();
29             workspaceEdit.EnableUndoRedo();
30         }
31         /// <summary>
32         /// 停止编辑Session,并设置是否保存编辑结果
33         /// </summary>
34         /// <param name="saveEdits"></param>
35         public void StopEdit(bool saveEdits) {
36             if (!workspaceEdit.IsBeingEdited())
37                 return;
38             workspaceEdit.StopEditOperation();
39             workspaceEdit.StopEditing(saveEdits);
40         }
41         /// <summary>
42         /// 重做编辑
43         /// </summary>
44         public void Redo() {
45             bool hasRedos = false;
46             workspaceEdit.HasRedos(ref hasRedos);
47             if (hasRedos) {
48                 workspaceEdit.RedoEditOperation();
49             }
50         }
51         /// <summary>
52         /// 撤销编辑
53         /// </summary>
54         public void Undo() {
55             bool hasUndos = false;
56             workspaceEdit.HasUndos(ref hasUndos);
57             if (hasUndos) {
58                 workspaceEdit.UndoEditOperation();
59             }
60         }
61         /// <summary>
62         /// 验证数据是否合法
63         /// </summary>
64         private void CheckValid() {
65             if (workspace == null)
66                 throw new ArgumentNullException();
67         }
68     }

 

转载于:https://www.cnblogs.com/xgyb12458/archive/2010/06/02/1749982.html

标签:Edit,void,Session,bool,workspace,public,workspaceEdit
来源: https://blog.csdn.net/weixin_34146986/article/details/93979227