diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd7da14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin +obj +.vs +*.user diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1dc253b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 by Svetlin Nakov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Nakov.TurtleGraphics/Nakov.TurtleGraphics-logo.png b/Nakov.TurtleGraphics/Nakov.TurtleGraphics-logo.png new file mode 100644 index 0000000..1eb1835 Binary files /dev/null and b/Nakov.TurtleGraphics/Nakov.TurtleGraphics-logo.png differ diff --git a/Nakov.TurtleGraphics/Nakov.TurtleGraphics.csproj b/Nakov.TurtleGraphics/Nakov.TurtleGraphics.csproj index df658a2..9669bed 100644 --- a/Nakov.TurtleGraphics/Nakov.TurtleGraphics.csproj +++ b/Nakov.TurtleGraphics/Nakov.TurtleGraphics.csproj @@ -1,66 +1,47 @@ - - - + + - Debug - AnyCPU - {ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11} Library - Properties - Nakov.TurtleGraphics - Nakov.TurtleGraphics - v2.0 - 512 - + netcoreapp3.1;net35;net5.0-windows + true + 2.0.2.1 + Svetlin Nakov + SoftUni + TurtleGraphics.NET + Copyright © Svetlin Nakov, 2016 + The .NET library "Nakov.TurtleGraphics" provides а very simple "turtle graphics" drawing interface for C# / .NET Windows Forms, designed for kids, learning to code. + +It supports all standard turtle commands like "move-forward", "move-backward", "rotate", "move-to", "pen-up", "pen-down". Animates the turtle actions to demonstrate how it moves and rotates. + +It provides a really simple API, through the static class "Turtle": +- Turtle.Rotate(30); +- Turtle.Forward(200); +- Turtle.PenUp(); +- Turtle.Rotate(120); +- Turtle.Forward(200); +- Turtle.PenDown(); +- Turtle.Rotate(120); +- Turtle.Forward(200); + LICENSE + https://www.nuget.org/packages/Nakov.TurtleGraphics + https://www.nuget.org/packages/Nakov.TurtleGraphics + Nakov.TurtleGraphics-logo.png + turtle-graphics C# .NET library Windows-Forms turtle graphics + This release supports .NET Core and .NET Framework. + true + 2.0.2.1 + 2.0.2.1 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - True - True - Resources.resx - - - - - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - + - + + True + + + + True + + - - + \ No newline at end of file diff --git a/Nakov.TurtleGraphics/Nakov.TurtleGraphics.nuspec b/Nakov.TurtleGraphics/Nakov.TurtleGraphics.nuspec deleted file mode 100644 index d255428..0000000 --- a/Nakov.TurtleGraphics/Nakov.TurtleGraphics.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - Nakov.TurtleGraphics - 1.0.0.2 - Nakov.TurtleGraphics - turtle graphics library for C# / .NET - This library provides а very simple "turtle graphics" drawing interface for C#, designed for kids, learning to code, or teachers who want to illustrate programming visually. - Svetlin Nakov - Svetlin Nakov - https://github.com/nakov/TurtleGraphics.NET - false - The Nakov.TurtleGraphics .NET library provides а very simple "turtle graphics" drawing interface for C# / .NET Windows Forms, designed for kids, learning to code. - Learn more at https://github.com/nakov/TurtleGraphics.NET - Copyright 2016 by Svetlin Nakov - turtle-graphics C# .NET library Windows-Forms turtle graphics - - \ No newline at end of file diff --git a/Nakov.TurtleGraphics/Properties/AssemblyInfo.cs b/Nakov.TurtleGraphics/Properties/AssemblyInfo.cs deleted file mode 100644 index 5b5ecfb..0000000 --- a/Nakov.TurtleGraphics/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Nakov.TurtleGraphics")] -[assembly: AssemblyDescription("Turtle Graphics library for Windows Forms")] -[assembly: AssemblyCompany("Software University (SoftUni)")] -[assembly: AssemblyProduct("Nakov Turtle Graphics for C#")] -[assembly: AssemblyCopyright("Copyright © Svetlin Nakov 2016")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ed9be8f0-2e5c-41ea-a8ec-a9db81d29a11")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.2")] -[assembly: AssemblyFileVersion("1.0.0.2")] diff --git a/Nakov.TurtleGraphics/Properties/Resources.resx b/Nakov.TurtleGraphics/Properties/Resources.resx index 474fe59..09be42e 100644 --- a/Nakov.TurtleGraphics/Properties/Resources.resx +++ b/Nakov.TurtleGraphics/Properties/Resources.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\Turtle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/Nakov.TurtleGraphics/Turtle.cs b/Nakov.TurtleGraphics/Turtle.cs index cc8a20f..e2e79a0 100644 --- a/Nakov.TurtleGraphics/Turtle.cs +++ b/Nakov.TurtleGraphics/Turtle.cs @@ -183,6 +183,10 @@ public static void Dispose() { if (drawControl != null) { + // Remove the associated events for the drawing control + drawControl.Paint -= DrawControl_Paint; + drawControl.ClientSizeChanged -= DrawControl_ClientSizeChanged; + // Release the pen object drawPen.Dispose(); drawPen = null; @@ -200,9 +204,7 @@ public static void Dispose() turtleHeadImage.Dispose(); turtleHeadImage = null; - // Release the drawing control and its associated events - drawControl.Paint -= DrawControl_Paint; - drawControl.ClientSizeChanged -= DrawControl_ClientSizeChanged; + // Release the drawing control drawControl.Invalidate(); drawControl = null; } diff --git a/Nakov.TurtleGraphics/create-nuget-package.cmd b/Nakov.TurtleGraphics/create-nuget-package.cmd deleted file mode 100644 index 361d79b..0000000 --- a/Nakov.TurtleGraphics/create-nuget-package.cmd +++ /dev/null @@ -1 +0,0 @@ -nuget pack Nakov.TurtleGraphics.csproj diff --git a/README.md b/README.md index 7960581..cbce022 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Nakov.TurtleGraphics +# Nakov.TurtleGraphics C# Turtle Graphics library - for teaching kids to code. -![Nakov Turtle Graphics for C# / .NET - free open-source library](https://github.com/nakov/TurtleGraphics.NET/blob/master/Nakov.TurtleGraphics-Demo.gif "Nakov Turtle Graphics for C# / .NET - free open-source library") +![Nakov Turtle Graphics for C# / .NET - free open-source library](https://github.com/nakov/TurtleGraphics.NET/raw/master/Nakov.TurtleGraphics-Demo.gif "Nakov Turtle Graphics for C# / .NET - free open-source library") This library provides а **very simple "[turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics)" drawing interface for C#**, designed for kids, learning to code, or teachers who want to illustrate programming visually. @@ -37,7 +37,7 @@ Turtle.Rotate(30); ``` 4. Enjoy the application: -![Nakov Turtle Graphics for C# / .NET - free open-source library](https://github.com/nakov/TurtleGraphics.NET/blob/master/Nakov.TurtleGraphics-Demo.gif "Nakov Turtle Graphics for C# / .NET - free open-source library") +![Nakov Turtle Graphics for C# / .NET - free open-source library](https://github.com/nakov/TurtleGraphics.NET/raw/master/Nakov.TurtleGraphics-Demo.gif "Nakov Turtle Graphics for C# / .NET - free open-source library") See the full source code here: https://github.com/nakov/TurtleGraphics.NET/tree/master/Turtle-Graphics-Example. @@ -54,7 +54,7 @@ The interface is intentionally simplified through a single static class (I know - `PenDown()` - moves the pen down (makes further moves visible). Further calls to `Forward(distance)` / `Backward(distance)` / `MoveTo(x, y)` will draw a line from the current to the new position. - `X` - gets / sets the current turtle horizontal position. The initial turtle position is the screen center {0, 0}. Increasing X will move the turtle right. - `Y` - gets / sets the current turtle vertical position. The initial turtle position is the screen center {0, 0}. Increasing Y will move the turtle up. - - `Angle` - gets / sets the current turtle direction (angle in degrees). The value of 0 means up, 90 means right, 180 means down and 270 means left. The `Angle` is always kept in the range [0...360). Initially the angle is 0. + - `Angle` - gets / sets the current turtle direction (angle in degrees). The value of 0 means up, 90 means right, 180 means down and 270 means left. The `Angle` is always kept in the range \[0...360). Initially the angle is 0. - `PenColor` - gets / sets the color of the pen. The default pen color is "blue". - `PenSize` - gets / sets the size of the pen (in pixels). The default pen size is 7. - `PenVisible` - gets / sets the visibility of the pen. The default pen size is true. True means the pen is down (draws a line when the turtle moves). False means the pen is up (no line is drawn when the turtle moves). diff --git a/TODO.txt b/TODO.txt index 757b025..cc1084d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,8 @@ -[not possible] TODO: add "create windows form on demand" feature. +[not possible] TODO: add "Create Windows Form on demand" feature. [fixed] bug: Reset() does not assign X = 0, Y = 0. bug: Does not compile in VS 2013 (.NET 4.5) [fixed] bug: Long draw with delay=200 fails, e.g. draw 200 lines. Seems like the draw takes too much time to be processed in the event handler. + diff --git a/Turtle-Graphics-Example/Turtle-Graphics-Example.csproj b/Turtle-Graphics-Example/Turtle-Graphics-Example.csproj index 40f3a63..008bdc2 100644 --- a/Turtle-Graphics-Example/Turtle-Graphics-Example.csproj +++ b/Turtle-Graphics-Example/Turtle-Graphics-Example.csproj @@ -1,69 +1,14 @@ - - - + + - Debug - AnyCPU - {0009E232-CD03-4C6D-B288-70EFA46083AB} WinExe + netcoreapp3.1 Turtle_Graphics_Example - Turtle-Graphics-Example - v2.0 - 512 - true - + true - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Nakov.TurtleGraphics.1.0.0.2\lib\net20\Nakov.TurtleGraphics.dll - True - - - - - - - - Form - - - TurtleGraphicsDemoForm.cs - - - - - - TurtleGraphicsDemoForm.cs - - + - + - - + \ No newline at end of file diff --git a/Turtle-Graphics-Example/TurtleGraphicsDemoForm.cs b/Turtle-Graphics-Example/TurtleGraphicsDemoForm.cs index 24ad9c9..5d767e4 100644 --- a/Turtle-Graphics-Example/TurtleGraphicsDemoForm.cs +++ b/Turtle-Graphics-Example/TurtleGraphicsDemoForm.cs @@ -16,6 +16,7 @@ private void buttonDraw_Click(object sender, EventArgs e) { // Assign a delay to visualize the drawing process Turtle.Delay = 150; + Turtle.PenSize = 8; // Draw a equilateral triangle Turtle.PenColor = Color.Green; @@ -31,11 +32,8 @@ private void buttonDraw_Click(object sender, EventArgs e) Turtle.PenUp(); Turtle.Backward(50); Turtle.PenDown(); - Turtle.PenColor = Color.Red; - Turtle.PenSize = 5; + Turtle.PenColor = Color.Blue; Turtle.Backward(100); - Turtle.PenColor = Turtle.DefaultColor; - Turtle.PenSize = Turtle.DefaultPenSize; Turtle.PenUp(); Turtle.Forward(150); Turtle.PenDown(); diff --git a/Turtle-Graphics-Example/TurtleGraphicsDemoForm.resx b/Turtle-Graphics-Example/TurtleGraphicsDemoForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Turtle-Graphics-Example/TurtleGraphicsDemoForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Turtle-Graphics-Example/packages.config b/Turtle-Graphics-Example/packages.config deleted file mode 100644 index c0fce66..0000000 --- a/Turtle-Graphics-Example/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/TurtleGraphics.NET.sln b/TurtleGraphics.NET.sln index 5e8e14f..9056ce9 100644 --- a/TurtleGraphics.NET.sln +++ b/TurtleGraphics.NET.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31005.135 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Turtle-Graphics-Example", "Turtle-Graphics-Example\Turtle-Graphics-Example.csproj", "{0009E232-CD03-4C6D-B288-70EFA46083AB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Turtle-Graphics-Example", "Turtle-Graphics-Example\Turtle-Graphics-Example.csproj", "{E1DC9935-6F3F-4ABB-BA24-FB64B04F3667}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nakov.TurtleGraphics", "Nakov.TurtleGraphics\Nakov.TurtleGraphics.csproj", "{ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nakov.TurtleGraphics", "Nakov.TurtleGraphics\Nakov.TurtleGraphics.csproj", "{7BE09D2D-D5A8-4EBC-83C9-2A8F3D522C26}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,16 +13,19 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED9BE8F0-2E5C-41EA-A8EC-A9DB81D29A11}.Release|Any CPU.Build.0 = Release|Any CPU - {0009E232-CD03-4C6D-B288-70EFA46083AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0009E232-CD03-4C6D-B288-70EFA46083AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0009E232-CD03-4C6D-B288-70EFA46083AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0009E232-CD03-4C6D-B288-70EFA46083AB}.Release|Any CPU.Build.0 = Release|Any CPU + {E1DC9935-6F3F-4ABB-BA24-FB64B04F3667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1DC9935-6F3F-4ABB-BA24-FB64B04F3667}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1DC9935-6F3F-4ABB-BA24-FB64B04F3667}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1DC9935-6F3F-4ABB-BA24-FB64B04F3667}.Release|Any CPU.Build.0 = Release|Any CPU + {7BE09D2D-D5A8-4EBC-83C9-2A8F3D522C26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BE09D2D-D5A8-4EBC-83C9-2A8F3D522C26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BE09D2D-D5A8-4EBC-83C9-2A8F3D522C26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BE09D2D-D5A8-4EBC-83C9-2A8F3D522C26}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1F6E104C-B49D-4E58-848B-A615FADACEFA} + EndGlobalSection EndGlobal