Esempio n. 1
0
        public static void SetColor(IntPtr layoutHandle, Settings settings)
        {
            if (layoutHandle == currentLanguageHanlder)
            {
                return;
            }
            currentLanguageHanlder = layoutHandle;

            string languageName = null;

            foreach (InputLanguage language in installedInputLanguages)
            {
                if (language.Handle == layoutHandle)
                {
                    languageName = language.Culture.ThreeLetterWindowsLanguageName;
                    break;
                }
            }


            try
            {
                if (isWin10)
                {
                    if (languageName == settings.DefaultLayoutName)
                    {
                        accentPolicy.GradientColor = settings.Win10DefaultLayoutColorScheme;
                    }
                    else
                    {
                        accentPolicy.GradientColor = settings.Win10AlternativeLayoutColorScheme;
                    }
                }
                else
                {
                    if (languageName == null)
                    {
                        return;
                    }

                    if (!DwmApi.DwmIsCompositionEnabled())
                    {
                        return;
                    }
                    var colorizationParams = (languageName == settings.DefaultLayoutName)
                        ? settings.DefaultLayoutColorScheme
                        : settings.AlternativeLayoutColorScheme;
                    DwmApi.DwmSetColorizationParameters(ref colorizationParams, 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw;
            }
        }
Esempio n. 2
0
 private void buttonPickAlternativeLayoutColor_Click(object sender, EventArgs e)
 {
     try
     {
         if (isWin10)
         {
             settings.Win10AlternativeLayoutColorScheme = GetWin10TaskbarColorAsInt();
         }
         else
         {
             DwmApi.WDM_COLORIZATION_PARAMS colorizationParams;
             DwmApi.DwmGetColorizationParameters(out colorizationParams);
             settings.AlternativeLayoutColorScheme = colorizationParams;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Не удалось получить текущую цветовую схему", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Esempio n. 3
0
 private static byte[] SerializeColorizationParams(DwmApi.WDM_COLORIZATION_PARAMS colorizationParams)
 {
     var stream = new MemoryStream();
     stream.Write(BitConverter.GetBytes(colorizationParams.Color1), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Color2), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Opaque), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Intensity), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Unknown1), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Unknown2), 0, sizeof (uint));
     stream.Write(BitConverter.GetBytes(colorizationParams.Unknown3), 0, sizeof (uint));
     return stream.ToArray();
 }