コード例 #1
0
        public int GetInteger(IntegerProperty prop)
        {
            //valid values are 0x961 to 0x978
            if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)IntegerProperty.ImageCount, (int)IntegerProperty.MinDpi5))
            {
                throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(IntegerProperty));
            }

            int val = 0;

            lastHResult = UxTheme.GetThemeInt(this, part, state, (int)prop, ref val);
            return(val);
        }
コード例 #2
0
        public static Image GetDwmWindowButton(AeroTitlebarButtonPart button, TitlebarButtonState state)
        {
            const int tmtAtlasrect  = 8002;
            const int tmtImagecount = 2401;

            using (var vs = GetDwmWindowVisualTheme())
            {
                using (var hInstance = LoadAeroTheme())
                {
                    Image result;
                    using (var nWindow = CreateNativeWindow())
                    {
                        using (var theme = LoadAeroThemeData(nWindow))
                        {
                            var atlas = GetImageAtlasFromTheme(vs, hInstance);
                            if (atlas == null)
                            {
                                return(null);
                            }

                            var rect = GetThemeRect(theme, (int)button, (int)state, tmtAtlasrect);

                            result = Slice(atlas, rect.Location, rect.Size);
                            if (state != TitlebarButtonState.None)
                            {
                                //Slice the buttons
                                UxTheme.GetThemeInt(theme, (int)button, (int)state, tmtImagecount, out var count);

                                var buttonSize = rect.Height / count;

                                var startPoint = Point.Empty;
                                var btnSize    = new Size(rect.Width, buttonSize);
                                startPoint.Offset(0, buttonSize * ((int)state - 1));

                                var buttonRect = new Rectangle(startPoint, btnSize);
                                buttonRect.Inflate(-1, -1);
                                result = Slice(result, buttonRect.Location, buttonRect.Size);
                            }
                        }
                    }

                    return(result);
                }
            }
        }