| 程序代码: | 
<CommandMethod("Cmd1")> _
    Public Shared Sub testColor()
        Dim clr As New Autodesk.AutoCAD.Windows.ColorDialog()
        If clr.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
            MessageBox.Show("Color was Not Selected", "Oooooops")
            Return
        End If
        If clr.Color.IsByAci Then
            ' get the RGB values of the Color.ColorIndex
            Dim colorIndex As Integer = clr.Color.ColorIndex
            Dim colorByte As System.Byte = System.Convert.ToByte(colorIndex)
            Dim rgb As Integer = Autodesk.AutoCAD.Colors.EntityColor.LookUpRgb(colorByte)
            Dim b As Long = (rgb And &HFFL)
            Dim g As Long = (rgb And &HFF00L) >> 8
            Dim r As Long = rgb >> 16
            ' not really required for this sample ..        
            Dim ri As Integer = System.Convert.ToInt32(r)
            Dim gi As Integer = System.Convert.ToInt32(g)
            Dim bi As Integer = System.Convert.ToInt32(b)
            ' Tell us about it !
            MessageBox.Show("Color is : " + clr.Color.ToString() + vbLf & "Color Index ToByte : " + colorByte.ToString() + vbLf & "Translated RGB int : " + rgb.ToString() + vbLf & "Translated R,G,B : " + ri.ToString() + "," + gi.ToString() + "," + bi.ToString(), "Color is by ACI")
        ElseIf clr.Color.IsByLayer Then
            MessageBox.Show("Color Code is : " + clr.Color.ToString(), "Color is By LAyer")
        ElseIf clr.Color.IsByBlock Then
            MessageBox.Show("Color Code is : " + clr.Color.ToString(), "Color is By Block")
        ElseIf clr.Color.HasBookName Then
            MessageBox.Show("Color Code is : " + clr.Color.ToString() + vbLf & " To RGB : " + clr.Color.Red.ToString() + "," + clr.Color.Green.ToString() + "," + clr.Color.Blue.ToString(), "Color Has Book Name")
        Else
            MessageBox.Show("Color Code is : " + clr.Color.ToString() + vbLf & " To RGB : " + clr.Color.Red.ToString() + "," + clr.Color.Green.ToString() + "," + clr.Color.Blue.ToString(), "Color is True Color")
        End If
    End Sub
http://www.theswamp.org/index.php?topic=14977.0
[本日志由 tiancao1001 于 2018-12-07 12:57 AM 编辑]
| 
 | 
暂时没有评论
| 发表评论 - 不要忘了输入验证码哦! | 
 
				
 用户登陆
 站点日历
 站点统计
 最新评论
 Autodesk.AutoCAD.Windows.ColorDialog Color lab   [ 日期:2018-12-05 ]   [ 来自: