public void SelectItem() { var menu = new SelectionMenu(); menu.AddItem(new SelectionMenuItem(string.Empty,"[None]", () => { ReferenceItem.SetInput(null); })); menu.ConvertAndAdd(ReferenceItem.GetAllowed().OfType<IItem>(), _ => { var item = _ as IValueItem; if (item == null) return; if (IsInput) { ReferenceItem.SetInput(item); } else { ReferenceItem.SetOutput(item); } }); InvertApplication.SignalEvent<IShowSelectionMenu>(_=>_.ShowSelectionMenu(menu)); // InvertGraphEditor.WindowManager.InitItemWindow(ReferenceItem.GetAllowed().ToArray(), _ => // { // InvertApplication.Execute(new LambdaCommand("Set Item", () => // { // // // })); // }); }
public void Execute(SelectTypeCommand command) { var menu = new SelectionMenu(); if (command.AllowNone) { menu.AddItem(new SelectionMenuItem("", "None", () => { command.Item.RelatedType = null; })); } // var types = GetRelatedTypes(command).ToArray(); foreach (var item in GetRelatedTypes(command)) { var type1 = item; if (command.Filter == null || command.Filter(item)) { menu.AddItem(new SelectionMenuItem(item, () => { var record = type1 as IDataRecord; if (record != null) { command.Item.RelatedType = record.Identifier; } else { command.Item.RelatedType = type1.FullName; } if (command.OnSelectionFinished != null) { command.OnSelectionFinished(); } })); } } Signal <IShowSelectionMenu>(_ => _.ShowSelectionMenu(menu)); }
public void SelectItem() { var menu = new SelectionMenu(); menu.AddItem(new SelectionMenuItem(string.Empty, "[None]", () => { ReferenceItem.SetInput(null); })); menu.ConvertAndAdd(ReferenceItem.GetAllowed().OfType <IItem>(), _ => { var item = _ as IValueItem; if (item == null) { return; } if (IsInput) { ReferenceItem.SetInput(item); } else { ReferenceItem.SetOutput(item); } }); InvertApplication.SignalEvent <IShowSelectionMenu>(_ => _.ShowSelectionMenu(menu)); // InvertGraphEditor.WindowManager.InitItemWindow(ReferenceItem.GetAllowed().ToArray(), _ => // { // InvertApplication.Execute(new LambdaCommand("Set Item", () => // { // // // })); // }); }
public void QueryPossibleConnections(SelectionMenu menu,DiagramViewModel diagramViewModel, ConnectorViewModel startConnector, Vector2 mousePosition) { var currentGraph = InvertApplication.Container.Resolve<WorkspaceService>().CurrentWorkspace.CurrentGraph; var allowedFilterNodes = FilterExtensions.AllowedFilterNodes[currentGraph.CurrentFilter.GetType()]; foreach (var item in allowedFilterNodes) { if (item.IsInterface) continue; if (item.IsAbstract) continue; var node = Activator.CreateInstance(item) as IDiagramNode; node.Repository = diagramViewModel.CurrentRepository; node.GraphId = currentGraph.Identifier; var vm = InvertGraphEditor.Container.GetNodeViewModel(node, diagramViewModel) as DiagramNodeViewModel; if (vm == null) continue; vm.IsCollapsed = false; var connectors = new List<ConnectorViewModel>(); vm.GetConnectors(connectors); var config = InvertGraphEditor.Container.Resolve<NodeConfigBase>(item.Name); var name = config == null ? item.Name : config.Name; foreach (var connector in connectors) { foreach (var strategy in InvertGraphEditor.ConnectionStrategies) { var connection = strategy.Connect(diagramViewModel, startConnector, connector); if (connection == null) continue; var node1 = node; var message = string.Format("Create {0}", name); //if (!string.IsNullOrEmpty(connector.Name)) //{ // message += string.Format(" and connect to {0}", connector.Name); //} var value = new KeyValuePair<IDiagramNode, ConnectionViewModel>(node1, connection); var qaItem = new SelectionMenuItem("Connect", message,() => { diagramViewModel.AddNode(value.Key, mousePosition); connection.Apply(value.Value as ConnectionViewModel); value.Key.IsSelected = true; value.Key.IsEditing = true; value.Key.Name = ""; }); menu.AddItem(qaItem); } } } }
public void QueryPossibleConnections(SelectionMenu menu, DiagramViewModel diagramViewModel, ConnectorViewModel startConnector, Vector2 mousePosition) { var currentGraph = InvertApplication.Container.Resolve <WorkspaceService>().CurrentWorkspace.CurrentGraph; var allowedFilterNodes = FilterExtensions.AllowedFilterNodes[currentGraph.CurrentFilter.GetType()]; foreach (var item in allowedFilterNodes) { if (item.IsInterface) { continue; } if (item.IsAbstract) { continue; } var node = Activator.CreateInstance(item) as IDiagramNode; node.Repository = diagramViewModel.CurrentRepository; node.GraphId = currentGraph.Identifier; var vm = InvertGraphEditor.Container.GetNodeViewModel(node, diagramViewModel) as DiagramNodeViewModel; if (vm == null) { continue; } vm.IsCollapsed = false; var connectors = new List <ConnectorViewModel>(); vm.GetConnectors(connectors); var config = InvertGraphEditor.Container.Resolve <NodeConfigBase>(item.Name); var name = config == null ? item.Name : config.Name; foreach (var connector in connectors) { foreach (var strategy in InvertGraphEditor.ConnectionStrategies) { var connection = strategy.Connect(diagramViewModel, startConnector, connector); if (connection == null) { continue; } var node1 = node; var message = string.Format("Create {0}", name); //if (!string.IsNullOrEmpty(connector.Name)) //{ // message += string.Format(" and connect to {0}", connector.Name); //} var value = new KeyValuePair <IDiagramNode, ConnectionViewModel>(node1, connection); var qaItem = new SelectionMenuItem("Connect", message, () => { diagramViewModel.AddNode(value.Key, mousePosition); connection.Apply(value.Value as ConnectionViewModel); value.Key.IsSelected = true; value.Key.IsEditing = true; value.Key.Name = ""; }); menu.AddItem(qaItem); } } } }