-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
473 additions
and
48 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
Source/Krypton Components/Krypton.Ribbon/Group Contents/KryptonRibbonGroupThemeComboBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Krypton.Ribbon | ||
{ | ||
public class KryptonRibbonGroupThemeComboBox : KryptonRibbonGroupComboBox | ||
{ | ||
#region Instance Fields | ||
private readonly ICollection<string> _supportedThemesNames; | ||
private int _selectedIndex; | ||
#endregion | ||
|
||
#region Public | ||
|
||
/// <summary> | ||
/// Helper, to return a new list of names | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public List<string> SupportedThemesList => _supportedThemesNames.ToList(); | ||
|
||
/// <summary> | ||
/// Gets and sets the ThemeSelectedIndex. | ||
/// </summary> | ||
[Category(@"Visuals")] | ||
[Description(@"Theme Selected Index. (Default = `Office 365 - Blue`)")] | ||
[DefaultValue(33)] | ||
public int ThemeSelectedIndex | ||
{ | ||
get => _selectedIndex; | ||
|
||
set => SelectedIndex = value; | ||
} | ||
|
||
private void ResetThemeSelectedIndex() => _selectedIndex = 33; | ||
|
||
private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != 33; | ||
|
||
/// <summary> | ||
/// Gets and sets the ThemeSelectedIndex. | ||
/// </summary> | ||
[Category(@"Visuals")] | ||
[Description(@"Custom Theme to use when `Custom` is selected")] | ||
[DefaultValue(null)] | ||
public KryptonCustomPaletteBase KryptonCustomPalette { get; set; } | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public KryptonManager Manager | ||
{ | ||
get; | ||
|
||
} = new(); | ||
|
||
#endregion | ||
|
||
#region Identity | ||
|
||
/// <summary>Initializes a new instance of the <see cref="KryptonRibbonGroupThemeComboBox" /> class.</summary> | ||
public KryptonRibbonGroupThemeComboBox() | ||
{ | ||
DropDownStyle = ComboBoxStyle.DropDownList; | ||
|
||
_supportedThemesNames = RibbonThemeManager.SupportedInternalThemeNames; | ||
|
||
_selectedIndex = 33; | ||
|
||
Items.AddRange(_supportedThemesNames.ToArray()); | ||
|
||
SelectedIndex = _selectedIndex; | ||
} | ||
|
||
#endregion | ||
|
||
#region Implementation | ||
|
||
/// <summary>Returns the palette mode.</summary> | ||
/// <returns> | ||
/// <br /> | ||
/// </returns> | ||
public PaletteMode ReturnPaletteMode() => Manager.GlobalPaletteMode; | ||
|
||
#endregion | ||
|
||
#region Protected Overrides | ||
|
||
protected override void OnSelectedIndexChanged(EventArgs e) | ||
{ | ||
RibbonThemeManager.ApplyTheme(Text, Manager); | ||
|
||
ThemeSelectedIndex = SelectedIndex; | ||
|
||
base.OnSelectedIndexChanged(e); | ||
if ((RibbonThemeManager.GetThemeManagerMode(Text) == PaletteMode.Custom) && (KryptonCustomPalette != null)) | ||
{ | ||
Manager.GlobalPalette = KryptonCustomPalette; | ||
} | ||
} | ||
|
||
|
||
#endregion | ||
|
||
#region Removed Designer visibility | ||
|
||
|
||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.