OSDN Git Service

123
authorunknown <hskwk@.(none)>
Fri, 9 Jul 2010 01:10:29 +0000 (10:10 +0900)
committerunknown <hskwk@.(none)>
Fri, 9 Jul 2010 01:10:29 +0000 (10:10 +0900)
dev4/psychlops/core/graphic/canvas.cs
dev4/psychlops/core/graphic/module.cs
dev4/psychlops/core/graphic/shape.cs
dev4/psychlops/extention/standard/widget.cs
test4/MainPage.xaml
test4/PsychlopsMain.cs
test4/TestPage.html [new file with mode: 0644]

index 0adfc4e..a695257 100644 (file)
@@ -144,7 +144,7 @@ namespace Psychlops
 \r
                        HtmlElement htmlHost = HtmlPage.Document.GetElementById("silverlightControlHost");\r
                        //if (htmlHost != null) HtmlPage.Window.Alert("silverlightControlHost is null");\r
-                       htmlHost.SetStyleAttribute("width", (200+wid).ToString()+"px");\r
+                       htmlHost.SetStyleAttribute("width", (wid).ToString()+"px");\r
                        htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px");\r
                        htmlHost.SetStyleAttribute("margin", "2em auto auto auto");\r
                }\r
index 7afeeaf..6fc1f15 100644 (file)
@@ -8,32 +8,19 @@ namespace Psychlops
        public partial struct Point\r
        {\r
                public double x, y, z;\r
-               public Point(double dx, double dy, double dz)\r
+               public Point(double dx, double dy, double dz = 0.0)\r
                {\r
                        x = dx;\r
                        y = dy;\r
                        z = dz;\r
                }\r
-               public Point(double dx, double dy)\r
-               {\r
-                       x = dx;\r
-                       y = dy;\r
-                       z = 0.0;\r
-               }\r
-               public Point set(double dx, double dy, double dz)\r
+               public Point set(double dx, double dy, double dz = 0.0)\r
                {\r
                        x = dx;\r
                        y = dy;\r
                        z = dz;\r
                        return this;\r
                }\r
-               public Point set(double dx, double dy)\r
-               {\r
-                       x = dx;\r
-                       y = dy;\r
-                       z = 0.0;\r
-                       return this;\r
-               }\r
 \r
                public static Point operator +(Point lhs, Point rhs)\r
                {\r
@@ -58,14 +45,7 @@ namespace Psychlops
                        r = g = b = lum;\r
                        a = 1.0;\r
                }\r
-               public Color(double red, double green, double blue)\r
-               {\r
-                       r = red;\r
-                       g = green;\r
-                       b = blue;\r
-                       a = 1.0;\r
-               }\r
-               public Color(double red, double green, double blue, double alpha)\r
+               public Color(double red, double green, double blue, double alpha = 1.0)\r
                {\r
                        r = red;\r
                        g = green;\r
@@ -77,14 +57,7 @@ namespace Psychlops
                        r = g = b = lum;\r
                        a = 1.0;\r
                }\r
-               public void set(double red, double green, double blue)\r
-               {\r
-                       r = red;\r
-                       g = green;\r
-                       b = blue;\r
-                       a = 1.0;\r
-               }\r
-               public void set(double red, double green, double blue, double alpha)\r
+               public void set(double red, double green, double blue, double alpha = 1.0)\r
                {\r
                        r = red;\r
                        g = green;\r
@@ -146,17 +119,17 @@ namespace Psychlops
                        target.datum = p;\r
                        return target.datum;\r
                }\r
-               public static Figure shift(this Figure target, double x, double y)\r
+               public static Figure shift(this Figure target, double x, double y, double z = 0.0)\r
                {\r
-                       return target.shift(new Point(x, y));\r
+                       return target.shift(new Point(x, y, z));\r
                }\r
                public static Figure centering(this Figure target)\r
                {\r
                        return target.centering(Main.drawable.getCenter());\r
                }\r
-               public static Figure centering(this Figure target, double x, double y)\r
+               public static Figure centering(this Figure target, double x, double y, double z = 0.0)\r
                {\r
-                       return target.centering(new Point(x, y));\r
+                       return target.centering(new Point(x, y, z));\r
                }\r
        }\r
 \r
index 82f19b7..d6ec793 100644 (file)
@@ -180,9 +180,9 @@ namespace Psychlops{
                        set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); }\r
                }\r
                public Rectangle move_to(Point p) { datum = p; return this; }\r
-               public Rectangle move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+               public Rectangle move_to(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; }\r
                public Rectangle locate(Point p) { datum = p; return this; }\r
-               public Rectangle locate(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+               public Rectangle locate(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; }\r
 \r
                public Figure shift(Point p)\r
                {\r
index 4f7fcfb..49c7848 100644 (file)
@@ -79,6 +79,8 @@ namespace Psychlops
                                        elem.SetProperty(name, value);\r
                                }\r
 \r
+\r
+                               public static implicit operator double(Element i) { return i.getValueAsDouble(); }\r
                                public double getValueAsDouble()\r
                                {\r
                                        double v = 0;\r
@@ -94,6 +96,7 @@ namespace Psychlops
                                        return v;\r
                                }\r
 \r
+                               public static implicit operator string(Element i) { return i.getProperty("value").ToString(); }\r
                                public System.Object getProperty(string name)\r
                                {\r
                                        Internal.Main.widgetStack.Dispatcher.BeginInvoke(new Connector.VoidString(getProperty__), name);\r
index da67b32..284d270 100644 (file)
@@ -6,7 +6,7 @@
        <StackPanel x:Name="TotalRoot">\r
                <Grid>\r
                        <Grid.ColumnDefinitions>\r
-                               <ColumnDefinition Width="200" />\r
+                               <ColumnDefinition Width="0" />\r
                                <ColumnDefinition Width="*" />\r
                        </Grid.ColumnDefinitions>\r
                        <StackPanel x:Name="Controller" Grid.Column="0">\r
index b9b3d57..32ba5e8 100644 (file)
@@ -1,4 +1,5 @@
-using Psychlops;\r
+\r
+using Psychlops;\r
 \r
 namespace PsychlopsSilverlight4test\r
 {\r
@@ -6,18 +7,37 @@ namespace PsychlopsSilverlight4test
        {\r
                public void psychlops_main()\r
                {\r
-                       var elem = Psychlops.Widgets.Browser.Element.byID("TheInput");\r
-\r
-                       Canvas window = new Canvas(500,500);\r
-\r
-                       var figure = new Rectangle();\r
-                       figure.set( 100, 100 );\r
-                       figure.fill = new Color(1.0, 0.0, 0.0);\r
+                       var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
+                       var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
+                       var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
+                       var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
+                       var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
+                       var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
+                       var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
+                       var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
+\r
+                       Canvas window = new Canvas(300, 300);\r
+\r
+                       var figure_r = new Rectangle();\r
+                       var figure_e = new Ellipse();\r
+                       Shape figure = figure_r;\r
                        \r
                        while (!Keyboard.esc.pushed())\r
                        {\r
+                               if (System.String.Compare(figure_type, "Rectangle") == 0)\r
+                               {\r
+                                       figure_r.set(size_x, size_y);\r
+                                       figure = figure_r;\r
+                               }\r
+                               else\r
+                               {\r
+                                       figure_e.set(size_x, size_y);\r
+                                       figure = figure_e;\r
+                               }\r
+                               figure.fill = new Color(color_r, color_g, color_b);\r
+\r
                                window.clear(Color.black);\r
-                               figure.centering().shift(elem.getValueAsDouble(), 1).draw();\r
+                               figure.centering().shift(shift_x, shift_y).draw();\r
                                window.flip();\r
                        }\r
                }\r
@@ -27,7 +47,6 @@ namespace PsychlopsSilverlight4test
 \r
 \r
 \r
-\r
 /*\r
 using Psychlops;\r
 \r
diff --git a/test4/TestPage.html b/test4/TestPage.html
new file mode 100644 (file)
index 0000000..a651178
--- /dev/null
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" >\r
+<!-- saved from url=(0014)about:internet -->\r
+<head>\r
+    <title>PsychlopsSilverlight4test</title>\r
+    <style type="text/css">\r
+    html, body {\r
+           height: 100%;\r
+           overflow: auto;\r
+    }\r
+    body {\r
+           padding: 0;\r
+           margin: 0;\r
+    }\r
+    #silverlightControlHost {\r
+           height: 100%;\r
+           text-align:center;\r
+    }\r
+    </style>\r
+    \r
+    <script type="text/javascript">\r
+        function onSilverlightError(sender, args) {\r
+            var appSource = "";\r
+            if (sender != null && sender != 0) {\r
+              appSource = sender.getHost().Source;\r
+            }\r
+            \r
+            var errorType = args.ErrorType;\r
+            var iErrorCode = args.ErrorCode;\r
+\r
+            if (errorType == "ImageError" || errorType == "MediaError") {\r
+              return;\r
+            }\r
+\r
+            var errMsg = "Silverlight アプリケーションでハンドルされていないエラーが発生しまし " +  appSource + "\n" ;\r
+\r
+            errMsg += "コード: "+ iErrorCode + "    \n";\r
+            errMsg += "カテゴリ: " + errorType + "       \n";\r
+            errMsg += "メッセージ: " + args.ErrorMessage + "     \n";\r
+\r
+            if (errorType == "ParserError") {\r
+                errMsg += "ファイル: " + args.xamlFile + "     \n";\r
+                errMsg += "行: " + args.lineNumber + "     \n";\r
+                errMsg += "位置: " + args.charPosition + "     \n";\r
+            }\r
+            else if (errorType == "RuntimeError") {           \r
+                if (args.lineNumber != 0) {\r
+                    errMsg += "行: " + args.lineNumber + "     \n";\r
+                    errMsg += "位置: " +  args.charPosition + "     \n";\r
+                }\r
+                errMsg += "メソッド名: " + args.methodName + "     \n";\r
+            }\r
+\r
+            throw new Error(errMsg);\r
+        }\r
+    </script>\r
+</head>\r
+<body>\r
+    <form id="parameters">\r
+               <input type="text" size="10" id="TheInput" />\r
+       </form>\r
+\r
+    <form id="form1" runat="server" style="height:60%">\r
+    <div id="silverlightControlHost">\r
+        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="90%" height="80%">\r
+                 <param name="source" value="Bin/Debug/PsychlopsSilverlight4test.xap"/>\r
+                 <param name="onError" value="onSilverlightError" />\r
+                 <param name="background" value="white" />\r
+                 <param name="minRuntimeVersion" value="3.0.40624.0" />\r
+                 <param name="autoUpgrade" value="true" />\r
+                 <param name="enableHtmlAccess" value="true" />\r
+                 <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">\r
+                         <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Microsoft Silverlight を入手" style="border-style:none"/>\r
+                 </a>\r
+           </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>\r
+    </form>\r
+</body>\r
+</html>\r