/*    public void HandlePen(object o, EventArgs ev)
    {
//        colorPopup.Popup();
        ColorSelectionDialog colorSel = 
            new ColorSelectionDialog("Select Pen Color");

        Gdk.Color currentColor = new Gdk.Color(0,0,0);
        currentColor.Red   = (ushort)(handwriting.Pen.PenColor.R * 65535);
        currentColor.Green = (ushort)(handwriting.Pen.PenColor.G * 65535);
        currentColor.Blue  = (ushort)(handwriting.Pen.PenColor.B * 65535);

        colorSel.ColorSelection.CurrentColor = currentColor;
        colorSel.ColorSelection.CurrentAlpha = 
            Convert.ToUInt16(handwriting.Pen.PenColor.A * 65535);
        colorSel.ColorSelection.HasOpacityControl = true;

        colorSel.ColorSelection.ColorChanged += ColorChanged;

        colorSel.ShowAll();
    }*/

    public void ColorChanged(object o, ColorSelectedEventArgs ev)
    {
        handwriting.Pen.PenColor = new Cairo.Color(
            (double)ev.NewColor.Red   / 65535.0,
            (double)ev.NewColor.Green / 65535.0,
            (double)ev.NewColor.Blue  / 65535.0,
            1.0);
    }
    public void ColorActivated(object o, EventArgs ev)
    {
        if(!(o is ImageMenuItem)) {
            return;
        }

        ImageMenuItem item = o as ImageMenuItem;

        if(!(item.Image is ColorBlockWidget)) {
            return;
        }

        ColorBlockWidget block = item.Image as ColorBlockWidget;

        ColorSelectedEventArgs args = new ColorSelectedEventArgs(
            block.Color, item);

        OnColorSelected(args);
    }
 private void tab_ColorSelected(object sender, ColorSelectedEventArgs args)
 {
     SelectColor(args);
 }
    protected void OnColorSelected(ColorSelectedEventArgs args)
    {
        SetMainColor(args.Sender);

        if(ColorSelected != null) {
            ColorSelected((object)args.Sender, args);
        }

        return;
    }