Skip to content

Commit

Permalink
Merge pull request #50 from AndrewKeepCoding/button-extensions
Browse files Browse the repository at this point in the history
Add ButtonExtensions
  • Loading branch information
AndrewKeepCoding authored Apr 15, 2024
2 parents b27b54c + cf10c75 commit c133784
Show file tree
Hide file tree
Showing 19 changed files with 522 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>AK.Toolkit.WinUI3.ButtonExtensionsSampleApp</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &gt;= 8">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>

<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240404000" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<!--
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
Tools extension to be activated for this project even if the Windows App SDK Nuget
package has not yet been restored.
-->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WinUI3\AK.Toolkit.WinUI3.ButtonExtensions\AK.Toolkit.WinUI3.ButtonExtensions.csproj" />
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Explorer "Package and Publish" context menu entry to be enabled for this project even if
the Windows App SDK Nuget package has not yet been restored.
-->
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Application
x:Class="AK.Toolkit.WinUI3.ButtonExtensionsSampleApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AK.Toolkit.WinUI3.ButtonExtensionsSampleApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application>
48 changes: 48 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Microsoft.UI.Xaml.Shapes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace AK.Toolkit.WinUI3.ButtonExtensionsSampleApp;
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}

/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}

private Window m_window;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8" ?>
<Window
x:Class="AK.Toolkit.WinUI3.ButtonExtensionsSampleApp.MainWindow"
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:AK.Toolkit.WinUI3.ButtonExtensionsSampleApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="using:AK.Toolkit.WinUI3"
mc:Ignorable="d">

<Grid ColumnDefinitions="*,*" ColumnSpacing="10">
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="Button">
<Setter Property="Width" Value="100" />
</Style>
</Grid.Resources>

<StackPanel
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Spacing="20">
<TextBlock
HorizontalAlignment="Center"
FontSize="32"
Text="😲 Default Button's behaviors" />
<StackPanel
x:Name="DefaultButtonsStackPanel"
HorizontalAlignment="Center"
Spacing="10">
<Button Click="Button_Click" Content="Click" />
<Button
Background="Red"
Click="Button_Click"
Content="Click" />
<Button
Background="Green"
Click="Button_Click"
Content="Click" />
<Button
Background="Blue"
Click="Button_Click"
Content="Click" />
</StackPanel>

</StackPanel>

<StackPanel
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Spacing="20">
<TextBlock
HorizontalAlignment="Center"
FontSize="32"
Text="🤩 This video's goal" />
<StackPanel
x:Name="ExtendedButtonsStackPanel"
HorizontalAlignment="Center"
Spacing="10">
<Button
toolkit:ButtonExtensions.PointerOverBackgroundLightnessFactor="1.2"
toolkit:ButtonExtensions.PressedBackgroundLightnessFactor="0.8"
Background="Red"
Click="Button_Click"
Content="Click" />
<Button
toolkit:ButtonExtensions.PointerOverBackgroundLightnessFactor="1.2"
toolkit:ButtonExtensions.PressedBackgroundLightnessFactor="0.8"
Background="Green"
Click="Button_Click"
Content="Click" />
<Button
toolkit:ButtonExtensions.PointerOverBackgroundLightnessFactor="1.2"
toolkit:ButtonExtensions.PressedBackgroundLightnessFactor="0.8"
Background="Blue"
Click="Button_Click"
Content="Click" />
</StackPanel>

</StackPanel>
</Grid>

</Window>
22 changes: 22 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace AK.Toolkit.WinUI3.ButtonExtensionsSampleApp;

public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
if (sender is not Button button)
{
return;
}

button.Content = "Clicked";
}
}
51 changes: 51 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="9a295de3-4d12-4fac-9e27-d6625711781c"
Publisher="CN=Andrew"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="9a295de3-4d12-4fac-9e27-d6625711781c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>AK.Toolkit.WinUI3.ButtonExtensionsSampleApp</DisplayName>
<PublisherDisplayName>Andrew</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="AK.Toolkit.WinUI3.ButtonExtensionsSampleApp"
Description="AK.Toolkit.WinUI3.ButtonExtensionsSampleApp"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"AK.Toolkit.WinUI3.ButtonExtensionsSampleApp (Package)": {
"commandName": "MsixPackage"
},
"AK.Toolkit.WinUI3.ButtonExtensionsSampleApp (Unpackaged)": {
"commandName": "Project"
}
}
}
19 changes: 19 additions & 0 deletions AK.Toolkit.WinUI3.ButtonExtensionsSampleApp/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="AK.Toolkit.WinUI3.ButtonExtensionsSampleApp.app"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>
56 changes: 56 additions & 0 deletions AK.Toolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AK.Toolkit.WinUI3.RichTextB
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AK.Toolkit.WinUI3.RichTextBlockExtensionsSampleApp", "Samples\AK.Toolkit.WinUI3.RichTextBlockExtensionsSampleApp\AK.Toolkit.WinUI3.RichTextBlockExtensionsSampleApp.csproj", "{DCDA10E1-12BB-4437-AADE-1BA1D79F1E00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AK.Toolkit.WinUI3.ButtonExtensions", "WinUI3\AK.Toolkit.WinUI3.ButtonExtensions\AK.Toolkit.WinUI3.ButtonExtensions.csproj", "{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AK.Toolkit.WinUI3.ButtonExtensionsSampleApp", "AK.Toolkit.WinUI3.ButtonExtensionsSampleApp\AK.Toolkit.WinUI3.ButtonExtensionsSampleApp.csproj", "{C58364A2-840A-4D37-8DFB-960A562F7DD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -326,6 +330,56 @@ Global
{DCDA10E1-12BB-4437-AADE-1BA1D79F1E00}.Release|x86.ActiveCfg = Release|x86
{DCDA10E1-12BB-4437-AADE-1BA1D79F1E00}.Release|x86.Build.0 = Release|x86
{DCDA10E1-12BB-4437-AADE-1BA1D79F1E00}.Release|x86.Deploy.0 = Release|x86
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|ARM.Build.0 = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|arm64.ActiveCfg = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|arm64.Build.0 = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|x64.ActiveCfg = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|x64.Build.0 = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|x86.ActiveCfg = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Debug|x86.Build.0 = Debug|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|Any CPU.Build.0 = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|ARM.ActiveCfg = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|ARM.Build.0 = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|arm64.ActiveCfg = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|arm64.Build.0 = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|x64.ActiveCfg = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|x64.Build.0 = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|x86.ActiveCfg = Release|Any CPU
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF}.Release|x86.Build.0 = Release|Any CPU
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|Any CPU.ActiveCfg = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|Any CPU.Build.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|Any CPU.Deploy.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|ARM.ActiveCfg = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|ARM.Build.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|ARM.Deploy.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|arm64.ActiveCfg = Debug|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|arm64.Build.0 = Debug|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|arm64.Deploy.0 = Debug|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x64.ActiveCfg = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x64.Build.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x64.Deploy.0 = Debug|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x86.ActiveCfg = Debug|x86
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x86.Build.0 = Debug|x86
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Debug|x86.Deploy.0 = Debug|x86
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|Any CPU.ActiveCfg = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|Any CPU.Build.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|Any CPU.Deploy.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|ARM.ActiveCfg = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|ARM.Build.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|ARM.Deploy.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|arm64.ActiveCfg = Release|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|arm64.Build.0 = Release|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|arm64.Deploy.0 = Release|ARM64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x64.ActiveCfg = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x64.Build.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x64.Deploy.0 = Release|x64
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x86.ActiveCfg = Release|x86
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x86.Build.0 = Release|x86
{C58364A2-840A-4D37-8DFB-960A562F7DD0}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -342,6 +396,8 @@ Global
{B2459114-5D81-48A4-8166-0B893CA00EC1} = {EDEB400F-756D-4F11-895A-4A8D2C72176A}
{70BC2116-5863-4F79-95A4-19176CCF3F6B} = {7F954F26-CA57-40C7-9268-51868AAE52D7}
{DCDA10E1-12BB-4437-AADE-1BA1D79F1E00} = {EDEB400F-756D-4F11-895A-4A8D2C72176A}
{3D24D1D2-5AAE-4C2C-9F24-0AB0C2E84FCF} = {7F954F26-CA57-40C7-9268-51868AAE52D7}
{C58364A2-840A-4D37-8DFB-960A562F7DD0} = {EDEB400F-756D-4F11-895A-4A8D2C72176A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5291613D-E375-45A4-ACBB-E655A7307CCC}
Expand Down
Loading

0 comments on commit c133784

Please sign in to comment.