Exemple #1
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", () =>
            //    {
            //    }));
            //});
        }
Exemple #2
0
    static void HierarchyItemCB(int instanceID, Rect selectionRect)
    {
        var go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

        if (go == null)
        {
            return;
        }

        var components = go.GetComponents(typeof(EcsComponent));
        var iconRect   = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(selectionRect).AlignHorisonallyByCenter(selectionRect).Translate(-5, 0);

        foreach (var component in components)
        {
            string icon = null;

            InvertApplication.SignalEvent <IFetchIcon>(_ => icon = _.FetchIcon(component));

            if (string.IsNullOrEmpty(icon))
            {
                continue;
            }
            var cCache = GUI.color;
            GUI.color = new Color(cCache.r, cCache.g, cCache.b, cCache.a * 0.7f);
            Drawer.DrawImage(iconRect, icon, true);
            iconRect  = iconRect.LeftOf(iconRect).Translate(-5, 0);
            GUI.color = cCache;
        }
    }
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            DrawBackground(platform, scale);
            var b = new Rect(Bounds);

            b.x     += 10;
            b.width -= 20;
            //base.Draw(platform, scale);
            platform.DrawColumns(b.Scale(scale), new float[] { _typeSize.x + 5, _nameSize.x },
                                 _ =>
            {
                platform.DoButton(_, _cachedTypeName, CachedStyles.ClearItemStyle, OptionClicked, OptionRightClicked);
            },
                                 _ =>
            {
                DrawName(_, platform, scale, DrawingAlignment.MiddleRight);
                platform.DoButton(_, "", CachedStyles.ClearItemStyle, () =>
                {
                    if (ItemViewModel.IsSelected)
                    {
                        //TODO: Eliminate hack: due to the inconsistent input mechanisms, I cannot fix: when clicking on type, type window appear, then click on the property,
                        //editing will begin, but type window will stay there. So here is a hack of signaling HideSelection event.

                        InvertApplication.SignalEvent <IHideSelectionMenu>(__ => __.HideSelection());

                        ItemViewModel.BeginEditing();
                    }
                    else
                    {
                        ItemViewModel.Select();
                    }
                }, OptionRightClicked);
            });
        }
        private void HandleInput(QuickAccessWindowViewModel data)
        {
            var evt = Event.current;

            if (evt.isKey && evt.type == EventType.KeyUp)
            {
                if (evt.keyCode == KeyCode.Return)
                {
                    data.Execute();
                    InvertApplication.SignalEvent <IWindowsEvents>(_ => _.WindowRequestCloseWithArea(this));
                }
                if (evt.keyCode == KeyCode.UpArrow)
                {
                    data.MoveUp();
                }
                if (evt.keyCode == KeyCode.DownArrow)
                {
                    data.MoveDown();
                }
                if (evt.keyCode == KeyCode.Escape)
                {
                    InvertApplication.SignalEvent <IWindowsEvents>(_ => _.WindowRequestCloseWithArea(this));
                }

                InvertApplication.SignalEvent <IWindowsEvents>(_ => _.WindowRefresh(this));
            }
        }
        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 virtual void OptionRightClicked()
        {
            if (!this.ItemViewModel.Enabled)
            {
                return;
            }
            // TODO 2.0 Quick Types Right Click menu
            InvertApplication.SignalEvent <IShowContextMenu>(_ => _.Show(null, this.ViewModelObject));
            //var menu = InvertGraphEditor.CreateCommandUI<ContextMenuUI>(true, typeof(IDiagramNodeItemCommand));

            //var types = InvertGraphEditor.TypesContainer.ResolveAll<GraphTypeInfo>();
            //foreach (var type in types)
            //{
            //    var type1 = type;
            //    menu.AddCommand(new SimpleEditorCommand<GenericTypedChildItem>((_) =>
            //    {
            //        _.RelatedType = type1.Name;
            //    },type1.Label,type1.Group));
            //}
            //foreach (var type in InvertGraphEditor.CurrentDiagramViewModel.CurrentNodes)
            //{
            //    var type1 = type;
            //    menu.AddCommand(new SimpleEditorCommand<GenericTypedChildItem>((_) =>
            //    {
            //        _.RelatedType = type1.Identifier;
            //    }, type1.Label, type1.Group));
            //}

            //menu.Go();
        }
Exemple #7
0
        public void Execute(SaveAndCompileCommand command)
        {
#if DEMO
            Signal <INotify>(x => x.NotifyWithActions("You're using the demo version of uFrame ECS.", NotificationIcon.Warning,
                                                      new NotifyActionItem()
            {
                Title  = "Buy Now",
                Action = () =>
                {
                    InvertGraphEditor.Platform.OpenLink("https://invertgamestudios.com/ecs/purchase");
                }
            },
                                                      new NotifyActionItem()
            {
                Title  = "Nope, Compile It",
                Action = () =>
                {
                    InvertApplication.SignalEvent <ITaskHandler>(_ => { _.BeginTask(Generate(command)); });
                }
            }
                                                      ));
#else
            InvertApplication.SignalEvent <ITaskHandler>(_ => { _.BeginTask(Generate(command)); });
#endif
        }
    protected override void DrawChildren(IPlatformDrawer platform, float scale)
    {
        for (int index = 0; index < Children.Count; index++)
        {
            var item = Children[index];

            if (index == 0)
            {
                item.Draw(platform, scale);
                continue;
            }
            var optionsBounds = new Rect(item.Bounds.x, item.Bounds.y + 4, item.Bounds.width,
                                         item.Bounds.height);
            if (item.IsSelected)
            {
                platform.DrawStretchBox(optionsBounds, CachedStyles.Item1, 0f);
            }
            optionsBounds.width -= 35;
            //optionsBounds.x += 15;
            item.Draw(platform, scale);
            platform.DoButton(optionsBounds, "", CachedStyles.ClearItemStyle, () =>
            {
                ViewModel.DiagramViewModel.DeselectAll();
                ViewModel.Select();
                item.ViewModelObject.Select();
                InvertApplication.SignalEvent <IGraphSelectionEvents>(_ => _.SelectionChanged(item.ViewModelObject));
            });
        }
    }
Exemple #9
0
        public void Execute(BackgroundTaskCommand command)
        {
            BackgroundWorker worker = new BackgroundWorker()
            {
                WorkerSupportsCancellation = true,
                WorkerReportsProgress      = true
            };

            InvertApplication.Log("Creating background task");
            worker.DoWork += (sender, args) =>
            {
                InvertApplication.Log("Executing background task");
                var bgCommand = args.Argument as BackgroundTaskCommand;

                if (bgCommand != null)
                {
                    bgCommand.Command.Worker = sender as BackgroundWorker;
                    bgCommand.Action(bgCommand.Command);
                }
            };
            worker.ProgressChanged += (sender, args) =>
            {
                InvertApplication.Log("PROGRESS");
                InvertApplication.SignalEvent <ICommandProgressEvent>(_ => _.Progress(null, args.UserState.ToString(), args.ProgressPercentage));
            };
            command.Task = new BackgroundTask(worker);
            worker.RunWorkerAsync(command);
        }
Exemple #10
0
        protected CodeConstructor RenderConstructor(object instance, KeyValuePair <MethodInfo, GenerateConstructor> templateMethod, IDiagramNodeItem data)
        {
            var info = templateMethod.Key;
            var dom  = templateMethod.Key.ToCodeConstructor();

            CurrentAttribute   = templateMethod.Value;
            CurrentConstructor = dom;
            PushStatements(dom.Statements);
            //            CurrentStatements = dom.Statements;
            var args       = new List <object>();
            var parameters = info.GetParameters();

            foreach (var arg in parameters)
            {
                args.Add(GetDefault(arg.ParameterType));
            }
            foreach (var item in templateMethod.Value.BaseCallArgs)
            {
                dom.BaseConstructorArgs.Add(new CodeSnippetExpression(item));
            }


            info.Invoke(instance, args.ToArray());
            PopStatements();
            CurrentDeclaration.Members.Add(dom);
            InvertApplication.SignalEvent <ICodeTemplateEvents>(_ => _.ConstructorAdded(instance, this, dom));
            return(dom);
        }
Exemple #11
0
 public void OnGUI()
 {
     if (InvertGraphEditor.Container != null)
     {
         InvertApplication.SignalEvent <IDrawDesignerWindow>(_ => _.DrawDesigner(position.width, position.height));
     }
 }
Exemple #12
0
        public IEnumerator AddGraphItems(IEnumerable <IDiagramNode> items)
        {
            var dictionary = new Dictionary <string, IFilterItem>();

            IFilterItem[] fitems = GraphData.CurrentFilter.FilterItems.ToArray <IFilterItem>();
            foreach (var item in GraphData.CurrentFilter.FilterItems)
            {
                if (dictionary.ContainsKey(item.NodeId))
                {
                    item.Repository.Remove(item);
                    continue;
                }
                dictionary.Add(item.NodeId, item);
            }

            FilterItems = dictionary;



            IsLoading = true;
            var connectors = new List <ConnectorViewModel>();

            // var time = DateTime.Now;
            foreach (var item in items)
            {
                // Get the ViewModel for the data
                //InvertApplication.Log("B-A" + DateTime.Now.Subtract(time).TotalSeconds.ToString());
                var mapping = InvertApplication.Container.RelationshipMappings[item.GetType(), typeof(ViewModel)];
                if (mapping == null)
                {
                    continue;
                }
                var vm = Activator.CreateInstance(mapping, item, this) as GraphItemViewModel;
                //var vm =
                //    InvertApplication.Container.ResolveRelation<ViewModel>(item.GetType(), item, this) as
                //        GraphItemViewModel;
                //InvertApplication.Log("B-B" + DateTime.Now.Subtract(time).TotalSeconds.ToString());
                if (vm == null)
                {
                    if (InvertGraphEditor.Platform.MessageBox("Node Error", string.Format("Couldn't find view-model for {0} would you like to remove this item?", item.GetType()), "Yes", "No"))
                    {
                        CurrentRepository.Remove(item);
                    }
                    continue;
                }
                vm.DiagramViewModel = this;
                GraphItems.Add(vm);
                //// Clear the connections on the view-model
                //vm.Connectors.Clear();
                //vm.GetConnectors(vm.Connectors);
                //connectors.AddRange(vm.Connectors);
                yield return(new TaskProgress(string.Format("Loading..."), 95f));
            }
            IsLoading = false;
            RefreshConnectors();
            //AddConnectors(connectors);
            InvertApplication.SignalEvent <IGraphLoaded>(_ => _.GraphLoaded());
            yield break;
        }
    public void UpdateToolbarItems()
    {
        ToolbarItems.Clear();
        var newItems = new List <WelcomeWindowToolbarItem>();

        InvertApplication.SignalEvent <IWelcomeWindowToolbarItemsQuery>(i => i.QueryForItems(newItems));
        ToolbarItems.AddRange(newItems);
    }
Exemple #14
0
 public void Execute()
 {
     InvertApplication.Execute(new LambdaCommand("Select Item", () =>
     {
         QuickLaunchItems[SelectedIndex].Action(QuickLaunchItems[SelectedIndex].Item);
     }));
     InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this));
 }
Exemple #15
0
 public void Update()
 {
     //if (!EditorApplication.isPlaying || EditorApplication.isPaused)
     //{
     Instance = this;
     InvertApplication.SignalEvent <IUpdate>(_ => _.Update());
     Repaint();
     //}
 }
 public void Execute(InfiniteLoopCommand command)
 {
     while (true)
     {
         InvertApplication.SignalEvent <ILogEvents>(
             i => i.Log(string.Format("Generated from infinite loop, {0}", DateTime.Now), MessageType.Info));
         Thread.Sleep(1000);
     }
 }
Exemple #17
0
        public void DrawDesigner(float width, float height)
        {
            if (EditorApplication.isCompiling)
            {
                InvertApplication.SignalEvent <ITaskProgressEvent>(_ => _.Progress(99f, "Waiting On Unity...", true));
            }

            InvertApplication.SignalEvent <IDrawUFrameWindow>(_ => _.Draw(width, height, mScrollPosition, 1f));
        }
Exemple #18
0
 public void Progress(float progress, string message)
 {
     try
     {
         InvertApplication.SignalEvent <ITaskProgressHandler>(_ => _.Progress(progress, message));
     }
     catch (Exception ex)
     {
     }
 }
Exemple #19
0
 public void ManagerRefreshed(IDataRecordManager manager)
 {
     InvertApplication.SignalEvent <IDataRecordManagerRefresh>(_ =>
     {
         if (_ != this)
         {
             _.ManagerRefreshed(manager);
         }
     });
 }
        public void OnGUI()
        {
            Instance = this;
            var rect = new Rect(0f, 0f, this.position.width, this.position.height);

            GUILayout.BeginArea(rect);
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
            InvertApplication.SignalEvent <IDrawNavigationHistory>(_ => _.DrawNavigationHistory(rect));
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
Exemple #21
0
        public override IEnumerable <IValueItem> GetAllowed()
        {
            var list = new List <ITypeInfo>();

            InvertApplication.SignalEvent <IQueryTypes>(_ => _.QueryTypes(list));
            if (Filter == null)
            {
                return(list.OfType <IValueItem>());
            }
            return(list.Where(Filter).OfType <IValueItem>());
        }
        public void OnGUI()
        {
            Instance = this;
            var rect = new Rect(0f, 0f, Screen.width, Screen.height);

            GUILayout.BeginArea(rect);
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
            InvertApplication.SignalEvent <IDrawBreakpointsExplorer>(_ => _.DrawBreakpointsExplorer(rect));
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
        void OnGUI()
        {
            var bounds   = new Rect(0, 0, this.position.width, this.position.height);
            var platform = InvertGraphEditor.PlatformDrawer;

            InvertApplication.SignalEvent <IDrawDatabasesList>(_ =>
            {
                _.DrawDatabasesList(platform, bounds, Items);
            });

            platform.DoButton(new Rect().WithSize(80, 30).InnerAlignWithBottomLeft(bounds.PadSides(15)), "Close", ElementDesignerStyles.ButtonStyle, Close);
        }
Exemple #24
0
    public void Execute(QuickAccessItem item)
    {
        var x = item.Item;
        var z = item;

        InvertApplication.Execute(new LambdaCommand("Select Item", () =>
        {
            z.Action(x);
        }));

        InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this));
    }
Exemple #25
0
        protected CodeMemberMethod RenderMethod(object instance, KeyValuePair <MethodInfo, GenerateMethod> templateMethod, IDiagramNodeItem data)
        {
            MethodInfo info;
            var        dom = TemplateType.MethodFromTypeMethod(templateMethod.Key.Name, out info, false);

            CurrentMember    = dom;
            CurrentAttribute = templateMethod.Value;
            PushStatements(dom.Statements);

            var args       = new List <object>();
            var parameters = info.GetParameters();

            foreach (var arg in parameters)
            {
                args.Add(GetDefault(arg.ParameterType));
            }

            CurrentDeclaration.Members.Add(dom);

            var result = info.Invoke(instance, args.ToArray());
            var a      = result as IEnumerable;

            if (a != null)
            {
                a.Cast <object>().ToArray();
                //    foreach (var item in dummyIteraters)
                //    {

                //    }
            }

            PopStatements();

            //var isOverried = false;
            //if (!IsDesignerFile && dom.Attributes != MemberAttributes.Final && templateMethod.Value.Location == TemplateLocation.Both)
            //{
            //    dom.Attributes |= MemberAttributes.Override;
            //    isOverried = true;
            //}
            //if ((info.IsVirtual && !IsDesignerFile) || (info.IsOverride() && !info.GetBaseDefinition().IsAbstract && IsDesignerFile))
            //{
            //    if (templateMethod.Value.CallBase)
            //    {
            //        //if (!info.IsOverride() || !info.GetBaseDefinition().IsAbstract && IsDesignerFile)
            //        //{
            //        dom.invoke_base(true);
            //        //}

            //    }
            //}
            InvertApplication.SignalEvent <ICodeTemplateEvents>(_ => _.MethodAdded(instance, this, dom));
            return(dom);
        }
Exemple #26
0
        void OnGUI()
        {
            if (this.Problem == null)
            {
                this.Close();
                return;
            }

            var bounds = new Rect().WithSize(this.position.width, this.position.height).PadSides(5);

            InvertApplication.SignalEvent <IDrawProblem>(_ => _.DrawProblemInspector(bounds, Problem));
        }
Exemple #27
0
    public void Execute(CreateGraphCommand command)
    {
        var workspaceService = Container.Resolve <WorkspaceService>();
        var repo             = Container.Resolve <IRepository>();
        var graph            = Activator.CreateInstance(command.GraphType) as IGraphData;

        repo.Add(graph);
        graph.Name = command.Name;
        workspaceService.CurrentWorkspace.AddGraph(graph);
        workspaceService.CurrentWorkspace.CurrentGraphId = graph.Identifier;
        InvertApplication.SignalEvent <INotify>(_ => _.Notify(command.Name + " graph has been created!", NotificationIcon.Info));
    }
Exemple #28
0
 public void OnInspectorUpdate()
 {
     InvertApplication.SignalEvent <IUpdate>(_ => _.Update());
     if (IsVisible)
     {
         Repaint();
     }
     //if (EditorApplication.isPlaying)
     //{
     //    Instance = this;
     //    InvertApplication.SignalEvent<IUpdate>(_ => _.Update());
     //    Repaint();
     //}
 }
Exemple #29
0
 public void RecordRemoving(IDataRecord record)
 {
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordRemoving>(_ =>
     {
         if (_ != this)
         {
             _.RecordRemoving(record);
         }
     });
 }
Exemple #30
0
 public void BeforePropertyChanged(IDataRecord record, string name, object previousValue, object nextValue)
 {
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordPropertyBeforeChange>(_ =>
     {
         if (_ != this)
         {
             _.BeforePropertyChanged(record, name, previousValue, nextValue);
         }
     });
 }