Exemplo n.º 1
0
        private void PerformEdit()
        {
            if (lstOptions.SelectedItems.Count == 0)
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            string optionName = lstOptions.SelectedItems[0].SubItems[0].Text;
            int    listIndex  = lstOptions.SelectedIndices[0];

            Project.UserOption currentOption = null;
            int index = -1;

            for (int i = 0; i < Project.Instance.UserOptions.Length; i++)
            {
                Project.UserOption option = Project.Instance.UserOptions[i];

                if (option.VariableName == optionName)
                {
                    index         = i;
                    currentOption = new Project.UserOption(option.VariableName, option.Category, option.VarType, option.Text, option.Description, option.Values, option.DefaultValue, option.IteratorType, option.ValidatorFunction, option.DefaultValueIsFunction, option.DisplayToUser, option.DisplayToUserIsFunction);
                    break;
                }
            }
            frmOptionEdit form = new frmOptionEdit(currentOption);

            Cursor = Cursors.Default;

            if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
            {
                string[] subItems = new string[9];
                subItems[0] = form.CurrentOption.VariableName;
                subItems[1] = form.CurrentOption.VarType.Name;
                subItems[2] = form.CurrentOption.Text;
                subItems[3] = form.CurrentOption.Description;

                for (int i = 0; i < form.CurrentOption.Values.Length; i++)
                {
                    if (i > 0)
                    {
                        subItems[4] += ", ";
                    }
                    subItems[4] += form.CurrentOption.Values[i];
                }
                subItems[5] = form.CurrentOption.Category;
                subItems[6] = form.CurrentOption.DefaultValue;
                subItems[7] = form.CurrentOption.IteratorType == null ? "" : form.CurrentOption.IteratorType.Name;
                subItems[8] = form.CurrentOption.ValidatorFunction;

                ListViewItem item = new ListViewItem(subItems);
                lstOptions.BeginUpdate();
                lstOptions.Items[lstOptions.SelectedItems[0].Index] = item;
                Project.Instance.UserOptions[index]  = form.CurrentOption;
                Project.Instance.IsDirty             = true;
                lstOptions.Items[listIndex].Selected = true;
                lstOptions.EndUpdate();
                return;
            }
        }
        private bool AddUserOptionNode(TreeListNode parentNode, Project.UserOption myOption, Project.UserOption theirOption)
        {
            int originalNumChildNodes = parentNode.Nodes.Count;

            if (myOption != null && theirOption != null)
            {
                if (myOption.Category != theirOption.Category)
                {
                    AddNodeBoth("Category", theirOption.Category, myOption.Category, parentNode, null);
                }
                if (myOption.DefaultValue != theirOption.DefaultValue)
                {
                    AddNodeBoth("DefaultValue", theirOption.DefaultValue, myOption.DefaultValue, parentNode, null);
                }
                if (myOption.Description != theirOption.Description)
                {
                    AddNodeBoth("Description", theirOption.Description, myOption.Description, parentNode, null);
                }
                if (myOption.IteratorType != theirOption.IteratorType)
                {
                    AddNodeBoth("IteratorType", theirOption.IteratorType, myOption.IteratorType, parentNode, null);
                }
                if (myOption.ResetPerSession != theirOption.ResetPerSession)
                {
                    AddNodeBoth("ResetPerSession", theirOption.ResetPerSession, myOption.ResetPerSession, parentNode, null);
                }
                if (myOption.Text != theirOption.Text)
                {
                    AddNodeBoth("Text", theirOption.Text, myOption.Text, parentNode, null);
                }
                // TODO: Handle enum values
                //if (myOption.Values != theirOption.Category) { AddNodeBoth("Category", theirOption.Category, myOption.Category, parentNode, null); }
                if (myOption.VariableName != theirOption.VariableName)
                {
                    AddNodeBoth("VariableName", theirOption.VariableName, myOption.VariableName, parentNode, null);
                }
                if (myOption.VarType != theirOption.VarType)
                {
                    AddNodeBoth("VarType", theirOption.VarType, myOption.VarType, parentNode, null);
                }

                return(originalNumChildNodes != parentNode.Nodes.Count);
            }
            else if (theirOption != null)
            {
                AddNodeTheirs("Category", theirOption.Category, null, parentNode, null);
                AddNodeTheirs("DefaultValue", theirOption.DefaultValue, null, parentNode, null);
                AddNodeTheirs("Description", theirOption.Description, null, parentNode, null);
                AddNodeTheirs("IteratorType", theirOption.IteratorType, null, parentNode, null);
                AddNodeTheirs("ResetPerSession", theirOption.ResetPerSession, null, parentNode, null);
                AddNodeTheirs("Text", theirOption.Text, null, parentNode, null);
                // TODO: Handle enum values
                //if (myOption.Values != theirOption.Category) { AddNodeTheirs("Category", myOption.Category, theirOption.Category, parentNode, null); }
                AddNodeTheirs("VariableName", theirOption.VariableName, null, parentNode, null);
                AddNodeTheirs("VarType", theirOption.VarType, null, parentNode, null);
            }
            else if (myOption != null)
            {
                AddNodeMine("Category", null, myOption.Category, parentNode, null);
                AddNodeMine("DefaultValue", null, myOption.DefaultValue, parentNode, null);
                AddNodeMine("Description", null, myOption.Description, parentNode, null);
                AddNodeMine("IteratorType", null, myOption.IteratorType, parentNode, null);
                AddNodeMine("ResetPerSession", null, myOption.ResetPerSession, parentNode, null);
                AddNodeMine("Text", null, myOption.Text, parentNode, null);
                // TODO: Handle enum values
                //if (myOption.Values != theirOption.Category) { AddNodeMine("Category", myOption.Category, theirOption.Category, parentNode, null); }
                AddNodeMine("VariableName", null, myOption.VariableName, parentNode, null);
                AddNodeMine("VarType", null, myOption.VarType, parentNode, null);
            }
            return(true);
        }
Exemplo n.º 3
0
        private void PerformEdit()
        {
            if (lstOptions.SelectedItems.Count == 0)
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            string optionName = lstOptions.SelectedItems[0].SubItems[0].Text;
            int listIndex = lstOptions.SelectedIndices[0];
            Project.UserOption currentOption = null;
            int index = -1;

            for (int i = 0; i < Project.Instance.UserOptions.Length; i++)
            {
                Project.UserOption option = Project.Instance.UserOptions[i];

                if (option.VariableName == optionName)
                {
                    index = i;
                    currentOption = new Project.UserOption(option.VariableName, option.Category, option.VarType, option.Text, option.Description, option.Values, option.DefaultValue, option.IteratorType, option.ValidatorFunction, option.DefaultValueIsFunction, option.DisplayToUser, option.DisplayToUserIsFunction);
                    break;
                }
            }
            frmOptionEdit form = new frmOptionEdit(currentOption);
            Cursor = Cursors.Default;

            if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
            {
                string[] subItems = new string[9];
                subItems[0] = form.CurrentOption.VariableName;
                subItems[1] = form.CurrentOption.VarType.Name;
                subItems[2] = form.CurrentOption.Text;
                subItems[3] = form.CurrentOption.Description;

                for (int i = 0; i < form.CurrentOption.Values.Length; i++)
                {
                    if (i > 0)
                    {
                        subItems[4] += ", ";
                    }
                    subItems[4] += form.CurrentOption.Values[i];
                }
                subItems[5] = form.CurrentOption.Category;
                subItems[6] = form.CurrentOption.DefaultValue;
                subItems[7] = form.CurrentOption.IteratorType == null ? "" : form.CurrentOption.IteratorType.Name;
                subItems[8] = form.CurrentOption.ValidatorFunction;

                ListViewItem item = new ListViewItem(subItems);
                lstOptions.BeginUpdate();
                lstOptions.Items[lstOptions.SelectedItems[0].Index] = item;
                Project.Instance.UserOptions[index] = form.CurrentOption;
                Project.Instance.IsDirty = true;
                lstOptions.Items[listIndex].Selected = true;
                lstOptions.EndUpdate();
                return;
            }
        }