vai*_*hav 6 silverlight performance bezier
我正在为Silverlight游戏设计扫雷类布局.目前,我在square控件上使用了用户Canvas控件.分配了属性.我还想在稍后阶段添加功能.它是关于使用贝塞尔曲线弯曲并使用x,y坐标绘制曲线上的那些正方形而不是循环.然后我想将方块的x,y位置发送到XML文件中.
我的问题是,在最小内存消耗,快速高效的性能以及易于实现方面,我应该采用哪种方式作为最佳优化组合.如果您的专家有任何其他想法,请告诉我.提前致谢.!
好吧,这些天我自己整理出了答案。我继续进行Square用户控件并在布局中使用它。
关于绘制 x/y 位置,我使用了这个:
Point point = myElement.TransformToVisual(App.Current.RootVisual as FrameworkElement)).Transform(new Point(0, 0));
Run Code Online (Sandbox Code Playgroud)
保存 XML 文件时出现故障,因为 silverlight 4 没有为浏览器内应用程序提供提升的权限。但后来我在保存按钮单击事件中使用了它:
SaveFileDialog dlgSave = new SaveFileDialog();
dlgSave.DefaultExt = "xml";
dlgSave.Filter = "XML Files (XML)|*.xml;";
dlgSave.FilterIndex = 1;
strXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + myXML.ToString();//myXML is the XDocument I created globally and saved data in it
try
{
bool check = (bool)dlgSave.ShowDialog();
if (check)
{
using (Stream stream = dlgSave.OpenFile())
{
StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8);
sw.Write(strXML);
sw.Close();
stream.Close();
}
MessageBox.Show("XML Saved successfully");
}
catch (SecurityException)
{
MessageBox.Show("There seems to be an issue with saving XML file on the disk, please try again...", "Something's not right", MessageBoxButton.OK);
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Saving here requires authorised permissions", "Access Denied", MessageBoxButton.OK);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
168 次 |
| 最近记录: |