Esempio n. 1
0
        public Toolbox(ToolboxService toolboxService, IPadWindow container)
        {
            this.toolboxService = toolboxService;
            this.container      = container;

            #region Toolbar
            DockItemToolbar toolbar = container.GetToolbar(PositionType.Top);

            filterEntry              = new SearchEntry();
            filterEntry.Ready        = true;
            filterEntry.HasFrame     = true;
            filterEntry.WidthRequest = 150;
            filterEntry.Changed     += new EventHandler(filterTextChanged);
            filterEntry.Show();

            toolbar.Add(filterEntry, true);

            catToggleButton             = new ToggleButton();
            catToggleButton.Image       = new Image(Ide.Gui.Stock.GroupByCategory, IconSize.Menu);
            catToggleButton.Toggled    += new EventHandler(toggleCategorisation);
            catToggleButton.TooltipText = GettextCatalog.GetString("Show categories");
            toolbar.Add(catToggleButton);

            compactModeToggleButton             = new ToggleButton();
            compactModeToggleButton.Image       = new ImageView(ImageService.GetIcon("md-compact-display", IconSize.Menu));
            compactModeToggleButton.Toggled    += new EventHandler(ToggleCompactMode);
            compactModeToggleButton.TooltipText = GettextCatalog.GetString("Use compact display");
            toolbar.Add(compactModeToggleButton);

            toolboxAddButton = new Button(new Gtk.Image(Ide.Gui.Stock.Add, IconSize.Menu));
            toolbar.Add(toolboxAddButton);
            toolboxAddButton.TooltipText = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Clicked    += new EventHandler(toolboxAddButton_Clicked);
            toolbar.ShowAll();

            #endregion

            toolboxWidget = new ToolboxWidget();
            toolboxWidget.SelectedItemChanged += delegate {
                selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
                toolboxService.SelectItem(selectedNode);
            };
            this.toolboxWidget.DragBegin += delegate(object sender, Gtk.DragBeginArgs e) {
                if (this.toolboxWidget.SelectedItem != null)
                {
                    this.toolboxWidget.HideTooltipWindow();
                    toolboxService.DragSelectedItem(this.toolboxWidget, e.Context);
                }
            };
            this.toolboxWidget.ActivateSelectedItem += delegate {
                toolboxService.UseSelectedItem();
            };

            fontChanger = new MonoDevelop.Ide.Gui.PadFontChanger(toolboxWidget, toolboxWidget.SetCustomFont, toolboxWidget.QueueResize);

            this.toolboxWidget.DoPopupMenu = ShowPopup;

            scrolledWindow = new MonoDevelop.Components.CompactScrolledWindow();
            base.PackEnd(scrolledWindow, true, true, 0);
            base.FocusChain = new Gtk.Widget [] { scrolledWindow };

            //Initialise self
            scrolledWindow.ShadowType       = ShadowType.None;
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest     = 150;
            scrolledWindow.Add(this.toolboxWidget);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += delegate { Refresh(); };
            toolboxService.ToolboxConsumerChanged += delegate { Refresh(); };
            Refresh();

            //set initial state
            this.toolboxWidget.ShowCategories = catToggleButton.Active = true;
            compactModeToggleButton.Active    = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            this.toolboxWidget.IsListMode     = !compactModeToggleButton.Active;
            this.ShowAll();
        }