Exemple #1
0
        public string chooseColor(ScriptScopeContext scope, string defaultColor) => scope.DoWindow(w => {
            var cc           = new ChooseColor();
            cc.lStructSize   = Marshal.SizeOf(cc);
            var lpCustColors = Marshal.AllocCoTaskMem(16 * sizeof(int));
            try
            {
                Marshal.Copy(customColors, 0, lpCustColors, 16);
                cc.hwndOwner    = w;
                cc.lpCustColors = lpCustColors;
                cc.Flags        = ChooseColorFlags.FullOpen | ChooseColorFlags.RgbInit;
                var c           = ColorTranslator.FromHtml(defaultColor);
                cc.rgbResult    = ColorTranslator.ToWin32(c);

                if (!ChooseColor(ref cc))
                {
                    return((string)null);
                }

                c = ColorTranslator.FromWin32(cc.rgbResult);
                return(ColorTranslator.ToHtml(c));
            }
            finally
            {
                Marshal.FreeCoTaskMem(lpCustColors);
            }
        });
Exemple #2
0
 internal static extern bool ChooseColor(ref ChooseColor cc);