/// <summary> /// Assign click handlers for workspace factory. /// </summary> /// <param name="controller"> The controller for the workspace /// factory tab.</param> private static void assignWorkspaceFactoryClickHandlers_(WorkspaceFactoryController controller) { // Import Custom Blocks button. Document.GetElementById("button_importBlocks").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.openModal("dropdownDiv_importBlocks"); })); Document.GetElementById("input_importBlocksJson").AddEventListener ("change", new Action <Event>((@event) => { controller.importBlocks(((HTMLInputElement)@event.Target).files[0], "JSON"); })); Document.GetElementById("input_importBlocksJson").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("input_importBlocksJs").AddEventListener ("change", new Action <Event>((@event) => { controller.importBlocks(((HTMLInputElement)@event.Target).files[0], "JavaScript"); })); Document.GetElementById("input_importBlocksJs").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.closeModal(); })); // Load to Edit button. Document.GetElementById("button_load").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.openModal("dropdownDiv_load"); })); Document.GetElementById("input_loadToolbox").AddEventListener ("change", new Action <Event>((@event) => { controller.importFile(((HTMLInputElement)@event.Target).files[0], WorkspaceFactoryController.MODE_TOOLBOX); })); Document.GetElementById("input_loadToolbox").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("input_loadPreload").AddEventListener ("change", new Action <Event>((@event) => { controller.importFile(((HTMLInputElement)@event.Target).files[0], WorkspaceFactoryController.MODE_PRELOAD); })); Document.GetElementById("input_loadPreload").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.closeModal(); })); // Export button. Document.GetElementById("dropdown_exportOptions").AddEventListener ("click", new Action(() => { controller.exportInjectFile(); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_exportToolbox").AddEventListener ("click", new Action(() => { controller.exportXmlFile(WorkspaceFactoryController.MODE_TOOLBOX); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_exportPreload").AddEventListener ("click", new Action(() => { controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_exportAll").AddEventListener ("click", new Action(() => { controller.exportInjectFile(); controller.exportXmlFile(WorkspaceFactoryController.MODE_TOOLBOX); controller.exportXmlFile(WorkspaceFactoryController.MODE_PRELOAD); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("button_export").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.openModal("dropdownDiv_export"); })); // Clear button. Document.GetElementById("button_clear").AddEventListener ("click", new Action(() => { controller.clearAll(); })); // Toolbox and Workspace tabs. Document.GetElementById("tab_toolbox").AddEventListener ("click", new Action(() => { controller.setMode(WorkspaceFactoryController.MODE_TOOLBOX); })); Document.GetElementById("tab_preload").AddEventListener ("click", new Action(() => { controller.setMode(WorkspaceFactoryController.MODE_PRELOAD); })); // "+" button. Document.GetElementById("button_add").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.openModal("dropdownDiv_add"); })); Document.GetElementById("dropdown_newCategory").AddEventListener ("click", new Action(() => { controller.addCategory(); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_loadCategory").AddEventListener ("click", new Action(() => { controller.loadCategory(); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_separator").AddEventListener ("click", new Action(() => { controller.addSeparator(); BlockFactory.blocklyFactory.closeModal(); })); Document.GetElementById("dropdown_loadStandardToolbox").AddEventListener ("click", new Action(() => { controller.loadStandardToolbox(); BlockFactory.blocklyFactory.closeModal(); })); // "-" button. Document.GetElementById("button_remove").AddEventListener ("click", new Action(() => { controller.removeElement(); })); // Up/Down buttons. Document.GetElementById("button_up").AddEventListener ("click", new Action(() => { controller.moveElement(-1); })); Document.GetElementById("button_down").AddEventListener ("click", new Action(() => { controller.moveElement(1); })); // Edit Category button. Document.GetElementById("button_editCategory").AddEventListener ("click", new Action(() => { BlockFactory.blocklyFactory.openModal("dropdownDiv_editCategory"); })); Document.GetElementById("dropdown_name").AddEventListener ("click", new Action(() => { controller.changeCategoryName(); BlockFactory.blocklyFactory.closeModal(); })); // Make/Remove Shadow buttons. Document.GetElementById("button_addShadow").AddEventListener ("click", new Action(() => { controller.addShadow(); WorkspaceFactoryInit.displayAddShadow_(false); WorkspaceFactoryInit.displayRemoveShadow_(true); })); Document.GetElementById("button_removeShadow").AddEventListener ("click", new Action(() => { controller.removeShadow(); WorkspaceFactoryInit.displayAddShadow_(true); WorkspaceFactoryInit.displayRemoveShadow_(false); // Disable shadow editing button if turning invalid shadow block back // to normal block. if (Blockly.Core.selected.getSurroundParent() == null) { ((HTMLButtonElement)Document.GetElementById("button_addShadow")).Disabled = true; } })); // Help button on workspace tab. Document.GetElementById("button_optionsHelp").AddEventListener ("click", new Action(() => { Window.Open("https://developers.google.com/blockly/guides/get-started/web#configuration"); })); // Reset to Default button on workspace tab. Document.GetElementById("button_standardOptions").AddEventListener ("click", new Action(() => { controller.setStandardOptionsAndUpdate(); })); }