Beispiel #1
0
        private void ShowToggleCandidatesMenu()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }
            dlg.Reset();
            dlg.SetHeading(19133);                  // Add/Remove Candidate

            dlg.Add(GUILocalizeStrings.Get(19134)); // Toggle 1
            dlg.Add(GUILocalizeStrings.Get(19135)); // Toggle 2
            dlg.Add(GUILocalizeStrings.Get(19136)); // Toggle 3
            dlg.Add(GUILocalizeStrings.Get(19137)); // Toggle 4
            dlg.Add(GUILocalizeStrings.Get(19138)); // Toggle 5
            dlg.Add(GUILocalizeStrings.Get(19139)); // Toggle 6
            dlg.Add(GUILocalizeStrings.Get(19140)); // Toggle 7
            dlg.Add(GUILocalizeStrings.Get(19141)); // Toggle 8
            dlg.Add(GUILocalizeStrings.Get(19142)); // Toggle 9

            dlg.DoModal(GetID);

            if (dlg.SelectedId == -1)
            {
                return;
            }

            int controlId = GetFocusControlId();

            if (controlId >= 1000 && controlId <= 9008)
            {
                CellControl cntlFoc = (CellControl)GetControl(controlId);

                if (cntlFoc != null)
                {
                    if (cntlFoc.IsCandidate(dlg.SelectedId))
                    {
                        cntlFoc.RemoveCandidate(dlg.SelectedId);
                    }
                    else
                    {
                        cntlFoc.SetCandidate(dlg.SelectedId);
                    }
                }
            }

            CheckCandidates();
        }
Beispiel #2
0
 private void ResetCandidates()
 {
     for (int row = 0; row < grid.CellsInRow; row++)
     {
         for (int column = 0; column < grid.CellsInRow; column++)
         {
             int         cellControlId = (1000 * (row + 1)) + column;
             CellControl cntlFoc       = (CellControl)GetControl(cellControlId);
             cntlFoc.ClearCandidates();
             //if (cntlFoc.CellValue == 0)
             {
                 for (int i = 1; i <= 9; i++)
                 {
                     cntlFoc.SetCandidate(i);
                 }
                 cntlFoc.ShowCandidates = _Settings.ShowCandidates;
             }
         }
     }
     CheckCandidates();
 }
Beispiel #3
0
        public override void OnAction(Action action)
        {
            if (action.wID == Action.ActionType.ACTION_SELECT_ITEM || action.wID == Action.ActionType.ACTION_MOUSE_CLICK)
            {
                int controlId = GetFocusControlId();
                if (controlId >= 1000 && controlId <= 9008)
                {
                    // Show dialog
                    CellControl cntlFoc = (CellControl)GetControl(controlId);
                    int         row     = (controlId / 1000) - 1;
                    int         column  = controlId % 1000;

                    if (cntlFoc.editable)
                    {
                        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg != null)
                        {
                            dlg.Reset();
                            dlg.SetHeading(GUILocalizeStrings.Get(19116)); // Cell value

                            for (int index = 1; index < 10; index++)
                            {
                                dlg.Add("");
                            }
                            dlg.Add(GUILocalizeStrings.Get(19117)); // Clear cell
                            dlg.SelectedLabel = cntlFoc.CellValue - 1;
                            dlg.DoModal(GetWindowId());
                            if (dlg.SelectedLabel < 0)
                            {
                                return;
                            }
                            else
                            {
                                if (dlg.SelectedId == 10)
                                {
                                    cntlFoc.CellValue       = 0;
                                    grid.cells[row, column] = 0;
                                }
                                else
                                {
                                    if (!_Settings.Block || cntlFoc.SolutionValue == dlg.SelectedId)
                                    {
                                        cntlFoc.CellValue       = dlg.SelectedId;
                                        grid.cells[row, column] = dlg.SelectedId;

                                        if (this.GridIsComplete())
                                        {
                                            this.Result();
                                        }
                                    }
                                }
                            }
                        }
                        CheckCandidates();
                    }
                }
            }
            else if (action.wID == Action.ActionType.ACTION_KEY_PRESSED ||
                     (action.wID >= Action.ActionType.REMOTE_0 && action.wID <= Action.ActionType.REMOTE_9))
            {
                int controlId = GetFocusControlId();
                if (controlId >= 1000 && controlId <= 9008)
                {
                    CellControl cntlFoc = (CellControl)GetControl(controlId);
                    int         row     = (controlId / 1000) - 1;
                    int         column  = controlId % 1000;

                    if (cntlFoc != null)
                    {
                        if (action.wID == Action.ActionType.ACTION_KEY_PRESSED)
                        {
                            if (action.m_key.KeyChar == 8)
                            {
                                cntlFoc.CellValue       = 0;
                                grid.cells[row, column] = 0;
                            }
                            else if (action.m_key.KeyChar == 35) // #
                            {
                                _nextNumberIsToggle = true;
                            }
                            else if (action.m_key.KeyChar == 42) // *
                            {
                                _nextNumberIsFilter = true;
                            }
                        }
                        else if (action.wID >= Action.ActionType.REMOTE_0 && action.wID <= Action.ActionType.REMOTE_9)
                        {
                            int value = (action.wID - Action.ActionType.REMOTE_0);

                            if (!_nextNumberIsToggle && !_nextNumberIsFilter)
                            {
                                if (value == 0 || !_Settings.Block || cntlFoc.SolutionValue == value)
                                {
                                    cntlFoc.CellValue       = value;
                                    grid.cells[row, column] = value;

                                    if (this.GridIsComplete())
                                    {
                                        this.Result();
                                    }
                                }
                            }
                            else if (_nextNumberIsToggle)
                            {
                                if (value > 0)
                                {
                                    if (cntlFoc.IsCandidate(value))
                                    {
                                        cntlFoc.RemoveCandidate(value);
                                    }
                                    else
                                    {
                                        cntlFoc.SetCandidate(value);
                                    }
                                }
                                _nextNumberIsToggle = false;
                            }
                            else if (_nextNumberIsFilter)
                            {
                                _Settings.Filter         = value;
                                _Settings.ShowCandidates = true;
                                _nextNumberIsFilter      = false;
                            }
                        }
                        CheckCandidates();
                    }
                }
            }
            else if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
            {
                StopTimer();
            }
            else if (action.wID == Action.ActionType.ACTION_CONTEXT_MENU)
            {
                ShowContextMenu();
            }
            else if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
            {
                StopTimer();
            }
            base.OnAction(action);
        }