Skip to content

Commit adf123a

Browse files
author
MrsSima
committed
Added basics of Graphic Constraint System
1 parent ce60f6a commit adf123a

26 files changed

+525
-26
lines changed

src/EditorPluginInterfaces/EditorPluginInterfaces.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
</CodeAnalysisRuleSet>
4545
</PropertyGroup>
4646
<ItemGroup>
47+
<Reference Include="PresentationFramework" />
4748
<Reference Include="System" />
4849
<Reference Include="System.Core" />
4950
<Reference Include="System.Xml.Linq" />
@@ -57,6 +58,7 @@
5758
<Compile Include="EdgeEventArgs.cs" />
5859
<Compile Include="ElementEventArgs.cs" />
5960
<Compile Include="IConsole.cs" />
61+
<Compile Include="IElementProvider.cs" />
6062
<Compile Include="IModel.cs" />
6163
<Compile Include="IPlugin.cs" />
6264
<Compile Include="IPalette.cs" />

src/WpfControlsLib/Controls/Scene/IElementProvider.cs renamed to src/EditorPluginInterfaces/IElementProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License. */
1414

15-
namespace WpfControlsLib.Controls.Scene
15+
namespace EditorPluginInterfaces
1616
{
1717
/// <summary>
1818
/// Something that can say what element scene shall create when someone clicks on it. For example, selected

src/EditorPluginInterfaces/PluginConfig.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace EditorPluginInterfaces
1616
{
17+
using System.Windows.Controls;
1718
using Toolbar;
1819

1920
/// <summary>
@@ -44,7 +45,22 @@ public class PluginConfig
4445
/// <summary>
4546
/// Palette's reference that should be given to plugin
4647
/// </summary>
47-
public IPalette Palette { get; }
48+
public IElementProvider ElementProvider { get; }
49+
50+
/// <summary>
51+
/// DockPanel for Constraints plugin that should be given to plugin
52+
/// </summary>
53+
public Grid ConstraintsGrid { get; }
54+
55+
/// <summary>
56+
/// RightPanel
57+
/// </summary>
58+
public Grid RightPanel { get; }
59+
60+
/// <summary>
61+
/// RightPanel
62+
/// </summary>
63+
public Grid SceneGrid { get; }
4864

4965
/// <summary>
5066
/// Initializes a new instance of <see cref="PluginConfig"/>
@@ -54,14 +70,17 @@ public class PluginConfig
5470
/// <param name="scene">Scene</param>
5571
/// <param name="toolbar">Toolbar</param>
5672
/// <param name="console">Console</param>
57-
/// <param name="palette">Palette</param>
58-
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IPalette palette)
73+
/// <param name="elementProvider">Element provider</param>
74+
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IElementProvider elementProvider, Grid constraintsGrid, Grid rightPanel, Grid sceneGrid)
5975
{
6076
this.Model = model;
6177
this.Scene = scene;
6278
this.Toolbar = toolbar;
6379
this.Console = console;
64-
this.Palette = palette;
80+
this.ElementProvider = elementProvider;
81+
this.ConstraintsGrid = constraintsGrid;
82+
this.RightPanel = rightPanel;
83+
this.SceneGrid = sceneGrid;
6584
}
6685
}
6786
}

src/WpfControlsLib/Controls/Palette/Palette.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License. */
1414

15+
using EditorPluginInterfaces;
1516
using System.Windows;
1617
using System.Windows.Controls;
1718
using System.Windows.Controls.Primitives;
@@ -22,7 +23,7 @@ namespace WpfControlsLib.Controls.Palette
2223
/// <summary>
2324
/// Palette with elements of a visual language.
2425
/// </summary>
25-
public partial class Palette : UserControl
26+
public partial class Palette : UserControl, IPalette
2627
{
2728
private bool isInDrag;
2829
private readonly PaletteViewModel paletteViewModel;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ namespace WpfControlsLib.Controls.Scene
3131
using WpfControlsLib.Controls.Scene.EventArguments;
3232
using WpfControlsLib.Model;
3333
using WpfControlsLib.ViewModel;
34+
using EditorPluginInterfaces;
3435

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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public void InitModel(string modelName)
7272

7373
foreach (var edge in model.Edges)
7474
{
75-
/* var isViolation = Constraints.CheckEdge(edgeViewModel, this.repo, modelName); */
76-
7775
var sourceNode = edge.From as INode;
7876
var targetNode = edge.To as INode;
7977
if (sourceNode == null || targetNode == null)

src/WpfControlsLib/WpfControlsLib.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
<Compile Include="Controls\Scene\EventArguments\ElementAddedEventArgs.cs" />
130130
<Compile Include="Controls\Scene\EventArguments\ElementRemovedEventArgs.cs" />
131131
<Compile Include="Controls\Scene\Geometry.cs" />
132-
<Compile Include="Controls\Scene\IElementProvider.cs" />
133132
<Compile Include="Controls\Scene\EventArguments\NodeSelectedEventArgs.cs" />
134133
<Compile Include="Controls\Scene\Scene.xaml.cs">
135134
<DependentUpon>Scene.xaml</DependentUpon>

src/WpfEditor/View/MainWindow.xaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
</Grid.RowDefinitions>
5454

5555
<Grid.ColumnDefinitions>
56-
<ColumnDefinition Width="*" MinWidth="100"/>
5756
<ColumnDefinition Width="Auto"/>
57+
<ColumnDefinition Width="*"/>
5858
<ColumnDefinition Width="Auto"/>
5959
</Grid.ColumnDefinitions>
6060

@@ -70,8 +70,16 @@
7070
</MenuItem>
7171
</Menu>
7272

73+
<!-- LeftPanel -->
74+
<Grid
75+
x:Name="constraintsGrid"
76+
Grid.Row="1"
77+
Grid.Column="0"
78+
HorizontalAlignment="Left"/>
79+
80+
7381
<!-- Area and console -->
74-
<Grid Grid.Row="1" Grid.Column="0">
82+
<Grid Grid.Row="1" Grid.Column="1">
7583

7684
<Grid.RowDefinitions>
7785
<RowDefinition Height="Auto"/>
@@ -84,9 +92,11 @@
8492
<toolbar:ToolbarView x:Name="toolBar" Grid.Row="0" DataContext="{Binding Toolbar}"/>
8593

8694
<!-- Scene area -->
87-
<scene:Scene Grid.Row="1" x:Name="scene"/>
95+
<Grid x:Name="sceneGrid" Grid.Row="1">
96+
<scene:Scene x:Name="scene"/>
97+
</Grid>
8898

89-
<!-- GridSplitter for console -->
99+
<!-- GridSplitter for console -->
90100
<GridSplitter Grid.Row ="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="5"/>
91101

92102
<!-- Console with error messages -->
@@ -95,10 +105,10 @@
95105
</Grid>
96106

97107
<!-- GridSplitter for RightPanel-->
98-
<GridSplitter Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="5"/>
108+
<GridSplitter Grid.Row="1" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="5"/>
99109

100110
<!-- RightPanel -->
101-
<DockPanel Grid.Row="1" Grid.Column="2">
111+
<DockPanel Grid.Row="1" Grid.Column="3">
102112
<Grid x:Name="rightPanel">
103113
<Grid.RowDefinitions>
104114
<RowDefinition Height="Auto"/>
@@ -125,13 +135,6 @@
125135
<DataGridTextColumn Header="Value" IsReadOnly="False" Binding="{Binding Value}"/>
126136
</DataGrid.Columns>
127137
</DataGrid>
128-
129-
<Button
130-
Grid.Row="5"
131-
Content="Constraints"
132-
HorizontalAlignment="Stretch"
133-
VerticalAlignment="Bottom"
134-
Click="ConstraintsButtonClick" Height="26"/>
135138
</Grid>
136139

137140
</DockPanel>

src/WpfEditor/View/MainWindow.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ internal partial class MainWindow : INotifyPropertyChanged
4343

4444
public ToolbarViewModel Toolbar { get; } = new ToolbarViewModel();
4545

46+
private IElementProvider temporaryElementProvider;
47+
4648
public string WindowTitle
4749
{
4850
get
@@ -83,7 +85,8 @@ public MainWindow()
8385
this.scene.NodeSelected += (sender, args) => this.attributesView.DataContext = args.Node;
8486
this.scene.EdgeSelected += (sender, args) => this.attributesView.DataContext = args.Edge;
8587

86-
this.scene.Init(this.model, this.controller, new PaletteAdapter(this.palette));
88+
this.temporaryElementProvider = new PaletteAdapter(this.palette);
89+
this.scene.Init(this.model, this.controller, this.temporaryElementProvider);
8790

8891
this.modelSelector.Init(this.model);
8992
this.modelSelector.ChangeModel(2);
@@ -130,7 +133,7 @@ private void InitAndLaunchPlugins()
130133
foreach (var plugindir in pluginDirs)
131134
{
132135
var dirs = new List<string>(System.IO.Directory.GetDirectories(plugindir + "/bin"));
133-
var config = new PluginConfig(this.model, null, null, this.Console, null);
136+
var config = new PluginConfig(this.model, this.scene, null, this.Console, this.temporaryElementProvider, this.constraintsGrid, this.rightPanel, this.sceneGrid);
134137
foreach (var dir in dirs)
135138
{
136139
libs.LaunchPlugins(dir, config);
7.1 KB
Loading

0 commit comments

Comments
 (0)