コード例 #1
0
        private void BtnPrevAction_Click(object sender, RoutedEventArgs e)
        {
            if (LstInstruction.SelectedIndex == -1)
            {
                BtnPrevAction.IsEnabled = false;
                MessageBox.Show("Starting Execution");
                return;
            }

            BtnNextAction.IsEnabled = true;

            LstInstruction.SelectedIndex -= 1;
            LstInstruction.ScrollIntoView(LstInstruction.SelectedItem);

            if (BlkCurrentExecution == null)
            {
                return;
            }

            MoveDisk(false);

            if (LstInstruction.SelectedIndex == -1)
            {
                BtnPrevAction.IsEnabled = false;
            }
        }
コード例 #2
0
        private void BtnRestartAction_Click(object sender, RoutedEventArgs e)
        {
            if (InstructionsList.Count != 0)
            {
                LstInstruction.SelectedIndex = -1;

                BtnPrevAction.IsEnabled = false;
                BtnNextAction.IsEnabled = true;

                LstInstruction.ScrollIntoView(LstInstruction.SelectedIndex);

                GenerateDisks(Convert.ToInt32(TxtNumOfDisk.Text), CmbStartPeg.SelectedIndex);
                DisableTextChange(true);
                PrevInstructionStack.Clear();
            }
        }
コード例 #3
0
        private void BtnNextAction_Click(object sender, RoutedEventArgs e)
        {
            BtnPrevAction.IsEnabled    = true;
            BtnRestartAction.IsEnabled = true;

            LstInstruction.SelectedIndex += 1;
            LstInstruction.ScrollIntoView(LstInstruction.SelectedItem);

            if (BlkCurrentExecution == null)
            {
                return;
            }

            MoveDisk(true, BlkCurrentExecution.Text);

            if (LstInstruction.SelectedIndex == LstInstruction.Items.Count - 1)
            {
                BtnNextAction.IsEnabled = false;
                MessageBox.Show("Solved!");
            }
        }