Exemplo n.º 1
0
        /// <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
                };
            }
        }
Exemplo n.º 2
0
        /// <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;
            }
        }