Exemple #1
0
        public Color this[String colorName]
        {
            get
            {
                IntPtr name = IntPtr.Zero;
                UInt32 colorType;

                try
                {
                    name      = Marshal.StringToHGlobalUni("Immersive" + colorName);
                    colorType = UXTheme.GetImmersiveColorTypeFromName(name);
                    if (colorType == 0xFFFFFFFF)
                    {
                        throw new InvalidOperationException();
                    }
                }
                finally
                {
                    if (name != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(name);
                        name = IntPtr.Zero;
                    }
                }

                return(this[colorType]);
            }
        }
Exemple #2
0
        public Color this[String colorName]
        {
            get
            {
                IntPtr name = IntPtr.Zero;
                UInt32 colorType;

                try
                {
                    name      = Marshal.StringToHGlobalUni("Immersive" + colorName);
                    colorType = UXTheme.GetImmersiveColorTypeFromName(name);
                    try
                    {
                        if (colorType == 0xFFFFFFFF)
                        {
                            throw new InvalidOperationException();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("The OS system on your machine is not Windows 10. This project required to use Windows 10.");
                    }
                }
                finally
                {
                    if (name != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(name);
                        name = IntPtr.Zero;
                    }
                }

                return(this[colorType]);
            }
        }
            public Padding?GetMargins(Graphics graphics, StateTypeId state)
            {
                VisualStyleRenderer renderer = GetRenderer(state);

                if (renderer == null)
                {
                    return(null);
                }


                // VisualStyleRenderer.GetMargins always throws an exception, make an explicit API call
                int stateId = state.ToInt32(null);

                UXTheme.MARGINS margins;
                IntPtr          hdc = graphics.GetHdc();

                try
                {
                    UXTheme.GetThemeMargins(renderer.Handle, hdc, this._partId.ToInt32(null), stateId,
                                            (int)MarginProperty.SizingMargins, IntPtr.Zero, out margins);
                    // TODO: include padding
                    return(new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight));
                }
                finally
                {
                    graphics.ReleaseHdc(hdc);
                }
            }
 protected override void OnPaint(PaintEventArgs e)
 {
     if (DwmAPI.DwmIsCompositionEnabled() && !DesignMode)
     {
         UXTheme.DrawText(e.Graphics, Text, this.Font, ClientRectangle, ForeColor, TextAlignToFormatFlags(TextAlign) | TextFormatFlags.NoClipping, UXTheme.TextStyle.Glowing);
     }
     else
     {
         base.OnPaint(e);
     }
 }
Exemple #5
0
 public Color this[UInt32 colorType] {
     get {
         UInt32 nativeColor = UXTheme.GetImmersiveColorFromColorSetEx(this._colorSet, colorType, false, 0);
         //if (nativeColor == 0)
         //    throw new InvalidOperationException();
         return(System.Windows.Media.Color.FromArgb(
                    (Byte)((0xFF000000 & nativeColor) >> 24),
                    (Byte)((0x000000FF & nativeColor) >> 0),
                    (Byte)((0x0000FF00 & nativeColor) >> 8),
                    (Byte)((0x00FF0000 & nativeColor) >> 16)
                    ));
     }
 }
Exemple #6
0
 public Color this[uint colorType]
 {
     get
     {
         uint nativeColor = UXTheme.GetImmersiveColorFromColorSetEx(_colorSet, colorType, false, 0);
         //if (nativeColor == 0)
         //    throw new InvalidOperationException();
         return(Color.FromArgb(
                    (byte)((0xFF000000 & nativeColor) >> 24),
                    (byte)((0x000000FF & nativeColor) >> 0),
                    (byte)((0x0000FF00 & nativeColor) >> 8),
                    (byte)((0x00FF0000 & nativeColor) >> 16)
                    ));
     }
 }
Exemple #7
0
        // HACK: GetAllColorNames collects the available color names by brute forcing the OS function.
        //   Since there is currently no known way to retrieve all possible color names,
        //   the method below just tries all indices from 0 to 0xFFF ignoring errors.
        public List <String> GetAllColorNames()
        {
            List <String> allColorNames = new List <String>();

            for (UInt32 i = 0; i < 0xFFF; i++)
            {
                IntPtr typeNamePtr = UXTheme.GetImmersiveColorNamedTypeByIndex(i);
                if (typeNamePtr != IntPtr.Zero)
                {
                    IntPtr typeName = (IntPtr)Marshal.PtrToStructure(typeNamePtr, typeof(IntPtr));
                    allColorNames.Add(Marshal.PtrToStringUni(typeName));
                }
            }

            return(allColorNames);
        }
Exemple #8
0
        private void Settings_Load(object sender, EventArgs e)
        {
            labelCopyrightSCTT.Text = labelCopyrightSCTT.Text.Replace("{sctt_ver}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            if (ApplicationEntryPoint.SCTCompatMode)
            {
                labelCopyrightSCT.Show();
                labelCopyrightSCT.Text = labelCopyrightSCT.Text.Replace("{sct_ver}", Assembly.LoadFrom("C:\\SCT\\SCT.exe").GetName().Version.ToString());
            }

            LoadSettings();

            if (ApplicationEntryPoint.SCTCompatMode)
            {
                bannerPictureBox.Image = Properties.Resources.logo_sct_t;
            }
            else
            {
                bannerPictureBox.Image = Properties.Resources.logo_sctt;
            }

            _ = UXTheme.SetWindowTheme(Handle, " ", " ");

            LayoutTaskbarPreview();
        }