Esempio n. 1
0
        private void btnApplyType_Click(object sender, EventArgs e)
        {
            if (cmbBoxNodeType.SelectedIndex < 0)
            {
                return;
            }
            if (treeViewAdvControl.SelectedNode == null)
            {
                ShowErrorMsg(CDefines.GetDStr("NothingSelected"));
                return;
            }
            Constant.NodeTypeDefine newtype = GetTypeFromName(cmbBoxNodeType.SelectedItem.ToString());
            PlistNodeData           data    = GetNodeData(treeViewAdvControl.SelectedNode);

            if (data.nodeType == newtype)
            {
                return;
            }
            object oldvalue = data.GetOldValue();

            data.nodeType = newtype;
            data.SetNewValue(oldvalue);
            RefreshEditPanel();
            RefreshTreeIcon(newtype);
        }
Esempio n. 2
0
        Node AddNodeAndValue(Node parent, string nodename, object nodevalue)
        {
            if (string.IsNullOrEmpty(nodename))
            {
                new Exception("node name can not be empty!");
            }
            Node nodeAdded = null;

            if (parent != null)
            {
                PlistNodeData data = parent.Tag as PlistNodeData;
                if (!CheckAddNodePossible(data.nodeType))
                {
                    ShowErrorMsg(CDefines.GetDStr("AddChildFailure"));
                    return(null);
                }
                nodeAdded = AddChild(parent, nodename);
            }
            else
            {
                nodeAdded = AddRoot(nodename);
            }

            Constant.NodeTypeDefine itemtype = GetItemTypeByValue(nodevalue);
            PlistNodeData           nodedata = InitNodeData(itemtype, nodename);

            nodedata.SetNewValue(nodevalue);
            nodeAdded.Tag      = nodedata;
            nodeAdded.Image    = imageListToolbar.Images[nodedata.nodeType.ToString()];
            haveUnsavedChanges = true;
            return(nodeAdded);
        }