Skip to content

Commit 0a9242d

Browse files
authored
Merge pull request #275 from Avid29/marquee
[Feature] Marquee Text Control
2 parents 6542f93 + 2282efc commit 0a9242d

24 files changed

+1106
-1
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,6 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
432432

433433
# Require file header
434434
dotnet_diagnostic.IDE0073.severity = warning
435+
436+
# Uno platform exposes IDisposable on Storyboard publicly when it should be internal. Ignore this.
437+
dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = T:Windows.UI.Xaml.Media.Animation.Storyboard

common/GlobalUsings_WinUI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
global using Windows.UI.Xaml.Input;
2727
global using Windows.UI.Xaml.Markup;
2828
global using Windows.UI.Xaml.Media;
29+
global using Windows.UI.Xaml.Media.Animation;
2930
global using Windows.UI.Xaml.Navigation;
3031

3132
#else
@@ -40,6 +41,7 @@
4041
global using Microsoft.UI.Xaml.Input;
4142
global using Microsoft.UI.Xaml.Markup;
4243
global using Microsoft.UI.Xaml.Media;
44+
global using Microsoft.UI.Xaml.Media.Animation;
4345
global using Microsoft.UI.Xaml.Navigation;
4446
#endif
4547

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
3+
powershell ..\..\common\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
WinUI 2 under UWP uses TargetFramework uap10.0.*
3+
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
4+
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.
5+
6+
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
7+
8+
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
9+
For UWP / WinAppSDK / Uno packages, place the package references here.
10+
-->
11+
<Project>
12+
<!-- WinUI 2 / UWP -->
13+
<ItemGroup Condition="'$(IsUwp)' == 'true'">
14+
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
15+
</ItemGroup>
16+
17+
<!-- WinUI 2 / Uno -->
18+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
19+
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
20+
</ItemGroup>
21+
22+
<!-- WinUI 3 / WinAppSdk -->
23+
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
24+
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
25+
</ItemGroup>
26+
27+
<!-- WinUI 3 / Uno -->
28+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
29+
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
30+
</ItemGroup>
31+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
2+
<PropertyGroup>
3+
<ToolkitComponentName>MarqueeText</ToolkitComponentName>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<Compile Update="MarqueeTextSample.xaml.cs">
8+
<DependentUpon>MarqueeTextSample.xaml</DependentUpon>
9+
</Compile>
10+
11+
<UpToDateCheckInput Remove="MarqueeTextSample.xaml" />
12+
</ItemGroup>
13+
14+
<!-- Sets this up as a toolkit component's sample project -->
15+
<Import Project="$(RepositoryDirectory)common\ToolkitComponent.SampleProject.props" />
16+
</Project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: MarqueeText
3+
author: Avid29
4+
description: A control for scrolling text in a marquee fashion.
5+
keywords: Marquee, Control, Text
6+
dev_langs:
7+
- csharp
8+
category: Controls
9+
subcategory: StatusAndInfo
10+
discussion-id: 231
11+
issue-id: 0
12+
---
13+
14+
# MarqueeText
15+
16+
The MarqueeText control allows text to scroll in a marquee fashion. The control is heavily templated and many changes can be made by modifying the style. The control can also be adjusted using the Speed, Behavior, RepeatBehavior, and Direction properties.
17+
18+
##Speed
19+
20+
The speed property determines how quickly the text moves in pixels per second. The speed can be adjusted mid-animation and handled continously.
21+
22+
##Behavior
23+
24+
The MarqueeText control has 3 behaviors
25+
26+
###Ticker
27+
28+
Ticker mode starts with all text off the screen then scrolls the text across across the screen. When the animation finishes in the mode no text will be on screen.
29+
30+
###Looping
31+
32+
Looping mode will begin with the start of the text fully in frame then scroll towards the end. When the end is reached it will loop back to the start of the text. Nothing will happen if the text fits in frame.
33+
34+
###Bouncing
35+
36+
Looping mode will begin with the start of the text fully in frame then scroll towards the end. When the end is reached it will bounce and scroll backwards to the start of the text. Nothing will happen if the text fits in frame.
37+
38+
##RepeatBehavior
39+
40+
The repeat behavior determines how many times the marquee will loop before the animation finishes. It can be a number of iteration, a duration, or forever.
41+
42+
##Direction
43+
44+
The default direction is left, meaning the text will move leftwards, but this can be changed to right, up, or down. Direction changed between left and right or up and down are handled continously, meaning that the animation will resume from its current position if changed between these directions.
45+
46+
> [!Sample MarqueeTextSample]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
2+
<Page x:Class="MarqueeTextExperiment.Samples.MarqueeTextSample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarqueeTextRns"
7+
xmlns:local="MarqueeTextExperiment.Samples"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d">
10+
11+
<StackPanel Padding="16">
12+
<labs:MarqueeText Behavior="{x:Bind ConvertStringToMarqueeBehavior(MQBehavior), Mode=OneWay}"
13+
Direction="{x:Bind ConvertStringToMarqueeDirection(MQDirection), Mode=OneWay}"
14+
FontSize="18"
15+
RepeatBehavior="Forever"
16+
Speed="{x:Bind MQSpeed, Mode=OneWay}"
17+
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
18+
</StackPanel>
19+
</Page>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Labs.WinUI.MarqueeTextRns;
6+
7+
namespace MarqueeTextExperiment.Samples;
8+
[ToolkitSample(id: nameof(MarqueeTextSample), "MarqueeText", description: "A control for scrolling text in a marquee fashion.")]
9+
[ToolkitSampleNumericOption("MQSpeed", initial: 96, min: 48, max: 196, step: 1, Title = "Speed")]
10+
[ToolkitSampleMultiChoiceOption("MQDirection", "Left", "Right", "Up", "Down", Title = "Marquee Direction")]
11+
//[ToolkitSampleMultiChoiceOption("MarqueeRepeat", "Repeat", "Forever", "1x", "2x")]
12+
#if !HAS_UNO
13+
[ToolkitSampleMultiChoiceOption("MQBehavior", "Ticker", "Looping", "Bouncing", Title = "Marquee Behavior")]
14+
#else
15+
[ToolkitSampleMultiChoiceOption("MQBehavior", "Ticker", "Looping", Title = "Marquee Behavior")]
16+
#endif
17+
public sealed partial class MarqueeTextSample : Page
18+
{
19+
public MarqueeTextSample()
20+
{
21+
this.InitializeComponent();
22+
}
23+
24+
private MarqueeBehavior ConvertStringToMarqueeBehavior(string str) => str switch
25+
{
26+
"Looping" => MarqueeBehavior.Looping,
27+
"Ticker" => MarqueeBehavior.Ticker,
28+
#if !HAS_UNO
29+
"Bouncing" => MarqueeBehavior.Bouncing,
30+
#endif
31+
_ => throw new System.NotImplementedException(),
32+
};
33+
34+
private MarqueeDirection ConvertStringToMarqueeDirection(string str) => str switch
35+
{
36+
"Left" => MarqueeDirection.Left,
37+
"Up" => MarqueeDirection.Up,
38+
"Right" => MarqueeDirection.Right,
39+
"Down" => MarqueeDirection.Down,
40+
_ => throw new System.NotImplementedException(),
41+
};
42+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.CompilerServices;
6+
7+
// These `InternalsVisibleTo` calls are intended to make it easier for
8+
// for any internal code to be testable in all the different test projects
9+
// used with the Labs infrastructure.
10+
[assembly: InternalsVisibleTo("MarqueeText.Tests.Uwp")]
11+
[assembly: InternalsVisibleTo("MarqueeText.Tests.WinAppSdk")]
12+
[assembly: InternalsVisibleTo("CommunityToolkit.Labs.Tests.Uwp")]
13+
[assembly: InternalsVisibleTo("CommunityToolkit.Labs.Tests.WinAppSdk")]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
2+
<PropertyGroup>
3+
<ToolkitComponentName>MarqueeText</ToolkitComponentName>
4+
<Description>This package contains MarqueeText.</Description>
5+
<Version>0.0.2</Version>
6+
7+
<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
8+
<RootNamespace>CommunityToolkit.Labs.WinUI.MarqueeTextRns</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<UpToDateCheckInput Remove="MarqueeText.xaml" />
13+
</ItemGroup>
14+
15+
<!-- Sets this up as a toolkit component's source project -->
16+
<Import Project="$(RepositoryDirectory)common\ToolkitComponent.SourceProject.props" />
17+
</Project>

0 commit comments

Comments
 (0)