public DataNodeTabViewModel(EditorEnvironment editorEnvironment) : base("DataNodes", editorEnvironment) { var nodeFactory = new DataNodeFactory(editorEnvironment); var comboBoxValues = new List <string> { "Test", "A", "42" }; nodeFactory.ComboBoxValueProviders["TestSelection"] = new ComboBoxValueProvider(() => comboBoxValues); editorEnvironment.NodeFactory = nodeFactory; EditorViewModel = new TreeEditorViewModel(editorEnvironment); EditorViewModel.AddDefaultCommands(); EditorViewModel.AddDefaultContextMenuCommands(); var catalogTypes = new List <Type> { typeof(SubData) }; EditorViewModel.CatalogItems.AddItems(NodeCatalogItem.CreateItemsForTypes(catalogTypes)); EditorViewModel.ContextMenuCommands.Add(Commands.ContextMenuCommand.Seperator); EditorViewModel.ContextMenuCommands.Add(new Commands.ContextMenuCommand("TestDataNodeWriteRead", TestDataNodeWriteRead)); EditorViewModel.ContextMenuCommands.Add(new Commands.ContextMenuCommand("WriteToFile", WriteToFile)); EditorViewModel.ContextMenuCommands.Add(new Commands.ContextMenuCommand("ReadFromFile", ReadFromFile)); EditorViewModel.ContextMenuCommands.Add(Commands.ContextMenuCommand.Seperator); var dialogRootNode = nodeFactory.CreateDataNode(typeof(RootData)); EditorViewModel.AddRootNode(dialogRootNode); }
public DirectoryTabViewModel(EditorEnvironment editorEnvironment) : base("Directory", editorEnvironment) { editorEnvironment.NodeFactory = new TreeNodeFactory(editorEnvironment); EditorViewModel = new TreeEditorViewModel(editorEnvironment); EditorViewModel.AddRootNodes(GetDriveNodes()); EditorViewModel.Commands.Add(new Commands.EditorCommand("Refresh", "Reloads the directory info", () => { EditorViewModel.ClearRootNodes(); EditorViewModel.AddRootNodes(GetDriveNodes()); })); }
public DefaultTabViewModel(EditorEnvironment editorEnvironment) : base("Default", editorEnvironment) { editorEnvironment.NodeFactory = new TreeNodeFactory(editorEnvironment); EditorViewModel = new TreeEditorViewModel(editorEnvironment); EditorViewModel.AddDefaultCommands(); EditorViewModel.AddDefaultContextMenuCommands(); EditorViewModel.CatalogItems.AddItems(NodeCatalogItem.CreateItemsForAssignableTypes(typeof(IDefaultNode), Assembly.GetExecutingAssembly())); var containerNode = editorEnvironment.NodeFactory.CreateNode <DefaultContainer>(); EditorViewModel.AddRootNode(containerNode); }
static void Initialize() { // Remember to initialize that JoinableTaskContext if you need it var mainloop = new MockMainLoop(); mainloop.Start().Wait(); MefJoinableTaskContext = mainloop.JoinableTaskContext; System.Threading.SynchronizationContext.SetSynchronizationContext(mainloop); EditorEnvironment.DefaultAssemblies = new string[2] { typeof(EditorEnvironment).Assembly.Location, // Microsoft.VisualStudio.MiniEditor typeof(Microsoft.VisualStudio.Text.VirtualSnapshotPoint).Assembly.Location, //Microsoft.VisualStudio.Text.Logic }.ToImmutableArray(); // Create the MEF composition // can be awaited instead if your framework supports it EditorEnvironment = EditorEnvironment.InitializeAsync( typeof(XmlParser).Assembly.Location, typeof(XmlCompletionSource <,>).Assembly.Location, typeof(MSBuildCompletionSource).Assembly.Location, typeof(TestEnvironment).Assembly.Location ).Result; if (EditorEnvironment.CompositionErrors.Length > 0) { Console.WriteLine("Composition Errors:"); foreach (var error in EditorEnvironment.CompositionErrors) { Console.WriteLine("\t" + error); } } // Register your own logging mechanism to print eventual errors // in your extensions var errorHandler = EditorEnvironment .GetEditorHost() .GetService <EditorHostExports.CustomErrorHandler> (); errorHandler.ExceptionHandled += (s, e) => Console.WriteLine(e.Exception); EditorCatalog = new EditorCatalog(EditorEnvironment); }
public ViewModel() { var editorEnvironment = new EditorEnvironment(); // Disable the undo/redo stack during the node initialization editorEnvironment.UndoRedoStack.IsEnabled = false; // Create a unique copy of the environment, because all tabs use their own node factory, // but can share the same undo stack AddTab(new DataNodes.DataNodeTabViewModel(new EditorEnvironment(editorEnvironment))); AddTab(new Default.DefaultTabViewModel(new EditorEnvironment(editorEnvironment))); AddTab(new Directory.DirectoryTabViewModel(new EditorEnvironment(editorEnvironment))); AddTab(new Dialog.DialogTabViewModel(new EditorEnvironment(editorEnvironment))); // Enable the undo/redo stack after the node initialization editorEnvironment.UndoRedoStack.IsEnabled = true; SelectedTab = TabViewModels.FirstOrDefault(); }
public DialogTabViewModel(EditorEnvironment editorEnvironment) : base("Dialog", editorEnvironment) { var nodeFactory = new CustomNodeFactory(editorEnvironment); editorEnvironment.NodeFactory = nodeFactory; EditorViewModel = new TreeEditorViewModel(editorEnvironment); EditorViewModel.AddDefaultCommands(); EditorViewModel.AddDefaultContextMenuCommands(); EditorViewModel.CatalogItems.AddItems(NodeCatalogItem.CreateItemsForAssignableTypes(typeof(DialogNode), Assembly.GetExecutingAssembly())); EditorViewModel.CatalogItems.Add(new NodeCatalogItem(ShowTextHelloWorldCatalogName, "Actions", "ShowText with 'Hello world!'", typeof(ShowTextAction))); EditorViewModel.ContextMenuCommands.Add(new Commands.ContextMenuCommand("Say 'Hello world!'", () => EditorViewModel.SelectedNode is ShowTextAction, () => (EditorViewModel.SelectedNode as ShowTextAction).Text = "Hello world!")); var dialogRootNode = nodeFactory.CreateDialogRootNode(); EditorViewModel.AddRootNode(dialogRootNode); }
public TabViewModel(string header, EditorEnvironment editorEnvironment) { Header = header; EditorEnvironment = editorEnvironment; }
//******************************************************************************** // OnInspectorGUI //******************************************************************************** public override void OnInspectorGUI() { EditorBehaviour.BehaviourSelectIndex = 0; Info.HelpButtonIndex = 0; if (m_creature_debug != null) { m_creature_control.Display.ShowDebug = m_creature_debug.enabled; } else { m_creature_control.Display.ShowDebug = false; } GUI.changed = false; EditorGUILayout.Separator(); Info.HelpEnabled = m_creature_control.Display.ShowHelp; Info.DescriptionEnabled = m_creature_control.Display.ShowHelpDescription; // COCKPIT EditorRegister.Print(m_creature_control.gameObject.name); EditorDisplay.Print(m_creature_control.Display); EditorInfo.Print(m_creature_control); // ESSENTIALS EditorEssentials.Print(m_creature_control); // STATUS EditorStatus.Print(m_creature_control); // MISSIONS EditorMissions.Print(m_creature_control); // INTERACTION EditorInteraction.Print(m_creature_control); // ENVIRONMENT EditorEnvironment.Print(m_creature_control); //BEHAVIOURS EditorBehaviour.Print(m_creature_control); if (m_creature_control.Display.ShowDebug) { if (m_creature_debug == null) { m_creature_debug = m_creature_control.gameObject.AddComponent <ICECreatureControlDebug>(); } else if (m_creature_debug.enabled == false) { m_creature_debug.enabled = true; } } else if (m_creature_debug != null) { m_creature_debug.enabled = false; /* * DestroyImmediate( m_creature_control.GetComponent<ICECreatureControlDebug>() ); * EditorGUIUtility.ExitGUI();*/ } if (GUI.changed) { EditorUtility.SetDirty(m_creature_control); } }
public EditorCatalog(EditorEnvironment env) => Host = env.GetEditorHost();