Exemplo n.º 1
0
        /// <summary>
        /// Displays an color picker dialog.
        /// <para>REQUIREMENT: calling thread must be STAThread.</para>
        /// </summary>
        /// <param name="defaultColor">Default color.</param>
        /// <returns>Picked or default color in case the selection is cancelled.</returns>
        public static Bgr<byte> PickColor(Bgr<byte> defaultColor = default(Bgr<byte>))
        {            
            Bgr<byte> color = defaultColor;
            using (ColorDialog dialog = new ColorDialog())
            {
                dialog.Color = new Eto.Drawing.Color { Bb = defaultColor.B, Gb = defaultColor.G, Rb = defaultColor.R };
                var result = dialog.ShowDialog(null);
                if (result == DialogResult.Ok)
                    color = new Bgr<byte> { B = (byte)dialog.Color.Bb, G = (byte)dialog.Color.Gb, R = (byte)dialog.Color.Rb };
            }

            return color;
        }
Exemplo n.º 2
0
		Control PickColor ()
		{
			var button = new Button { Text = "Pick Color" };
			button.Click += delegate {
				var dialog = new ColorDialog ();
				dialog.ColorChanged += delegate {
					// you need to handle this event for OS X, where the dialog is a floating window
					Log.Write (dialog, "ColorChanged, Color: {0}", dialog.Color);
				};
				var result = dialog.ShowDialog (this.ParentWindow);
				if (result == DialogResult.Ok) {
					Log.Write (dialog, "Result: {0}, Color: {1}", result, dialog.Color);
				}
				else
					Log.Write (dialog, "Result: {0}", result);
			};
			return button;
		}
Exemplo n.º 3
0
		Control PickColorWithStartingColor()
		{
			var button = new Button { Text = "Pick Color with initial starting color (green)" };
			button.Click += delegate
			{
				var dialog = new ColorDialog
				{
					Color = Colors.Lime
				};
				dialog.ColorChanged += delegate
				{
					// need to handle this event for OS X, where the dialog is a floating window
					Log.Write(dialog, "ColorChanged, Color: {0}", dialog.Color);
				};
				var result = dialog.ShowDialog(ParentWindow);
				if (result == DialogResult.Ok)
				{
					Log.Write(dialog, "Result: {0}, Color: {1}", result, dialog.Color);
				}
				else
					Log.Write(dialog, "Result: {0}", result);
			};
			return button;
		}
Exemplo n.º 4
0
			/// <summary>
			/// Raises the color changed event.
			/// </summary>
			public void OnColorChanged(ColorDialog widget, EventArgs e)
			{
				widget.Platform.Invoke(() => widget.OnColorChanged(e));
			}
Exemplo n.º 5
0
 /// <summary>
 /// Raises the color changed event.
 /// </summary>
 public void OnColorChanged(ColorDialog widget, EventArgs e)
 {
     widget.Platform.Invoke(() => widget.OnColorChanged(e));
 }