Пример #1
0
    public PageControl(string name, NotebookManager manager, IWin32Window mainForm)
    {
        ItemName  = name;
        _manager  = manager;
        _mainForm = mainForm;

        Controls.Add(_scrollPanel = new() {
            Dock       = DockStyle.Fill,
            AutoScroll = true,
        });
        _scrollPanel.Controls.Add(_flow = new() {
            AutoSize      = true,
            AutoSizeMode  = AutoSizeMode.GrowAndShrink,
            FlowDirection = FlowDirection.TopDown,
            WrapContents  = false,
            Margin        = Padding.Empty,
        });

        Controls.Add(_toolStrip = new() {
            Dock = DockStyle.Top,
        });
        _toolStrip.Items.Add(_executeAllButton = new ToolStripButton {
            Text = "Execute all"
        });
        _executeAllButton.Click += ExecuteAllButton_Click;
        _toolStrip.Items.Add(_acceptAllButton = new ToolStripButton {
            Text    = "Accept all",
            Enabled = false
        });
        _acceptAllButton.Click += AcceptAllButton_Click;
        var separator = new ToolStripSeparator();

        _toolStrip.Items.Add(separator);
        _toolStrip.Items.Add(_addTextButton = new ToolStripButton {
            Text = "Add text"
        });
        _addTextButton.Click += AddTextButton_Click;
        _toolStrip.Items.Add(_addQueryButton = new ToolStripButton {
            Text = "Add query"
        });
        _addQueryButton.Click += AddQueryButton_Click;
        _toolStrip.SetMenuAppearance();

        DividerBlockControl divider = new();

        divider.AddBlock += Divider_AddPart;
        InsertBlock(divider, 0);

        Ui ui = new(this, padded : false);

        ui.Init(_toolStrip);
        ui.Init(_executeAllButton, Resources.ControlPlayBlue, Resources.control_play_blue32);
        ui.Init(_acceptAllButton, Resources.accept_button, Resources.accept_button32);
        ui.Init(separator);
        var addTextIcon16  = Ui.SuperimposePlusSymbol(Resources.font);
        var addTextIcon32  = Ui.SuperimposePlusSymbol(Resources.font32);
        var addQueryIcon16 = Ui.SuperimposePlusSymbol(Resources.table);
        var addQueryIcon32 = Ui.SuperimposePlusSymbol(Resources.table32);

        ui.Init(_addTextButton, addTextIcon16, addTextIcon32);
        ui.Init(_addQueryButton, addQueryIcon16, addQueryIcon32);
        ui.Init(_scrollPanel);
        ui.Init(_flow);

        UserOptions.OnUpdateAndNow(this, () => {
            var opt    = UserOptions.Instance;
            var colors = opt.GetColors();
            BackColor  = colors[UserOptionsColor.GRID_BACKGROUND];
        });

        UserOptions.OnUpdatePost(this, () => {
            OnSizeChanged(EventArgs.Empty);
        });

        OnSizeChanged(EventArgs.Empty);

        LoadPage();
    }