Skip to content

Commit 85ed355

Browse files
Some small corrections in new constraints functionality
1 parent b91a8a6 commit 85ed355

File tree

6 files changed

+33
-18
lines changed

6 files changed

+33
-18
lines changed

src/EditorPluginInterfaces/PluginConfig.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public class PluginConfig
5656
/// <summary>
5757
/// Allows plugin to subscribe to the model change.
5858
/// </summary>
59-
public Action<String> OnMainModelChanged;
59+
public Action<string> OnMainModelChanged;
6060

6161
/// <summary>
6262
/// Allows plugin to remove model selector from the editor.
6363
/// </summary>
64-
public Action<bool> ChangeSelectorVisibility;
64+
public Action<bool> ChangeModelSelectorVisibility;
6565

6666
/// <summary>
6767
/// Allows plugin to change model in the editor.
@@ -77,6 +77,8 @@ public class PluginConfig
7777
/// <param name="toolbar">Toolbar</param>
7878
/// <param name="console">Console</param>
7979
/// <param name="palette">Palette</param>
80+
/// <param name="leftPanelGrid">Grid where left panel elements are located. Empty by default, but plugins can
81+
/// use it to add some new tools.</param>
8082
public PluginConfig(IModel model, IScene scene, IToolbar toolbar, IConsole console, IPalette palette, Grid leftPanelGrid)
8183
{
8284
this.Model = model;

src/Repo/Repo.fsproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,9 @@
102102
<Compile Include="FacadeLayer\Repo.fs" />
103103
<Compile Include="RepoFactory.fs" />
104104
<Content Include="app.config" />
105-
<Content Include="packages.config" />
106105
</ItemGroup>
107106
<ItemGroup>
108107
<Reference Include="mscorlib" />
109-
<Reference Include="Newtonsoft.Json">
110-
<HintPath>..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
111-
</Reference>
112108
<Reference Include="System" />
113109
<Reference Include="System.Core" />
114110
<Reference Include="System.IO.Compression" />
@@ -126,6 +122,14 @@
126122
</When>
127123
</Choose>
128124
<Choose>
129-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'" />
125+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
126+
<ItemGroup>
127+
<Reference Include="Newtonsoft.Json">
128+
<HintPath>..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
129+
<Private>True</Private>
130+
<Paket>True</Paket>
131+
</Reference>
132+
</ItemGroup>
133+
</When>
130134
</Choose>
131135
</Project>

src/WpfControlsLib/Model/Model.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ public void RemoveElement(Repo.IElement element)
169169
}
170170

171171
public void SetElementAllowed(Repo.IElement element, bool isAllowed)
172-
{
173-
this.RaiseElementCheck(element, isAllowed);
174-
}
172+
=> this.RaiseElementCheck(element, isAllowed);
175173

176174
private void RaiseNewVertex(Repo.INode node)
177175
{

src/WpfControlsLib/ViewModel/EdgeViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ public class EdgeViewModel : EdgeBase<NodeViewModel>, INotifyPropertyChanged, IG
1212
{
1313
private EdgeTypeEnum edgeType = EdgeTypeEnum.Association;
1414
private IList<AttributeViewModel> attributes = new List<AttributeViewModel>();
15-
private SolidColorBrush brush = new SolidColorBrush(Colors.Blue);
15+
private SolidColorBrush brush = Brushes.Blue;
1616
private bool isAllowed = true;
1717

18+
private static readonly SolidColorBrush invalidEdgeBrush = Brushes.Red;
19+
private static readonly SolidColorBrush defaultEdgeBrush = Brushes.Blue;
20+
1821
private string text;
1922

2023
public EdgeViewModel(NodeViewModel source, NodeViewModel target, double weight = 1)
@@ -57,7 +60,8 @@ public bool IsAllowed
5760
set
5861
{
5962
this.isAllowed = value;
60-
this.Color = value ? new SolidColorBrush(Colors.Blue) : new SolidColorBrush(Colors.Red);
63+
// TODO: Color property can be set by an user, and user color will be forgotten after IsAllowed change.
64+
this.Color = value ? defaultEdgeBrush : invalidEdgeBrush;
6165
}
6266
}
6367

src/WpfEditor/View/MainWindow.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ private void InitAndLaunchPlugins()
133133
{
134134
var dirs = new List<string>(System.IO.Directory.GetDirectories(plugindir + "/bin"));
135135
var config = new PluginConfig(this.model, null, null, this.Console, null, this.leftPanelGrid);
136-
config.ChangeSelectorVisibility = (x) => { this.modelSelector.SelectorVisibility = x; };
136+
config.ChangeModelSelectorVisibility = (x) => { this.modelSelector.SelectorVisibility = x; };
137137
config.ChangeModel = this.SelectModel;
138138
foreach (var dir in dirs)
139139
{
140140
libs.LaunchPlugins(dir, config);
141141
}
142+
142143
if (config.OnMainModelChanged != null)
144+
{
143145
this.OnModelChanged += new Action<string>(config.OnMainModelChanged);
146+
}
144147
}
145148
}
146149

src/WpfEditor/WpfEditor.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
<Prefer32Bit>true</Prefer32Bit>
5050
</PropertyGroup>
5151
<ItemGroup>
52-
<Reference Include="FSharp.Core, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
53-
<HintPath>..\..\packages\FSharp.Core.4.6.2\lib\net45\FSharp.Core.dll</HintPath>
54-
</Reference>
5552
<Reference Include="System" />
5653
<Reference Include="System.Data" />
5754
<Reference Include="System.Xml" />
@@ -116,7 +113,6 @@
116113
<Generator>ResXFileCodeGenerator</Generator>
117114
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
118115
</EmbeddedResource>
119-
<None Include="packages.config" />
120116
<None Include="paket.references" />
121117
<None Include="Properties\Settings.settings">
122118
<Generator>SettingsSingleFileGenerator</Generator>
@@ -177,7 +173,15 @@
177173
<Resource Include="View\Pictures\Toolbar\undo.png" />
178174
</ItemGroup>
179175
<Choose>
180-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'" />
176+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
177+
<ItemGroup>
178+
<Reference Include="FSharp.Core">
179+
<HintPath>..\..\packages\FSharp.Core\lib\net45\FSharp.Core.dll</HintPath>
180+
<Private>True</Private>
181+
<Paket>True</Paket>
182+
</Reference>
183+
</ItemGroup>
184+
</When>
181185
</Choose>
182186
<Choose>
183187
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">

0 commit comments

Comments
 (0)