Пример #1
0
        private void GenerateProfileStack(string focusedKey = null)
        {
            selected_item = null;
            this.profiles_stack.Children.Clear();

            /*Image profile_desktop = new Image
             * {
             *  Tag = Global.Configuration.desktop_profile,
             *  Source = new BitmapImage(new Uri(@"Resources/desktop_icon.png", UriKind.Relative)),
             *  ToolTip = "Desktop Settings",
             *  Margin = new Thickness(0, 5, 0, 0)
             * };
             * profile_desktop.MouseDown += ProfileImage_MouseDown;
             * this.profiles_stack.Children.Add(profile_desktop);*/

            //Included Game Profiles
            foreach (string profile_k in Global.Configuration.ProfileOrder)
            {
                if (!Global.LightingStateManager.Events.ContainsKey(profile_k))
                {
                    continue;
                }

                Profiles.Application application = (Profiles.Application)Global.LightingStateManager.Events[profile_k];
                ImageSource          icon        = application.Icon;
                UserControl          control     = application.Control;
                if (icon != null && control != null)
                {
                    Image profile_image;
                    if (application is GenericApplication)
                    {
                        GenericApplicationSettings settings = (application.Settings as GenericApplicationSettings);
                        profile_image = new Image
                        {
                            Tag     = application,
                            Source  = icon,
                            ToolTip = settings.ApplicationName + " Settings",
                            Margin  = new Thickness(0, 5, 0, 0)
                        };
                        profile_image.MouseDown += ProfileImage_MouseDown;

                        Image profile_remove = new Image
                        {
                            Source              = new BitmapImage(new Uri(@"Resources/removeprofile_icon.png", UriKind.Relative)),
                            ToolTip             = $"Remove {settings.ApplicationName} Profile",
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment   = VerticalAlignment.Bottom,
                            Height              = 16,
                            Width      = 16,
                            Visibility = Visibility.Hidden,
                            Tag        = profile_k
                        };
                        profile_remove.MouseDown += RemoveProfile_MouseDown;

                        Grid profile_grid = new Grid
                        {
                            Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)),
                            Margin     = new Thickness(0, 5, 0, 0),
                            Tag        = profile_remove
                        };

                        profile_grid.MouseEnter += Profile_grid_MouseEnter;
                        profile_grid.MouseLeave += Profile_grid_MouseLeave;

                        profile_grid.Children.Add(profile_image);
                        profile_grid.Children.Add(profile_remove);

                        this.profiles_stack.Children.Add(profile_grid);
                    }
                    else
                    {
                        profile_image = new Image
                        {
                            Tag        = application,
                            Source     = icon,
                            ToolTip    = application.Config.Name + " Settings",
                            Margin     = new Thickness(0, 5, 0, 0),
                            Visibility = application.Settings.Hidden ? Visibility.Collapsed : Visibility.Visible
                        };
                        profile_image.MouseDown += ProfileImage_MouseDown;
                        this.profiles_stack.Children.Add(profile_image);
                    }

                    if (application.Config.ID.Equals(focusedKey))
                    {
                        this.FocusedApplication = application;
                        this.TransitionToProfile(profile_image);
                    }
                }
            }

            //Add new profiles button
            profile_add = new Image
            {
                Source  = new BitmapImage(new Uri(@"Resources/addprofile_icon.png", UriKind.Relative)),
                ToolTip = "Add a new Lighting Profile",
                Margin  = new Thickness(0, 5, 0, 0)
            };
            profile_add.MouseDown += AddProfile_MouseDown;
            this.profiles_stack.Children.Add(profile_add);

            //Show hidden profiles button
            profile_hidden = new Image
            {
                Source  = _not_visible,
                ToolTip = "Toggle Hidden profiles' visibility",
                Margin  = new Thickness(0, 5, 0, 0)
            };
            profile_hidden.MouseDown += HiddenProfile_MouseDown;
            this.profiles_stack.Children.Add(profile_hidden);
        }
Пример #2
0
        private void GenerateProfileStack()
        {
            selected_item = null;
            this.profiles_stack.Children.Clear();

            Image profile_desktop = new Image
            {
                Tag     = Global.Configuration.desktop_profile,
                Source  = new BitmapImage(new Uri(@"Resources/desktop_icon.png", UriKind.Relative)),
                ToolTip = "Desktop Settings",
                Margin  = new Thickness(0, 5, 0, 0)
            };

            profile_desktop.MouseDown += ProfileImage_MouseDown;
            this.profiles_stack.Children.Add(profile_desktop);

            //Included Game Profiles
            foreach (string profile_k in Global.Configuration.ProfileOrder)
            {
                ProfileManager profile = Global.Configuration.ApplicationProfiles[profile_k];
                ImageSource    icon    = profile.GetIcon();
                UserControl    control = profile.GetUserControl();

                if (icon != null && control != null)
                {
                    Image profile_image = new Image
                    {
                        Tag        = profile,
                        Source     = icon,
                        ToolTip    = profile.Name + " Settings",
                        Margin     = new Thickness(0, 5, 0, 0),
                        Visibility = profile.Settings.Hidden ? Visibility.Collapsed : Visibility.Visible
                    };
                    profile_image.MouseDown += ProfileImage_MouseDown;
                    this.profiles_stack.Children.Add(profile_image);
                }
            }

            //Populate with added profiles
            foreach (var kvp in Global.Configuration.additional_profiles)
            {
                ProfileManager profile = kvp.Value;
                ImageSource    icon    = profile.GetIcon();
                UserControl    control = profile.GetUserControl();

                if (icon != null && control != null)
                {
                    GenericApplicationSettings settings = (profile.Settings as GenericApplicationSettings);
                    Image profile_image = new Image
                    {
                        Tag     = profile,
                        Source  = icon,
                        ToolTip = settings.ApplicationName + " Settings",
                        Margin  = new Thickness(0, 5, 0, 0)
                    };
                    profile_image.MouseDown += ProfileImage_MouseDown;

                    Image profile_remove = new Image
                    {
                        Source              = new BitmapImage(new Uri(@"Resources/removeprofile_icon.png", UriKind.Relative)),
                        ToolTip             = $"Remove {settings.ApplicationName} Profile",
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Bottom,
                        Height              = 16,
                        Width      = 16,
                        Visibility = Visibility.Hidden,
                        Tag        = kvp.Key
                    };
                    profile_remove.MouseDown += RemoveProfile_MouseDown;

                    Grid profile_grid = new Grid
                    {
                        Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)),
                        Margin     = new Thickness(0, 5, 0, 0),
                        Tag        = profile_remove
                    };

                    profile_grid.MouseEnter += Profile_grid_MouseEnter;
                    profile_grid.MouseLeave += Profile_grid_MouseLeave;

                    profile_grid.Children.Add(profile_image);
                    profile_grid.Children.Add(profile_remove);

                    this.profiles_stack.Children.Add(profile_grid);
                }
            }

            //Add new profiles button
            profile_add = new Image
            {
                Source  = new BitmapImage(new Uri(@"Resources/addprofile_icon.png", UriKind.Relative)),
                ToolTip = "Add a new Lighting Profile",
                Margin  = new Thickness(0, 5, 0, 0)
            };
            profile_add.MouseDown += AddProfile_MouseDown;
            this.profiles_stack.Children.Add(profile_add);

            //Show hidden profiles button
            profile_hidden = new Image
            {
                Source  = _not_visible,
                ToolTip = "Toggle Hidden profiles' visibility",
                Margin  = new Thickness(0, 5, 0, 0)
            };
            profile_hidden.MouseDown += HiddenProfile_MouseDown;
            this.profiles_stack.Children.Add(profile_hidden);
        }