X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev4%2Fpsychlops%2Fcore%2Fgraphic%2Fmodule.cs;h=6adecfd3314ac29ae0fc8b3b7e99eab5cc8b2c85;hb=97a97a46267462940a24f18ad5bbd0f77006dfd9;hp=7afeeaf212a2ae3b92d6e0333e985375b3c09d6f;hpb=cb8916a7a5cd929f57b3f9edd99209680db90546;p=psychlops%2Fsilverlight.git diff --git a/dev4/psychlops/core/graphic/module.cs b/dev4/psychlops/core/graphic/module.cs index 7afeeaf..6adecfd 100644 --- a/dev4/psychlops/core/graphic/module.cs +++ b/dev4/psychlops/core/graphic/module.cs @@ -4,34 +4,63 @@ using System.Windows; namespace Psychlops { - - public partial struct Point + public static class StaticFunctions { - public double x, y, z; - public Point(double dx, double dy, double dz) + public static T[] NewArray(int x) + where T : new() { - x = dx; - y = dy; - z = dz; + T[] t = new T[x]; + for (int i = 0; i < x; i++) + { + t[i] = new T(); + } + return t; } - public Point(double dx, double dy) + public static T[,] NewArray(int x, int y) + where T : new() { - x = dx; - y = dy; - z = 0.0; + T[,] t = new T[x,y]; + for (int i = 0; i < x; i++) + { + for (int j = 0; j < x; j++) + { + t[i,j] = new T(); + } + } + return t; + } + public static T[,,] NewArray(int x, int y, int z) + where T : new() + { + T[,,] t = new T[x, y, z]; + for (int i = 0; i < x; i++) + { + for (int j = 0; j < y; j++) + { + for (int k = 0; k < z; k++) + { + t[i, j, k] = new T(); + } + } + } + return t; } - public Point set(double dx, double dy, double dz) + } + + public partial struct Point + { + public double x, y, z; + public Point(double dx, double dy, double dz = 0.0) { x = dx; y = dy; z = dz; - return this; } - public Point set(double dx, double dy) + public Point set(double dx, double dy, double dz = 0.0) { x = dx; y = dy; - z = 0.0; + z = dz; return this; } @@ -58,14 +87,7 @@ namespace Psychlops r = g = b = lum; a = 1.0; } - public Color(double red, double green, double blue) - { - r = red; - g = green; - b = blue; - a = 1.0; - } - public Color(double red, double green, double blue, double alpha) + public Color(double red, double green, double blue, double alpha = 1.0) { r = red; g = green; @@ -77,14 +99,7 @@ namespace Psychlops r = g = b = lum; a = 1.0; } - public void set(double red, double green, double blue) - { - r = red; - g = green; - b = blue; - a = 1.0; - } - public void set(double red, double green, double blue, double alpha) + public void set(double red, double green, double blue, double alpha = 1.0) { r = red; g = green; @@ -123,6 +138,7 @@ namespace Psychlops void polygon(Polygon drawee); void letters(Letters drawee); void image(Image drawee); + void group(Group drawee); void msg(string s, double x, double y, Color c); } @@ -146,17 +162,17 @@ namespace Psychlops target.datum = p; return target.datum; } - public static Figure shift(this Figure target, double x, double y) + public static Figure shift(this Figure target, double x, double y, double z = 0.0) { - return target.shift(new Point(x, y)); + return target.shift(new Point(x, y, z)); } public static Figure centering(this Figure target) { return target.centering(Main.drawable.getCenter()); } - public static Figure centering(this Figure target, double x, double y) + public static Figure centering(this Figure target, double x, double y, double z = 0.0) { - return target.centering(new Point(x, y)); + return target.centering(new Point(x, y, z)); } } @@ -165,6 +181,76 @@ namespace Psychlops public interface PrimitiveFigure : Figure { UIElement toNative(); + UIElement poolNative(Canvas c); + } + } + + public partial class Group : Internal.PrimitiveFigure + { + System.Collections.Generic.List
list; + System.Windows.Controls.Canvas cnvs; + System.Windows.Media.TransformGroup trans; + System.Windows.Media.TransformCollection transF; + System.Windows.Media.RotateTransform rotateF; + SimpleProcedure setRotation_; + System.Windows.Media.ScaleTransform scaleF; + SimpleProcedure setScaling_; + System.Windows.Media.TranslateTransform translateF; + + bool AsyncBool; + double rotation_; + public double rotation + { + get { return rotation_; } + set { rotation_ = value; rotateF.Dispatcher.BeginInvoke(setRotation_); } + } + public Point axis + { + get; + set; + } + Point scaling_; + public Point scaling + { + get { return scaling_; } + set { scaling_ = value; scaleF.Dispatcher.BeginInvoke(setScaling_); } + } + + AppendFunc1 append_; + + public Group() + { + setRotation_ = new SimpleProcedure(setRotation__); + setScaling_ = new SimpleProcedure(setScaling__); + append_ = new AppendFunc1(append__); + list = new System.Collections.Generic.List
(); + AsyncBool = false; + initialize__(); + while (!AsyncBool) { } + } + + public Group append(Internal.PrimitiveFigure fig) + { + list.Add(fig); + cnvs.Dispatcher.BeginInvoke(append_, fig); + return this; + } + + public Point datum { get; set; } + public Figure shift(Point p) + { + datum = datum + p; + return this; + } + public Figure centering(Point p) + { + datum = p; + return this; + } + public void draw() + { + Main.drawable.group(this); } } + } \ No newline at end of file