Ejemplo n.º 1
0
        private void AnalyzeAssembly(Assembly assembly)
        {
            if (assembly.ReflectionOnly)
            {
                return;
            }

            IEnumerable <Type> nodeTypes = Enumerable.Empty <Type>();

            nodeTypes = assembly.GetTypes();
            nodeTypes = nodeTypes.Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(Node)) && t != typeof(Flow) && !t.IsSubclassOf(typeof(Flow)))
                        .Where(t => t.GetConstructor(Type.EmptyTypes) != null);

            foreach (Type type in nodeTypes)
            {
                NodeTypeInfo     nodeType     = NodeTypeInfo.From(type);
                NodeCategoryInfo nodeCategory = NodeCategories.FirstOrDefault(c => c.Category == nodeType.Category);

                if (nodeCategory == null)
                {
                    NodeCategories.Add(nodeCategory = new NodeCategoryInfo(nodeType.Category));
                }

                nodeCategory.Nodes.Add(nodeType);
            }
        }
Ejemplo n.º 2
0
        public static NodeTypeInfo From(Type type)
        {
            if (type != typeof(Node) && !type.IsSubclassOf(typeof(Node)))
            {
                return(null);
            }

            NodeTypeInfo typeInfo;

            if (!typeInfos.TryGetValue(type, out typeInfo))
            {
                typeInfos.Add(type, typeInfo = new NodeTypeInfo(type));
            }

            return(typeInfo);
        }
Ejemplo n.º 3
0
        private void NodeList_MouseMove(object sender, MouseEventArgs e)
        {
            if (!draggingNode || e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            Grid             grid             = sender as Grid;
            ContentPresenter contentPresenter = VisualTreeHelper.GetParent(grid) as ContentPresenter;

            DependencyObject itemsControl = contentPresenter;

            while (!(itemsControl is ItemsControl))
            {
                itemsControl = VisualTreeHelper.GetParent(itemsControl);
            }

            NodeTypeInfo nodeTypeInfo = contentPresenter.Content as NodeTypeInfo;
            DataObject   dragData     = new DataObject("FlowTomator.Node", nodeTypeInfo.Type);

            DragDrop.DoDragDrop(grid, dragData, DragDropEffects.Move);

            draggingNode = false;
        }