This class represents one tool in the Toolbox accordion which can show to the right of the page when the user expands it. There is a subclass for each tool. These objects are serialized as part of the meta.json file representing the state of a book. The State field is persisted in this way; it is also passed in to the JavaScript that manages the toolbox. New fields and properties should be kept non-public or marked with an appropriate attribute if they should NOT be persisted in JSON. New subclasses will typically require a new case in CreateFromJsonToolId and also in ToolboxToolConverter.ReadJson. Note that the values of the Name field are used in the json and therefore cannot readily be changed. (Migration would handle a change going forward, but older Blooms would lose the data at best.)
Exemplo n.º 1
0
 public static void LoadPanelIntoToolbox(HtmlDom domForToolbox, ToolboxTool tool, List<string> checkedBoxes, string toolboxFolder)
 {
     // For all the toolbox tools, the tool name is used as the name of both the folder where the
     // assets for that tool are kept, and the name of the main htm file that represents the tool.
     var fileName = tool.ToolId + "ToolboxPanel.html";
     var path = BloomFileLocator.sTheMostRecentBloomFileLocator.LocateFile(fileName);
     Debug.Assert(!string.IsNullOrEmpty(path));
     AppendToolboxPanel(domForToolbox, path);
     checkedBoxes.Add(tool.ToolId + "Check");
 }
Exemplo n.º 2
0
        public static void LoadPanelIntoToolbox(HtmlDom domForToolbox, ToolboxTool tool, List <string> checkedBoxes, string toolboxFolder)
        {
            // For all the toolbox tools, the tool name is used as the name of both the folder where the
            // assets for that tool are kept, and the name of the main htm file that represents the tool.
            var fileName = tool.ToolId + "ToolboxPanel.html";
            var path     = BloomFileLocator.sTheMostRecentBloomFileLocator.LocateFile(fileName);

            Debug.Assert(!string.IsNullOrEmpty(path));
            AppendToolboxPanel(domForToolbox, path);
            checkedBoxes.Add(tool.ToolId + "Check");
        }
Exemplo n.º 3
0
        private static void UpdateActiveToolSetting(Book.Book book, string toolName, bool enabled)
        {
            var tools = book.BookInfo.Tools;
            var item  = tools.FirstOrDefault(t => t.ToolId == toolName);

            if (item == null)
            {
                item = ToolboxTool.CreateFromToolId(toolName);
                tools.Add(item);
            }
            item.Enabled = enabled;
        }