mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-23 11:18:27 +00:00
Added BindableVector
This commit is contained in:
parent
f4ff157a63
commit
0d578131d8
33
OSCADSharp/OSCADSharp/Bindings/BindableVector.cs
Normal file
33
OSCADSharp/OSCADSharp/Bindings/BindableVector.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OSCADSharp.Scripting;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Bindings
|
||||||
|
{
|
||||||
|
internal class BindableVector : Vector3, IBindable
|
||||||
|
{
|
||||||
|
private Bindings bindings = new Bindings(new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "x", "x" },
|
||||||
|
{ "y", "y" },
|
||||||
|
{ "z", "z" }
|
||||||
|
});
|
||||||
|
|
||||||
|
public void Bind(string property, Variable variable)
|
||||||
|
{
|
||||||
|
this.bindings.Add<BindableVector>(this, property, variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string x = this.bindings.Contains("x") ? this.bindings.Get("x").BoundVariable.Name : this.X.ToString();
|
||||||
|
string y = this.bindings.Contains("y") ? this.bindings.Get("y").BoundVariable.Name : this.Y.ToString();
|
||||||
|
string z = this.bindings.Contains("z") ? this.bindings.Get("z").BoundVariable.Name : this.Z.ToString();
|
||||||
|
|
||||||
|
return String.Format("[{0}, {1}, {2}]", x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -57,6 +57,7 @@
|
|||||||
<Compile Include="Scripting\Variable.cs" />
|
<Compile Include="Scripting\Variable.cs" />
|
||||||
<Compile Include="Settings\Settings.cs" />
|
<Compile Include="Settings\Settings.cs" />
|
||||||
<Compile Include="Sizes.cs" />
|
<Compile Include="Sizes.cs" />
|
||||||
|
<Compile Include="Bindings\BindableVector.cs" />
|
||||||
<Compile Include="Spatial\Bounds.cs" />
|
<Compile Include="Spatial\Bounds.cs" />
|
||||||
<Compile Include="Spatial\Matrix.cs" />
|
<Compile Include="Spatial\Matrix.cs" />
|
||||||
<Compile Include="Transforms\HulledObject.cs" />
|
<Compile Include="Transforms\HulledObject.cs" />
|
||||||
|
|||||||
@ -4,13 +4,15 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using OSCADSharp.Spatial;
|
using OSCADSharp.Spatial;
|
||||||
|
using OSCADSharp.Bindings;
|
||||||
|
using OSCADSharp.Scripting;
|
||||||
|
|
||||||
namespace OSCADSharp.Solids
|
namespace OSCADSharp.Solids
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Cube geometry
|
/// A Cube geometry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Cube : OSCADObject
|
public class Cube : OSCADObject, IBindable
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -124,6 +126,24 @@ namespace OSCADSharp.Solids
|
|||||||
new Vector3(this.Size.X / 2, this.Size.Y / 2, this.Size.Z / 2));
|
new Vector3(this.Size.X / 2, this.Size.Y / 2, this.Size.Z / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bindings.Bindings bindings = new Bindings.Bindings(new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "center", "center" },
|
||||||
|
{ "size", "size" }
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Binds a a variable to a property on this object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||||
|
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||||
|
/// literal value of the property</param>
|
||||||
|
public void Bind(string property, Variable variable)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
//this.bindings.Add<Cube>(this, property, variable);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user