Example #1
0
        /// <summary>
        /// Edit and update a Limit Modifier.
        /// </summary>
        /// <param name="treLimit"></param>
        /// <param name="cmsLimitModifier"></param>
        protected void UpdateLimitModifier(TreeView treLimit, ContextMenuStrip cmsLimitModifier)
        {
            TreeNode      objSelectedNode  = treLimit.SelectedNode;
            LimitModifier objLimitModifier = CommonFunctions.FindByIdWithNameCheck(treLimit.SelectedNode.Tag.ToString(),
                                                                                   _objCharacter.LimitModifiers);

            //If the LimitModifier couldn't be found (Ie it comes from an Improvement or the user hasn't properly selected a treenode, fail out early.
            if (objLimitModifier == null)
            {
                MessageBox.Show(LanguageManager.GetString("Warning_NoLimitFound"));
                return;
            }
            frmSelectLimitModifier frmPickLimitModifier = new frmSelectLimitModifier(objLimitModifier);

            frmPickLimitModifier.ShowDialog(this);

            if (frmPickLimitModifier.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            //Remove the old LimitModifier to ensure we don't double up.
            _objCharacter.LimitModifiers.Remove(objLimitModifier);
            // Create the new limit modifier.
            TreeNode objNode = new TreeNode();

            objLimitModifier = new LimitModifier(_objCharacter);
            string strLimit     = treLimit.SelectedNode.Parent.Text;
            string strCondition = frmPickLimitModifier.SelectedCondition;

            objLimitModifier.Create(frmPickLimitModifier.SelectedName, frmPickLimitModifier.SelectedBonus, strLimit,
                                    strCondition, objNode);
            objLimitModifier.Guid = new Guid(objSelectedNode.Tag.ToString());
            if (objLimitModifier.InternalId == Guid.Empty.ToString())
            {
                return;
            }

            _objCharacter.LimitModifiers.Add(objLimitModifier);

            //Add the new treeview node for the LimitModifier.
            objNode.ContextMenuStrip = cmsLimitModifier;
            objNode.Text             = objLimitModifier.DisplayName;
            objNode.Tag = objLimitModifier.InternalId;
            objSelectedNode.Parent.Nodes.Add(objNode);
            objSelectedNode.Remove();
        }
Example #2
0
        private void cmdAddLimitModifier_Click(object sender, EventArgs e)
        {
            try
            {
                // Select the Limit node if we're currently on a child.
                if (treLimit.SelectedNode.Level > 1)
                    treLimit.SelectedNode = treLimit.SelectedNode.Parent;

                frmSelectLimitModifier frmPickLimitModifier = new frmSelectLimitModifier();
                frmPickLimitModifier.ShowDialog(this);

                if (frmPickLimitModifier.DialogResult == DialogResult.Cancel)
                    return;

                // Create the new limit modifier.
                TreeNode objNode = new TreeNode();
                LimitModifier objLimitModifier = new LimitModifier(_objCharacter);
                string strLimit = treLimit.SelectedNode.Text;
                string strCondition = frmPickLimitModifier.SelectedCondition;
                objLimitModifier.Create(frmPickLimitModifier.SelectedName, frmPickLimitModifier.SelectedBonus, strLimit, strCondition, _objCharacter, objNode);
                if (objLimitModifier.InternalId == Guid.Empty.ToString())
                    return;

                objNode.ContextMenuStrip = cmsLimitModifier;
                _objCharacter.LimitModifiers.Add(objLimitModifier);

                treLimit.SelectedNode.Nodes.Add(objNode);
                treLimit.SelectedNode.Expand();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectLimitModifier"), LanguageManager.Instance.GetString("MessageTitle_SelectLimitModifier"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
        /// <summary>
        /// Edit and update a Limit Modifier.
        /// </summary>
        /// <param name="treLimit"></param>
        /// <param name="cmsLimitModifier"></param>
        protected void UpdateLimitModifier(TreeView treLimit, ContextMenuStrip cmsLimitModifier)
        {
            TreeNode objSelectedNode = treLimit.SelectedNode;
            LimitModifier objLimitModifier = _objFunctions.FindLimitModifier(treLimit.SelectedNode.Tag.ToString(),
                _objCharacter.LimitModifiers);
            //If the LimitModifier couldn't be found (Ie it comes from an Improvement or the user hasn't properly selected a treenode, fail out early.
            if (objLimitModifier == null)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Warning_NoLimitFound"));
                return;
            }
            frmSelectLimitModifier frmPickLimitModifier = new frmSelectLimitModifier(objLimitModifier);
            frmPickLimitModifier.ShowDialog(this);

            if (frmPickLimitModifier.DialogResult == DialogResult.Cancel)
                return;

            //Remove the old LimitModifier to ensure we don't double up.
            _objCharacter.LimitModifiers.Remove(objLimitModifier);
            // Create the new limit modifier.
            TreeNode objNode = new TreeNode();
            objLimitModifier = new LimitModifier(_objCharacter);
            string strLimit = treLimit.SelectedNode.Parent.Text;
            string strCondition = frmPickLimitModifier.SelectedCondition;
            objLimitModifier.Create(frmPickLimitModifier.SelectedName, frmPickLimitModifier.SelectedBonus, strLimit,
                strCondition, _objCharacter, objNode);
            objLimitModifier.Guid = new Guid(objSelectedNode.Tag.ToString());
            if (objLimitModifier.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.LimitModifiers.Add(objLimitModifier);

            //Add the new treeview node for the LimitModifier.
            objNode.ContextMenuStrip = cmsLimitModifier;
            objNode.Text = objLimitModifier.DisplayName;
            objNode.Tag = objLimitModifier.InternalId;
            objSelectedNode.Parent.Nodes.Add(objNode);
            objSelectedNode.Remove();
        }