Пример #1
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            if (swap_rect.ContainsPoint(ev.X, ev.Y))
            {
                Color temp = PintaCore.Palette.PrimaryColor;
                PintaCore.Palette.PrimaryColor   = PintaCore.Palette.SecondaryColor;
                PintaCore.Palette.SecondaryColor = temp;
                GdkWindow.Invalidate();
            }
            else if (reset_rect.ContainsPoint(ev.X, ev.Y))
            {
                PintaCore.Palette.PrimaryColor   = new Color(0, 0, 0);
                PintaCore.Palette.SecondaryColor = new Color(1, 1, 1);
                GdkWindow.Invalidate();
            }

            if (primary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Primary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.PrimaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.PrimaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }
            else if (secondary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Secondary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.SecondaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.SecondaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }

            int pal = PointToPalette((int)ev.X, (int)ev.Y);

            if (pal >= 0)
            {
                if (ev.Button == 3)
                {
                    PintaCore.Palette.SecondaryColor = palette[pal];
                }
                else if (ev.Button == 1)
                {
                    PintaCore.Palette.PrimaryColor = palette[pal];
                }
                else
                {
                    Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Palette Color"));
                    csd.TransientFor = PintaCore.Chrome.MainWindow;
                    csd.ColorSelection.PreviousColor     = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentColor      = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentAlpha      = palette[pal].GdkColorAlpha();
                    csd.ColorSelection.HasOpacityControl = true;

                    int response = csd.Run();

                    if (response == (int)Gtk.ResponseType.Ok)
                    {
                        palette[pal] = csd.ColorSelection.GetCairoColor();
                    }

                    csd.Destroy();
                }

                GdkWindow.Invalidate();
            }

            // Insert button press handling code here.
            return(base.OnButtonPressEvent(ev));
        }
Пример #2
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            if (swap_rect.ContainsPoint (ev.X, ev.Y)) {
                Color temp = PintaCore.Palette.PrimaryColor;
                PintaCore.Palette.PrimaryColor = PintaCore.Palette.SecondaryColor;
                PintaCore.Palette.SecondaryColor = temp;
                GdkWindow.Invalidate ();
            }

            if (primary_rect.ContainsPoint (ev.X, ev.Y)) {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Primary Color"));
                csd.ColorSelection.PreviousColor = PintaCore.Palette.PrimaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentColor = PintaCore.Palette.PrimaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentAlpha = PintaCore.Palette.PrimaryColor.GdkColorAlpha ();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run ();

                if (response == (int)Gtk.ResponseType.Ok) {
                    PintaCore.Palette.PrimaryColor = csd.ColorSelection.GetCairoColor ();
                }

                csd.Destroy ();
            } else if (secondary_rect.ContainsPoint (ev.X, ev.Y)) {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Secondary Color"));
                csd.ColorSelection.PreviousColor = PintaCore.Palette.SecondaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentColor = PintaCore.Palette.SecondaryColor.ToGdkColor ();
                csd.ColorSelection.CurrentAlpha = PintaCore.Palette.SecondaryColor.GdkColorAlpha ();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run ();

                if (response == (int)Gtk.ResponseType.Ok) {
                    PintaCore.Palette.SecondaryColor = csd.ColorSelection.GetCairoColor ();
                }

                csd.Destroy ();
            }

            int pal = PointToPalette ((int)ev.X, (int)ev.Y);

            if (pal >= 0) {
                if (ev.Button == 3)
                    PintaCore.Palette.SecondaryColor = palette[pal];
                else if (ev.Button == 1)
                    PintaCore.Palette.PrimaryColor = palette[pal];
                else {
                    Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog (Catalog.GetString ("Choose Palette Color"));
                    csd.ColorSelection.PreviousColor = palette[pal].ToGdkColor ();
                    csd.ColorSelection.CurrentColor = palette[pal].ToGdkColor ();
                    csd.ColorSelection.CurrentAlpha = palette[pal].GdkColorAlpha ();
                    csd.ColorSelection.HasOpacityControl = true;

                    int response = csd.Run ();

                    if (response == (int)Gtk.ResponseType.Ok) {
                        palette[pal] = csd.ColorSelection.GetCairoColor ();
                    }

                    csd.Destroy ();
                }

                GdkWindow.Invalidate ();
            }

            // Insert button press handling code here.
            return base.OnButtonPressEvent (ev);
        }
Пример #3
0
 public void Dispose()
 {
     dlg.Destroy();
 }