optimise performance for minesweeper-style game silverlight
bezier, performance, silverlight
Solution
Well, over the days, I sorted out the answer myself. I continued through my `Square` user control and used it in the layout.
About plotting of the x/y positions, I used this:
Point point = myElement.TransformToVisual(App.Current.RootVisual as FrameworkElement)).Transform(new Point(0, 0));
There was a glitch in saving XML file because silverlight 4 does not give elevated privileges for in-browser application. But then I used this on my save button click event:
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);
}
Problem
I am designing a minesweeper kind of layout for a game in silverlight. Currently, I have used a `square` user control on the `Canvas` control. There are properties assigned to it. I also want to add a functionality at a later stage. It is about curving using the bezier curves and plotting those squares on the curve with the x,y co-ordinates instead of looping through. Then I want to send the square's x,y position in an XML file. My question is that what way should I use that will be the best optimized combination in terms of least memory consumption, fast and efficient performance as well as easy implementation. If you experts have any other ideas, please let me know. Thanks in advance.!