Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CubeKit.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Project Path="src/core/Riverside.Toolkit.Animations/Riverside.Toolkit.Animations.shproj" />
<Project Path="src/core/Riverside.Toolkit.Controls.Crimson/Riverside.Toolkit.Controls.Crimson.shproj" Id="f2ca66e2-ab46-45c2-88f1-a2ad68cf8c66" />
<Project Path="src/core/Riverside.Toolkit.Controls.Primitives/Riverside.Toolkit.Controls.Primitives.shproj" />
<Project Path="src/core/Riverside.Toolkit.Controls.Settings/Riverside.Toolkit.Controls.Settings.shproj" Id="d131c7fe-6aed-4515-8c28-17da95b09fea" />
<Project Path="src/core/Riverside.Toolkit.Controls.TitleBar/Riverside.Toolkit.Controls.TitleBar.shproj" />
<Project Path="src/core/Riverside.Toolkit.Converters/Riverside.Toolkit.Converters.shproj" />
<Project Path="src/core/Riverside.Toolkit.Extensions/Riverside.Toolkit.Extensions.shproj" />
Expand Down Expand Up @@ -63,6 +64,7 @@
</Project>
<Project Path="src/platforms/Riverside.GlowUI.WinUI.Styles/Riverside.GlowUI.WinUI.Styles.csproj" Id="14a51f57-a0de-4539-aa52-53aad65380b5" />
<Project Path="src/platforms/Riverside.Toolkit.Uno.Controls.Primitives/Riverside.Toolkit.Uno.Controls.Primitives.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.Uno.Controls.Settings/Riverside.Toolkit.Uno.Controls.Settings.csproj" Id="0a6ee9c5-b4ea-4b73-bc83-ce018881cc53" />
<Project Path="src/platforms/Riverside.Toolkit.Uno.Converters/Riverside.Toolkit.Uno.Converters.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.Uno.Extensions/Riverside.Toolkit.Uno.Extensions.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.Uno.Helpers/Riverside.Toolkit.Uno.Helpers.csproj" />
Expand All @@ -77,6 +79,9 @@
<Project Path="src/platforms/Riverside.Toolkit.Uwp.Controls.Primitives/Riverside.Toolkit.Uwp.Controls.Primitives.csproj">
<Platform Solution="Release|*" Project="x64" />
</Project>
<Project Path="src/platforms/Riverside.Toolkit.Uwp.Controls.Settings/Riverside.Toolkit.Uwp.Controls.Settings.csproj" Id="665b6b8f-808f-42cf-b85f-6e924bfe7e3a">
<Platform Solution="Release|*" Project="x64" />
</Project>
<Project Path="src/platforms/Riverside.Toolkit.Uwp.Converters/Riverside.Toolkit.Uwp.Converters.csproj">
<Platform Solution="Release|*" Project="x64" />
</Project>
Expand All @@ -98,6 +103,7 @@
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Animations/Riverside.Toolkit.WinUI.Animations.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Controls.Crimson/Riverside.Toolkit.WinUI.Controls.Crimson.csproj" Id="e50ac24a-5e97-4309-9197-1a3bed5f0505" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Controls.Primitives/Riverside.Toolkit.WinUI.Controls.Primitives.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Controls.Settings/Riverside.Toolkit.WinUI.Controls.Settings.csproj" Id="5536109a-3f16-4a88-a4e6-a8b6f070d877" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Controls.TitleBar/Riverside.Toolkit.WinUI.Controls.TitleBar.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Converters/Riverside.Toolkit.WinUI.Converters.csproj" />
<Project Path="src/platforms/Riverside.Toolkit.WinUI.Extensions/Riverside.Toolkit.WinUI.Extensions.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions eng/MultiTarget/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
global using global::Microsoft.UI.Xaml.Media.Animation;
global using global::Microsoft.UI.Xaml.Shapes;
global using global::Microsoft.UI.Xaml.Controls.Primitives;
global using global::Microsoft.UI.Xaml.Automation;
#elif Uwp
global using global::Windows;
global using global::Windows.UI.Xaml;
Expand All @@ -47,6 +48,7 @@
global using global::Windows.UI.Xaml.Media.Animation;
global using global::Windows.UI.Xaml.Shapes;
global using global::Windows.UI.Xaml.Controls.Primitives;
global using global::Windows.UI.Xaml.Automation;
#elif Wpf
global using global::System.Windows;
global using global::System.Windows.Controls;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>d131c7fe-6aed-4515-8c28-17da95b09fea</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Riverside.Toolkit.Controls.Settings</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\core\$(Import_RootNamespace)\**\*.cs" Exclude="obj\**;bin\**" />
<Page Include="..\..\core\$(Import_RootNamespace)\**\*.xaml" Exclude="obj\**;bin\**">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>d131c7fe-6aed-4515-8c28-17da95b09fea</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Riverside.Toolkit.Controls.Settings.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
117 changes: 117 additions & 0 deletions src/core/Riverside.Toolkit.Controls.Settings/SettingsBlockControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<UserControl
x:Class="Riverside.Toolkit.Controls.SettingsBlockControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Riverside.Toolkit.Controls"
xmlns:local1="using:Riverside.Toolkit.Converters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">

<UserControl.Resources>
<local1:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<local1:NullToTrueConverter x:Key="NullToFalseConverter" Inverse="True" />
<local1:NullToTrueConverter x:Key="NullToTrueConverter" Inverse="False" />
<local1:StringNullOrWhiteSpaceToTrueConverter x:Key="StringNullOrWhiteSpaceToFalseConverter" Inverse="True" />
<local1:StringNullOrWhiteSpaceToTrueConverter x:Key="StringNullOrWhiteSpaceToTrueConverter" Inverse="False" />

<Style x:Key="TextBlockGroupHeaderStyle" TargetType="TextBlock">
<Setter Property="Margin" Value="0,8,0,4" />
<Setter Property="FontSize" Value="16" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="FontWeight" Value="Bold" />
</Style>

<Style x:Key="GridSettingsBlockStyle" TargetType="Grid">
<Setter Property="Background" Value="{ThemeResource ExpanderHeaderBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ExpanderHeaderBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="{StaticResource ExpanderMinHeight}" />
<Setter Property="Padding" Value="16,4,16,4" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
</Style>

<Style
x:Key="ButtonSettingsBlockStyle"
BasedOn="{StaticResource DefaultButtonStyle}"
TargetType="Button">
<Setter Property="Background" Value="{ThemeResource ExpanderHeaderBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ExpanderHeaderBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="16,4,16,4" />
<Setter Property="MinHeight" Value="{StaticResource ExpanderMinHeight}" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
</Style>
</UserControl.Resources>

<Grid>

<!-- Expander -->
<Grid x:Name="ExpanderPreGrid" x:Load="{x:Bind ExpandableContent, Mode=OneWay, Converter={StaticResource NullToFalseConverter}}">
<Grid x:Name="ExpanderGrid" x:Load="{x:Bind IsClickable, Mode=OneWay, Converter={StaticResource InverseBooleanConverter}}">
<muxc:Expander
x:Name="ExpanderControl"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
AutomationProperties.Name="{x:Bind Title, Mode=OneWay}"
Collapsed="Expander_Collapsed"
Expanding="Expander_Expanding"
IsExpanded="{x:Bind IsExpanded, Mode=TwoWay}">
<muxc:Expander.Header>
<local:SettingsDisplayControl
Title="{x:Bind Title, Mode=OneWay}"
Margin="0,4"
AdditionalDescriptionContent="{x:Bind AdditionalDescriptionContent, Mode=OneWay}"
Description="{x:Bind Description, Mode=OneWay}"
Icon="{x:Bind Icon, Mode=OneWay}"
SettingsActionableElement="{x:Bind SettingsActionableElement, Mode=OneWay}" />
</muxc:Expander.Header>

<ContentPresenter
Margin="-16"
HorizontalAlignment="Stretch"
Content="{x:Bind ExpandableContent, Mode=OneWay}" />
</muxc:Expander>
</Grid>
</Grid>

<!-- Button -->
<Grid x:Name="ButtonPreGrid" x:Load="{x:Bind ExpandableContent, Mode=OneWay, Converter={StaticResource NullToTrueConverter}}">
<Grid x:Name="ButtonGrid" x:Load="{x:Bind IsClickable, Mode=OneWay}">
<Button
x:Name="ActionableButton"
Command="{x:Bind ButtonCommand, Mode=OneWay}"
Style="{StaticResource ButtonSettingsBlockStyle}">
<local:SettingsDisplayControl
Title="{x:Bind Title, Mode=OneWay}"
AdditionalDescriptionContent="{x:Bind AdditionalDescriptionContent, Mode=OneWay}"
Description="{x:Bind Description, Mode=OneWay}"
Icon="{x:Bind Icon, Mode=OneWay}"
SettingsActionableElement="{x:Bind SettingsActionableElement, Mode=OneWay}" />
</Button>
</Grid>
</Grid>

<!-- Grid -->
<Grid x:Name="StaticPreGrid" x:Load="{x:Bind ExpandableContent, Mode=OneWay, Converter={StaticResource NullToTrueConverter}}">
<Grid
x:Name="StaticGrid"
x:Load="{x:Bind IsClickable, Mode=OneWay, Converter={StaticResource InverseBooleanConverter}}"
Style="{StaticResource GridSettingsBlockStyle}">
<local:SettingsDisplayControl
Title="{x:Bind Title, Mode=OneWay}"
AdditionalDescriptionContent="{x:Bind AdditionalDescriptionContent, Mode=OneWay}"
Description="{x:Bind Description, Mode=OneWay}"
Icon="{x:Bind Icon, Mode=OneWay}"
SettingsActionableElement="{x:Bind SettingsActionableElement, Mode=OneWay}" />
</Grid>
</Grid>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System;
using System.Windows.Input;

namespace Riverside.Toolkit.Controls
{
[ContentProperty(Name = nameof(SettingsActionableElement))]
public sealed partial class SettingsBlockControl : UserControl
{
public FrameworkElement SettingsActionableElement { get; set; }

public ICommand ButtonCommand
{
get { return (ICommand)GetValue(ButtonCommandProperty); }
set { SetValue(ButtonCommandProperty, value); }
}
public static readonly DependencyProperty ButtonCommandProperty =
DependencyProperty.Register("ButtonCommand", typeof(ICommand), typeof(SettingsBlockControl), new PropertyMetadata(null));

public static readonly DependencyProperty ExpandableContentProperty = DependencyProperty.Register(
"ExpandableContent",
typeof(FrameworkElement),
typeof(SettingsBlockControl),
new PropertyMetadata(null)
);

public FrameworkElement ExpandableContent
{
get => (FrameworkElement)GetValue(ExpandableContentProperty);
set => SetValue(ExpandableContentProperty, value);
}

public static readonly DependencyProperty AdditionalDescriptionContentProperty = DependencyProperty.Register(
"AdditionalDescriptionContent",
typeof(FrameworkElement),
typeof(SettingsBlockControl),
new PropertyMetadata(null)
);

public FrameworkElement AdditionalDescriptionContent
{
get => (FrameworkElement)GetValue(AdditionalDescriptionContentProperty);
set => SetValue(AdditionalDescriptionContentProperty, value);
}

public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
"Title",
typeof(string),
typeof(SettingsBlockControl),
new PropertyMetadata(null)
);

public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}

public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(
"Description",
typeof(string),
typeof(SettingsBlockControl),
new PropertyMetadata(null)
);

public string Description
{
get => (string)GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}

public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
"Icon",
typeof(IconElement),
typeof(SettingsBlockControl),
new PropertyMetadata(null)
);

public IconElement Icon
{
get => (IconElement)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

public static readonly DependencyProperty IsClickableProperty = DependencyProperty.Register(
"IsClickable",
typeof(bool),
typeof(SettingsBlockControl),
new PropertyMetadata(false)
);

public bool IsClickable
{
get => (bool)GetValue(IsClickableProperty);
set => SetValue(IsClickableProperty, value);
}

public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register(
"IsExpanded",
typeof(bool),
typeof(SettingsBlockControl),
new PropertyMetadata(false)
);

public bool IsExpanded
{
get => (bool)GetValue(IsExpandedProperty);
set => SetValue(IsExpandedProperty, value);
}

//
// Summary:
// Occurs when a button control is clicked.
public event EventHandler<bool> Click;

public SettingsBlockControl()
{
InitializeComponent();
Loaded += SettingsBlockControl_Loaded;
}

private void SettingsBlockControl_Loaded(object sender, RoutedEventArgs e)
{
if (ActionableButton is not null)
{
AutomationProperties.SetName(ActionableButton, Title);
}
}

private void Expander_Expanding(Microsoft.UI.Xaml.Controls.Expander sender, Microsoft.UI.Xaml.Controls.ExpanderExpandingEventArgs args)
{
Click?.Invoke(this, true);
}

private void Expander_Collapsed(Microsoft.UI.Xaml.Controls.Expander sender, Microsoft.UI.Xaml.Controls.ExpanderCollapsedEventArgs args)
{
Click?.Invoke(this, false);
}
}
}
Loading
Loading