Пример #1
0
        private void _InitializeWindowCornerRadius()
        {
            // The radius of window corners isn't exposed as a true system parameter.
            // It instead is a logical size that we're approximating based on the current theme.
            // There aren't any known variations based on theme color.
            Assert.IsNeitherNullNorEmpty(UxThemeName);

            // These radii are approximate.  The way WPF does rounding is different than how
            //     rounded-rectangle HRGNs are created, which is also different than the actual
            //     round corners on themed Windows.  For now we're not exposing anything to
            //     mitigate the differences.
            var cornerRadius = default(CornerRadius);

            // This list is known to be incomplete and very much not future-proof.
            // On XP there are at least a couple of shipped themes that this won't catch,
            // "Zune" and "Royale", but WPF doesn't know about these either.
            // If a new theme was to replace Aero, then this will fall back on "classic" behaviors.
            // This isn't ideal, but it's not the end of the world.  WPF will generally have problems anyways.
            switch (UxThemeName.ToUpperInvariant())
            {
            case "LUNA":
                cornerRadius = new CornerRadius(6, 6, 0, 0);
                break;

            case "AERO":
                // Aero has two cases.  One with glass and one without...
                if (NativeMethodsShell.DwmIsCompositionEnabled())
                {
                    cornerRadius = new CornerRadius(8);
                }
                else
                {
                    cornerRadius = new CornerRadius(6, 6, 0, 0);
                }
                break;

            case "CLASSIC":
            case "ZUNE":
            case "ROYALE":
            default:
                cornerRadius = new CornerRadius(0);
                break;
            }

            WindowCornerRadius = cornerRadius;
        }
Пример #2
0
        // Most properties exposed here have a way of being queried directly
        // and a way of being notified of updates via a window message.
        // This region is a grouping of both, for each of the exposed properties.

        private void _InitializeIsGlassEnabled()
        {
            IsGlassEnabled = NativeMethodsShell.DwmIsCompositionEnabled();
        }