\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
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
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
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
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
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
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
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
<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
-using Psychlops;\r
+\r
+using Psychlops;\r
\r
namespace PsychlopsSilverlight4test\r
{\r
{\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
\r
\r
\r
-\r
/*\r
using Psychlops;\r
\r
--- /dev/null
+<!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