コード例 #1
0
ファイル: EvaluationForm.cs プロジェクト: radtek/Klokan
        /// <summary>
        /// Handles the editButton_Clicked event for all category edit buttons in this form.
        /// Makes sure that correct data is displayed in the configuration form
        /// and also saves all new configurations.
        /// </summary>
        /// <param name="categoryName"></param>
        private void EditButtonHandle(string categoryName)
        {
            KlokanCategoryBatch categoryBatch;
            bool isAdd = false;

            // if the category is already configured
            if (categoryConfigurations.ContainsKey(categoryName))
            {
                categoryBatch = categoryConfigurations[categoryName].batch;
            }
            else
            {
                // create a new one and set the flag saying that it will have to be saved when configured
                categoryBatch = new KlokanCategoryBatch {
                    CategoryName = categoryName
                };
                isAdd = true;
            }

            // open a configuration form as a dialog
            CategoryEditForm form = new CategoryEditForm(categoryBatch);

            form.StartPosition = FormStartPosition.CenterScreen;
            var dialogResult = form.ShowDialog();

            if (dialogResult == DialogResult.OK && isAdd)
            {
                // save the configuration
                categoryConfigurations[categoryName] = new CategoryBatchConfig {
                    batch = categoryBatch, isIncluded = true
                };
            }
        }
コード例 #2
0
ファイル: EvaluationForm.cs プロジェクト: radtek/Klokan
        /// <summary>
        /// Handles the checkBox_CheckedChanged event for all checkboxes in this form.
        /// Makes sure that a category is always configured when added into a selection.
        /// </summary>
        /// <param name="categoryName">Name of the category.</param>
        /// <param name="checkBox">A checkbox belonging to the category.</param>
        /// <param name="editButton">An edit button belonging to the category.</param>
        private void CheckBoxHandle(string categoryName, CheckBox checkBox, Button editButton)
        {
            // checkbox was checked
            if (checkBox.Checked)
            {
                // if the category is already configured
                if (categoryConfigurations.ContainsKey(categoryName))
                {
                    // just include it in the selection of categories for the final klokan batch
                    categoryConfigurations[categoryName].isIncluded = true;
                }
                else
                {
                    // open a configuration form in the form of a dialog
                    KlokanCategoryBatch categoryBatch = new KlokanCategoryBatch {
                        CategoryName = categoryName
                    };
                    CategoryEditForm form = new CategoryEditForm(categoryBatch);
                    form.StartPosition = FormStartPosition.CenterScreen;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        // save the configuration
                        categoryConfigurations[categoryName] = new CategoryBatchConfig {
                            batch = categoryBatch, isIncluded = true
                        };
                    }
                }

                editButton.Enabled = true;
            }
            else
            {
                if (categoryConfigurations.ContainsKey(categoryName))
                {
                    categoryConfigurations[categoryName].isIncluded = false;
                }

                editButton.Enabled = false;
            }
        }
コード例 #3
0
        /// <param name="categoryBatch">
        /// The batch needs to have a name set, so that it can be displayed in this form.
        /// The batch is then going to be edited in this form and changes will be saved if the DialogResult is OK.
        /// </param>
        public CategoryEditForm(KlokanCategoryBatch categoryBatch)
        {
            InitializeComponent();

            formCaptionBase    = this.Text;
            sheetLabelTextBase = sheetLabel.Text;

            this.Text       = formCaptionBase + " (" + categoryBatch.CategoryName + ")";
            sheetLabel.Text = sheetLabelTextBase + " (0):";

            this.categoryBatch = categoryBatch;

            // show the content of the batch if there is something there already,
            if (categoryBatch.CorrectAnswers != null)
            {
                correctAnswers = categoryBatch.CorrectAnswers;

                FormTableHandling.DrawAnswers(table1PictureBox, correctAnswers, 0, FormTableHandling.DrawCross, Color.Black);
                FormTableHandling.DrawAnswers(table2PictureBox, correctAnswers, 1, FormTableHandling.DrawCross, Color.Black);
                FormTableHandling.DrawAnswers(table3PictureBox, correctAnswers, 2, FormTableHandling.DrawCross, Color.Black);
            }
            // otherwise initialize default values
            else
            {
                correctAnswers = new bool[3, 8, 5];
            }

            if (categoryBatch.SheetFilenames != null && categoryBatch.SheetFilenames.Count > 0)
            {
                answerSheetFilenames           = categoryBatch.SheetFilenames;
                answerSheetsListBox.DataSource = answerSheetFilenames;
            }
            else
            {
                answerSheetFilenames = new List <string>();
            }
        }