private static void FocusedProfileChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ConfigUI th = source as ConfigUI; Profiles.Application value = e.NewValue as Profiles.Application; //th.ctrlLayerManager.Visibility = value == null ? Visibility.Collapsed : Visibility.Visible; //th.ctrlProfileManager.Visibility = value == null ? Visibility.Collapsed : Visibility.Visible; th.gridManagers.Visibility = value == null ? Visibility.Collapsed : Visibility.Visible; if (value == null) { return; } /*th.content_grid.Children.Clear(); * UIElement element = value.GetUserControl(); * //th.content_grid.DataContext = element; * th.content_grid.MinHeight = ((UserControl)element).MinHeight; * th.content_grid.Children.Add(element); * th.content_grid.UpdateLayout();*/ th.content_grid.Content = value.GetUserControl(); th.content_grid.UpdateLayout(); }
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.GetIcon(); UserControl control = application.GetUserControl(); 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); }