示例#1
0
    ///// <summary>
    ///// The child list control.
    ///// </summary>
    //public KTreeView Control => _tv;

    public CiPopupList(CiCompletion compl)
    {
        _compl = compl;

        _tv = new KTreeView {
            ItemMarginLeft = 20,
            //HotTrack = true, //no
            CustomDraw = new _CustomDraw(this),
            //test = true
        };
        _tv.ItemActivated  += _tv_ItemActivated;
        _tv.SelectedSingle += _tv_SelectedSingle;

        _tb = new StackPanel {
            Background = SystemColors.ControlBrush
        };

        var cstyle = Application.Current.FindResource(ToolBar.CheckBoxStyleKey) as Style;
        var bstyle = Application.Current.FindResource(ToolBar.ButtonStyleKey) as Style;

        var kindNames = CiUtil.ItemKindNames;

        _kindButtons = new CheckBox[kindNames.Length];
        for (int i = 0; i < kindNames.Length; i++)
        {
            _AddButton(_kindButtons[i] = new CheckBox(), kindNames[i], CiComplItem.ImageResource((CiItemKind)i));
            _kindButtons[i].Click     += _KindButton_Click;
        }

        _tb.Children.Add(new Separator());

        _AddButton(_groupButton = new CheckBox(), "Group by namespace or inheritance", "resources/ci/groupby.xaml");
        _groupButton.Click     += _GroupButton_Click;
        if (App.Settings.ci_complGroup)
        {
            _groupButton.IsChecked = true;
        }

        //var options = new Button();
        //options.Click += _Options_Click;
        //_AddButton(options, "Options", "resources/images/settingsgroup_16x.xaml");

        void _AddButton(ButtonBase b, string text, string image)
        {
            b.Style   = (b is CheckBox) ? cstyle : bstyle;
            b.Content = ResourceUtil.GetWpfImageElement(image);
            b.ToolTip = text;
            AutomationProperties.SetName(b, text);
            b.Focusable = false;             //would close popup
            _tb.Children.Add(b);
        }

        _panel = new DockPanel {
            Background = SystemColors.WindowBrush
        };
        DockPanel.SetDock(_tb, Dock.Left);
        _panel.Children.Add(_tb);
        _panel.Children.Add(_tv);
        _popup = new KPopup {
            Size       = (300, 360),
            Content    = _panel,
            CloseHides = true,
            Name       = "Ci.Completion",
            WindowName = "Au completion list",
        };

        _textPopup = new CiPopupText(CiPopupText.UsedBy.PopupList);
        _tpTimer   = new timer(_ShowTextPopup);
    }
示例#2
0
    ///// <summary>
    ///// The child list control.
    ///// </summary>
    //public AuListControl ListControl => _list;

    public CiPopupList(CiCompletion compl)
    {
        _compl = compl;

        _w = new _Window(this);
        _w.SuspendLayout();
        _w.Size = Au.Util.ADpi.ScaleSize((300, 360));

        _list = new _FastListBox();
        _list.SuspendLayout();
        _list.AccessibleName         = _list.Name = "Codein_list";
        _list.Dock                   = DockStyle.Fill;
        _list.BackColor              = Color.White;
        _list.ZItemClick            += _list_ItemClick;
        _list.ZSelectedIndexChanged += _list_SelectedIndexChanged;

        _tb = new Au.Util.AToolStrip();
        _tb.SuspendLayout();
        _tb.AccessibleName = _tb.Name = "Codein_listFilter";
        _tb.Renderer       = new AuDockPanel.ZDockedToolStripRenderer();
        _tb.GripStyle      = ToolStripGripStyle.Hidden;
        _tb.LayoutStyle    = ToolStripLayoutStyle.VerticalStackWithOverflow;
        int tbWidth = 0;

        var kindNames = CiUtil.ItemKindNames;

        _nKindButtons = kindNames.Length;
        for (int i = 0; i < kindNames.Length; i++)
        {
            _AddButton(kindNames[i], CiUtil.GetKindImage((CiItemKind)i));
        }
        _tb.Items.Add(new ToolStripSeparator());
        _groupButton = _AddButton("Group by namespace or inheritance", EdResources.GetImageNoCacheDpi(nameof(Au.Editor.Resources.Resources.ciGroupBy)));
        if (Program.Settings.ci_complGroup)
        {
            _groupButton.Checked = true;
        }

        ToolStripButton _AddButton(string text, Image image)
        {
            var b = _tb.Items.Add(image) as ToolStripButton;

            b.DisplayStyle = ToolStripItemDisplayStyle.Image;
            b.ImageScaling = ToolStripItemImageScaling.None;
            b.Name         = b.AccessibleName = b.ToolTipText = text;
            b.Margin       = new Padding(1, 1, 0, 0);
            if (tbWidth == 0)
            {
                tbWidth = 4 + b.ContentRectangle.Left * 2 + image.Width;
            }
            return(b);
        }

        _tb.Width        = tbWidth; _tb.AutoSize = false;  //does not work well with autosize, eg width too small when high DPI
        _tb.Dock         = DockStyle.Left;
        _tb.ItemClicked += _tb_ItemClicked;

        _w.Controls.Add(_list);
        _w.Controls.Add(_tb);
        _tb.ResumeLayout();
        _list.ResumeLayout();
        _w.ResumeLayout(true);

        _imgStatic   = EdResources.GetImageNoCacheDpi(nameof(Au.Editor.Resources.Resources.ciOverlayStatic));
        _imgAbstract = EdResources.GetImageNoCacheDpi(nameof(Au.Editor.Resources.Resources.ciOverlayAbstract));

        _popupHtml  = new CiPopupHtml(CiPopupHtml.UsedBy.PopupList);
        _popupTimer = new ATimer(_ShowPopupHtml);
    }