Exemple #1
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)
            {
                var dummyIteraters = 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 #2
0
        public virtual Type FindType(string clrTypeString)
        {
            var name = clrTypeString.Split(',').FirstOrDefault();

            if (name != null)
            {
                return(InvertApplication.FindType(name));
            }

            return(null);

            return(null);
        }
 public static void LoadPluginsFolder(string pluginsFolder)
 {
     if (!Directory.Exists(pluginsFolder))
     {
         Directory.CreateDirectory(pluginsFolder);
     }
     foreach (var plugin in Directory.GetFiles(pluginsFolder, "*.dll"))
     {
         var assembly = Assembly.LoadFrom(plugin);
         assembly = AppDomain.CurrentDomain.Load(assembly.GetName());
         InvertApplication.CachedAssembly(assembly);
     }
 }
 public void RecordRemoving(IDataRecord record)
 {
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordRemoving>(_ =>
     {
         if (_ != this)
         {
             _.RecordRemoving(record);
         }
     });
 }
Exemple #5
0
 public TutorialStep SaveAndCompile(GraphNode node)
 {
     return(new TutorialStep("Save & Compile the project.", () =>
     {
         if (InvertApplication.FindType(node.FullName) == null)
         {
             return string.Format("Expected generated types are not found. Make sure that:\n\n" +
                                  "* You clicked 'Save and Compile' button\n" +
                                  "* Generation is finished\n" +
                                  "* Unity console does not contain compilation errors\n");
         }
         return null;
     }));
 }
 public void BeforePropertyChanged(IDataRecord record, string name, object previousValue, object nextValue)
 {
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordPropertyBeforeChange>(_ =>
     {
         if (_ != this)
         {
             _.BeforePropertyChanged(record, name, previousValue, nextValue);
         }
     });
 }
Exemple #7
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);
 }
        public void Load(bool async = false)
        {
            GraphItems.Clear();
            //GraphItems.Add(InspectorViewModel);

            // var graphItems = new List<GraphItemViewModel>();
            //// var time = DateTime.Now;
            // foreach (var item in CurrentNodes)
            // {

            //     // 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);
            // }
            CurrentNodes = GraphData.CurrentFilter.FilterNodes.Distinct().ToArray();
            NavigationViewModel.Refresh();
            //if (async)
            //{
            InvertApplication.SignalEvent <ITaskHandler>(_ => _.BeginBackgroundTask(AddGraphItems(CurrentNodes)));
            //}
            //else
            //{
            //var e = AddGraphItems();
            //while (e.MoveNext())
            //{

            //}
            //}
        }
 public void RecordRemoved(IDataRecord record)
 {
     //TODO Check already invoked in JsonFileRecordManager and FastJsonFileRecordManager
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordRemoved>(_ =>
     {
         if (_ != this)
         {
             _.RecordRemoved(record);
         }
     });
 }
Exemple #10
0
        private IEnumerable <IDrawer> CreateDrawers()
        {
            InvertApplication.Log("Creating drawers");
            foreach (var item in ViewModel.ContentItems)
            {
                var drawer = InvertGraphEditor.Container.CreateDrawer(item);
                if (drawer == null)
                {
                    InvertApplication.Log(string.Format("Couldn't create drawer for {0} make sure it is registered.",
                                                        item.GetType().Name));
                    continue;
                }

                yield return(drawer);
            }
        }
        private IEnumerable <OutputGenerator> CreateTemplateGenerators(IGraphConfiguration config, IDataRecord graphItem, Type templateType)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (graphItem == null)
            {
                throw new ArgumentNullException("graphItem");
            }
            if (templateType == null)
            {
                throw new ArgumentNullException("templateType");
            }

            var templateClassType = templateType.GetGenericArguments()[1];
            var templateAttribute = templateClassType.GetCustomAttributes(typeof(TemplateClass), true)
                                    .OfType <TemplateClass>()
                                    .FirstOrDefault();

            if (templateAttribute == null)
            {
                InvertApplication.Log(string.Format("ClassTemplate attribute not found on {0} ", templateClassType.Name));
                yield break;
            }


            if (templateAttribute.Location == TemplateLocation.DesignerFile || templateAttribute.Location == TemplateLocation.Both)
            {
                var template = Activator.CreateInstance(templateType) as CodeGenerator;
                template.ObjectData     = graphItem;
                template.IsDesignerFile = true;

                //template.AssetDirectory = graphItem.Graph.Project.SystemDirectory;
                template.AssetDirectory = config.CodeOutputPath;
                yield return(template);
            }
            if (templateAttribute.Location == TemplateLocation.EditableFile || templateAttribute.Location == TemplateLocation.Both)
            {
                var template = Activator.CreateInstance(templateType) as CodeGenerator;
                template.ObjectData     = graphItem;
                template.IsDesignerFile = false;
                template.AssetDirectory = config.CodeOutputPath;

                yield return(template);
            }
        }
        public static IEnumerable <Type> GetDerivedTypes <T>(bool includeAbstract = false, bool includeBase = true)
        {
            var type = typeof(T);

            if (includeBase)
            {
                yield return(type);
            }
            if (includeAbstract)
            {
                foreach (var assembly in CachedAssemblies)
                {
                    //if (!assembly.FullName.StartsWith("Invert")) continue;
                    foreach (var t in assembly
                             .GetTypes()
                             .Where(x => type.IsAssignableFrom(x)))
                    {
                        yield return(t);
                    }
                }
            }
            else
            {
                var items = new List <Type>();
                foreach (var assembly in CachedAssemblies)
                {
                    try
                    {
                        foreach (var t in assembly
                                 .GetTypes()
                                 .Where(x => type.IsAssignableFrom(x) && !x.IsAbstract))
                        {
                            items.Add(t);
                        }
                    }
                    catch (Exception ex)
                    {
                        InvertApplication.Log(ex.Message);
                    }
                }
                foreach (var item in items)
                {
                    yield return(item);
                }
            }
        }
Exemple #13
0
        public void Execute(CreateWorkspaceCommand command)
        {
            var workspace = Activator.CreateInstance(command.WorkspaceType) as Workspace;

            if (workspace == null)
            {
                throw new Exception("Workspace cannot be created! If you are using custom workspace type, make sure it derives from Workspace class.");
            }
            workspace.Name = command.Name;
            command.Result = workspace;
            Repository.Add(workspace);
            Execute(new OpenWorkspaceCommand()
            {
                Workspace = workspace
            });

            InvertApplication.SignalEvent <INotify>(_ => _.Notify(command.Name + " workspace has been created!", NotificationIcon.Info));
        }
        public static IDrawer CreateDrawer <TDrawerBase>(this IQFrameworkContainer container, ViewModel viewModel) where TDrawerBase : IDrawer
        {
            if (_drawers != null)
            {
            }
            if (viewModel == null)
            {
                InvertApplication.LogError("Data is null.");
                return(null);
            }
            var drawer = container.ResolveRelation <TDrawerBase>(viewModel.GetType(), viewModel);

            if (drawer == null)
            {
                InvertApplication.Log(String.Format("Couldn't Create drawer for {0}.", viewModel.GetType()));
            }
            return(drawer);
        }
        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);
        }
Exemple #16
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(_ => { });
        }
Exemple #17
0
        public override void OnRightClick(MouseEvent mouseEvent)
        {
            DiagramViewModel.LastMouseEvent = mouseEvent;
            BubbleEvent(d => d.OnRightClick(mouseEvent), mouseEvent);
            if (DrawersAtMouse == null)
            {
                ShowAddNewContextMenu(mouseEvent);
                return;
            }
            //var item = DrawersAtMouse.OrderByDescending(p=>p.ZOrder).FirstOrDefault();
            IDrawer item = DrawersAtMouse.OfType <ConnectorDrawer>().FirstOrDefault();

            if (item != null)
            {
                InvertApplication.SignalEvent <IShowContextMenu>(_ => _.Show(mouseEvent, item.ViewModelObject));
                return;
            }
            item = DrawersAtMouse.OfType <ItemDrawer>().FirstOrDefault();
            if (item != null)
            {
                if (item.Enabled)
                {
                    ShowItemContextMenu(mouseEvent);
                }
                return;
            }
            item = DrawersAtMouse.OfType <DiagramNodeDrawer>().FirstOrDefault();
            if (item == null)
            {
                item = DrawersAtMouse.OfType <HeaderDrawer>().FirstOrDefault();
            }
            if (item != null)
            {
                if (!item.ViewModelObject.IsSelected)
                {
                    item.ViewModelObject.Select();
                }
                ShowContextMenu(mouseEvent);
                return;
            }
            ShowAddNewContextMenu(mouseEvent);
        }
Exemple #18
0
 public void LoadDiagram(IGraphData diagram)
 {
     InvertGraphEditor.DesignerWindow = this;
     if (diagram == null)
     {
         return;
     }
     try
     {
         DiagramDrawer       = new DiagramDrawer(new DiagramViewModel(diagram));
         DiagramDrawer.Dirty = true;
         //DiagramDrawer.Data.ApplyFilter();
         DiagramDrawer.Refresh(InvertGraphEditor.PlatformDrawer);
     }
     catch (Exception ex)
     {
         InvertApplication.LogException(ex);
         InvertApplication.Log("Either a plugin isn't installed or the file could no longer be found. See Exception error");
     }
 }
Exemple #19
0
        public void DeselectAll()
        {
            if (InspectorViewModel != null)
            {
                InspectorViewModel.TargetViewModel = null;
            }

            foreach (var item in AllViewModels.ToArray())
            {
                var ivm = item as ItemViewModel;
                if (ivm != null)
                {
                    if (ivm.IsEditing)
                    {
                        ivm.EndEditing();
                        break;
                    }
                }
                var nvm = item as DiagramNodeViewModel;
                if (nvm != null)
                {
                    if (nvm.IsEditing)
                    {
                        nvm.EndEditing();
                        break;
                    }
                }


                if (item.IsSelected)
                {
                    item.IsSelected = false;
                }
            }


            InvertApplication.SignalEvent <INothingSelectedEvent>(_ => _.NothingSelected());
#if UNITY_EDITOR
            UnityEngine.GUI.FocusControl("");
#endif
        }
        protected override void CreateContent()
        {
            base.CreateContent();

            foreach (var item in GraphItem.DisplayedItems)
            {
                var vm = GetDataViewModel(item);

                if (vm == null)
                {
                    InvertApplication.LogError(string.Format("Couldn't find view-model for {0}", item.GetType()));
                    continue;
                }
                vm.DiagramViewModel = DiagramViewModel;
                ContentItems.Add(vm);
            }



            AddPropertyFields();
        }
Exemple #21
0
        public static void GenerateFile(FileInfo fileInfo, CodeFileGenerator codeFileGenerator)
        {
            // Get the path to the directory
            var directory = System.IO.Path.GetDirectoryName(fileInfo.FullName);

            // Create it if it doesn't exist
            if (directory != null && !Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            try
            {
                // Write the file
                File.WriteAllText(fileInfo.FullName, codeFileGenerator.ToString());
            }
            catch (Exception ex)
            {
                InvertApplication.LogException(ex);
                InvertApplication.Log("Coudln't create file " + fileInfo.FullName);
            }
        }
Exemple #22
0
        public override void Loaded(QFrameworkContainer container)
        {
            base.Loaded(container);
            FlagByName.Clear();
            foreach (var item in InvertApplication.GetDerivedTypes <IDiagramNodeItem>())
            {
                var flagProperties = item.GetProperties(BindingFlags.Default | BindingFlags.Public | BindingFlags.Instance).Where(p => p.IsDefined(typeof(NodeFlag), true)).ToArray();
                foreach (var property in flagProperties)
                {
                    var attr = property.GetCustomAttributes(typeof(NodeFlag), true).OfType <NodeFlag>().FirstOrDefault();
                    FlagByName.Add(attr.Name, new FlagConfig(item, attr.Name, attr.Color)
                    {
                        PropertyInfo = property
                    });
                }
            }

            foreach (var item in container.ResolveAll <FlagConfig>())
            {
                FlagByName.Add(item.FlagName, item);
            }
        }
Exemple #23
0
        public void Select(GraphItemViewModel viewModelObject)
        {
            if (viewModelObject == null)
            {
                return;
            }

            InspectorViewModel.TargetViewModel = viewModelObject;

            if (viewModelObject.IsSelected)
            {
                return;
            }
            if (LastMouseEvent != null && LastMouseEvent.ModifierKeyStates != null && !LastMouseEvent.ModifierKeyStates.Alt)
            {
                DeselectAll();
            }

            viewModelObject.IsSelected = true;
            InvertApplication.SignalEvent <IGraphSelectionEvents>(
                _ => _.SelectionChanged(viewModelObject));
        }
Exemple #24
0
        //public NodeConfig<TNode> Validator(Func<TNode, bool> validate, string message, ValidatorType validatorType = ValidatorType.Warning)
        //{
        //    Validators.Add(new NodeValidator<TNode>()
        //    {
        //        Validate = validate,
        //        Message = message,
        //        Type = validatorType

        //    });
        //    return this;
        //}
#if !SERVER
        public NodeConfig <TNode> LoadDerived <TViewModel>(Action <NodeConfig <TNode>, Type> configure = null)
        {
            foreach (var item in InvertApplication.GetDerivedTypes <TNode>(false, false))
            {
                Container.RegisterRelation(item, typeof(ViewModel), typeof(TViewModel));

                var config = new NodeConfig <TNode>(Container);
                config.NodeType = item;
                Container.RegisterInstance <NodeConfigBase>(config, item.Name);
                config.Name = item.Name.Replace("Shell", "").Replace("Node", "");
                //config.Tags.Add(config.Name);
                if (configure != null)
                {
                    configure(config, item);
                }
                else
                {
                    HasSubNode(item);
                }
            }
            return(this);
        }
        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(CreateDatabaseCommand command)
        {
            if (Directory.Exists(command.Name))
            {
                throw new Exception(string.Format("Database {0} already exists.", command.Name));
            }
            var dbDir  = Directory.CreateDirectory(Path.Combine(DbRootPath, command.Name + ".db"));
            var db     = new TypeDatabase(new JsonRepositoryFactory(dbDir.FullName));
            var config = GetConfig(db, command.Name);

            config.Namespace      = command.Namespace;
            config.Title          = command.Name;
            config.CodeOutputPath = command.CodePath;
            config.Namespace      = command.Namespace ?? config.Namespace;
            config.FullPath       = dbDir.FullName;
            config.Database       = db;
            db.Commit();
            CurrentDatabaseIdentifier   = config.Identifier;
            InvertApplication.Container = null;
            if (InvertApplication.Container != null)
            {
                InvertApplication.SignalEvent <INotify>(_ => _.Notify(command.Name + " Database " + " has been created!", NotificationIcon.Info));
            }
        }
Exemple #27
0
        private bool DrawDiagram(IPlatformDrawer drawer, Vector2 scrollPosition, float scale, Rect diagramRect)
        {
            var screen = new Vector2(Screen.width, Screen.height);


            if (DiagramDrawer == null)
            {
                if (Workspace != null)
                {
                    if (Workspace.CurrentGraph != null)
                    {
                        LoadDiagram(Workspace.CurrentGraph);
                    }
                }
            }

            if (DiagramDrawer != null && DiagramViewModel != null && InvertGraphEditor.Settings.UseGrid)
            {
                if (_cachedLines == null || _cachedScroll != scrollPosition || _cachedScreen != screen)
                {
                    var lines = new List <CachedLineItem>();

                    var softColor = InvertGraphEditor.Settings.GridLinesColor;
                    var hardColor = InvertGraphEditor.Settings.GridLinesColorSecondary;
                    var x         = -scrollPosition.x;

                    var every10 = 0;

                    while (x < DiagramRect.x + DiagramRect.width + scrollPosition.x)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color   = hardColor;
                            every10 = 0;
                        }
                        if (x > diagramRect.x)
                        {
                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(x, diagramRect.y), new Vector3(x, diagramRect.x + diagramRect.height + scrollPosition.y + 85) },
                                Color = color
                            });
                        }

                        x += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    var y = -scrollPosition.y + 80;
                    every10 = 10;
                    while (y < DiagramRect.y + DiagramRect.height + scrollPosition.y)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color   = hardColor;
                            every10 = 0;
                        }
                        if (y > diagramRect.y)
                        {
                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(diagramRect.x, y), new Vector3(diagramRect.x + diagramRect.width + scrollPosition.x, y) },
                                Color = color
                            });
                        }

                        y += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    _cachedLines  = lines.ToArray();
                    _cachedScreen = screen;
                    _cachedScroll = scrollPosition;
                }

                for (int i = 0; i < _cachedLines.Length; i++)
                {
                    Drawer.DrawLine(_cachedLines[i].Lines, _cachedLines[i].Color);
                }
            }
            if (DiagramDrawer != null)
            {
                InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.BeforeDrawGraph(diagramRect));
                DiagramDrawer.Bounds = new Rect(0f, 0f, diagramRect.width, diagramRect.height);

                DiagramDrawer.Draw(drawer, 1f);

                if (_shouldProcessInputFromDiagram)
                {
                    InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.ProcessInput());
                }
                InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.AfterDrawGraph(DiagramDrawer.Bounds));
            }
            return(false);
        }
Exemple #28
0
        public void Draw(float width, float height, Vector2 scrollPosition, float scale)
        {
            DiagramDrawer.IsEditingField = false;
            if (Drawer == null)
            {
                InvertApplication.Log("DRAWER IS NULL");
                return;
            }
            var diagramRect = new Rect();

            if (DrawToolbar)
            {
                var toolbarTopRect  = new Rect(0, 0, width, 18);
                var tabsRect        = new Rect(0, toolbarTopRect.height, width, 31);
                var breadCrumbsRect = new Rect(0, tabsRect.y + tabsRect.height, width, 30);

                diagramRect = new Rect(0f, breadCrumbsRect.y + breadCrumbsRect.height, width,
                                       height - ((toolbarTopRect.height * 2)) - breadCrumbsRect.height - 31);
                var toolbarBottomRect = new Rect(0f, diagramRect.y + diagramRect.height, width,
                                                 toolbarTopRect.height);


                List <DesignerWindowModalContent> modalItems = new List <DesignerWindowModalContent>();
                Signal <IQueryDesignerWindowModalContent>(_ => _.QueryDesignerWindowModalContent(modalItems));

                List <DesignerWindowOverlayContent> overlayItems = new List <DesignerWindowOverlayContent>();
                Signal <IQueryDesignerWindowOverlayContent>(_ => _.QueryDesignerWindowOverlayContent(overlayItems));

                //Disable diagram input if any modal content presents or if mouse is over overlay content
                _shouldProcessInputFromDiagram = !modalItems.Any() && overlayItems.All(i => !i.Drawer.CalculateBounds(diagramRect).Contains(Event.current.mousePosition));

                Drawer.DrawStretchBox(toolbarTopRect, CachedStyles.Toolbar, 0f);

                Drawer.DoToolbar(toolbarTopRect, this, ToolbarPosition.Left);
                //drawer.DoToolbar(toolbarTopRect, this, ToolbarPosition.Right);

                Drawer.DrawRect(tabsRect, InvertGraphEditor.Settings.GridLinesColor);

                //Drawer.DoTabs(Drawer,tabsRect, this);
                DiagramRect = diagramRect;

                /*
                 * DRAW DIAGRAM
                 * Using GUI.color hack to avoid transparent diagram on disabled input (Thanks Unity :( )
                 */

                if (!_shouldProcessInputFromDiagram)
                {
                    Drawer.DisableInput();
                }

                if (DiagramDrawer != null)
                {
                    DiagramDrawer.DrawTabs(Drawer, tabsRect);
                    DiagramDrawer.DrawBreadcrumbs(Drawer, breadCrumbsRect.y);
                }

                var fpsCounterRect = tabsRect.WithWidth(80).RightOf(tabsRect).Translate(-100, 0);

                if (ShowFPS)
                {
                    if ((DateTime.Now - _lastFpsUpdate).TotalMilliseconds > 1000)
                    {
                        _fpsShown      = _framesLastSec;
                        _lastFpsUpdate = DateTime.Now;
                        _framesLastSec = 0;
                    }
                    else
                    {
                        _framesLastSec++;
                    }
                    Drawer.DrawLabel(fpsCounterRect, string.Format("FPS: {0}", _fpsShown), CachedStyles.WizardSubBoxTitleStyle);
                }

                Drawer.DrawRect(diagramRect, InvertGraphEditor.Settings.BackgroundColor);

                DiagramRect = diagramRect;

                DrawDiagram(Drawer, scrollPosition, scale, diagramRect);

                Drawer.EnableInput();

                /*
                 * DRAW OVERLAY CONTENT
                 */

                if (modalItems.Any())
                {
                    Drawer.DisableInput();
                }

                foreach (var item in overlayItems)
                {
                    var bounds      = item.Drawer.CalculateBounds(diagramRect);
                    var isMouseOver = bounds.Contains(Event.current.mousePosition);

                    var colorCache = GUI.color;

                    if (!isMouseOver && !item.DisableTransparency)
                    {
                        GUI.color = new Color(colorCache.r, colorCache.g, colorCache.b, colorCache.a / 4);
                    }

                    item.Drawer.Draw(bounds);

                    GUI.color = colorCache;
                }

                Drawer.EnableInput();

                /*
                 * DRAW MODAL CONTENT
                 */

                if (modalItems.Any())
                {
                    var modalBackgroundRect = new Rect().Cover(breadCrumbsRect, tabsRect, diagramRect);
                    var modalContentRect    = new Rect().WithSize(800, 500).CenterInsideOf(modalBackgroundRect);
                    var activeModal         = modalItems.OrderBy(i => i.ZIndex).Last();

                    Drawer.DisableInput();

                    foreach (var source in modalItems.OrderBy(i => i.ZIndex).Except(new[] { activeModal }))
                    {
                        source.Drawer(modalContentRect);
                    }

                    Drawer.EnableInput();

                    Drawer.DrawRect(modalBackgroundRect, new Color(0, 0, 0, 0.8f));

                    activeModal.Drawer(modalContentRect);
                }


                DrawToolip(breadCrumbsRect);

                Drawer.DoToolbar(toolbarBottomRect, this, ToolbarPosition.BottomLeft);
                //drawer.DoToolbar(toolbarBottomRect, this, ToolbarPosition.BottomRight);
            }
            else
            {
                diagramRect = new Rect(0f, 0f, width, height);
                DiagramRect = diagramRect;
                DrawDiagram(Drawer, scrollPosition, scale, diagramRect);
            }

            InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.AfterDrawDesignerWindow(new Rect(0, 0, width, height)));
            InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.DrawComplete());
        }
        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);
            }
        }
Exemple #30
0
 public void Execute <TCommand>(TCommand command) where TCommand :  ICommand
 {
     InvertApplication.Execute(command);
 }