diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/App.config b/OSCADSharp/OSCADSharp.ConsoleTests/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/OSCADSharp/OSCADSharp.ConsoleTests/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/OSCADSharp.ConsoleTests.csproj b/OSCADSharp/OSCADSharp.ConsoleTests/OSCADSharp.ConsoleTests.csproj new file mode 100644 index 0000000..335063f --- /dev/null +++ b/OSCADSharp/OSCADSharp.ConsoleTests/OSCADSharp.ConsoleTests.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {E1010464-A816-4F86-AE22-8465C27723C4} + Exe + Properties + OSCADSharp.ConsoleTests + OSCADSharp.ConsoleTests + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {e420ce17-2f13-4abc-87d7-c9744df39d3d} + OSCADSharp + + + + + \ No newline at end of file diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs new file mode 100644 index 0000000..775a4c8 --- /dev/null +++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs @@ -0,0 +1,27 @@ +using OSCADSharp.Solids; +using OSCADSharp.Transforms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OSCADSharp.ConsoleTests +{ + class Program + { + static void Main(string[] args) + { + Cube cube = new Cube() { + Size = new Vector3(5, 5, 5), + Center = true + }; + + ColoredObject co = new ColoredObject(cube, "Red"); + var evenMoreColors = new ColoredObject(co, "Blue", .5); + + Console.WriteLine(evenMoreColors.ToString()); + Console.ReadKey(); + } + } +} diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Properties/AssemblyInfo.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7e608fd --- /dev/null +++ b/OSCADSharp/OSCADSharp.ConsoleTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("OSCADSharp.ConsoleTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OSCADSharp.ConsoleTests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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("e1010464-a816-4f86-ae22-8465c27723c4")] + +// 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.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OSCADSharp/OSCADSharp.sln b/OSCADSharp/OSCADSharp.sln index 97303c6..9eb3226 100644 --- a/OSCADSharp/OSCADSharp.sln +++ b/OSCADSharp/OSCADSharp.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSCADSharp", "OSCADSharp\OSCADSharp.csproj", "{E420CE17-2F13-4ABC-87D7-C9744DF39D3D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSCADSharp.ConsoleTests", "OSCADSharp.ConsoleTests\OSCADSharp.ConsoleTests.csproj", "{E1010464-A816-4F86-AE22-8465C27723C4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {E420CE17-2F13-4ABC-87D7-C9744DF39D3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {E420CE17-2F13-4ABC-87D7-C9744DF39D3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {E420CE17-2F13-4ABC-87D7-C9744DF39D3D}.Release|Any CPU.Build.0 = Release|Any CPU + {E1010464-A816-4F86-AE22-8465C27723C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1010464-A816-4F86-AE22-8465C27723C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1010464-A816-4F86-AE22-8465C27723C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1010464-A816-4F86-AE22-8465C27723C4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OSCADSharp/OSCADSharp/BlockFormatter.cs b/OSCADSharp/OSCADSharp/BlockFormatter.cs new file mode 100644 index 0000000..b233c23 --- /dev/null +++ b/OSCADSharp/OSCADSharp/BlockFormatter.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OSCADSharp +{ + /// + /// A class that creates blocks of curly-braced script with the + /// specified level of indentation + /// + internal class BlockFormatter + { + private string outerCode; + private string innerCode; + private string indentationAmount = " "; + + internal BlockFormatter(string outerCode, string innerCode) + { + this.outerCode = outerCode; + this.innerCode = innerCode; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine(outerCode); + sb.AppendLine("{"); + using (StringReader reader = new StringReader(this.innerCode)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + sb.Append(this.indentationAmount); + sb.Append(line); + sb.Append(Environment.NewLine); + } + } + sb.AppendLine("}"); + + return sb.ToString(); + } + } +} diff --git a/OSCADSharp/OSCADSharp/OSCADSharp.csproj b/OSCADSharp/OSCADSharp/OSCADSharp.csproj index 9c8f4c5..d8eebd4 100644 --- a/OSCADSharp/OSCADSharp/OSCADSharp.csproj +++ b/OSCADSharp/OSCADSharp/OSCADSharp.csproj @@ -40,6 +40,7 @@ + diff --git a/OSCADSharp/OSCADSharp/Solids/Cube.cs b/OSCADSharp/OSCADSharp/Solids/Cube.cs index d390e9a..6c00987 100644 --- a/OSCADSharp/OSCADSharp/Solids/Cube.cs +++ b/OSCADSharp/OSCADSharp/Solids/Cube.cs @@ -9,7 +9,7 @@ namespace OSCADSharp.Solids /// /// A Cube geometry /// - public class Cube + public class Cube : OSCADObject { #region Attributes /// diff --git a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs index 440869d..7cfe512 100644 --- a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs +++ b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs @@ -9,7 +9,7 @@ namespace OSCADSharp.Solids /// /// A Cylinder geometry /// - public class Cylinder + public class Cylinder : OSCADObject { #region Attributes /// diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs index d591c7d..bc07254 100644 --- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs +++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs @@ -9,7 +9,7 @@ namespace OSCADSharp.Solids /// /// A Sphere geometry /// - public class Sphere + public class Sphere : OSCADObject { #region Attributes /// diff --git a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs index 2bfda21..2f545ae 100644 --- a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs +++ b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs @@ -9,16 +9,33 @@ namespace OSCADSharp.Transforms /// /// An object that has color and/or opacity applied to it /// - public class ColoredObject + public class ColoredObject : OSCADObject { #region Attributes public string Color { get; set; } = "Yellow"; public double Opacity { get; set; } = 1.0; #endregion + private OSCADObject obj; + + /// + /// Creates a colorized object + /// + /// The object(s) to which color will be applied + /// The string-wise name of the color to be applied + /// Opacity from 0.0 to 1.0 + public ColoredObject(OSCADObject obj, string Color = "Yellow", double opacity = 1.0) + { + this.obj = obj; + this.Color = Color; + this.Opacity = opacity; + } + public override string ToString() { - return String.Format("color(\"{0}\", {1})", this.Color, this.Opacity); + string colorCommand = String.Format("color(\"{0}\", {1})", this.Color, this.Opacity); + var formatter = new BlockFormatter(colorCommand, this.obj.ToString()); + return formatter.ToString(); } } }