Ejemplo n.º 1
0
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Enabled;

            ApplicationData.Current.LocalSettings.Values.Clear();

            game = new LightsOutGame();
            CreateGrid();
            DrawGrid();
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Restore state
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("settings"))
            {
                var settings = ApplicationData.Current.LocalSettings.Values["settings"] as ApplicationDataCompositeValue;

                int gridSize = (int)settings["gridSize"];
                game.GridSize = gridSize;

                string colorRgb = settings["gridColor"] as string;
                gridColor = ColorConverter.ConvertFromString(colorRgb);

                CreateGrid();
            }

            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("game"))
            {
                string gridJson = ApplicationData.Current.LocalSettings.Values["game"] as string;
                game = JsonConvert.DeserializeObject <LightsOutGame>(gridJson);
            }

            DrawGrid();
        }