From 2d16c7bc232e1d8e0f57404c4b37e3a8db6ab207 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Jul 2010 10:10:29 +0900 Subject: [PATCH] 123 --- dev4/psychlops/core/graphic/canvas.cs | 2 +- dev4/psychlops/core/graphic/module.cs | 43 +++------------- dev4/psychlops/core/graphic/shape.cs | 4 +- dev4/psychlops/extention/standard/widget.cs | 3 ++ test4/MainPage.xaml | 2 +- test4/PsychlopsMain.cs | 39 +++++++++++---- test4/TestPage.html | 78 +++++++++++++++++++++++++++++ 7 files changed, 122 insertions(+), 49 deletions(-) create mode 100644 test4/TestPage.html diff --git a/dev4/psychlops/core/graphic/canvas.cs b/dev4/psychlops/core/graphic/canvas.cs index 0adfc4e..a695257 100644 --- a/dev4/psychlops/core/graphic/canvas.cs +++ b/dev4/psychlops/core/graphic/canvas.cs @@ -144,7 +144,7 @@ namespace Psychlops HtmlElement htmlHost = HtmlPage.Document.GetElementById("silverlightControlHost"); //if (htmlHost != null) HtmlPage.Window.Alert("silverlightControlHost is null"); - htmlHost.SetStyleAttribute("width", (200+wid).ToString()+"px"); + htmlHost.SetStyleAttribute("width", (wid).ToString()+"px"); htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px"); htmlHost.SetStyleAttribute("margin", "2em auto auto auto"); } diff --git a/dev4/psychlops/core/graphic/module.cs b/dev4/psychlops/core/graphic/module.cs index 7afeeaf..6fc1f15 100644 --- a/dev4/psychlops/core/graphic/module.cs +++ b/dev4/psychlops/core/graphic/module.cs @@ -8,32 +8,19 @@ namespace Psychlops public partial struct Point { public double x, y, z; - public Point(double dx, double dy, double dz) + public Point(double dx, double dy, double dz = 0.0) { x = dx; y = dy; z = dz; } - public Point(double dx, double dy) - { - x = dx; - y = dy; - z = 0.0; - } - public Point set(double dx, double dy, double dz) + public Point set(double dx, double dy, double dz = 0.0) { x = dx; y = dy; z = dz; return this; } - public Point set(double dx, double dy) - { - x = dx; - y = dy; - z = 0.0; - return this; - } public static Point operator +(Point lhs, Point rhs) { @@ -58,14 +45,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 +57,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; @@ -146,17 +119,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)); } } diff --git a/dev4/psychlops/core/graphic/shape.cs b/dev4/psychlops/core/graphic/shape.cs index 82f19b7..d6ec793 100644 --- a/dev4/psychlops/core/graphic/shape.cs +++ b/dev4/psychlops/core/graphic/shape.cs @@ -180,9 +180,9 @@ namespace Psychlops{ set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); } } public Rectangle move_to(Point p) { datum = p; return this; } - public Rectangle move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; } + public Rectangle move_to(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; } public Rectangle locate(Point p) { datum = p; return this; } - public Rectangle locate(double x, double y, double z) { datum = new Point(x, y, z); return this; } + public Rectangle locate(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; } public Figure shift(Point p) { diff --git a/dev4/psychlops/extention/standard/widget.cs b/dev4/psychlops/extention/standard/widget.cs index 4f7fcfb..49c7848 100644 --- a/dev4/psychlops/extention/standard/widget.cs +++ b/dev4/psychlops/extention/standard/widget.cs @@ -79,6 +79,8 @@ namespace Psychlops elem.SetProperty(name, value); } + + public static implicit operator double(Element i) { return i.getValueAsDouble(); } public double getValueAsDouble() { double v = 0; @@ -94,6 +96,7 @@ namespace Psychlops return v; } + public static implicit operator string(Element i) { return i.getProperty("value").ToString(); } public System.Object getProperty(string name) { Internal.Main.widgetStack.Dispatcher.BeginInvoke(new Connector.VoidString(getProperty__), name); diff --git a/test4/MainPage.xaml b/test4/MainPage.xaml index da67b32..284d270 100644 --- a/test4/MainPage.xaml +++ b/test4/MainPage.xaml @@ -6,7 +6,7 @@ - + diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index b9b3d57..32ba5e8 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,4 +1,5 @@ -using Psychlops; + +using Psychlops; namespace PsychlopsSilverlight4test { @@ -6,18 +7,37 @@ namespace PsychlopsSilverlight4test { public void psychlops_main() { - var elem = Psychlops.Widgets.Browser.Element.byID("TheInput"); - - Canvas window = new Canvas(500,500); - - var figure = new Rectangle(); - figure.set( 100, 100 ); - figure.fill = new Color(1.0, 0.0, 0.0); + var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE"); + var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X"); + var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y"); + var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X"); + var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y"); + var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R"); + var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G"); + var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B"); + + Canvas window = new Canvas(300, 300); + + var figure_r = new Rectangle(); + var figure_e = new Ellipse(); + Shape figure = figure_r; while (!Keyboard.esc.pushed()) { + if (System.String.Compare(figure_type, "Rectangle") == 0) + { + figure_r.set(size_x, size_y); + figure = figure_r; + } + else + { + figure_e.set(size_x, size_y); + figure = figure_e; + } + figure.fill = new Color(color_r, color_g, color_b); + window.clear(Color.black); - figure.centering().shift(elem.getValueAsDouble(), 1).draw(); + figure.centering().shift(shift_x, shift_y).draw(); window.flip(); } } @@ -27,7 +47,6 @@ namespace PsychlopsSilverlight4test - /* using Psychlops; diff --git a/test4/TestPage.html b/test4/TestPage.html new file mode 100644 index 0000000..a651178 --- /dev/null +++ b/test4/TestPage.html @@ -0,0 +1,78 @@ + + + + + PsychlopsSilverlight4test + + + + + +
+ +
+ +
+
+ + + + + + + + + Microsoft Silverlight を入手 + +
+
+ + -- 2.11.0