Esempio n. 1
0
        private void AddAttributePoolClick(object sender, EventArgs e)
        {
            if (_attributePoolDialog.ShowDialog(this) == DialogResult.OK)
            {
                var name = _attributePoolDialog.AttributePoolName;

                try
                {
                    // Create a new instance.
                    var instance = new AttributePool {
                        Name = name
                    };

                    // Register it.
                    AttributePoolManager.Add(instance);

                    // And select it.
                    SelectAttributePool(instance);

                    // Add undo command.
                    PushUndo("add attribute pool", () =>
                    {
                        if (MessageBox.Show(this,
                                            "Are you sure you wish to delete the attribute pool '" + instance.Name + "'?",
                                            "Confirmation", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            AttributePoolManager.Remove(instance);
                            return(true);
                        }
                        return(false);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Failed creating new attribute pool:\n" + ex, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
        private void RemoveClick(object sender, EventArgs e)
        {
            if (pgProperties.SelectedObject == null)
            {
                return;
            }

            if (tvData.Focused || (sender == miDelete && miDelete.Visible))
            {
                if (pgProperties.SelectedObject is IFactory)
                {
                    var factory = (IFactory)pgProperties.SelectedObject;
                    if ((ModifierKeys & Keys.Shift) != 0 ||
                        MessageBox.Show(this,
                                        "Are you sure you wish to delete the factory '" + factory.Name + "'?",
                                        "Confirmation", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        FactoryManager.Remove(factory);

                        // Add undo command.
                        PushUndo("remove factory", () =>
                        {
                            FactoryManager.Add(factory);
                            return(true);
                        });
                    }
                }
                else if (pgProperties.SelectedObject is ItemPool)
                {
                    var itemPool = (ItemPool)pgProperties.SelectedObject;
                    if ((ModifierKeys & Keys.Shift) != 0 ||
                        MessageBox.Show(this,
                                        "Are you sure you wish to delete the item pool '" + itemPool.Name + "'?",
                                        "Confirmation", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        ItemPoolManager.Remove(itemPool);

                        // Add undo command.
                        PushUndo("remove item pool", () =>
                        {
                            ItemPoolManager.Add(itemPool);
                            return(true);
                        });
                    }
                }
                else if (pgProperties.SelectedObject is AttributePool)
                {
                    var attributePool = (AttributePool)pgProperties.SelectedObject;
                    if ((ModifierKeys & Keys.Shift) != 0 ||
                        MessageBox.Show(this,
                                        "Are you sure you wish to delete the attribute pool '" + attributePool.Name + "'?",
                                        "Confirmation", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        AttributePoolManager.Remove(attributePool);

                        // Add undo command.
                        PushUndo("remove attribute pool", () =>
                        {
                            AttributePoolManager.Add(attributePool);
                            return(true);
                        });
                    }
                }
            }
        }