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); }
public void TemplateSetup() { foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>()) { var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName); if (type == null) { continue; } Ctx.TryAddNamespace(type.Namespace); } }
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)); }
public void TemplateSetup() { // Support inheritance Ctx.CurrentDeclaration.BaseTypes.Clear(); if (!CommandNode.IsStruct) { if (CommandNode.BaseNode != null) { Ctx.CurrentDeclaration.BaseTypes.Add((CommandNode.BaseNode.Name + "Command").ToCodeReference()); } else { Ctx.SetBaseType(typeof(ViewModelCommand)); } } else { if (CommandNode.BaseNode != null) { throw new TemplateException(Ctx.Item.Name + " is Struct, but BaseNode = " + CommandNode.BaseNode.FullName); } Ctx.CurrentDeclaration.IsClass = false; Ctx.CurrentDeclaration.IsStruct = true; if (Ctx.IsDesignerFile) { Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IViewModelCommand)); } } foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>()) { var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName); if (type == null) { continue; } Ctx.TryAddNamespace(type.Namespace); } if (!Ctx.IsDesignerFile) { Ctx.CurrentDeclaration.BaseTypes.Clear(); } else { Ctx.CurrentDeclaration.Name = string.Format("{0}Command", Ctx.Data.Name); } }
public void BeforePropertyChanged(IDataRecord record, string name, object previousValue, object nextValue) { if (SilentMode) { return; } InvertApplication.SignalEvent <IDataRecordPropertyBeforeChange>(_ => { if (_ != this) { _.BeforePropertyChanged(record, name, previousValue, nextValue); } }); }
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 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 OnInspectorUpdate() { InvertApplication.SignalEvent <IUpdate>(_ => _.Update()); if (IsVisible) { Repaint(); } //if (EditorApplication.isPlaying) //{ // Instance = this; // InvertApplication.SignalEvent<IUpdate>(_ => _.Update()); // Repaint(); //} }
public void OnGUI() { EventType currentType = Event.current.type; if (InvertGraphEditor.Container != null) { InvertApplication.SignalEvent <IDrawDesignerWindow>(_ => _.DrawDesigner(position.width, position.height)); } if (currentType == EventType.MouseMove || currentType == EventType.MouseDrag) { Repaint(); } }
public void RecordRemoving(IDataRecord record) { if (SilentMode) { return; } InvertApplication.SignalEvent <IDataRecordRemoving>(_ => { if (_ != this) { _.RecordRemoving(record); } }); }
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 TemplateSetup() { // Support inheritance Ctx.CurrentDeclaration.BaseTypes.Clear(); if (!SimpleClassNode.IsStruct) { if (Ctx.IsDesignerFile) { if (SimpleClassNode.BaseNode != null) { Ctx.CurrentDeclaration.BaseTypes.Add((SimpleClassNode.BaseNode.Name).ToCodeReference()); } Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IJSonSerializable)); } else { Ctx.SetBaseType((SimpleClassNode.Node.Name + "Base").ToCodeReference()); } } else { if (SimpleClassNode.BaseNode != null) { throw new TemplateException(Ctx.Item.Name + " is Struct, but BaseNode = " + SimpleClassNode.BaseNode.FullName); } Ctx.CurrentDeclaration.IsClass = false; Ctx.CurrentDeclaration.IsStruct = true; if (Ctx.IsDesignerFile) { Ctx.CurrentDeclaration.Name = Ctx.Data.Node.Name.Clean(); Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IJSonSerializable)); } } foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>()) { var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName); if (type == null) { continue; } Ctx.TryAddNamespace(type.Namespace); } Ctx.AddIterator("Property", node => node.Properties); Ctx.AddIterator("Collection", node => node.Collections); }
public void RecordRemoved(IDataRecord record) { //TODO Check already invoked in JsonFileRecordManager and FastJsonFileRecordManager if (SilentMode) { return; } InvertApplication.SignalEvent <IDataRecordRemoved>(_ => { if (_ != this) { _.RecordRemoved(record); } }); }
public void Execute(AddGraphToWorkspace command) { var workspaceService = Container.Resolve <WorkspaceService>(); var repo = Container.Resolve <IRepository>(); var workspaceGraphs = workspaceService.CurrentWorkspace.Graphs.Select(p => p.Identifier).ToArray(); var importableGraphs = repo.AllOf <IGraphData>().Where(p => !workspaceGraphs.Contains(p.Identifier)); InvertGraphEditor.WindowManager.InitItemWindow(importableGraphs, _ => { InvertApplication.Execute(new LambdaCommand("Add Graph", () => { workspaceService.CurrentWorkspace.AddGraph(_); })); }); }
public NavigationItem CreateNavigationItem(IGraphFilter 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(filter); })); } }; return(navigationItem); }
public void Import(List <ExportedRepository> exportedItems) { foreach (var item in exportedItems) { var type = InvertApplication.FindType(item.Type); if (type != null) { var repository = GetRepositoryFor(type); foreach (var record in item.Records) { repository.Import(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); } }
public void Execute(LoginCommand command) { AuthorizationState = AuthorizationState.InProgress; GlobalProgressMessage = "Logging in..."; Thread.Sleep(2000); KoinoniaSettings.AccessToken = "12345"; KoinoniaSettings.AccessTokenExpirationDate = DateTime.Now.AddHours(2); Settings.Commit(); GlobalProgressMessage = null; InvertApplication.SignalEvent <ILoggedInEvent>(_ => _.LoggedIn()); }
public void Progress(float progress, string message) { try { InvertApplication.SignalEvent <ITaskProgressHandler>(_ => _.Progress(progress, message)); //if (progress > 100f) //{ // EditorUtility.ClearProgressBar(); // return; //} //EditorUtility.DisplayProgressBar("Generating", message, progress/1f); } catch (Exception ex) { } }
public override IEnumerable <IValueItem> GetAllowed() { var action = this.Node as IVariableContextProvider; if (action != null) { foreach (var item in action.GetAllContextVariables().Where(p => p.VariableType.IsAssignableTo(VariableType))) { yield return(item); } } else { InvertApplication.Log("BS"); } }
public override void Perform(SceneTypeNode node) { if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { return; } var paths = node.Project.SystemDirectory; var scenesPath = System.IO.Path.Combine(paths, "Scenes"); var relativeScenesPath = System.IO.Path.Combine(node.Graph.AssetDirectory, "Scenes"); if (!Directory.Exists(scenesPath)) { Directory.CreateDirectory(scenesPath); } EditorApplication.NewScene(); var go = new GameObject(string.Format("_{0}Root", node.Name)); var type = InvertApplication.FindType(node.FullName); if (type != null) { go.AddComponent(type); } EditorUtility.SetDirty(go); var scenePath = System.IO.Path.Combine(scenesPath, node.Name + ".unity"); var relativeScenePath = System.IO.Path.Combine(relativeScenesPath, node.Name + ".unity"); if (!File.Exists(scenePath)) { EditorApplication.SaveScene(System.IO.Path.Combine(relativeScenesPath, node.Name + ".unity"), false); AssetDatabase.Refresh(); } else { EditorApplication.SaveScene(); AssetDatabase.Refresh(); } if (!UnityEditor.EditorBuildSettings.scenes.Any(s => { return(s.path.EndsWith(node.Name + ".unity")); })) { var list = EditorBuildSettings.scenes.ToList(); list.Add(new EditorBuildSettingsScene(relativeScenePath, true)); EditorBuildSettings.scenes = list.ToArray(); } }
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 IDrawer CreateDrawer <TDrawerBase>(this IUFrameContainer 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(), new object[] { viewModel }); if (drawer == null) { InvertApplication.Log(String.Format("Couldn't Create drawer for {0}.", viewModel.GetType())); } return(drawer); }
private void DrawLoginScreen(Rect bounds) { float loginScreenSide = 200; GUILayout.BeginArea(new Rect((bounds.width - loginScreenSide) / 2, (bounds.height - loginScreenSide) / 2, loginScreenSide, loginScreenSide)); Username = GUILayout.TextField(Username ?? ""); Password = GUILayout.TextField(Password ?? ""); if (GUILayout.Button("Login")) { InvertApplication.ExecuteInBackground(new LoginCommand() { Username = Username, Password = Password }); } GUILayout.EndArea(); }
private void ShowAddPointerMenu <TItem>(string name, Action addItem, Action <TItem> addPointer) where TItem : IDiagramNodeItem { var ctxMenu = new UnityEditor.GenericMenu(); ctxMenu.AddItem(new GUIContent("New " + name), false, () => { InvertApplication.Execute(() => { addItem(); }); }); ctxMenu.AddSeparator(""); var nodeConfigSection = NodeViewModel.DiagramViewModel.CurrentRepository.AllOf <TItem>(); foreach (var item in nodeConfigSection) { var item1 = item; ctxMenu.AddItem(new GUIContent(item.Name), false, () => { InvertApplication.Execute(() => { addPointer(item1); }); }); } ctxMenu.ShowAsContext(); }
public virtual bool CanConnect(IConnectable output, IConnectable input) { if (CanConnect(output.GetType(), input.GetType())) { if (output.GetType().Name == "ShellNodeConfig" && input.GetType().Name == "ShellNodeConfigInput") { InvertApplication.Log("!!!!Bingo!!!!"); InvertApplication.Log("CanOutputTo : " + output.CanOutputTo(input)); InvertApplication.Log("CanInputFrom : " + input.CanInputFrom(output)); } if (output.CanOutputTo(input) && input.CanInputFrom(output)) { return(true); } } return(false); }
private void TryNavigateToItem(IItem item) { if (InvertGraphEditor.CurrentDiagramViewModel != null) { InvertGraphEditor.CurrentDiagramViewModel.NothingSelected(); } var itemAsNode = item as IDiagramNodeItem; if (itemAsNode != null) { InvertApplication.Execute(new NavigateToNodeCommand() { Node = itemAsNode.Node }); return; } }
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 void UpgradeProject() //{ // uFrameEditor.ExecuteCommand(new ConvertToJSON()); //} public void NothingSelected() { var items = SelectedNodeItems.OfType <ItemViewModel>().Where(p => p.IsEditing).ToArray(); if (items.Length > 0) { InvertApplication.Execute(() => { foreach (var item in items) { item.EndEditing(); } }); } DeselectAll(); //InvertGraphEditor.ExecuteCommand(_ => { }); }
public void TemplateSetup() { var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } else { type = InvertApplication.FindType(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } } Ctx.CurrentDeclaration.Name = Ctx.Data.Name + "Command"; Ctx.AddCondition("Argument", _ => _.HasArgument); }