using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;

namespace iTripLog.Edit
{
    public sealed class ColorDialog
    {
        [DllImport("commdlg.dll", EntryPoint = "ChooseColor")]
        public static extern bool CreateColorDialog(CHOOSECOLOR chooseColor);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr GetActiveWindow();


        [StructLayout(LayoutKind.Sequential)]
        public class CHOOSECOLOR
        {
            private int lStructSize;
            internal IntPtr hwndOwner; // 依托窗口
            private IntPtr hInstance;
            internal int rgbResult; // 通过该值获得选择的颜色值
            internal IntPtr lpCustColors; // 用户自己定义的颜色，也就是现实在颜色框下方的两排
            internal uint Flags; // 选择框的类型
            private int lCustData;
            private IntPtr lpfnHook;
            private IntPtr lpTemplateName;
            public CHOOSECOLOR()
            {
                this.lStructSize = Marshal.SizeOf(this);
                this.hwndOwner = IntPtr.Zero;
                this.hInstance = IntPtr.Zero;
                this.rgbResult = 0xffffff;
                this.lpCustColors = IntPtr.Zero;
                this.Flags = 0;
                this.lCustData = 0;
                this.lpfnHook = IntPtr.Zero;
                this.lpTemplateName = IntPtr.Zero;
            }
        }

        [Flags]
        public enum ColorFlags : uint
        {
            AnyColor = 0x100,
            FullOpen = 2,
            PreventFullOpen = 4,
            RgbInit = 1,
            SolidColor = 0x80
        }
    }
}
