Exemplo n.º 1
0
        private void CreateNewSectionItem(NodeConfigSectionBase section1, DiagramNodeViewModel vm)
        {
            var item = Activator.CreateInstance(section1.SourceType) as GenericNodeChildItem;

            item.Node = vm.GraphItemObject as GraphNode;
            DiagramViewModel.CurrentRepository.Add(item);
            item.Name = item.Repository.GetUniqueName(section1.Name);

            OnAdd(section1, item);

            if (typeof(ITypedItem).IsAssignableFrom(section1.SourceType))
            {
                InvertApplication.Execute(new SelectTypeCommand()
                {
                    PrimitiveOnly     = false,
                    AllowNone         = false,
                    IncludePrimitives = true,
                    Item = item as ITypedItem,
                    OnSelectionFinished = () =>
                    {
                        item.IsSelected = true;
                        item.IsEditing  = true;
                    }
                });
            }
            else
            {
                item.IsEditing = true;
            }
        }
Exemplo n.º 2
0
 public void NavigateTo(string identifier)
 {
     InvertApplication.Execute(new NavigateByIdCommand()
     {
         Identifier = identifier
     });
 }
Exemplo n.º 3
0
 public void NavigateByName(string name)
 {
     InvertApplication.Execute(new NavigateByNameCommand()
     {
         ItemName = name
     });
 }
Exemplo n.º 4
0
        public void Navigate()
        {
            InvertApplication.Execute(new FilterBySelectionCommand());
//
//            if (SelectedNode == null) return;
//            if (SelectedNode.IsFilter)
//            {
//
//                if (SelectedNode.GraphItemObject == GraphData.CurrentFilter)
//                {
//                    GraphData.PopFilter();
//                    GraphData.UpdateLinks();
//
//                }
//                else
//                {
//                    var graphFilter = SelectedNode.GraphItemObject as IGraphFilter;
//                    GraphData.PushFilter(graphFilter);
//                    GraphData.UpdateLinks();
//                }
//                //   if (command.SaveInHistory) SaveNewStep(null);
//
//            }
//            InvertApplication.Execute(new FilterBySelectionCommand()
//            {
//
//            });
        }
Exemplo n.º 5
0
 public bool KeyEvent(KeyCode keyCode, ModifierKeyState state)
 {
     if (state.Ctrl && keyCode == KeyCode.Z)
     {
         InvertApplication.Execute(new UndoCommand());
         return(true);
     }
     if (state.Ctrl && keyCode == KeyCode.Y)
     {
         InvertApplication.Execute(new RedoCommand());
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        public void ShowSelectionListWindow()
        {
            EndEditing();
            InvertApplication.Execute(new SelectTypeCommand()
            {
                PrimitiveOnly     = false,
                AllowNone         = false,
                IncludePrimitives = true,
                Item = this.DataObject as ITypedItem,
            });
            // TODO 2.0 Typed Item Selection Window
            // This was in the drawer re-implement

            //if (!this.ItemViewModel.Enabled) return;
            //if (TypedItemViewModel.Data.Precompiled) return;
            //var commandName = ViewModelObject.DataObject.GetType().Name.Replace("Data", "") + "TypeSelection";

            //var command = InvertGraphEditor.Container.Resolve<IEditorCommand>(commandName);
        }
Exemplo n.º 7
0
        //public void UpgradeProject()
        //{
        //    uFrameEditor.ExecuteCommand(new ConvertToJSON());
        //}

        public void NothingSelected()
        {
            var items = SelectedNodeItems.OfType <ItemViewModel>().Where(p => p.IsEditing).ToArray();

            if (items.Length > 0)
            {
                InvertApplication.Execute(() =>
                {
                    foreach (var item in items)
                    {
                        item.EndEditing();
                    }
                });
            }

            DeselectAll();

            //InvertGraphEditor.ExecuteCommand(_ => { });
        }
        public void Refresh()
        {
            Tabs.Clear();

            foreach (var tab in DesignerWindow.Designer.Tabs)
            {
                var tab1           = tab;
                var navigationItem = new NavigationItem()
                {
                    Icon            = "CommandIcon",
                    SpecializedIcon = null,

                    //State = DesignerWindow.Designer.CurrentTab.Graph == tab ? NavigationItemState.Current : NavigationItemState.Regular,
                    Title            = tab.Title + (tab.IsDirty ? "*" : string.Empty),
                    NavigationAction = x =>
                    {
                        InvertApplication.Execute(new LambdaCommand("Change Current Graph", () =>
                        {
                            WorkspaceService.CurrentWorkspace.CurrentGraphId = tab1.Identifier;
                            //DesignerWindow.SwitchDiagram(WorkspaceService.CurrentWorkspace.Graphs.FirstOrDefault(p => p.Identifier == tab.Identifier));
                        }));
                    },
                    CloseAction = x =>
                    {
                        InvertApplication.Execute(new LambdaCommand("Close Graph", () =>
                        {
                            this.DiagramViewModel.CurrentRepository.RemoveAll <WorkspaceGraph>(p => p.GraphId == tab1.Identifier);
                        }));
                    }
                };

                if (DesignerWindow.Workspace != null && DesignerWindow.Workspace.CurrentGraph != null &&
                    tab.Identifier == DesignerWindow.Workspace.CurrentGraph.Identifier)
                {
                    navigationItem.State = NavigationItemState.Current;
                }
                else
                {
                    navigationItem.State = NavigationItemState.Regular;
                }

                Tabs.Add(navigationItem);
            }

            Breadcrubs.Clear();

            foreach (var filter in new[] { DiagramViewModel.GraphData.RootFilter }.Concat(this.DiagramViewModel.GraphData.GetFilterPath()))
            {
                var filter1        = filter;
                var navigationItem = new NavigationItem()
                {
                    Icon             = "CommandIcon",
                    Title            = filter.Name,
                    State            = DiagramViewModel.GraphData != null && DiagramViewModel.GraphData.CurrentFilter == filter ? NavigationItemState.Current : NavigationItemState.Regular,
                    NavigationAction = x =>
                    {
                        InvertApplication.Execute(new LambdaCommand("Back", () => { DiagramViewModel.GraphData.PopToFilter(filter1); }));
                    }
                };

                if (filter == DiagramViewModel.GraphData.RootFilter)
                {
                    navigationItem.SpecializedIcon = "RootFilterIcon";
                }

                Breadcrubs.Add(navigationItem);
            }
        }
Exemplo n.º 9
0
 public void Execute <TCommand>(TCommand command) where TCommand :  ICommand
 {
     InvertApplication.Execute(command);
 }
Exemplo n.º 10
0
        public override void OnMouseUp(MouseEvent e)
        {
            base.OnMouseUp(e);
            if (CurrentConnection != null)
            {
                InvertApplication.Execute(new LambdaCommand("Create Connection", () =>
                {
                    CurrentConnection.Apply(CurrentConnection);
                }));
            }
            else
            {
                var mouseData = e;
                InvertApplication.SignalEvent <IShowConnectionMenu>(
                    _ => _.Show(DiagramViewModel, StartConnector, mouseData.MouseUpPosition));

                //var allowedFilterNodes = FilterExtensions.AllowedFilterNodes[this.DiagramViewModel.CurrentRepository.CurrentFilter.GetType()];
                //var menu = InvertGraphEditor.CreateCommandUI<ContextMenuUI>();
                //foreach (var item in allowedFilterNodes)
                //{
                //    if (item.IsInterface) continue;
                //    if (item.IsAbstract) continue;

                //    var node = Activator.CreateInstance(item) as IDiagramNode;
                //    node.Graph = this.DiagramViewModel.GraphData;
                //    var vm = InvertGraphEditor.Container.GetNodeViewModel(node, this.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(this.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);
                //            menu.AddCommand(
                //             new SimpleEditorCommand<DiagramViewModel>(delegate(DiagramViewModel n)
                //             {


                //                 //UnityEditor.EditorWindow.FocusWindowIfItsOpen(typeof (ElementsDesigner));

                //                 InvertGraphEditor.ExecuteCommand(_ =>
                //                 {
                //                     this.DiagramViewModel.AddNode(value.Key,e.MouseUpPosition);
                //                     connection.Apply(value.Value as ConnectionViewModel);
                //                     value.Key.IsSelected = true;
                //                     value.Key.IsEditing = true;
                //                     value.Key.Name = "";
                //                 });
                //             },message));
                //        }

                //    }

                //}
                //menu.Go();
            }


            foreach (var a in PossibleConnections)
            {
                a.IsMouseOver = false;
                a.IsSelected  = false;
            }
            e.Cancel();
        }
Exemplo n.º 11
0
        public void DrawBreadcrumbs(IPlatformDrawer platform, float y)
        {
            var navPanelRect    = new Rect(4, y, 60, 30f);
            var breadcrumbsRect = new Rect(64, y, Bounds.width - 44, 30f);

            platform.DrawRect(Bounds.WithOrigin(0, y).WithHeight(30), InvertGraphEditor.Settings.BackgroundColor);

            var back = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.LeftHalf());

            platform.DoButton(back, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                              () =>
            {
                InvertApplication.Execute(new NavigateBackCommand());
            });
            platform.DrawImage(back.PadSides(4), "BackIcon", true);

            var forward = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.RightHalf());

            platform.DoButton(forward, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                              () =>
            {
                InvertApplication.Execute(new NavigateForwardCommand());
            });
            platform.DrawImage(forward.PadSides(4), "ForwardIcon", true);

            var x = 1f;

            var styles    = DiagramViewModel.NavigationViewModel.BreadcrumbsStyle;
            var iconsTine = new Color(1, 1, 1, 0.5f);

            foreach (var usitem in DiagramViewModel.NavigationViewModel.Breadcrubs.ToArray())
            {
                var   item                 = usitem;
                var   textSize             = platform.CalculateTextSize(usitem.Title, CachedStyles.BreadcrumbTitleStyle);
                float buttonContentPadding = 5;
                float buttonIconsPadding   = 5;
                bool  useSpecIcon          = !string.IsNullOrEmpty(item.SpecializedIcon);
                var   buttonWidth          = textSize.x + buttonContentPadding * 2 + 8;
                if (!string.IsNullOrEmpty(item.Icon))
                {
                    buttonWidth += buttonIconsPadding + 16;
                }
                if (useSpecIcon)
                {
                    buttonWidth += buttonIconsPadding + 16;
                }

                var buttonRect = new Rect()
                                 .AlignAndScale(breadcrumbsRect)
                                 .WithWidth(buttonWidth)
                                 .PadSides(3)
                                 .Translate(x, 0);

                var icon1Rect = new Rect()
                                .WithSize(16, 16)
                                .AlignTopRight(buttonRect)
                                .AlignHorisonallyByCenter(buttonRect)
                                .Translate(-buttonContentPadding, 0);

                var icon2Rect = new Rect()
                                .WithSize(16, 16)
                                .Align(buttonRect)
                                .AlignHorisonallyByCenter(buttonRect)
                                .Translate(buttonContentPadding, 0);

                var textRect = new Rect()
                               .WithSize(textSize.x, textSize.y)
                               .Align(useSpecIcon ? icon2Rect : buttonRect)
                               .AlignHorisonallyByCenter(buttonRect)
                               .Translate(useSpecIcon ? buttonIconsPadding + 16 : buttonContentPadding, -1);

                var dotRect = new Rect()
                              .WithSize(16, 16)
                              .RightOf(buttonRect)
                              .AlignHorisonallyByCenter(buttonRect)
                              .Translate(-3, 0);

                platform.DoButton(buttonRect, "", item.State == NavigationItemState.Current ? CachedStyles.BreadcrumbBoxActiveStyle : CachedStyles.BreadcrumbBoxStyle, item.NavigationAction);
                platform.DrawLabel(textRect, item.Title, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleCenter);
                platform.DrawImage(icon1Rect, styles.GetIcon(item.Icon, iconsTine), true);

                if (useSpecIcon)
                {
                    platform.DrawImage(icon2Rect, styles.GetIcon(item.SpecializedIcon, iconsTine), true);
                }
                if (item.State != NavigationItemState.Current)
                {
                    platform.DrawImage(dotRect, styles.GetIcon("DotIcon", iconsTine), true);
                }

                x += buttonRect.width + 16 - 6;
            }
        }
Exemplo n.º 12
0
        public void DrawBreadcrumbs(IPlatformDrawer platform, float y)
        {
            var navPanelRect    = new Rect(4, y, 60, 30f);
            var breadcrumbsRect = new Rect(64, y, Bounds.width - 44, 30f);

            platform.DrawRect(Bounds.WithOrigin(0, y).WithHeight(30), InvertGraphEditor.Settings.BackgroundColor);

            var back = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.LeftHalf());

            platform.DoButton(back, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                              () =>
            {
                InvertApplication.Execute(new NavigateBackCommand());
            });
            platform.DrawImage(back.PadSides(4), "BackIcon", true);

            var forward = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.RightHalf());

            platform.DoButton(forward, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                              () =>
            {
                InvertApplication.Execute(new NavigateForwardCommand());
            });
            platform.DrawImage(forward.PadSides(4), "ForwardIcon", true);

            //var color = new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.8f, InvertGraphEditor.Settings.BackgroundColor.g * 0.8f, InvertGraphEditor.Settings.BackgroundColor.b * 0.8f, 1f);
            //platform.DrawRect(rect, color);

//            var lineRect = new Rect(rect);
//            lineRect.height = 2;
//            lineRect.y = y + 38f;
//            platform.DrawRect(lineRect, new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.6f, InvertGraphEditor.Settings.BackgroundColor.g * 0.6f, InvertGraphEditor.Settings.BackgroundColor.b * 0.6f, 1f));
//
//
//            var first = true;
//            if (_cachedPaths != null)
//            foreach (var item in _cachedPaths)
//            {
//                var item1 = item;
//                platform.DoButton(new Rect(x, rect.y + 20 - (item.Value.y / 2), item.Value.x, item.Value.y), first ? item.Key.Name : "< " + item.Key.Name, first ? CachedStyles.GraphTitleLabel : CachedStyles.ItemTextEditingStyle,
//                    () =>
//                    {
//                        InvertApplication.Execute(new LambdaCommand(() =>
//                        {
//                            DiagramViewModel.GraphData.PopToFilter(item1.Key);
//                        }));
//                    });
//                x += item.Value.x + 15;
//                first = false;
//            }


            var x = 1f;

            var styles    = DiagramViewModel.NavigationViewModel.BreadcrumbsStyle;
            var iconsTine = new Color(1, 1, 1, 0.5f);

            foreach (var usitem in DiagramViewModel.NavigationViewModel.Breadcrubs.ToArray())
            {
                var   item                 = usitem;
                var   textSize             = platform.CalculateTextSize(usitem.Title, CachedStyles.BreadcrumbTitleStyle);
                float buttonContentPadding = 5;
                float buttonIconsPadding   = 5;
                bool  useSpecIcon          = !string.IsNullOrEmpty(item.SpecializedIcon);
                var   buttonWidth          = textSize.x + buttonContentPadding * 2 + 8;
                if (!string.IsNullOrEmpty(item.Icon))
                {
                    buttonWidth += buttonIconsPadding + 16;
                }
                if (useSpecIcon)
                {
                    buttonWidth += buttonIconsPadding + 16;
                }

                var buttonRect = new Rect()
                                 .AlignAndScale(breadcrumbsRect)
                                 .WithWidth(buttonWidth)
                                 .PadSides(3)
                                 .Translate(x, 0);

                var icon1Rect = new Rect()
                                .WithSize(16, 16)
                                .AlignTopRight(buttonRect)
                                .AlignHorisonallyByCenter(buttonRect)
                                .Translate(-buttonContentPadding, 0);

                var icon2Rect = new Rect()
                                .WithSize(16, 16)
                                .Align(buttonRect)
                                .AlignHorisonallyByCenter(buttonRect)
                                .Translate(buttonContentPadding, 0);

                var textRect = new Rect()
                               .WithSize(textSize.x, textSize.y)
                               .Align(useSpecIcon ? icon2Rect : buttonRect)
                               .AlignHorisonallyByCenter(buttonRect)
                               .Translate(useSpecIcon ? buttonIconsPadding + 16 : buttonContentPadding, -1);

                var dotRect = new Rect()
                              .WithSize(16, 16)
                              .RightOf(buttonRect)
                              .AlignHorisonallyByCenter(buttonRect)
                              .Translate(-3, 0);

                platform.DoButton(buttonRect, "", item.State == NavigationItemState.Current ? CachedStyles.BreadcrumbBoxActiveStyle : CachedStyles.BreadcrumbBoxStyle, item.NavigationAction);
                platform.DrawLabel(textRect, item.Title, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleCenter);
                platform.DrawImage(icon1Rect, styles.GetIcon(item.Icon, iconsTine), true);

                if (useSpecIcon)
                {
                    platform.DrawImage(icon2Rect, styles.GetIcon(item.SpecializedIcon, iconsTine), true);
                }
                if (item.State != NavigationItemState.Current)
                {
                    platform.DrawImage(dotRect, styles.GetIcon("DotIcon", iconsTine), true);
                }

                x += buttonRect.width + 16 - 6;
            }
        }
Exemplo n.º 13
0
 public void Add()
 {
     InvertApplication.Execute(AddCommand);
 }