コード例 #1
0
ファイル: Main.cs プロジェクト: GloomyBoy/Solver
        private void clbSwaps_SelectedIndexChanged(object sender, EventArgs e)
        {
            var listBox = sender as CheckedListBox;
            var swap    = listBox.SelectedItem as SwapResult;

            pbGameGrid.Image = GridDrawer.GetGridImage(_grid);
            GridDrawer.DrawSwap((Bitmap)pbGameGrid.Image, swap);
            pbEnemies.Image = new Bitmap(pbEnemies.Width, pbEnemies.Height);
            GridDrawer.GetGridEnemies(_grid, pbEnemies.Image);
            GridDrawer.GetSwapResultPicture(swap, pbEnemies.Image);
            //var proposed = swap.NextTurnPropositions;
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: GloomyBoy/Solver
        private void LoadImage(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                return;
            }
            PictureHelper.LoadImage(bitmap, out var grid);
            if (grid == null || grid.IsEqual(_grid))
            {
                return;
            }

            _grid = grid;
            if (cbRec.Checked)
            {
                bitmap.Save(_recordFolder + $"\\record_{_recordIndex}.png");
                _recordIndex++;
            }
            if (_grid.WeakSlot >= 0 && cbTitanColor.SelectedIndex >= 0)
            {
                foreach (var i in Enumerable.Range(1, 5))
                {
                    _grid._enemies[i] = (CellColor)cbTitanColor.SelectedItem;
                }
            }
            pbGameGrid.Image = GridDrawer.GetGridImage(grid);
            pbEnemies.Image  = new Bitmap(pbEnemies.Width, pbEnemies.Height);
            GridDrawer.GetGridEnemies(grid, pbEnemies.Image);
            var results = GridAnalyzer.GetPossibleSwaps(grid);

            results = results.OrderByDescending(r => r, new TitanSwapComparer()).ToList();
            clbSwaps.Items.Clear();
            clbSwaps.Items.AddRange(items: results.ToArray());
            if (results.Count > 0)
            {
                clbSwaps.SetSelected(0, true);
            }
        }