예제 #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;
        }
예제 #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;
		}
예제 #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;
		}
예제 #4
0
파일: ColorDialog.cs 프로젝트: mhusen/Eto
			/// <summary>
			/// Raises the color changed event.
			/// </summary>
			public void OnColorChanged(ColorDialog widget, EventArgs e)
			{
				widget.Platform.Invoke(() => widget.OnColorChanged(e));
			}
예제 #5
0
 /// <summary>
 /// Raises the color changed event.
 /// </summary>
 public void OnColorChanged(ColorDialog widget, EventArgs e)
 {
     widget.Platform.Invoke(() => widget.OnColorChanged(e));
 }