Exemplo n.º 1
0
    private void ExecuteAllButton_Click(object sender, EventArgs e)
    {
        AcceptAll();

        _manager.CommitOpenEditors();

        List <Action> uiThreadActions    = new();
        var           queryBlockControls = _flow.Controls.OfType <QueryBlockControl>().ToList();

        WaitForm.Go(TopLevelControl, "Page Execution", "Executing all queries...", out _, () => {
            foreach (var queryBlockControl in queryBlockControls)
            {
                var output = queryBlockControl.ExecuteOnWorkerThread();
                uiThreadActions.Add(() => {
                    queryBlockControl.Output?.Dispose();
                    queryBlockControl.Output = output;
                    queryBlockControl.Invalidate();
                });
            }
        });

        foreach (var action in uiThreadActions)
        {
            action();
        }
        OnSizeChanged(EventArgs.Empty);

        _manager.SetDirty();
        _manager.Rescan();
    }
Exemplo n.º 2
0
    public ExplorerControl(NotebookManager manager, IWin32Window mainForm)
    {
        InitializeComponent();
        _mainForm = mainForm;
        _manager  = manager;
        _manager.NotebookChange += (sender, e) => HandleNotebookChange(e);
        _contextMenuStrip.SetMenuAppearance();
        _toolStrip.SetMenuAppearance();
        _toolStrip.Padding   = new(this.Scaled(1), 0, 0, 0);
        _toolStrip.BackColor = SystemColors.Window;

        ImageList imageList = new() {
            ColorDepth = ColorDepth.Depth32Bit,
            ImageSize  = new(this.Scaled(16), this.Scaled(16)),
        };

        // Same order as the ICON_* constants.
        // ICON_PAGE
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.page, Resources.page32, dispose: false));
        // ICON_SCRIPT
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.script, Ui.ShiftImage(Resources.script32, 0, 1), dispose: false));
        // ICON_TABLE
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.table, Resources.table32, dispose: false));
        // ICON_VIEW
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.filter, Resources.filter32, dispose: false));
        // ICON_LINKED_TABLE
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.link, Resources.link32, dispose: false));
        // ICON_KEY
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.key, Resources.key32, dispose: false));
        // ICON_COLUMN
        imageList.Images.Add(Ui.GetScaledIcon(this, Resources.bullet_white, Resources.bullet_white32, dispose: false));

        _tree = new ExplorerTreeView {
            BorderStyle      = BorderStyle.None,
            ContextMenuStrip = _contextMenuStrip,
            Dock             = DockStyle.Fill,
            FullRowSelect    = true,
            LabelEdit        = true,
            ShowRootLines    = true,
        };
        _tree.ImageList             = imageList;
        _tree.TreeViewNodeSorter    = new ExplorerNodeComparer();
        _tree.AfterLabelEdit       += Tree_AfterLabelEdit;
        _tree.BeforeExpand         += Tree_BeforeExpand;
        _tree.BeforeLabelEdit      += Tree_BeforeLabelEdit;
        _tree.KeyDown              += Tree_KeyDown;
        _tree.NodeMouseClick       += Tree_NodeMouseClick;
        _tree.NodeMouseDoubleClick += Tree_NodeMouseDoubleClick;
        _tree.EnableDoubleBuffering();
        _toolStripContainer.ContentPanel.Controls.Add(_tree);

        Ui      ui             = new(this, false);
        Padding buttonPadding  = new(this.Scaled(2));
        var     newPageImage16 = Ui.SuperimposePlusSymbol(Resources.page);
        var     newPageImage32 = Ui.SuperimposePlusSymbol(Resources.page32);

        ui.Init(_toolbarNewPageButton, newPageImage16, newPageImage32);
        var newScriptImage16 = Ui.SuperimposePlusSymbol(Resources.script);
        var newScriptImage32 = Ui.SuperimposePlusSymbol(Ui.ShiftImage(Resources.script32, 0, 1));

        ui.Init(_toolbarNewScriptButton, newScriptImage16, newScriptImage32);

        _tree.GotFocus += (sender, e) => {
            _manager.CommitOpenEditors();
            _manager.Rescan(notebookItemsOnly: true);
        };
    }