Esempio n. 1
0
        protected override void OnBuildToolBar(Toolbar tb)
        {
            base.OnBuildToolBar(tb);

            // Change the cursor when the BrushWidth is changed.
            brush_width.ComboBox.Changed += (sender, e) => SetCursor(DefaultCursor);

            tb.AppendItem(new Gtk.SeparatorToolItem());

            if (brush_label == null)
            {
                brush_label = new ToolBarLabel(string.Format(" {0}:  ", Catalog.GetString("Type")));
            }

            if (brush_combo_box == null)
            {
                brush_combo_box = new ToolBarComboBox(100, 0, false);
                brush_combo_box.ComboBox.Changed += (o, e) => {
                    Gtk.TreeIter iter;
                    if (brush_combo_box.ComboBox.GetActiveIter(out iter))
                    {
                        active_brush = (BasePaintBrush)brush_combo_box.Model.GetValue(iter, 1);
                    }
                    else
                    {
                        active_brush = default_brush;
                    }
                };

                RebuildBrushComboBox();
            }

            tb.AppendItem(brush_label);
            tb.AppendItem(brush_combo_box);
        }
Esempio n. 2
0
        public PaintBrushTool(IServiceManager services) : base(services)
        {
            brushes = services.GetService <IPaintBrushService> ();

            if (!brushes.Any())
            {
                throw new InvalidOperationException("There are no registered paint brushes.");
            }

            default_brush = brushes.First();
            active_brush  = default_brush;

            brushes.BrushAdded   += (_, _) => RebuildBrushComboBox();
            brushes.BrushRemoved += (_, _) => RebuildBrushComboBox();
        }
Esempio n. 3
0
        /// <summary>
        /// Rebuild the list of brushes.
        /// </summary>
        private void RebuildBrushComboBox()
        {
            brush_combo_box.Model.Clear();
            default_brush = null;

            foreach (var brush in PintaCore.PaintBrushes)
            {
                if (default_brush == null)
                {
                    default_brush = (BasePaintBrush)brush;
                }
                brush_combo_box.Model.AppendValues(brush.Name, brush);
            }

            brush_combo_box.ComboBox.Active = 0;
        }
Esempio n. 4
0
        /// <summary>
        /// Rebuild the list of brushes.
        /// </summary>
        private void RebuildBrushComboBox()
        {
            if (!brushes.Any())
            {
                throw new InvalidOperationException("There are no registered paint brushes.");
            }

            default_brush = brushes.First();

            BrushComboBox.ComboBox.RemoveAll();

            foreach (var brush in brushes)
            {
                BrushComboBox.ComboBox.AppendText(brush.Name);
            }

            BrushComboBox.ComboBox.Active = 0;
        }