Example #1
0
        //public static void UpdateThemeResources(ResourceDictionary dictionary)
        //{
        //    dictionary[@"WindowBackground"] = new SolidColorBrush(GetWindowBackgroundColor());

        //    SetBrush(dictionary, "WindowForeground", @"ImmersiveApplicationTextDarkTheme");
        //    ReplaceBrush(dictionary, "CottonSwabSliderThumb", @"ImmersiveSystemAccent");
        //    ReplaceBrush(dictionary, "CottonSwabSliderTrackBackground", SystemParameters.HighContrast ? "ImmersiveSystemAccentLight1" : "ImmersiveControlDarkSliderTrackBackgroundRest");
        //    SetBrushWithOpacity(dictionary, "CottonSwabSliderTrackBackgroundHover", SystemParameters.HighContrast ? "ImmersiveSystemAccentLight1" : "ImmersiveDarkBaseMediumHigh", SystemParameters.HighContrast ? 1.0 : 0.25);
        //    SetBrush(dictionary, "CottonSwabSliderTrackBackgroundPressed", @"ImmersiveControlDarkSliderTrackBackgroundRest");
        //    ReplaceBrush(dictionary, "CottonSwabSliderTrackFill", @"ImmersiveSystemAccentLight1");
        //    SetBrush(dictionary, "CottonSwabSliderThumbHover", @"ImmersiveControlDarkSliderThumbHover");
        //    SetBrush(dictionary, "CottonSwabSliderThumbPressed", @"ImmersiveControlDarkSliderThumbHover");
        //}

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Color GetWindowBackgroundColor()
        {
            string resource;

            if (SystemInformation.HighContrast)
            {
                resource = "ImmersiveApplicationBackground";
            }
            else if (UserSystemPreferencesService.UseAccentColor)
            {
                resource = IsWindowTransparencyEnabled ? "ImmersiveSystemAccentDark2" : "ImmersiveSystemAccentDark1";
            }
            else
            {
                resource = "ImmersiveDarkChromeMedium";
            }

            Color color = AccentColorService.GetColorByTypeName(resource);

            //return color;
            //color.A = (byte)(IsWindowTransparencyEnabled ? 190 : 255);
            return(Color.FromArgb(IsWindowTransparencyEnabled ? 190 : 255, color.R, color.G, color.B));
        }
Example #2
0
        public AppItemViewModel(IAudioMixerViewModelCallback callback, EarTrumpetAudioSessionModelGroup sessions)
        {
            _sessions = sessions;
            // select a session at random as sndvol does.
            var session = _sessions.Sessions.First();

            IconHeight = IconWidth = 24;
            SessionId  = session.SessionId;
            ProcessId  = session.ProcessId;
            ExeName    = GetExeName(session.DisplayName);
            IsDesktop  = session.IsDesktop;

            _volume = Convert.ToInt32(Math.Round((session.Volume * 100),
                                                 MidpointRounding.AwayFromZero));
            _isMuted  = session.IsMuted;
            _callback = callback;

            if (session.IsDesktop)
            {
                try
                {
                    if (Path.GetExtension(session.IconPath) == ".dll")
                    {
                        Icon = IconExtensions.ExtractIconFromDll(session.IconPath);
                    }
                    else
                    {
                        // override for SpeechRuntime.exe (Repo -> HEY CORTANA)
                        if (session.IconPath.ToLowerInvariant().Contains("speechruntime.exe"))
                        {
                            var sysType = Environment.Is64BitOperatingSystem ? "SysNative" : "System32";
                            Icon = IconExtensions.ExtractIconFromDll(Path.Combine("%windir%", sysType, "Speech\\SpeechUX\\SpeechUXWiz.exe"), 0);
                        }
                        else
                        {
                            Icon = System.Drawing.Icon.ExtractAssociatedIcon(session.IconPath).ToImageSource();
                        }
                    }
                }
                catch
                {
                    // ignored
                }
                if (Icon == null)
                {
                    Background = new SolidColorBrush(AccentColorService.GetColorByTypeName("ImmersiveSystemAccent"));
                }
                else
                {
                    Background = new SolidColorBrush(Colors.Transparent);
                }
            }
            else
            {
                if (File.Exists(session.IconPath)) //hack until we invoke the resource manager correctly.
                {
                    Icon = new BitmapImage(new Uri(session.IconPath));
                }
                Background = new SolidColorBrush(AccentColorService.FromABGR(session.BackgroundColor));
            }
        }