Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanSoloweow committed Jun 13, 2020
2 parents b3b3158 + 11e51da commit 8badf0e
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
<StartupObject>SimpleStateMachineNodeEditor.App</StartupObject>
<ApplicationIcon>StateMachine.ico</ApplicationIcon>
<SignAssembly>false</SignAssembly>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor</PackageProjectUrl>
<PackageIcon>SimpleStateMachine.png</PackageIcon>
<RepositoryUrl>https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor</RepositoryUrl>
<PackageTags>statemachine state-machine finite-state-machine</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Description>Node editor for SimpleStateMachine</Description>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>1.0.3.0</FileVersion>
<PackageReleaseNotes>Some fix
Some optimization
Feature with opacity
Custom for drag and drop textbox
Undo - Redo for renaming</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions SimpleStateMachineNodeEditor/Styles/MyTextBox.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<TextBox x:Class="SimpleStateMachineNodeEditor.Styles.MyTextBox"
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:SimpleStateMachineNodeEditor.Styles"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" AllowDrop="True" IsUndoEnabled="True" TextWrapping="NoWrap" BorderThickness="0,0,0,0" Background="{x:Null}" BorderBrush="{x:Null}" Style="{DynamicResource StyleEmptyTextBox}">
</TextBox>
44 changes: 44 additions & 0 deletions SimpleStateMachineNodeEditor/Styles/MyTextBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
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;

namespace SimpleStateMachineNodeEditor.Styles
{
/// <summary>
/// Логика взаимодействия для TestBox.xaml
/// </summary>
public partial class MyTextBox : TextBox
{
public MyTextBox()
{
InitializeComponent();
this.ContextMenu = null;
}

protected override void OnDragEnter(DragEventArgs e)
{
if(e.Effects != DragDropEffects.Move)
{
base.OnDragEnter(e);
}
}


protected override void OnDragOver(DragEventArgs e)
{
if (e.Effects != DragDropEffects.Move)
{
base.OnDragOver(e);
}
}
}
}
17 changes: 10 additions & 7 deletions SimpleStateMachineNodeEditor/Styles/Node/ElementNodeHeader.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
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:SimpleStateMachineNodeEditor.Styles.Node"
mc:Ignorable="d"
>
<Border CornerRadius="5,5,0,0" VerticalAlignment="Stretch" Background="{DynamicResource ColorNodeHeader}">
<Grid>
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.Styles.Node"
xmlns:styles="clr-namespace:SimpleStateMachineNodeEditor.Styles"
mc:Ignorable="d" >
<Border CornerRadius="5,5,0,0" VerticalAlignment="Stretch" >
<Border.Background>
<SolidColorBrush Color="{DynamicResource ColorNodeHeader}" />
</Border.Background>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Name="TextBox" Grid.Column="0" VerticalAlignment="Center" VerticalContentAlignment="Center" Style="{DynamicResource StyleEmptyTextBox}" HorizontalContentAlignment="Center" BorderThickness="0,0,0,0" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{DynamicResource ColorNodeHeaderForeground}" Padding="10,2,0,2" ScrollViewer.CanContentScroll="True" HorizontalAlignment="Center" />
<Button Name ="ButtonCollapse" Grid.Column="1" Style="{DynamicResource StyleNodeCollapseButton}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5">
<styles:MyTextBox x:Name="TextBoxElement" Grid.Column="0" VerticalAlignment="Center" ScrollViewer.CanContentScroll="True" HorizontalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="{DynamicResource ColorNodeHeaderForeground}" Padding="10,2,0,2" />
<Button Name ="ButtonCollapse" Grid.Column="1" Style="{DynamicResource StyleNodeCollapseButton}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" >
<Button.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="ButtonRotate" Angle="0" CenterX="4" CenterY="2" />
Expand Down
4 changes: 1 addition & 3 deletions SimpleStateMachineNodeEditor/Styles/StyleEmptyTextBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" >
<Border.ContextMenu>
<ContextMenu Visibility="Collapsed"/>
</Border.ContextMenu>
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />

</Border>
</ControlTemplate>
</Setter.Value>
Expand Down
23 changes: 12 additions & 11 deletions SimpleStateMachineNodeEditor/Styles/Themes/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<SolidColorBrush x:Key="ColorSelectedElement" Color="#D23030"/>

<SolidColorBrush x:Key="ColorConnect" Color="White"/>
<SolidColorBrush x:Key="ColorConnect" Color="White" />

<SolidColorBrush x:Key="ColorConnector" Color="White"/>

Expand Down Expand Up @@ -79,21 +79,22 @@
<!--#endregion Menu-->

<!--#region Node-->
<SolidColorBrush x:Key="ColorNodeBackground" Color="#FF2D2D2D"/>

<Color x:Key="ColorNodeBackground">#E52D2D2D</Color>
<SolidColorBrush x:Key="ColorNodeBorderBrush" Color="LightGray"/>


<SolidColorBrush x:Key="ColorNodeHeader" Color="#FF123D6A"/>


<!--<Color x:Key="ColorNodeHeader" R="18" G="61" B="106" A="200"/>-->
<Color x:Key="ColorNodeHeader">#90123d6a</Color>
<!--<SolidColorBrush x:Key="ColorNodeHeader" Color="#123d6a" Opacity="0.5"/>-->

<SolidColorBrush x:Key="ColorNodeHeaderForeground" Color="White"/>


<SolidColorBrush x:Key="ColorNodeCollapseButtonBackground" Color="White"/>
<SolidColorBrush x:Key="ColorNodeCollapseButtonBorderBrush" Color="White"/>

<SolidColorBrush x:Key="ColorNodeCollapseButtonMouseOverBackground" Color="#D23030"/>
<SolidColorBrush x:Key="ColorNodeCollapseButtonMouseOverBorderBrush" Color="#D23030"/>
<SolidColorBrush x:Key="ColorNodeCollapseButtonBackground" Color="White" />
<SolidColorBrush x:Key="ColorNodeCollapseButtonBorderBrush" Color="White" />

<SolidColorBrush x:Key="ColorNodeCollapseButtonMouseOverBackground" Color="#D23030" />
<SolidColorBrush x:Key="ColorNodeCollapseButtonMouseOverBorderBrush" Color="#D23030" />
<!--#endregion Node-->

</ResourceDictionary>
12 changes: 6 additions & 6 deletions SimpleStateMachineNodeEditor/Styles/Themes/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<SolidColorBrush x:Key="ColorSelectedElement" Color="#D23030"/>

<SolidColorBrush x:Key="ColorConnect" Color="#414141"/>
<SolidColorBrush x:Key="ColorConnect" Color="#98989a"/>

<SolidColorBrush x:Key="ColorConnector" Color="#414141"/>
<SolidColorBrush x:Key="ColorConnector" Color="#98989a"/>

<SolidColorBrush x:Key="ColorConnectorForeground" Color="Black"/>

Expand Down Expand Up @@ -76,12 +76,12 @@
<!--#endregion Menu-->

<!--#region Node-->
<SolidColorBrush x:Key="ColorNodeBackground" Color="#eeeef2"/>


<Color x:Key="ColorNodeBackground" >#E5eeeef2</Color>

<SolidColorBrush x:Key="ColorNodeBorderBrush" Color="#c2c3c9"/>


<SolidColorBrush x:Key="ColorNodeHeader" Color="#414141"/>
<Color x:Key="ColorNodeHeader" >#90414141</Color>

<SolidColorBrush x:Key="ColorNodeHeaderForeground" Color="White"/>

Expand Down
20 changes: 9 additions & 11 deletions SimpleStateMachineNodeEditor/View/ViewConnect.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" IsHitTestVisible="False">
<Grid>
<Path x:Name="PathElement" StrokeDashCap="Round" StrokeLineJoin="Round" Stroke="{DynamicResource ColorConnect}" StrokeEndLineCap="Round" StrokeStartLineCap="Round">
<Path.Data>
<PathGeometry x:Name="PathGeometryElement">
<PathFigure x:Name="PathFigureElement" IsClosed="False">
<BezierSegment x:Name="BezierSegmentElement"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</Grid>
<Path x:Name="PathElement" StrokeDashCap="Round" StrokeLineJoin="Round" Stroke="{DynamicResource ColorConnect}" StrokeEndLineCap="Round" StrokeStartLineCap="Round">
<Path.Data>
<PathGeometry x:Name="PathGeometryElement">
<PathFigure x:Name="PathFigureElement" IsClosed="False">
<BezierSegment x:Name="BezierSegmentElement"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</UserControl>
5 changes: 2 additions & 3 deletions SimpleStateMachineNodeEditor/View/ViewConnect.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ private void SetupBinding()
{
this.WhenActivated(disposable =>
{
Canvas.SetZIndex((UIElement)this.VisualParent, this.ViewModel.FromConnector.Node.Zindex + 1);

this.OneWayBind(this.ViewModel, x => x.Stroke, x => x.PathElement.Stroke).DisposeWith(disposable);

this.OneWayBind(this.ViewModel, x => x.StartPoint, x => x.PathFigureElement.StartPoint).DisposeWith(disposable);
Expand All @@ -63,9 +65,6 @@ private void SetupBinding()
this.OneWayBind(this.ViewModel, x => x.FromConnector.NodesCanvas.Scale.Value, x => x.PathElement.StrokeThickness).DisposeWith(disposable);

this.WhenAnyValue(x => x.ViewModel.ToConnector).Where(x=>x!=null).Subscribe(_ => UpdateZindex()).DisposeWith(disposable);

Canvas.SetZIndex((UIElement)this.VisualParent, this.ViewModel.FromConnector.Node.Zindex+1);

});
}

Expand Down
8 changes: 4 additions & 4 deletions SimpleStateMachineNodeEditor/View/ViewLeftConnector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
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:SimpleStateMachineNodeEditor.View"
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.View"
xmlns:styles="clr-namespace:SimpleStateMachineNodeEditor.Styles"
x:Name="LeftConnector" HorizontalAlignment="Stretch" VerticalAlignment="Top" AllowDrop="True" >

<Grid x:Name="GridElement" Background="{DynamicResource ColorNodeBackground}">
<Grid x:Name="GridElement" Background="#00000000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Name="TextBoxElement" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,5,3" TextWrapping="NoWrap" BorderThickness="0,0,0,0" Background="{x:Null}" BorderBrush="{x:Null}" Style="{DynamicResource StyleEmptyTextBox}"/>
<styles:MyTextBox x:Name="TextBoxElement" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,5,3" />
<Ellipse Name="EllipseElement" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="-7,0,0,0" Height="12" Width="12" AllowDrop="True" StrokeThickness="1" />
</Grid>

Expand Down
5 changes: 4 additions & 1 deletion SimpleStateMachineNodeEditor/View/ViewNode.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
xmlns:enums="clr-namespace:SimpleStateMachineNodeEditor.Helpers.Enums"
mc:Ignorable="d" Focusable="True" AllowDrop="True" Visibility="Visible">

<Border x:Name="BorderElement" CornerRadius="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="{DynamicResource ColorNodeBorderBrush}" Background="{DynamicResource ColorNodeBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="80">
<Border x:Name="BorderElement" CornerRadius="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="{DynamicResource ColorNodeBorderBrush}" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="80">
<Border.Background>
<SolidColorBrush Color="{DynamicResource ColorNodeBackground}" />
</Border.Background>
<StackPanel Margin="0,0,0,5">
<NodeStyles:ElementNodeHeader x:Name="NodeHeaderElement" />
<!--Grid For Input and Output-->
Expand Down
12 changes: 6 additions & 6 deletions SimpleStateMachineNodeEditor/View/ViewNode.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ private void SetupBinding()

this.OneWayBind(this.ViewModel, x => x.BorderBrush, x => x.BorderElement.BorderBrush).DisposeWith(disposable);

this.OneWayBind(this.ViewModel, x => x.Name, x => x.NodeHeaderElement.TextBox.Text).DisposeWith(disposable);
this.OneWayBind(this.ViewModel, x => x.Name, x => x.NodeHeaderElement.TextBoxElement.Text).DisposeWith(disposable);

this.Bind(this.ViewModel, x => x.NameEnable, x => x.NodeHeaderElement.TextBox.IsEnabled).DisposeWith(disposable);
this.Bind(this.ViewModel, x => x.NameEnable, x => x.NodeHeaderElement.TextBoxElement.IsEnabled).DisposeWith(disposable);

this.OneWayBind(this.ViewModel, x => x.Point1.X, x => x.TranslateTransformElement.X).DisposeWith(disposable);

Expand Down Expand Up @@ -126,10 +126,10 @@ private void OnEventMouseLeftDowns(MouseButtonEventArgs e)
}
private void Validate(RoutedEventArgs e)
{
if (NodeHeaderElement.TextBox.Text != ViewModel.Name)
ViewModel.CommandValidateName.ExecuteWithSubscribe(NodeHeaderElement.TextBox.Text);
if (NodeHeaderElement.TextBox.Text != ViewModel.Name)
NodeHeaderElement.TextBox.Text = ViewModel.Name;
if (NodeHeaderElement.TextBoxElement.Text != ViewModel.Name)
ViewModel.CommandValidateName.ExecuteWithSubscribe(NodeHeaderElement.TextBoxElement.Text);
if (NodeHeaderElement.TextBoxElement.Text != ViewModel.Name)
NodeHeaderElement.TextBoxElement.Text = ViewModel.Name;
}

private void OnEventMouseDown(MouseButtonEventArgs e)
Expand Down
25 changes: 12 additions & 13 deletions SimpleStateMachineNodeEditor/View/ViewRightConnector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:enums="clr-namespace:SimpleStateMachineNodeEditor.Helpers.Enums"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:styles="clr-namespace:SimpleStateMachineNodeEditor.Styles"
mc:Ignorable="d"
x:Name="RightConnector" HorizontalAlignment="Stretch" VerticalAlignment="Top" BorderThickness="0" AllowDrop="True">
<Border x:Name="BorderElement" CornerRadius="5,5,5,5" Background="{DynamicResource ColorNodeBackground}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Name="TextBoxElement" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,3" TextWrapping="NoWrap" BorderThickness="0,0,0,0" Background="{x:Null}" BorderBrush="{x:Null}" Style="{DynamicResource StyleEmptyTextBox}"/>
<Ellipse Name="EllipseElement" Grid.Row="0" Grid.Column="1" Margin="0,0,-7,0" HorizontalAlignment="Right" VerticalAlignment="Center" Height="12" Width="12" AllowDrop="True" StrokeThickness="1" />
</Grid>
</Border>
<Grid x:Name="GridElement" Background="#00000000" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<styles:MyTextBox x:Name="TextBoxElement" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,3" />
<Ellipse Name="EllipseElement" Grid.Row="0" Grid.Column="1" Margin="0,0,-7,0" HorizontalAlignment="Right" VerticalAlignment="Center" Height="12" Width="12" AllowDrop="True" StrokeThickness="1" />
</Grid>
</UserControl>
11 changes: 5 additions & 6 deletions SimpleStateMachineNodeEditor/View/ViewRightConnector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ private void SetupEvents()
{
this.EllipseElement.Events().MouseLeftButtonDown.Subscribe(e => ConnectDrag(e)).DisposeWith(disposable);
this.TextBoxElement.Events().LostFocus.Subscribe(e => Validate(e)).DisposeWith(disposable);
this.BorderElement.Events().PreviewMouseLeftButtonDown.Subscribe(e => ConnectorDrag(e)).DisposeWith(disposable);
this.BorderElement.Events().PreviewDragEnter.Subscribe(e => ConnectorDragEnter(e)).DisposeWith(disposable);
this.BorderElement.Events().PreviewDragOver.Subscribe(e => e.Handled = true).DisposeWith(disposable);
this.BorderElement.Events().PreviewDrop.Subscribe(e => ConnectorDrop(e)).DisposeWith(disposable);
this.GridElement.Events().PreviewMouseLeftButtonDown.Subscribe(e => ConnectorDrag(e)).DisposeWith(disposable);
this.GridElement.Events().PreviewDragEnter.Subscribe(e => ConnectorDragEnter(e)).DisposeWith(disposable);
this.GridElement.Events().PreviewDrop.Subscribe(e => ConnectorDrop(e)).DisposeWith(disposable);
});
}
private void OnEventMouseOver(bool value)
Expand Down Expand Up @@ -129,7 +128,7 @@ private void ConnectDrag(MouseButtonEventArgs e)
this.ViewModel.CommandConnectPointDrag.ExecuteWithSubscribe();
DataObject data = new DataObject();
data.SetData("Node", this.ViewModel.Node);
DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
this.ViewModel.CommandCheckConnectPointDrop.ExecuteWithSubscribe();
e.Handled = true;
}
Expand All @@ -144,7 +143,7 @@ private void ConnectorDrag(MouseButtonEventArgs e)
this.ViewModel.CommandConnectorDrag.ExecuteWithSubscribe();
DataObject data = new DataObject();
data.SetData("Connector", this.ViewModel);
DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
}
else if (Keyboard.IsKeyDown(Key.LeftShift))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using SimpleStateMachineNodeEditor.Helpers;
using System.Windows;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;

namespace SimpleStateMachineNodeEditor.ViewModel
{
Expand Down Expand Up @@ -88,6 +90,7 @@ private void SetAsStart(ViewModelNode node)
{
node.Input.Visible = false;
node.CanBeDelete = false;
StartState = node;
}

#endregion Setup Nodes
Expand Down
Loading

0 comments on commit 8badf0e

Please sign in to comment.