Пример #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);
        }
Пример #2
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 (LinkDataDefinitionsForm frm = new LinkDataDefinitionsForm(baseNode))
                    {
                        IDataPersistence dp = getDataPersistence(baseNode);
                        if (dp != null)
                        {
                            IDecisionTree tree = baseNode.Tree;
                            List <LinkDataDefinitionsForm.ListBoxItem> Elements = new List <LinkDataDefinitionsForm.ListBoxItem>();
                            foreach (string reference in dp.DataConnections)
                            {
                                IBaseNode node = tree.GetNodeByReference(reference);
                                if (node != null)
                                {
                                    Elements.Add(new LinkDataDefinitionsForm.ListBoxItem(node, 0));
                                }
                            }
                            frm.Elements = Elements;

                            if (svc.ShowDialog(frm) == DialogResult.OK)
                            {
                                dp.DataConnections.Clear();
                                foreach (LinkDataDefinitionsForm.ListBoxItem lbi in frm.Elements)
                                {
                                    dp.DataConnections.Add(lbi.Node.Reference);
                                }
                            }
                        }
                    }
                }
            }

            return(value);
        }