Exemplo n.º 1
0
        void ctl_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            SudokuSquareControl ctl = (SudokuSquareControl)sender;

            if (e.PropertyName == "Selected")
            {
                if (ctl.SelectionStatus == SquareSelectionStatus.Selected)
                {
                    _selectedSquare = ctl.SudokuSquare.Position;
                    ctl.DisplayMode = SquareDisplayMode.Normal; //don't show dismissed values on the focused square


                    lblStatus.Text = ctl.SudokuSquare.Position.ToString();

                    foreach (Point position in _squareLookup.Keys)
                    {
                        SudokuSquareControl curr = _squareLookup[position];
                        if (curr != ctl)
                        {
                            if (ctl.SudokuSquare.UserValue.HasValue && curr.SudokuSquare.UserValue == ctl.SudokuSquare.UserValue)
                            {
                                curr.SelectionStatus = SquareSelectionStatus.Highlighted;
                            }
                            else
                            {
                                curr.SelectionStatus = SquareSelectionStatus.Normal;
                            }
                        }
                    }

                    RefreshBoard();
                }
            }
        }
Exemplo n.º 2
0
        private void RefreshBoard()
        {
            SudokuSquareControl selectedSquare = _squareLookup[_selectedSquare];

            foreach (Point position in _squareLookup.Keys)
            {
                SudokuSquareControl curr = _squareLookup[position];

                if (!curr.SudokuSquare.UserValue.HasValue && (curr != selectedSquare))
                {
                    if (Program.Preferences.DismissedValueVisibility == DismissedValueVisibility.Always)
                    {
                        curr.DisplayMode = SquareDisplayMode.DismissedValues;
                    }
                    else if (Program.Preferences.DismissedValueVisibility == DismissedValueVisibility.Never)
                    {
                        curr.DisplayMode = SquareDisplayMode.Normal;
                    }
                    else if (Program.Preferences.DismissedValueVisibility == DismissedValueVisibility.AroundSelectedSquare)
                    {
                        //show non-dismissed values for relevant squares w/o a value alrady set
                        if ((curr.SudokuSquare.Position.X == selectedSquare.SudokuSquare.Position.X) ||
                            (curr.SudokuSquare.Position.Y == selectedSquare.SudokuSquare.Position.Y) ||
                            (YetAnotherSudokuPlayer.Components.Utils.GetSuperCell(curr.SudokuSquare.Position)
                             == YetAnotherSudokuPlayer.Components.Utils.GetSuperCell(selectedSquare.SudokuSquare.Position)))
                        {
                            curr.DisplayMode = SquareDisplayMode.DismissedValues;
                        }
                        else
                        {
                            curr.DisplayMode = SquareDisplayMode.Normal;
                        }
                    }
                }
                else
                {
                    curr.DisplayMode = SquareDisplayMode.Normal;
                }

                //_squareLookup[position].Refresh();
            }
        }
Exemplo n.º 3
0
        void MainForm_Load(object sender, EventArgs e)
        {
            lblStatus.Text = "";
            lblStatus.Invalidate();
            lblGameDifficulty.Text = "";
            lblGameDifficulty.Invalidate();
            lblGameComments.Text = "";
            lblGameComments.Invalidate();
            undoToolStripMenuItem.Enabled = UndoRedoManager.CanUndo;
            redoToolStripMenuItem.Enabled = UndoRedoManager.CanRedo;
            toolStripProgressBar1.Visible = false;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    TableLayoutPanel subPanel = (TableLayoutPanel)tableLayoutPanelMain.GetControlFromPosition(i, j);
                    for (int subi = 0; subi < 3; subi++)
                    {
                        for (int subj = 0; subj < 3; subj++)
                        {
                            SudokuSquareControl ctl = new SudokuSquareControl();
                            ctl.Margin = new Padding(0);
                            ctl.Dock   = DockStyle.Fill;
                            subPanel.Controls.Add(ctl, subi, subj);
                            Point position = new Point(i * 3 + subi, j * 3 + subj);
                            ctl.PropertyChanged += new PropertyChangedEventHandler(ctl_PropertyChanged);
                            _squareLookup.Add(position, ctl);
                            _squareLookup[position].SudokuSquare = _board.GetSquare(position);
                        }
                    }
                }
            }

            RefreshBoard();

            _squareLookup[_selectedSquare].Focus();

            splitContainer1.Panel2Collapsed = !Program.Preferences.ShowMoveHistory;
        }