screwed around with optimizations and styles

NodesAndConnections
Liam Golly 5 years ago
parent 9b64435906
commit a9918c479a

@ -30,8 +30,11 @@
<component name="ChangeListManager">
<list default="true" id="8d840f1a-4000-4390-ab3f-2383ed6434d5" name="Default Changelist" comment="Updated Paths with a direction enum, and added seaskipper costs enum">
<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$/Controls/EditorCanvas.xaml" beforeDir="false" afterPath="$PROJECT_DIR$/Controls/EditorCanvas.xaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Controls/EditorCanvas.xaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Controls/EditorCanvas.xaml.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Controls/Node.xaml" beforeDir="false" afterPath="$PROJECT_DIR$/Controls/Node.xaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Controls/Node.xaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Controls/Node.xaml.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NodeEditor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/NodeEditor.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/MainWindow.xaml" beforeDir="false" afterPath="$PROJECT_DIR$/MainWindow.xaml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -47,7 +50,7 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="mock://C:/Users/Liam/NodeEditor/Controls/Path.xaml.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="mock://C:/Users/Liam/NodeEditor/Controls/Node.xaml.cs" root0="SKIP_HIGHLIGHTING" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
@ -57,8 +60,11 @@
<option value="$PROJECT_DIR$/Extensions/SeaskipperCosts.cs" />
<option value="$PROJECT_DIR$/Extensions/Direction.cs" />
<option value="$PROJECT_DIR$/Controls/Path.xaml.cs" />
<option value="$PROJECT_DIR$/Controls/Node.xaml.cs" />
<option value="$PROJECT_DIR$/NodeEditor.csproj" />
<option value="$PROJECT_DIR$/Controls/EditorCanvas.xaml.cs" />
<option value="$PROJECT_DIR$/Controls/EditorCanvas.xaml" />
<option value="$PROJECT_DIR$/Controls/Node.xaml.cs" />
<option value="$PROJECT_DIR$/Controls/Node.xaml" />
</list>
</option>
</component>
@ -117,6 +123,7 @@
<workItem from="1608418548513" duration="1911000" />
<workItem from="1608578473230" duration="1904000" />
<workItem from="1608581445298" duration="4238000" />
<workItem from="1608585736986" duration="1797000" />
</task>
<task id="LOCAL-00001" summary="Added custom Node control">
<created>1608580007149</created>
@ -139,7 +146,14 @@
<option name="project" value="LOCAL" />
<updated>1608584795551</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Hopefully fixed runtime identifiers stopping the program from running.">
<created>1608585937903</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1608585937903</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -191,20 +205,37 @@
<MESSAGE value="Added custom Node control" />
<MESSAGE value="Added Paths custom control and Modes enum." />
<MESSAGE value="Updated Paths with a direction enum, and added seaskipper costs enum" />
<option name="LAST_COMMIT_MESSAGE" value="Updated Paths with a direction enum, and added seaskipper costs enum" />
<MESSAGE value="Hopefully fixed runtime identifiers stopping the program from running." />
<option name="LAST_COMMIT_MESSAGE" value="Hopefully fixed runtime identifiers stopping the program from running." />
</component>
<component name="WindowStateProjectService">
<state x="0" y="228" key="SettingsEditor" timestamp="1608583242732">
<state width="914" height="320" key="GridCell.Tab.0.bottom" timestamp="1608587216769">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state width="914" height="320" key="GridCell.Tab.0.bottom/0.0.1920.1160@0.0.1920.1160" timestamp="1608587216769" />
<state width="914" height="320" key="GridCell.Tab.0.center" timestamp="1608587216769">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state width="914" height="320" key="GridCell.Tab.0.center/0.0.1920.1160@0.0.1920.1160" timestamp="1608587216769" />
<state width="914" height="320" key="GridCell.Tab.0.left" timestamp="1608587216769">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state width="914" height="320" key="GridCell.Tab.0.left/0.0.1920.1160@0.0.1920.1160" timestamp="1608587216769" />
<state width="914" height="320" key="GridCell.Tab.0.right" timestamp="1608587216769">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state width="914" height="320" key="GridCell.Tab.0.right/0.0.1920.1160@0.0.1920.1160" timestamp="1608587216769" />
<state x="0" y="228" key="SettingsEditor" timestamp="1608586092924">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state x="0" y="228" key="SettingsEditor/0.0.1920.1160@0.0.1920.1160" timestamp="1608583242732" />
<state x="0" y="228" key="SettingsEditor/0.0.1920.1160@0.0.1920.1160" timestamp="1608586092924" />
<state x="92" y="92" width="1736" height="976" key="VCS.FileHistoryDialog" timestamp="1608585366848">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state x="92" y="92" width="1736" height="976" key="VCS.FileHistoryDialog/0.0.1920.1160@0.0.1920.1160" timestamp="1608585366848" />
<state x="552" y="313" key="Vcs.Push.Dialog.v2" timestamp="1608582676704">
<state x="552" y="313" key="Vcs.Push.Dialog.v2" timestamp="1608585941128">
<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="1608582676704" />
<state x="552" y="313" key="Vcs.Push.Dialog.v2/0.0.1920.1160@0.0.1920.1160" timestamp="1608585941128" />
</component>
</project>

@ -1,18 +1,20 @@
<UserControl x:Class="NodeEditor.EditorCanvas"
<UserControl x:Class="NodeEditor.Controls.EditorCanvas"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:NodeEditor.Controls"
xmlns:local="clr-namespace:NodeEditor"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Canvas Name="m_EditorCanvas" Background="Green">
<Canvas Name="mapCanvas" Background="Blue">
<Canvas.RenderTransform>
<MatrixTransform/>
<MatrixTransform />
</Canvas.RenderTransform>
<Image Name="map" Source="../main-map.png"></Image>
<Image Name="map" Source="../main-map.png" />
<controls:Node />
</Canvas>
<TextBox Name="test"></TextBox>
<TextBox Name="test" />
</Canvas>
</UserControl>
</UserControl>

@ -1,29 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.WebSockets;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;
using NodeEditor.Extensions;
namespace NodeEditor
namespace NodeEditor.Controls
{
/// <summary>
/// Interaction logic for EditorCanvas.xaml
/// </summary>
public partial class EditorCanvas : UserControl
{
Point? dragStart = null;
private Point? _dragStart = null;
public EditorCanvas()
{
@ -38,26 +25,25 @@ namespace NodeEditor
{
var element = (UIElement) sender;
// dragStart = new Point(e.GetPosition(mapCanvas).X * st.ScaleX, e.GetPosition(mapCanvas).Y * st.ScaleY);
var transform = mapCanvas.RenderTransform as MatrixTransform;
dragStart = new Point(e.GetPosition(mapCanvas).X * transform.Value.M11, e.GetPosition(mapCanvas).Y * transform.Value.M22);
if (mapCanvas.RenderTransform is MatrixTransform transform)
_dragStart = new Point(e.GetPosition(mapCanvas).X * transform.Value.M11,
e.GetPosition(mapCanvas).Y * transform.Value.M22);
element.CaptureMouse();
}
private void MapCanvas_StopDrag(object sender, MouseEventArgs e)
{
var element = (UIElement)sender;
dragStart = null;
_dragStart = null;
element.ReleaseMouseCapture();
}
private void MapCanvas_Drag(object sender, MouseEventArgs e)
{
if (dragStart != null && e.LeftButton == MouseButtonState.Pressed)
{
var newPoint = e.GetPosition(m_EditorCanvas);
if (_dragStart == null || e.LeftButton != MouseButtonState.Pressed) return;
var newPoint = e.GetPosition(m_EditorCanvas);
Canvas.SetLeft(mapCanvas, newPoint.X - dragStart.Value.X);
Canvas.SetTop(mapCanvas, newPoint.Y - dragStart.Value.Y);
}
Canvas.SetLeft(mapCanvas, newPoint.X - _dragStart.Value.X);
Canvas.SetTop(mapCanvas, newPoint.Y - _dragStart.Value.Y);
}
private void MapCanvas_OnScroll(object sender, MouseWheelEventArgs e)
@ -74,7 +60,7 @@ namespace NodeEditor
// }
var element = sender as UIElement;
var position = e.GetPosition(element);
var transform = mapCanvas.RenderTransform as MatrixTransform;
if (!(mapCanvas.RenderTransform is MatrixTransform transform)) return;
var matrix = transform.Matrix;
var scale = e.Delta >= 0 ? 1.1 : (1.0 / 1.1); // choose appropriate scaling factor

@ -1,12 +1,36 @@
<UserControl x:Class="NodeEditor.Controls.Node"
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: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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
<Button Height="10" Width="10"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Stroke="Black"
StrokeThickness="0">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Offset="0" Color="Gray"/>
<GradientStop Offset="1" Color="Gray"/>
<GradientStop Offset="1" Color="DarkGray"/>
<RadialGradientBrush.Transform>
<TransformGroup>
<ScaleTransform ScaleY="0.65"/>
</TransformGroup>
</RadialGradientBrush.Transform>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</UserControl>

@ -15,7 +15,7 @@ namespace NodeEditor.Controls
public Node()
{
Nodes.Add(this);
Name = GetIndexOf(this).ToString();
//Name = GetIndexOf(this).ToString();
Desc = "";
InitializeComponent();
}

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NodeEditor"
xmlns:controls="clr-namespace:NodeEditor.Controls"
mc:Ignorable="d"
WindowStyle="ToolWindow"
WindowStartupLocation="CenterScreen"
@ -64,8 +65,8 @@
<!-- ~1~ </Canvas> @1@ -->
<!-- -->
<!-- </Grid> -->
<local:EditorCanvas Background="Black" Margin="20,20,20,20">
<controls:EditorCanvas Background="Black" Margin="20,20,20,20">
</local:EditorCanvas>
</controls:EditorCanvas>
</Window>

Loading…
Cancel
Save