Csharp/CSharp Tutorial/GUI Windows Forms/ColorDialog — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:15, 26 мая 2010

ColorDialog.AllFullOpen = false

using System;
using System.Drawing;
using System.ruponentModel;
using System.Windows.Forms;

public class ColorDialogFullOpenOff{
    public static void Main(){
    ColorDialog dlg=new ColorDialog();
    dlg.AllowFullOpen = false;
    dlg.ShowDialog();
  }
}

ColorDialog.FullOpen = true

using System;
using System.Drawing;
using System.ruponentModel;
using System.Windows.Forms;

public class ColorDialogFullOpen{
    public static void Main(){
    ColorDialog dlg=new ColorDialog();
    dlg.FullOpen = true;
    dlg.ShowDialog();
  }
}

ColorDialog With Custom Color

using System;        
using System.Drawing;
using System.ruponentModel;
using System.Windows.Forms;

public class ColorDialogWithCustomColor{
    public static void Main(){
    ColorDialog dlg=new ColorDialog();
    dlg.FullOpen = true;
    // Define the first five of the custom color settings
       // 0xAARRGGBB where AA is alpha, 
                        // RR is red, 
                     // GG is green 
                     // BB is blue 
    // expressed as the hexadecimal byte equivalent
    dlg.CustomColors = new int[5]{0x00ff8040, 0x00c256fe,
               0x00aa2005, 0x0004f002, 0x002194b5};
    dlg.ShowDialog();
  }
}

Display Color Dialog and get the selection

using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
public class MainClass{
    public static void Main() {
        System.Windows.Forms.ColorDialog colorDlg = new System.Windows.Forms.ColorDialog();
        Color currColor;
                
        colorDlg.AnyColor = true;
        colorDlg.ShowHelp = true;
        currColor = Color.BlueViolet;
 
        if (colorDlg.ShowDialog() != DialogResult.Cancel)  {
             currColor = colorDlg.Color;
            // Show current color.
             string strARGB = colorDlg.Color.ToString();
             MessageBox.Show(strARGB, "Color is:");
        }
    }
}

Set default color

using System;
using System.Drawing;
using System.ruponentModel;
using System.Windows.Forms;

public class ColorDialogInitColor{
    public static void Main(){
    ColorDialog dlg=new ColorDialog();
        dlg.Color = Color.PaleGoldenrod;
    dlg.ShowDialog();
  }
}