Exemplo n.º 1
0
        public void FixValue()
        {
#if RAW_HSV
            binding.SetMin(
                (int)Math.Round(internalValueMin[0] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[1] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[2] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[3] * 255, MidpointRounding.AwayFromZero),
                isActive);

            binding.SetMax(
                (int)Math.Round(internalValueMax[0] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[1] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[2] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[3] * 255, MidpointRounding.AwayFromZero),
                isActive);
#else
            if (binding.ColorSpace == Data.ColorSpace.HSVA)
            {
                var ivmin = (float[])internalValueMin.Clone();
                var ivmax = (float[])internalValueMax.Clone();
                convertRGB2HSV(ivmin);
                convertRGB2HSV(ivmax);

                binding.SetMin(
                    (int)Math.Round(ivmin[0] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmin[1] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmin[2] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmin[3] * 255, MidpointRounding.AwayFromZero),
                    isActive);

                binding.SetMax(
                    (int)Math.Round(ivmax[0] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmax[1] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmax[2] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(ivmax[3] * 255, MidpointRounding.AwayFromZero),
                    isActive);
            }
            else
            {
                binding.SetMin(
                    (int)Math.Round(internalValueMin[0] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMin[1] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMin[2] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMin[3] * 255, MidpointRounding.AwayFromZero),
                    isActive);

                binding.SetMax(
                    (int)Math.Round(internalValueMax[0] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMax[1] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMax[2] * 255, MidpointRounding.AwayFromZero),
                    (int)Math.Round(internalValueMax[3] * 255, MidpointRounding.AwayFromZero),
                    isActive);
            }
#endif
        }
Exemplo n.º 2
0
        public void Update()
        {
            if (binding != null)
            {
                internalValueMax[0] = binding.R.Max / 255.0f;
                internalValueMax[1] = binding.G.Max / 255.0f;
                internalValueMax[2] = binding.B.Max / 255.0f;
                internalValueMax[3] = binding.A.Max / 255.0f;

                internalValueMax[0] = binding.R.Min / 255.0f;
                internalValueMax[1] = binding.G.Min / 255.0f;
                internalValueMax[2] = binding.B.Min / 255.0f;
                internalValueMax[3] = binding.A.Min / 255.0f;
            }

            Console.WriteLine("Not implemented. (HSV, gauss, range)");

            if (Manager.NativeManager.ColorEdit4(Label + id, internalValueMax, swig.ColorEditFlags.None))
            {
                binding.SetMax(
                    (int)(internalValueMax[0] * 255),
                    (int)(internalValueMax[1] * 255),
                    (int)(internalValueMax[2] * 255),
                    (int)(internalValueMax[3] * 255));
            }

            if (Manager.NativeManager.ColorEdit4(Label + id, internalValueMin, swig.ColorEditFlags.None))
            {
                binding.SetMin(
                    (int)(internalValueMin[0] * 255),
                    (int)(internalValueMin[1] * 255),
                    (int)(internalValueMin[2] * 255),
                    (int)(internalValueMin[3] * 255));
            }
        }
Exemplo n.º 3
0
        public void FixValue()
        {
            binding.SetMin(
                (int)(internalValueMin[0] * 255),
                (int)(internalValueMin[1] * 255),
                (int)(internalValueMin[2] * 255),
                (int)(internalValueMin[3] * 255),
                isActive);

            binding.SetMax(
                (int)(internalValueMax[0] * 255),
                (int)(internalValueMax[1] * 255),
                (int)(internalValueMax[2] * 255),
                (int)(internalValueMax[3] * 255),
                isActive);
        }
Exemplo n.º 4
0
        public override void Update()
        {
            isPopupShown = false;

            if (binding != null)
            {
                internalValueMax[0] = binding.R.Max / 255.0f;
                internalValueMax[1] = binding.G.Max / 255.0f;
                internalValueMax[2] = binding.B.Max / 255.0f;
                internalValueMax[3] = binding.A.Max / 255.0f;

                internalValueMax[0] = binding.R.Min / 255.0f;
                internalValueMax[1] = binding.G.Min / 255.0f;
                internalValueMax[2] = binding.B.Min / 255.0f;
                internalValueMax[3] = binding.A.Min / 255.0f;
            }

            var colorSpace = binding.ColorSpace == Data.ColorSpace.RGBA ? swig.ColorEditFlags.RGB : swig.ColorEditFlags.HSV;

            Manager.NativeManager.PushItemWidth(150);

            if (Manager.NativeManager.ColorEdit4(id, internalValueMin, swig.ColorEditFlags.NoOptions | colorSpace))
            {
                binding.SetMin(
                    (int)(internalValueMin[0] * 255),
                    (int)(internalValueMin[1] * 255),
                    (int)(internalValueMin[2] * 255),
                    (int)(internalValueMin[3] * 255));
            }

            Popup();

            Manager.NativeManager.SameLine();
            Manager.NativeManager.Text("最小");

            if (Manager.NativeManager.ColorEdit4(id, internalValueMax, swig.ColorEditFlags.NoOptions | colorSpace))
            {
                binding.SetMax(
                    (int)(internalValueMax[0] * 255),
                    (int)(internalValueMax[1] * 255),
                    (int)(internalValueMax[2] * 255),
                    (int)(internalValueMax[3] * 255));
            }

            Popup();

            Manager.NativeManager.SameLine();
            Manager.NativeManager.Text("最大");

            Manager.NativeManager.PopItemWidth();
        }
Exemplo n.º 5
0
        public void FixValue()
        {
            binding.SetMin(
                (int)Math.Round(internalValueMin[0] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[1] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[2] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMin[3] * 255, MidpointRounding.AwayFromZero),
                isActive);

            binding.SetMax(
                (int)Math.Round(internalValueMax[0] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[1] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[2] * 255, MidpointRounding.AwayFromZero),
                (int)Math.Round(internalValueMax[3] * 255, MidpointRounding.AwayFromZero),
                isActive);
        }
Exemplo n.º 6
0
 private void btn_color_min_Click(object sender, EventArgs e)
 {
     if (binding != null)
     {
         colorDialog.Color = Color.FromArgb(binding.R.Min, binding.G.Min, binding.B.Min);
         if (Binding.ColorSpace == Data.ColorSpace.HSVA)
         {
             colorDialog.Color = HSVToRGB(colorDialog.Color);
             colorDialog.ShowDialog();
             colorDialog.Color = RGBToHSV(colorDialog.Color);
         }
         else
         {
             colorDialog.ShowDialog();
         }
         binding.SetMin(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B);
     }
     else
     {
     }
 }