2021-08-23 19:48:52 +02:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Windows.UI.Xaml;
|
2021-10-01 15:11:09 +02:00
|
|
|
|
using Windows.UI.Xaml.Automation.Peers;
|
2021-08-23 19:48:52 +02:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Controls
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a control that can contain multiple settings (or other) controls
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[TemplateVisualState(Name = "Normal", GroupName = "CommonStates")]
|
|
|
|
|
|
[TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")]
|
|
|
|
|
|
public partial class SettingsGroup : ItemsControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public SettingsGroup()
|
|
|
|
|
|
{
|
|
|
|
|
|
DefaultStyleKey = typeof(SettingsGroup);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(
|
|
|
|
|
|
"Header",
|
|
|
|
|
|
typeof(string),
|
|
|
|
|
|
typeof(SettingsGroup),
|
|
|
|
|
|
new PropertyMetadata(default(string)));
|
|
|
|
|
|
|
|
|
|
|
|
[Localizable(true)]
|
|
|
|
|
|
public string Header
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (string)GetValue(HeaderProperty);
|
|
|
|
|
|
set => SetValue(HeaderProperty, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnApplyTemplate()
|
|
|
|
|
|
{
|
|
|
|
|
|
IsEnabledChanged -= SettingsGroup_IsEnabledChanged;
|
|
|
|
|
|
SetEnabledState();
|
|
|
|
|
|
IsEnabledChanged += SettingsGroup_IsEnabledChanged;
|
|
|
|
|
|
base.OnApplyTemplate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SettingsGroup_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetEnabledState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetEnabledState()
|
|
|
|
|
|
{
|
|
|
|
|
|
VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true);
|
|
|
|
|
|
}
|
2021-10-01 15:11:09 +02:00
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SettingsGroupAutomationPeer(this);
|
|
|
|
|
|
}
|
2021-08-23 19:48:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|