Ejemplo n.º 1
0
    public string NewItem(NotebookItemType type, string name = null, string data = null)
    {
        var existingNames = Notebook.UserData.Items.Select(x => x.Name.ToLowerInvariant()).ToHashSet();

        if (name == null)
        {
            int i;
            for (i = 1; existingNames.Contains($"{type.ToString().ToLowerInvariant()}{i}"); i++)
            {
            }
            name = $"{type}{i}";
        }
        else if (existingNames.Contains(name.ToLowerInvariant()))
        {
            throw new Exception($"There is already a notebook item named \"{name}\".");
        }
        switch (type)
        {
        case NotebookItemType.Page:
            Notebook.UserData.Items.Add(new PageNotebookItemRecord {
                Name = name, Blocks = new(),
            });
            break;
Ejemplo n.º 2
0
 public NotebookItem(NotebookItemType type, string name, bool isVirtualTable = false)
 {
     Type           = type;
     Name           = name;
     IsVirtualTable = isVirtualTable;
 }
Ejemplo n.º 3
0
 private static int GetOrder(NotebookItemType t) =>
 t switch
 {