Skip to content

Commit

Permalink
Add triangle shape
Browse files Browse the repository at this point in the history
  • Loading branch information
miroiu committed Jun 22, 2024
1 parent 42fc155 commit 8a83457
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
15 changes: 12 additions & 3 deletions Examples/Nodify.Shapes/Canvas/CanvasView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
Opacity="0.8" />
</DataTemplate>

<DataTemplate DataType="{x:Type local:TriangleViewModel}">
<Polygon Points="0,100 50,0 100,100"
Stretch="Fill"
Fill="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}"
Stroke="{Binding BorderColor, Converter={StaticResource ColorToSolidColorBrushConverter}}"
StrokeThickness="2"
Opacity="0.8" />
</DataTemplate>

<DataTemplate DataType="{x:Type local:ShapeToolbarViewModel}">
<Canvas Visibility="{Binding Shape, Converter={StaticResource BooleanToVisibilityConverter}}">
<shared:Swatches SelectedColor="{Binding Shape.Color}"
Expand Down Expand Up @@ -479,9 +488,6 @@
Margin="0 0 50 50"
Height="38"
CornerRadius="3">
<Border.Effect>
<DropShadowEffect ShadowDepth="1" />
</Border.Effect>

<ItemsControl ItemsSource="{Binding Cursors}">
<ItemsControl.ItemsPanel>
Expand All @@ -498,6 +504,9 @@
Margin="-3"
Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}"
Padding="6 2">
<Border.Effect>
<DropShadowEffect ShadowDepth="1" />
</Border.Effect>
<Button Command="{x:Static nodify:EditorCommands.BringIntoView}"
CommandParameter="{Binding Location}"
CommandTarget="{Binding ElementName=Editor}"
Expand Down
9 changes: 7 additions & 2 deletions Examples/Nodify.Shapes/Canvas/CanvasViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,16 @@ private void FillCanvasWithShapes()
};
Shapes.Add(rectangle2);

Connections.Add(new ConnectionViewModel(ellipse2.BottomConnector, rectangle2.TopConnector));
var triangle = new TriangleViewModel
{
Location = new Point(800, 200)
};
Shapes.Add(triangle);

Connections.Add(new ConnectionViewModel(ellipse2.BottomConnector, rectangle2.TopConnector));
Connections.Add(new ConnectionViewModel(rectangle.RightConnector, rectangle2.RightConnector));

SelectedShapes.Add(rectangle);
SelectedShapes.Add(triangle);

Decorators.Add(ShapeToolbar);
Decorators.AddRange(Cursors);
Expand Down
13 changes: 13 additions & 0 deletions Examples/Nodify.Shapes/Canvas/Shapes/TriangleViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Windows.Media;

namespace Nodify.Shapes.Canvas
{
public class TriangleViewModel : ShapeViewModel
{
public TriangleViewModel()
{
Color = Color.FromRgb(235, 195, 71);
Text = "Triangle";
}
}
}

0 comments on commit 8a83457

Please sign in to comment.