Пример #1
0
        private void SelectReferenceItem(NodeConfigSectionBase section, NodeConfigSectionBase section1)
        {
            if (section.AddCommandType != null)
            {
            }

            var menu = new SelectionMenu();


            if (section1.AllowDuplicates)
            {
                menu.ConvertAndAdd(section1.GenericSelector(GraphItem).ToArray().OfType <IItem>(), _ =>
                {
                    GraphItem.AddReferenceItem(_ as TData, section1);
                });


                //InvertGraphEditor.WindowManager.InitItemWindow(section1.GenericSelector(GraphItem).ToArray(),
                //    (selected) => { GraphItem.AddReferenceItem(selected, section1); });
            }
            else
            {
                menu.ConvertAndAdd(section1.GenericSelector(GraphItem).Where(
                                       p =>
                                       !GraphItem.PersistedItems.OfType <GenericReferenceItem>()
                                       .Select(x => x.SourceIdentifier)
                                       .Contains(p.Identifier)).ToArray().OfType <IItem>(), _ =>
                {
                    GraphItem.AddReferenceItem(_ as TData, section1);
                });
            }

            InvertApplication.SignalEvent <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", () =>
//                {
//                    
//                   
//                }));
//            });
        }
Пример #3
0
        public void Show(DiagramViewModel diagramViewModel, ConnectorViewModel startConnector, Vector2 position)
        {
            var selectionMenu = new SelectionMenu();

            Signal <IQueryPossibleConnections>(_ => _.QueryPossibleConnections(selectionMenu, diagramViewModel, startConnector, position));
            Signal((IShowSelectionMenu _) => _.ShowSelectionMenu(selectionMenu, position));
        }
Пример #4
0
        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));
        }
Пример #5
0
        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 Show(DiagramViewModel diagramViewModel,ConnectorViewModel startConnector, Vector2 position)
 {
     var selectionMenu = new SelectionMenu();
     Signal<IQueryPossibleConnections>(_ => _.QueryPossibleConnections(selectionMenu, diagramViewModel, startConnector, position));
     Signal((IShowSelectionMenu _) => _.ShowSelectionMenu(selectionMenu, position));
 }
        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);
                    }
                }
            }
        }
Пример #8
0
        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);
                    }
                }
            }
        }