1 | //------------------------------------------------------------------------------
|
---|
2 | // <auto-generated>
|
---|
3 | // This code was generated by a tool.
|
---|
4 | //
|
---|
5 | // Changes to this file may cause incorrect behavior and will be lost if
|
---|
6 | // the code is regenerated.
|
---|
7 | // </auto-generated>
|
---|
8 | //------------------------------------------------------------------------------
|
---|
9 |
|
---|
10 | using DslModeling = global::Microsoft.VisualStudio.Modeling;
|
---|
11 | using DslDiagrams = global::Microsoft.VisualStudio.Modeling.Diagrams;
|
---|
12 | using DslShell = global::Microsoft.VisualStudio.Modeling.Shell;
|
---|
13 |
|
---|
14 | namespace HeuristicLab.SimulationCore
|
---|
15 | {
|
---|
16 | /// <summary>
|
---|
17 | /// Double-derived class to allow easier code customization.
|
---|
18 | /// </summary>
|
---|
19 | internal partial class HLSimDocView : HLSimDocViewBase
|
---|
20 | {
|
---|
21 | /// <summary>
|
---|
22 | /// Constructs a new HLSimDocView.
|
---|
23 | /// </summary>
|
---|
24 | public HLSimDocView(DslShell::ModelingDocData docData, global::System.IServiceProvider serviceProvider)
|
---|
25 | : base(docData, serviceProvider)
|
---|
26 | {
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | /// <summary>
|
---|
31 | /// Class that hosts the diagram surface in the Visual Studio document area.
|
---|
32 | /// </summary>
|
---|
33 | internal abstract class HLSimDocViewBase : DslShell::SingleDiagramDocView
|
---|
34 | {
|
---|
35 | /// <summary>
|
---|
36 | /// Constructs a new HLSimDocView.
|
---|
37 | /// </summary>
|
---|
38 | protected HLSimDocViewBase(DslShell::ModelingDocData docData, global::System.IServiceProvider serviceProvider) : base(docData, serviceProvider)
|
---|
39 | {
|
---|
40 | }
|
---|
41 |
|
---|
42 | /// <summary>
|
---|
43 | /// Called to initialize the view after the corresponding document has been loaded.
|
---|
44 | /// </summary>
|
---|
45 | protected override bool LoadView()
|
---|
46 | {
|
---|
47 | base.LoadView();
|
---|
48 |
|
---|
49 | global::System.Diagnostics.Debug.Assert(this.DocData.RootElement!=null);
|
---|
50 | if (this.DocData.RootElement == null)
|
---|
51 | {
|
---|
52 | return false;
|
---|
53 | }
|
---|
54 |
|
---|
55 | // The diagram should exist in the diagram partition by now, just need to find it and connect it to this view.
|
---|
56 | HLSimDocDataBase docData = this.DocData as HLSimDocDataBase;
|
---|
57 | global::System.Diagnostics.Debug.Assert(docData != null, "DocData for HLSimDocViewBase should be an HLSimDocDataBase!");
|
---|
58 | DslModeling::Partition diagramPartition = docData.GetDiagramPartition();
|
---|
59 | if (diagramPartition != null)
|
---|
60 | {
|
---|
61 | global::System.Collections.ObjectModel.ReadOnlyCollection<global::HeuristicLab.SimulationCore.HLSimDiagram> diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements<global::HeuristicLab.SimulationCore.HLSimDiagram>();
|
---|
62 | if (diagrams.Count > 0)
|
---|
63 | {
|
---|
64 | global::System.Diagnostics.Debug.Assert(diagrams.Count == 1, "Found more than one diagram, using the first one found.");
|
---|
65 | this.Diagram = (DslDiagrams::Diagram)diagrams[0];
|
---|
66 | }
|
---|
67 | else
|
---|
68 | {
|
---|
69 | return false;
|
---|
70 | }
|
---|
71 | }
|
---|
72 | else
|
---|
73 | {
|
---|
74 | return false;
|
---|
75 | }
|
---|
76 |
|
---|
77 | return true;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /// <summary>
|
---|
81 | /// Name of the toolbox tab that should be displayed when the diagram is opened.
|
---|
82 | /// </summary>
|
---|
83 | protected override string DefaultToolboxTabName
|
---|
84 | {
|
---|
85 | get
|
---|
86 | {
|
---|
87 | return global::HeuristicLab.SimulationCore.HLSimToolboxHelper.DefaultToolboxTabName;
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | /// <summary>
|
---|
92 | /// Returns the toolbox items count in the default tool box tab.
|
---|
93 | /// </summary>
|
---|
94 | protected override int DefaultToolboxTabToolboxItemsCount
|
---|
95 | {
|
---|
96 | get
|
---|
97 | {
|
---|
98 | return global::HeuristicLab.SimulationCore.HLSimToolboxHelper.DefaultToolboxTabToolboxItemsCount;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | /// <summary>
|
---|
104 | /// Context menu displayed when the user right-clicks on the design surface.
|
---|
105 | /// </summary>
|
---|
106 | protected override global::System.ComponentModel.Design.CommandID ContextMenuId
|
---|
107 | {
|
---|
108 | get
|
---|
109 | {
|
---|
110 | return Constants.HLSimDiagramMenu;
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | /// <summary>
|
---|
115 | /// Called when selection changes in this window.
|
---|
116 | /// </summary>
|
---|
117 | /// <remarks>
|
---|
118 | /// Overriden to update the F1 help keyword for the selection.
|
---|
119 | /// </remarks>
|
---|
120 | /// <param name="e"></param>
|
---|
121 | protected override void OnSelectionChanged(global::System.EventArgs e)
|
---|
122 | {
|
---|
123 | base.OnSelectionChanged(e);
|
---|
124 |
|
---|
125 | if(global::HeuristicLab.SimulationCore.HLSimHelpKeywordHelper.Instance != null)
|
---|
126 | {
|
---|
127 | DslModeling::ModelElement selectedElement = this.PrimarySelection as DslModeling::ModelElement;
|
---|
128 | if(selectedElement != null)
|
---|
129 | {
|
---|
130 | string f1Keyword = global::HeuristicLab.SimulationCore.HLSimHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);
|
---|
131 |
|
---|
132 | // If this is a presentation element, check the underlying model element for a help keyword
|
---|
133 | DslDiagrams::PresentationElement presentationElement = this.PrimarySelection as DslDiagrams::PresentationElement;
|
---|
134 | if(presentationElement != null)
|
---|
135 | {
|
---|
136 | selectedElement = presentationElement.ModelElement;
|
---|
137 | if(selectedElement != null)
|
---|
138 | {
|
---|
139 | string modelElementKeyword = global::HeuristicLab.SimulationCore.HLSimHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);
|
---|
140 | if(string.IsNullOrEmpty(f1Keyword))
|
---|
141 | {
|
---|
142 | // Presentation element does not have an F1 keyword, so push the keyword from the model element as an F1 keyword.
|
---|
143 | f1Keyword = modelElementKeyword;
|
---|
144 | }
|
---|
145 | else if (!string.IsNullOrEmpty(modelElementKeyword) && this.SelectionHelpService != null)
|
---|
146 | {
|
---|
147 | // Presentation element has an F1 keyword, so push model element keyword as a general dynamic help keyword (non-F1).
|
---|
148 | this.SelectionHelpService.AddContextAttribute(string.Empty, modelElementKeyword, global::System.ComponentModel.Design.HelpKeywordType.GeneralKeyword);
|
---|
149 | }
|
---|
150 | }
|
---|
151 | }
|
---|
152 |
|
---|
153 | if(!string.IsNullOrEmpty(f1Keyword) && this.SelectionHelpService != null)
|
---|
154 | {
|
---|
155 | this.SelectionHelpService.AddContextAttribute(string.Empty, f1Keyword, global::System.ComponentModel.Design.HelpKeywordType.F1Keyword);
|
---|
156 | }
|
---|
157 | }
|
---|
158 | }
|
---|
159 | }
|
---|
160 | }
|
---|
161 | }
|
---|
162 |
|
---|