Exemplo n.º 1
0
        public void Reset()
        {
            StartSprite = null;
            TurnSprite  = null;
            Rows        = 0;
            Columns     = 0;
            LastCell    = Rectangle.Empty;
            FirstCell   = Rectangle.Empty;
            VinLength   = 0;
            if (FreeCellSprites.Count > 0)
            {
                FreeCellSprites.Clear();
                HasChanges = true;
            }

            if (OCellSprites.Count > 0)
            {
                OCellSprites.Clear();
                HasChanges = true;
            }

            if (XCellSprites.Count > 0)
            {
                XCellSprites.Clear();
                HasChanges = true;
            }
        }
Exemplo n.º 2
0
        public void Reload()
        {
            Rows      = Settings.Default.Rows;
            FirstCell = Settings.Default.FirstCell;
            LastCell  = Settings.Default.LastCell;
            Columns   = Settings.Default.Columns;
            VinLength = Settings.Default.VinLength;
            try
            {
                var presetDir = Path.Combine(Environment.CurrentDirectory, GamePresetDir);
                if (Directory.Exists(presetDir))
                {
                    StartSprite = FromFile(nameof(StartSprite), presetDir);
                    TurnSprite  = FromFile(nameof(TurnSprite), presetDir);
                    var freeCellsDir = Path.Combine(presetDir, nameof(FreeCellSprites));
                    if (Directory.Exists(freeCellsDir))
                    {
                        FreeCellSprites.Clear();
                        var files = Directory.GetFiles(freeCellsDir);
                        foreach (var file in files)
                        {
                            var freeCellSprite = FromFile(file);
                            if (freeCellSprite != null)
                            {
                                FreeCellSprites.Add(freeCellSprite);
                            }
                        }
                    }

                    var oCellsDir = Path.Combine(presetDir, nameof(OCellSprites));
                    if (Directory.Exists(oCellsDir))
                    {
                        OCellSprites.Clear();
                        var files = Directory.GetFiles(oCellsDir);
                        foreach (var file in files)
                        {
                            var oCellSprite = FromFile(file);
                            if (oCellSprite != null)
                            {
                                OCellSprites.Add(oCellSprite);
                            }
                        }
                    }

                    var xCellsDir = Path.Combine(presetDir, nameof(XCellSprites));
                    if (Directory.Exists(xCellsDir))
                    {
                        XCellSprites.Clear();
                        var files = Directory.GetFiles(xCellsDir);
                        foreach (var file in files)
                        {
                            var xCellSprite = FromFile(file);
                            if (xCellSprite != null)
                            {
                                XCellSprites.Add(xCellSprite);
                            }
                        }
                    }
                }
            }
            catch (Exception excpt)
            {
                MessageBox.Show(excpt.Message, "Data initialization error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            HasChanges = false;
        }