Skip to content

Commit a8d6f57

Browse files
yurii-litvinovMrsSima
authored andcommitted
Fixed bug with splitter
1 parent 85ed355 commit a8d6f57

32 files changed

+1504
-9
lines changed

REAL.NET.sln

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.28721.148
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.28307.168
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
66
ProjectSection(SolutionItems) = preProject
@@ -60,6 +60,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfControlsLib.Tests", "tes
6060
EndProject
6161
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repo.CSharp.Tests", "tests\Repo.CSharp.Tests\Repo.CSharp.Tests.csproj", "{604E3254-B3F7-4A16-872A-B0EACC7846DC}"
6262
EndProject
63+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsMatcher", "src\plugins\ConstraintsMatcher\ConstraintsMatcher.csproj", "{10456FBA-B53A-486A-811A-96A5E962B026}"
64+
EndProject
65+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintsPlugin", "src\plugins\ConstraintsPlugin\ConstraintsPlugin.csproj", "{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}"
66+
EndProject
6367
Global
6468
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6569
Debug|Any CPU = Debug|Any CPU
@@ -210,6 +214,30 @@ Global
210214
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|Any CPU.Build.0 = Release|Any CPU
211215
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.ActiveCfg = Release|Any CPU
212216
{604E3254-B3F7-4A16-872A-B0EACC7846DC}.Release|x64.Build.0 = Release|Any CPU
217+
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218+
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|Any CPU.Build.0 = Debug|Any CPU
219+
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|x64.ActiveCfg = Debug|Any CPU
220+
{10456FBA-B53A-486A-811A-96A5E962B026}.Debug|x64.Build.0 = Debug|Any CPU
221+
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|Any CPU.ActiveCfg = Release|Any CPU
222+
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|Any CPU.Build.0 = Release|Any CPU
223+
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|x64.ActiveCfg = Release|Any CPU
224+
{10456FBA-B53A-486A-811A-96A5E962B026}.MonoRelease|x64.Build.0 = Release|Any CPU
225+
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|Any CPU.ActiveCfg = Release|Any CPU
226+
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|Any CPU.Build.0 = Release|Any CPU
227+
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|x64.ActiveCfg = Release|Any CPU
228+
{10456FBA-B53A-486A-811A-96A5E962B026}.Release|x64.Build.0 = Release|Any CPU
229+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
231+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.ActiveCfg = Debug|Any CPU
232+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Debug|x64.Build.0 = Debug|Any CPU
233+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.ActiveCfg = MonoRelease|Any CPU
234+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|Any CPU.Build.0 = MonoRelease|Any CPU
235+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.ActiveCfg = MonoRelease|Any CPU
236+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.MonoRelease|x64.Build.0 = MonoRelease|Any CPU
237+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
238+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|Any CPU.Build.0 = Release|Any CPU
239+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.ActiveCfg = Release|Any CPU
240+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD}.Release|x64.Build.0 = Release|Any CPU
213241
EndGlobalSection
214242
GlobalSection(SolutionProperties) = preSolution
215243
HideSolutionNode = FALSE
@@ -222,6 +250,8 @@ Global
222250
{C57410A1-A86F-418B-9AC7-38249450C497} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
223251
{8EDF4429-251A-416D-BB68-93F227191BCF} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
224252
{604E3254-B3F7-4A16-872A-B0EACC7846DC} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
253+
{10456FBA-B53A-486A-811A-96A5E962B026} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
254+
{F2CB1E30-1AED-49A9-91C5-BEE8E2922FBD} = {F12CD406-E1CD-43B7-B4BC-E2991723C56E}
225255
EndGlobalSection
226256
GlobalSection(ExtensibilityGlobals) = postSolution
227257
SolutionGuid = {D0B60BC3-B119-4CD6-8FC4-CD8FA1429BE4}

build.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let solutionFile = "REAL.NET.sln"
5252
// Default target configuration
5353
let configuration, doNotCopyBinaries =
5454
if RuntimeInformation.IsOSPlatform OSPlatform.Linux then
55-
"MonoRelease", ["WpfEditor"; "WpfControlsLib"; "AirSim"]
55+
"MonoRelease", ["WpfEditor"; "WpfControlsLib"; "AirSim"; "EditorPluginInterfaces"]
5656
else
5757
"Release", []
5858

src/EditorPluginInterfaces/PluginConfig.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ public class PluginConfig
6868
/// </summary>
6969
public Action<string> ChangeModel;
7070

71+
/// <summary>
72+
/// Main window's right panel area
73+
/// </summary>
74+
public Grid RightPanelGrid { get; set; }
75+
76+
/// <summary>
77+
/// SceneGrid
78+
/// </summary>
79+
public Grid SceneGrid { get; set; }
80+
81+
/// <summary>
82+
/// SceneGrid
83+
/// </summary>
84+
public Grid PaletteGrid { get; set; }
85+
7186
/// <summary>
7287
/// Initializes a new instance of <see cref="PluginConfig"/>
7388
/// </summary>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
(* Copyright 2017 Yurii Litvinov
2+
*
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
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
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. *)
14+
15+
namespace Repo.Metametamodels
16+
17+
open Repo
18+
open Repo.DataLayer
19+
open Repo.InfrastructureSemanticLayer
20+
21+
/// Initializes repository with Constraints Metamodel, first testing metamodel of a real language.
22+
type ConstraintsMetamodelBuilder() =
23+
interface IModelBuilder with
24+
member this.Build(repo: IRepo): unit =
25+
let infrastructure = InfrastructureSemanticLayer.InfrastructureSemantic(repo)
26+
let metamodel = infrastructure.Metamodel.Model
27+
28+
let find name = CoreSemanticLayer.Model.findNode metamodel name
29+
let findAssociation node name = CoreSemanticLayer.Model.findAssociationWithSource node name
30+
31+
let metamodelElement = find "Element"
32+
let metamodelNode = find "Node"
33+
let metamodelGeneralization = find "Generalization"
34+
let metamodelAssociation = find "Association"
35+
let metamodelAttribute = find "Attribute"
36+
37+
let metamodelStringNode = find "String"
38+
let metamodelBooleanNode = find "Boolean"
39+
let metamodelMetatypeNode = find "Metatype"
40+
let metamodelAttributeKindNode = find "AttributeKind"
41+
42+
let attributesAssociation = findAssociation metamodelElement "attributes"
43+
44+
let shapeAssociation = findAssociation metamodelElement "shape"
45+
let isAbstractAssociation = findAssociation metamodelElement "isAbstract"
46+
let instanceMetatypeAssociation = findAssociation metamodelElement "instanceMetatype"
47+
48+
let attributeKindAssociation = findAssociation metamodelAttribute "kind"
49+
let attributeStringValueAssociation = findAssociation metamodelAttribute "stringValue"
50+
51+
let edgeTargetNameAssociation = findAssociation metamodelAssociation "targetName"
52+
53+
let model = repo.CreateModel("ConstraintsMetamodel", metamodel)
54+
model.Properties <- model.Properties.Add ("IsVisible", false.ToString())
55+
56+
let (~+) (name, shape, isAbstract) =
57+
let node = infrastructure.Instantiate model metamodelNode :?> INode
58+
node.Name <- name
59+
infrastructure.Element.SetAttributeValue node "shape" shape
60+
infrastructure.Element.SetAttributeValue node "isAbstract" (if isAbstract then "true" else "false")
61+
infrastructure.Element.SetAttributeValue node "instanceMetatype" "Metatype.Node"
62+
63+
node
64+
65+
let (--|>) (source: IElement) target =
66+
model.CreateGeneralization(metamodelGeneralization, source, target) |> ignore
67+
68+
let (--->) (source: IElement) (target, targetName, linkName) =
69+
let edge = infrastructure.Instantiate model metamodelAssociation :?> IAssociation
70+
edge.Source <- Some source
71+
edge.Target <- Some target
72+
edge.TargetName <- targetName
73+
74+
infrastructure.Element.SetAttributeValue edge "shape" "View/Pictures/edge.png"
75+
infrastructure.Element.SetAttributeValue edge "isAbstract" "false"
76+
infrastructure.Element.SetAttributeValue edge "instanceMetatype" "Metatype.Edge"
77+
infrastructure.Element.SetAttributeValue edge "name" linkName
78+
79+
edge
80+
81+
let abstractNode = +("AbstractNode", "", true)
82+
let initialNode = +("InitialNode", "View/Pictures/initialBlock.png", false)
83+
let finalNode = +("FinalNode", "View/Pictures/finalBlock.png", false)
84+
85+
let abstractMotorsBlock = +("AbstractMotorsBlock", "", true)
86+
infrastructure.Element.AddAttribute abstractMotorsBlock "ports" "AttributeKind.String" "M3, M4"
87+
88+
let abstractMotorsPowerBlock = +("AbstractMotorsPowerBlock", "", true)
89+
infrastructure.Element.AddAttribute abstractMotorsPowerBlock "power" "AttributeKind.Int" "100"
90+
91+
let motorsForward = +("MotorsForward", "View/Pictures/enginesForwardBlock.png", false)
92+
let motorsBackward = +("MotorsBackward", "View/Pictures/enginesBackwardBlock.png", false)
93+
let motorsStop = +("MotorsStop", "View/Pictures/enginesStopBlock.png", false)
94+
let timer = +("Timer", "View/Pictures/timerBlock.png", false)
95+
96+
let allNodes = +("AllNodes", "View/Pictures/allNodes.png", false)
97+
let noNodes = +("NoNodes", "View/Pictures/noNodes.png", false)
98+
let orNode = +("OrNode", "View/Pictures/orNode.png", false)
99+
let notNode = +("NotNode", "View/Pictures/notNode.png", false)
100+
101+
let link = abstractNode ---> (abstractNode, "target", "Link")
102+
infrastructure.Element.AddAttribute link "guard" "AttributeKind.String" ""
103+
104+
infrastructure.Element.AddAttribute timer "delay" "AttributeKind.Int" "1000"
105+
106+
finalNode --|> abstractNode
107+
motorsForward --|> abstractMotorsPowerBlock
108+
motorsBackward --|> abstractMotorsPowerBlock
109+
abstractMotorsPowerBlock --|> abstractMotorsBlock
110+
motorsStop --|> abstractMotorsBlock
111+
abstractMotorsBlock --|> abstractNode
112+
timer --|> abstractNode
113+
allNodes --|> abstractNode
114+
noNodes --|> abstractNode
115+
orNode --|> abstractNode
116+
notNode --|> abstractNode
117+
118+
()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
(* Copyright 2017 Yurii Litvinov
2+
*
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
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
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. *)
14+
15+
namespace Repo.Metametamodels
16+
17+
open Repo.DataLayer
18+
open Repo.CoreSemanticLayer
19+
open Repo.InfrastructureSemanticLayer
20+
open System.Runtime.InteropServices
21+
22+
/// Initializes repository with test model conforming to Constraints Metamodel, actual program that can be written by end-user.
23+
type ConstraintsTestModelBuilder() =
24+
interface IModelBuilder with
25+
member this.Build(repo: IRepo): unit =
26+
let infrastructure = InfrastructureSemantic(repo)
27+
let metamodel = Repo.findModel repo "ConstraintsMetamodel"
28+
let infrastructureMetamodel = infrastructure.Metamodel.Model
29+
30+
let metamodelAbstractNode = Model.findNode metamodel "AbstractNode"
31+
let metamodelInitialNode = Model.findNode metamodel "InitialNode"
32+
let metamodelFinalNode = Model.findNode metamodel "FinalNode"
33+
let metamodelMotorsForward = Model.findNode metamodel "MotorsForward"
34+
let metamodelTimer = Model.findNode metamodel "Timer"
35+
36+
let metamodelAll = Model.findNode metamodel "AllNodes"
37+
38+
let metamodelOr = Model.findNode metamodel "OrNode"
39+
let metamodelNot = Model.findNode metamodel "NotNode"
40+
let metamodelNone = Model.findNode metamodel "NoNodes"
41+
42+
43+
let link = Model.findAssociationWithSource metamodelAbstractNode "target"
44+
45+
let model = repo.CreateModel("ConstraintsTestModel", metamodel)
46+
model.Properties <- model.Properties.Add ("IsVisible", false.ToString())
47+
let initialNode = infrastructure.Instantiate model metamodelInitialNode
48+
49+
let motorsForw = infrastructure.Instantiate model metamodelMotorsForward
50+
infrastructure.Element.SetAttributeValue motorsForw "ports" "M3, M4"
51+
infrastructure.Element.SetAttributeValue motorsForw "power" "10*"
52+
53+
54+
let (-->) (src: IElement) dst =
55+
let aLink = infrastructure.Instantiate model link :?> IAssociation
56+
aLink.Source <- Some src
57+
aLink.Target <- Some dst
58+
dst
59+
60+
61+
motorsForw |> ignore
62+
()

src/Repo/Repo.fsproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
<Compile Include="ModelBuilders\AirSimMetamodelBuilder.fs" />
9393
<Compile Include="ModelBuilders\AirSimModelBuilder.fs" />
9494
<Compile Include="ModelBuilders\CoreMetametamodelBuilder.fs" />
95+
<Compile Include="ModelBuilders\ConstraintsMetamodelBuilder.fs" />
96+
<Compile Include="ModelBuilders\ConstraintsTestModelBuilder.fs" />
9597
<Compile Include="FacadeLayer.fs" />
9698
<Compile Include="FacadeLayer\Attribute.fs" />
9799
<Compile Include="FacadeLayer\Element.fs" />

src/Repo/RepoFactory.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type RepoFactory =
3030
Metametamodels.RobotsTestModelBuilder() |> build
3131
Metametamodels.AirSimMetamodelBuilder() |> build
3232
Metametamodels.AirSimModelBuilder() |> build
33+
Metametamodels.ConstraintsMetamodelBuilder() |> build
34+
Metametamodels.ConstraintsTestModelBuilder() |> build
3335

3436
new FacadeLayer.Repo(data) :> IRepo
3537

src/WpfControlsLib/Controls/Scene/Scene.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace WpfControlsLib.Controls.Scene
2020
using System.Windows.Controls;
2121
using System.Windows.Input;
2222
using System.Windows.Media;
23+
using EditorPluginInterfaces;
2324
using GraphX.Controls;
2425
using GraphX.Controls.Models;
2526
using GraphX.PCL.Common.Enums;
@@ -35,7 +36,7 @@ namespace WpfControlsLib.Controls.Scene
3536
/// <summary>
3637
/// Visualizes model graph and makes it possible for a user to interact with it.
3738
/// </summary>
38-
public partial class Scene : UserControl
39+
public partial class Scene : UserControl, IScene
3940
{
4041
private readonly EditorObjectManager editorManager;
4142
private VertexControl previosVertex;

src/WpfControlsLib/Model/Graph.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ private void RemoveElement(IElement element)
198198
this.DataGraph.RemoveVertex(nodeViewModel);
199199
}
200200

201+
var model = this.model.Repo.Model(this.model.ModelName);
202+
model.DeleteElement(element);
201203
this.ElementRemoved?.Invoke(this, new ElementRemovedEventArgs { Element = element });
202204
}
203205

@@ -214,6 +216,7 @@ private void CheckElement(IElement element, bool isAllowed)
214216
var nodeViewModel = this.DataGraph.Vertices.First(x => x.Node == element);
215217
nodeViewModel.IsAllowed = isAllowed;
216218
}
219+
this.ElementRemoved?.Invoke(this, new ElementRemovedEventArgs { Element = element });
217220
}
218221

219222
public class DataVertexArgs : EventArgs

src/WpfControlsLib/ViewModel/NodeViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public Brush Color
4646
}
4747
}
4848

49+
/// <summary>
50+
/// Gets or sets border color for a node.
51+
/// </summary>
4952
public Brush BorderColor
5053
{
5154
get => this.borderColor;
@@ -56,6 +59,9 @@ public Brush BorderColor
5659
}
5760
}
5861

62+
/// <summary>
63+
/// Shows if node is allowed.
64+
/// </summary>
5965
public bool IsAllowed
6066
{
6167
get => this.isAllowed;

0 commit comments

Comments
 (0)