Added Paths custom control and Modes enum.

NodesAndConnections
Liam Golly 5 years ago
parent 9afbfb0443
commit 9ef2a57235

@ -14,9 +14,12 @@
<e p="EditorCanvas.xaml.cs" t="Include" />
<e p="Node.xaml" t="Include" />
<e p="Node.xaml.cs" t="Include" />
<e p="Path.xaml" t="Include" />
<e p="Path.xaml.cs" t="Include" />
</e>
<e p="Extensions" t="Include">
<e p="MathExtensions.cs" t="Include" />
<e p="Modes.cs" t="Include" />
<e p="MouseExtensions.cs" t="Include" />
<e p="ReadJSON.cs" t="Include" />
</e>

@ -28,12 +28,10 @@
</select>
</component>
<component name="ChangeListManager">
<list default="true" id="8d840f1a-4000-4390-ab3f-2383ed6434d5" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/riderModule.iml" afterDir="false" />
<list default="true" id="8d840f1a-4000-4390-ab3f-2383ed6434d5" name="Default Changelist" comment="Added custom Node control">
<change afterPath="$PROJECT_DIR$/Controls/Path.xaml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Extensions/Modes.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/contentModel.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.NodeEditor/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NodeEditor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/NodeEditor.csproj" afterDir="false" />
</list>
@ -54,6 +52,9 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Controls/Node.xaml.cs" />
<option value="$PROJECT_DIR$/Controls/Path.xaml" />
<option value="$PROJECT_DIR$/Extensions/Modes.cs" />
<option value="$PROJECT_DIR$/Controls/Path.xaml.cs" />
</list>
</option>
</component>
@ -106,8 +107,17 @@
<option name="presentableId" value="Default" />
<updated>1608418540783</updated>
<workItem from="1608418548513" duration="1911000" />
<workItem from="1608578473230" duration="1414000" />
<workItem from="1608578473230" duration="1904000" />
<workItem from="1608581445298" duration="934000" />
</task>
<task id="LOCAL-00001" summary="Added custom Node control">
<created>1608580007149</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1608580007149</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -152,8 +162,17 @@
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Added custom Node control" />
<option name="LAST_COMMIT_MESSAGE" value="Added custom Node control" />
</component>
<component name="WindowStateProjectService">
<state x="552" y="313" key="Vcs.Push.Dialog.v2" timestamp="1608580058123">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state x="552" y="313" key="Vcs.Push.Dialog.v2/0.0.1920.1160@0.0.1920.1160" timestamp="1608580058123" />
</component>
</project>

@ -0,0 +1,12 @@
<UserControl x:Class="NodeEditor.Controls.Path"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NodeEditor.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>

@ -0,0 +1,87 @@
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;
using NodeEditor.Extensions;
namespace NodeEditor.Controls
{
public partial class Path : UserControl
{
public static List<Path> Paths { get; } = new List<Path>();
public int[] Difficulty { get; set; }
public double Distance { get; set; }
public int LvlRequired { get; set; }
public Modes Mode { get; set; }
public int Cost { get; set; }
public Path()
{
Difficulty = new[] {1, 1, 1, 1, 1};
Distance = 0;
LvlRequired = 0;
Mode = Modes.Walk;
Cost = 0;
Paths.Add(this);
InitializeComponent();
}
public Path(int distance)
{
Difficulty = new[] {1, 1, 1, 1, 1};
Distance = distance;
LvlRequired = 0;
Mode = Modes.Walk;
Cost = 0;
Paths.Add(this);
InitializeComponent();
}
public Path(int distance, Modes mode)
{
Difficulty = new[] {1, 1, 1, 1, 1};
Distance = distance;
LvlRequired = 0;
Mode = mode;
Cost = 0;
Paths.Add(this);
InitializeComponent();
}
public Path(int distance, Modes mode, int cost)
{
Difficulty = new[] {1, 1, 1, 1, 1};
Distance = distance;
LvlRequired = 0;
Mode = mode;
Cost = cost;
Paths.Add(this);
InitializeComponent();
}
public Path(int distance, Modes mode, int cost, int lvlRequired)
{
Difficulty = new[] {1, 1, 1, 1, 1};
Distance = distance;
LvlRequired = lvlRequired;
Mode = mode;
Cost = cost;
Paths.Add(this);
InitializeComponent();
}
public Path(int distance, Modes mode, int cost, int lvlRequired, int[] difficulty)
{
Difficulty = difficulty;
Distance = distance;
LvlRequired = lvlRequired;
Mode = mode;
Cost = cost;
Paths.Add(this);
InitializeComponent();
}
public void Destroy()
{
var parentObject = VisualTreeHelper.GetParent(this);
var parent = parentObject as Canvas;
parent?.Children.Remove(this);
Paths.Remove(this);
}
}
}

@ -0,0 +1,12 @@
namespace NodeEditor.Extensions
{
public enum Modes
{
Seaskipper,
MageIsland,
Skyship,
Tunnel,
Elevator,
Walk
}
}

@ -68,7 +68,11 @@
<Compile Include="Controls\Node.xaml.cs">
<DependentUpon>Node.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Path.xaml.cs">
<DependentUpon>Path.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\MathExtensions.cs" />
<Compile Include="Extensions\Modes.cs" />
<Compile Include="Extensions\MouseExtensions.cs" />
<Compile Include="Extensions\ReadJSON.cs" />
<Page Include="Controls\EditorCanvas.xaml">
@ -79,6 +83,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Path.xaml" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

Loading…
Cancel
Save