Example #1
0
        private IColor GetColorByColorSelector()
        {
            //Set the initial color to be diaplyed when the dialog opens
            IColor pColor;

            pColor     = new RgbColorClass();
            pColor.RGB = 255;

            IColorSelector pSelector;

            pSelector       = new ColorSelectorClass();
            pSelector.Color = pColor;

            // Display the dialog
            if (pSelector.DoModal(0))
            {
                IColor pOutColor;
                pOutColor = pSelector.Color;
                return(pOutColor);
            }
            else
            {
                return(pColor);
            }
        }
		private void Button1_Click(object sender, System.EventArgs e)
		{
			IColorSelector ColorSelector = null;
			if (Buttons[0] == sender)
			{
				// Create color selector object.
				ColorSelector = new ColorSelectorClass();
				// Open the selector dialog.
				if (ColorSelector.DoModal(this.Handle.ToInt32()))
				{
					//
					// A Color was selected (if the above method returned false,
					// this indicates that the user pressed Cancel).
					txtStartColor.BackColor = System.Drawing.ColorTranslator.FromOle(ColorSelector.Color.RGB);
				}
				UpdateRamp();

			}
			else
			{
				ColorSelector = new ColorSelectorClass();
				if (ColorSelector.DoModal(this.Handle.ToInt32()))
					txtEndColor.BackColor = System.Drawing.ColorTranslator.FromOle(ColorSelector.Color.RGB);
				UpdateRamp();
			}
		}
 private void ToColorPictureBox_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor       = Cursors.Default;
         this.Enabled = false;
         IColorSelector ToColorSelector = new ColorSelectorClass()
         {
             Color = ToC,
         };
         if (ToColorSelector.DoModal(0))
         {
             ToC = ToColorSelector.Color as IRgbColor;
             if (ToC == null)
             {
                 throw new Exception("选择了非RGB颜色。。。");
             }
             else
             {
                 ResetT();
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.ToString());
         ToC = new RgbColorClass()
         {
             Transparency = T.A,
             Red          = T.R,
             Green        = T.G,
             Blue         = T.B,
         };
     }
     finally
     {
         this.Enabled = true;
         CreateColorRamp();
     }
 }
        private IColor GetColorByColorSelector()
        {
            //Set the initial color to be diaplyed when the dialog opens
            IColor pColor;
            pColor = new RgbColorClass();
            pColor.RGB = 255;

            IColorSelector pSelector;
            pSelector = new ColorSelectorClass();
            pSelector.Color = pColor;

            // Display the dialog
            if (pSelector.DoModal(0))
            {
                IColor pOutColor;
                pOutColor = pSelector.Color;
                return pOutColor;
            }
            else return pColor;
        }