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); } }
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); }
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; }