Ejemplo n.º 1
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                IBaseNode baseNode = context.Instance as IBaseNode;
                if (baseNode != null)
                {
                    using (DataConnectionForm frm = new DataConnectionForm(baseNode))
                    {
                        IDataPersistence dp = getDataPersistence(baseNode);
                        if (dp != null)
                        {
                            IDecisionTree tree     = baseNode.Tree;
                            List <string> Elements = new List <string>();
                            foreach (string reference in dp.DataConnections)
                            {
                                IBaseNode node = tree.GetNodeByReference(reference);
                                if (node != null)
                                {
                                    Elements.Add(node.Name);
                                }
                            }
                            frm.Elements = Elements;

                            if (svc.ShowDialog(frm) == DialogResult.OK)
                            {
                                List <string> result    = new List <string>();
                                IBaseNode     dataNodes = tree.RootNode.GetNode(eNodeType.DataObjects);
                                foreach (string name in frm.Elements)
                                {
                                    IBaseNode dc = dataNodes.GetNode(name);
                                    if (dc != null)
                                    {
                                        result.Add(dc.Reference);
                                    }
                                }

                                value = result.ToArray();
                            }
                        }
                    }
                }
            }

            return(value);
        }
Ejemplo n.º 2
0
        protected string GetNodeName(string name, IBaseNode node)
        {
            if (node != null)
            {
                int    index   = 1;
                bool   found   = false;
                string newName = name;

                while (!found)
                {
                    newName = string.Format("{0}-{1}", name, index++);
                    found   = node.GetNode(newName) == null;
                }

                return(newName);
            }

            return(name);
        }