1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Generator
19 using System
.Windows
.Forms
;
21 using WeifenLuo
.WinFormsUI
;
23 using Castle
.ActiveRecord
.Generator
.Actions
;
24 using Castle
.ActiveRecord
.Generator
.Parts
;
27 public class ARGeneratorLayout
: IApplicationLayout
30 private ActiveRecordGraphView arGraph
;
31 private OutputView outView
;
32 private ProjectExplorer projExplorer
;
33 private AvailableShapes avaShapes
;
35 public ARGeneratorLayout(Model model
)
40 #region IApplicationLayout Members
42 public void Install(IWorkspace workspace
)
46 arGraph
= new ActiveRecordGraphView(_model
);
47 arGraph
.ParentWorkspace
= workspace
;
49 outView
= new OutputView(_model
);
50 outView
.ParentWorkspace
= workspace
;
52 projExplorer
= new ProjectExplorer(_model
);
53 projExplorer
.ParentWorkspace
= workspace
;
55 avaShapes
= new AvailableShapes(_model
);
56 avaShapes
.ParentWorkspace
= workspace
;
60 FileActionGroup group1
= new FileActionGroup();
62 group1
.Install(workspace
);
64 ViewActionSet group2
= new ViewActionSet(arGraph
, outView
, projExplorer
, avaShapes
);
66 group2
.Install(workspace
);
68 HelpActionSet group3
= new HelpActionSet();
70 group3
.Install(workspace
);
74 public void Persist(IWorkspace workspace
)
76 String dirName
= Path
.GetDirectoryName(Application
.ExecutablePath
);
77 String configFile
= Path
.Combine(dirName
, "Layout.config");
79 workspace
.MainDockManager
.SaveAsXml(configFile
);
82 public void Restore(IWorkspace workspace
)
84 String configFile
= Path
.Combine(
85 Path
.GetDirectoryName(Application
.ExecutablePath
), "Layout.config");
87 if (File
.Exists(configFile
))
89 workspace
.MainDockManager
.LoadFromXml(configFile
,
90 new DeserializeDockContent(GetContentFromPersistString
));
94 arGraph
.Show(workspace
.MainDockManager
, DockState
.Document
);
95 outView
.Show(workspace
.MainDockManager
, DockState
.DockBottomAutoHide
);
96 projExplorer
.Show(workspace
.MainDockManager
, DockState
.DockRight
);
97 avaShapes
.Show(workspace
.MainDockManager
, DockState
.DockRight
);
103 private DockContent
GetContentFromPersistString(String persistString
)
105 if (persistString
== typeof(ActiveRecordGraphView
).ToString())
107 else if (persistString
== typeof(OutputView
).ToString())
109 else if (persistString
== typeof(ProjectExplorer
).ToString())
111 else if (persistString
== typeof(AvailableShapes
).ToString())