protected override void SetPercent(float percent)
 {
     m_selectedColor.Lightness = percent / 100;
     SelectedHSLColor = m_selectedColor;
     base.SetPercent(percent);
 }
 void OnWheelColorChanged(object sender, EventArgs e)
 {
     m_selectedColor.Hue = m_colorWheel.SelectedHSLColor.Hue;
     m_selectedColor.Saturation = m_colorWheel.SelectedHSLColor.Saturation;
     SelectedHSLColor = m_selectedColor;
 }
 protected override void SetPercent(PointF mousepoint)
 {
     RectangleF cr = ClientRectangleF;
     RectangleF br = BarRectangle;
     mousepoint.X += cr.X - br.X;
     mousepoint.Y += cr.Y - br.Y;
     m_selectedColor.Lightness = GetPercentSet(BarRectangle, Orientation, mousepoint);
     SelectedHSLColor = m_selectedColor;
     Refresh();
 }
 void OnLightnessColorChanged(object sender, EventArgs e)
 {
     m_selectedColor.Lightness = m_colorBar.SelectedHSLColor.Lightness;
     SelectedHSLColor = m_selectedColor;
 }
Esempio n. 5
0
		void SetColor(PointF mousepoint)
		{
			if (WheelRectangle.Contains(mousepoint) == false)
				return;

			PointF center = Util.Center(ColorWheelRectangle);
			double radius = Radius(ColorWheelRectangle);
			double dx = Math.Abs(mousepoint.X - center.X);
			double dy = Math.Abs(mousepoint.Y - center.Y);
			double angle = Math.Atan(dy / dx) / Math.PI * 180;
			double dist = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5);
			double saturation = dist/radius;
			//if (dist > radius + 5) // give 5 pixels slack
			//	return;
			if (dist < 6)
				saturation = 0; // snap to center

			if (mousepoint.X < center.X)
				angle = 180 - angle;
			if (mousepoint.Y > center.Y)
				angle = 360 - angle;

			SelectedHSLColor = new HSLColor(angle, saturation, SelectedHSLColor.Lightness);
		}
Esempio n. 6
0
		protected override bool ProcessDialogKey(Keys keyData)
		{
			HSLColor c = SelectedHSLColor;
			double hue = c.Hue;
			int step = 1;
			if ((keyData & Keys.Control) == Keys.Control)
				step = 5;

			if ((keyData & Keys.Up) == Keys.Up)
				hue += step;
			if ((keyData & Keys.Down) == Keys.Down)
				hue -= step;
			if (hue >= 360)
				hue = 0;
			if (hue < 0)
				hue = 359;

			if (hue != c.Hue)
			{
				c.Hue = hue;
				SelectedHSLColor = c;
				return true;
			}
			return base.ProcessDialogKey(keyData);
		}
Esempio n. 7
0
        /*
		public static bool operator != (HSLColor left, HSLColor right)
		{
			return !(left == right);
		}
		public static bool operator == (HSLColor left, HSLColor right)
		{
			return (left.Hue == right.Hue && 
					left.Lightness == right.Lightness && 
					left.Saturation == right.Saturation);
		}*/

	    public bool Equals(HSLColor other) {
	        return m_hue.Equals(other.m_hue) && m_saturation.Equals(other.m_saturation) && m_lightness.Equals(other.m_lightness);
	    }
Esempio n. 8
0
 protected override void SetPercent(float percent)
 {
     base.SetPercent(percent);
     m_selectedColor.Lightness = percent / 100;
     SelectedHSLColor          = m_selectedColor;
 }