示例#1
0
 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);
     }
 }
示例#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 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;
     }));
 }
示例#4
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);
         }
     });
 }
示例#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);
 }
示例#6
0
 public void RecordRemoving(IDataRecord record)
 {
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordRemoving>(_ =>
     {
         if (_ != this)
         {
             _.RecordRemoving(record);
         }
     });
 }
示例#7
0
        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())
            //{

            //}
            //}
        }
示例#8
0
 public void RecordRemoved(IDataRecord record)
 {
     //TODO Check already invoked in JsonFileRecordManager and FastJsonFileRecordManager
     if (SilentMode)
     {
         return;
     }
     InvertApplication.SignalEvent <IDataRecordRemoved>(_ =>
     {
         if (_ != this)
         {
             _.RecordRemoved(record);
         }
     });
 }
        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);
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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);
                }
            }
        }
示例#12
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));
        }
示例#13
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);
        }
        //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(_ => { });
        }
示例#15
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);
        }
示例#16
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");
     }
 }
示例#17
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
        }
示例#18
0
        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();
        }
示例#19
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);
            }
        }
示例#20
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));
        }
示例#21
0
        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);
        }
示例#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);
            }
        }
示例#23
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;
        }
示例#24
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", () =>
//                {
//
//
//                }));
//            });
        }
示例#25
0
        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));
            }
        }
示例#26
0
 public void Execute <TCommand>(TCommand command) where TCommand :  ICommand
 {
     InvertApplication.Execute(command);
 }
        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();
        }
示例#28
0
        public IEnumerator Generate(SaveAndCompileCommand command)
        {
            var repository = InvertGraphEditor.Container.Resolve <IRepository>();

            var remove = repository.AllOf <IClassNode>().Where(p => string.IsNullOrEmpty(p.Name)).ToArray();

            foreach (var item in remove)
            {
                repository.Remove(item);
            }

            repository.Commit();
            var config = InvertGraphEditor.Container.Resolve <IGraphConfiguration>();
            var items  = GetItems(repository, command.ForceCompileAll).Distinct().ToArray();

            yield return
                (new TaskProgress(0f, "Validating"));

            var a = ValidationSystem.ValidateNodes(items.OfType <IDiagramNode>().ToArray());

            while (a.MoveNext())
            {
                yield return(a.Current);
            }
            if (ValidationSystem.ErrorNodes.SelectMany(n => n.Errors).Any(e => e.Siverity == ValidatorType.Error))
            {
                Signal <INotify>(_ => _.Notify("Please, fix all errors before compiling.", NotificationIcon.Error));
                yield break;
            }
            Signal <IUpgradeDatabase>(_ => _.UpgradeDatabase(config as uFrameDatabaseConfig));
            Signal <ICompilingStarted>(_ => _.CompilingStarted(repository));
            // Grab all the file generators
            var fileGenerators = InvertGraphEditor.GetAllFileGenerators(config, items, true).ToArray();

            var length = 100f / (fileGenerators.Length + 1);
            var index  = 0;

            foreach (var codeFileGenerator in fileGenerators)
            {
                index++;
                yield return(new TaskProgress(length * index, "Generating " + System.IO.Path.GetFileName(codeFileGenerator.AssetPath)));

                // Grab the information for the file
                var fileInfo = new FileInfo(codeFileGenerator.SystemPath);
                // Make sure we are allowed to generate the file
                if (!codeFileGenerator.CanGenerate(fileInfo))
                {
                    var fileGenerator = codeFileGenerator;
                    InvertApplication.SignalEvent <ICompileEvents>(_ => _.FileSkipped(fileGenerator));

                    if (codeFileGenerator.Generators.All(p => p.AlwaysRegenerate))
                    {
                        if (File.Exists(fileInfo.FullName))
                        {
                            File.Delete(fileInfo.FullName);
                        }
                    }

                    continue;
                }

                GenerateFile(fileInfo, codeFileGenerator);
                CodeFileGenerator generator = codeFileGenerator;
                InvertApplication.SignalEvent <ICompileEvents>(_ => _.FileGenerated(generator));
            }
            ChangedRecrods.Clear();
            InvertApplication.SignalEvent <ICompileEvents>(_ => _.PostCompile(config, items));
            foreach (var item in items.OfType <IGraphData>())
            {
                item.IsDirty = false;
            }
            yield return
                (new TaskProgress(100f, "Complete"));

#if UNITY_EDITOR
            repository.Commit();
            if (InvertGraphEditor.Platform != null) // Testability
            {
                InvertGraphEditor.Platform.RefreshAssets();
            }
#endif
        }
示例#29
0
 public void Execute(SaveAndCompileCommand command)
 {
     InvertApplication.SignalEvent <ITaskHandler>(_ => { _.BeginTask(Generate(command)); });
 }
示例#30
0
        private void AddSection(NodeConfigSectionBase section)
        {
            //if (DiagramViewModel != null && DiagramViewModel.CurrentRepository.CurrentFilter.IsAllowed(null, section.SourceType)) return;
            var section1 = section as NodeConfigSectionBase;

            if (!IsVisible(section.Visibility))
            {
                return;
            }

            if (!string.IsNullOrEmpty(section.Name))
            {
                var header = new GenericItemHeaderViewModel()
                {
                    Name          = section.Name,
                    NodeViewModel = this,
                    NodeConfig    = NodeConfig,
                    SectionConfig = section1,
                };
                //if (section.AttributeInfo != null)
                //{
                //    header.IsNewLine = inputConfig.AttributeInfo.IsNewRow;
                //}
                //else
                //{
                //    header.IsNewLine = true;
                //}

                header.AddCommand = section1.AllowAdding ? new LambdaCommand("Add Item", () =>
                {
                    OnAdd(section, section1, this);
                }) : null;


                ContentItems.Add(header);
            }

            if (section1.GenericSelector != null && section1.ReferenceType == null)
            {
                foreach (var item in section1.GenericSelector(GraphItem).OfType <IDiagramNodeItem>().OrderBy(p => p.Order))
                {
                    if (section.SourceType.IsAssignableFrom(item.GetType()))
                    {
                        var vm            = GetDataViewModel(item) as GraphItemViewModel;
                        var itemViewModel = vm as ItemViewModel;
                        if (itemViewModel != null)
                        {
                            itemViewModel.IsEditable = section1.IsEditable;
                            ApplyInputConfiguration(section, item, vm.InputConnector, section.AllowMultipleInputs);
                            ApplyOutputConfiguration(section, item, vm.OutputConnector, section.AllowMutlipleOutputs);
                        }

                        if (vm == null)
                        {
                            InvertApplication.LogError(
                                string.Format(
                                    "Couldn't find view-model for {0} in section {1} with child type {2}",
                                    item.GetType(), section1.Name, section1.SourceType.Name));
                            continue;
                        }

                        vm.DiagramViewModel = DiagramViewModel;
                        ContentItems.Add(vm);
                    }
                    else
                    {
                        InvertApplication.LogError(string.Format("Types do not match {0} and {1}", section.SourceType,
                                                                 item.GetType()));
                    }
                }
            }
            else
            {
                foreach (var item in GraphItem.PersistedItems)
                {
                    if (section.SourceType.IsAssignableFrom(item.GetType()))
                    {
                        var vm = GetDataViewModel(item) as ItemViewModel;


                        if (vm == null)
                        {
                            InvertApplication.LogError(string.Format("Couldn't find view-model for {0}", item.GetType()));
                            continue;
                        }
                        vm.IsEditable       = section1.IsEditable;
                        vm.DiagramViewModel = DiagramViewModel;
                        if (section1.HasPredefinedOptions)
                        {
                            vm.IsEditable = false;
                        }
                        ApplyInputConfiguration(section, item, vm.InputConnector, section.AllowMultipleInputs);
                        ApplyOutputConfiguration(section, item, vm.OutputConnector, section.AllowMutlipleOutputs);
                        ContentItems.Add(vm);
                    }
                }
            }
        }