FrameTimerX 1.0.2

.NET Standard 2.0
dotnet add package FrameTimerX --version 1.0.2
NuGet\Install-Package FrameTimerX -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FrameTimerX" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FrameTimerX --version 1.0.2
#r "nuget: FrameTimerX, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install FrameTimerX as a Cake Addin
#addin nuget:?package=FrameTimerX&version=1.0.2

// Install FrameTimerX as a Cake Tool
#tool nuget:?package=FrameTimerX&version=1.0.2

FrameTimerX v1.0.2

Author: Marcos Lapa dos Santos

A cross-platform Timer that runs inside a Xamarin.Forms.Frame

Features:

  • AutoStart Timer
  • CountDown/CountUp
  • TimerTypes: "hh:mm:ss" | "mm:ss" | IntergerCounter
  • Visual Warning (Frame BackgroundColor Changing)
  • Negative Numbers (Auto Stop on zero by default)

Configuration:

  1. Add the component to your xaml page:
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"             
             ...             
             xmlns:frt="clr-namespace:FrameTimerX;assembly=FrameTimerX"             
             ...             
             x:Class="YourProject.MainPage">
  1. Creating a simple FrameTimerX (Default Type = "hh:mm:ss"; AutoStart = true)
    <frt:FrameTimer IsAutoStarted="True" />

Examples

  1. Configuring the FrameTimerX for a Integer CountDown, TickVelocity = 500 miliseconds
    <frt:FrameTimer BackgroundColor="LightBlue" 
          StartingCounter="50" TickVelocity="500"            
          IsCountDown="True" IsAutoStarted="True"
          TimerType="IntegerCounter" />
  1. Starting manually a FrameTimerX in a button click
  • On Xaml file:
        <frt:FrameTimer x:Name="frtManual" BackgroundColor="LightGreen" 
                        StartingMinute="1" StartingSecond="0" IsCountDown="True" TimerType="MinuteSecond" 
                        HorizontalOptions="Center" VerticalOptions="Center" />
        <Button Text="Start" Clicked="Button_Clicked"/>
  • On .cs file:
    private void Button_Clicked(object sender, EventArgs e){
      frtManual.Start();
    }
    
  1. Creating a FrameTimerX with alternate background color on Warning
        <frt:FrameTimer AllowNegativeValues="True" BackgroundColor="LightCoral" WarningColor="Orange"                       
                        StartingCounter="30" TickVelocity="500" EnableWarning="True" ClockFontNegaviteTextColor="DarkBlue"
                        IsCountDown="True" IsAutoStarted="True" TimerType="IntegerCounter" 
                        StartWarningCount="10" HorizontalOptions="Center" VerticalOptions="Center" />

Handling Events

FrameTimerX has the Started, Stopped, Resumed and WarningStarted events to handle. We can use the CodeBehind or MVVM (Command) aproach.

CodeBehind sample

Handling the Stopped event

XAML File

        <frt:FrameTimer StartingCounter="0" TickVelocity="500" Stopped="FrtTimer_Stopped"
                        IsAutoStarted="True" TimerType="IntegerCounter" />

CS File

        private void FrtTimer_Stopped(object sender, FrameTimerEventArgs args)
        {
            Debug.WriteLine("=======================================================");
            Debug.WriteLine("========== Simple Stopped Event raised!!!!! ===========");
            Debug.WriteLine($"  ==> Counter:{args.Counter}");
            Debug.WriteLine($"  ==> Hour:{args.Hour}");
            Debug.WriteLine($"  ==> Minute:{args.Minute}");
            Debug.WriteLine($"  ==> Second:{args.Second}");
            Debug.WriteLine("=======================================================");
        }

MVVM (Bindable Command) sample

Handling the WarningStarted event

XAML File (Remember to link your ViewModel to the Page Context before...)

        <frt:FrameTimer StartingCounter="90" TickVelocity="1000" TimerType="IntegerCounter"
                        EnableWarning="True" StartWarningTime="30"
                        WarningColor="Orange" IsCountDown="True" 
                        OnStartWarning="{Binding StartWarningCommmand} />

CS File ⇒ ViewModel

        // Constructor
        public MyViewModel(){
            StartWarningCommmand = new Command(StartWarning);
        }
        
        public Command StartWarningCommmand { get; }

        public void StartWarning()
        {
            Debug.WriteLine("########### Warning Started! ###########");
        }

Added Features

  • ResetTimerOnAppearing property: Now you can choose if your timer resets on PageAppearing or not.
  • Pause method and event (now the Stop method resets the timer)

Known Issues

  • We can't put any componente inside the FrameTimer, because it'll became a simple Frame. For example, if we do something like this:
        <frt:FrameTimer IsAutoStarted="True" BorderColor="Black">
           <StackLayout>
               <Label Text="Test"></Label>
           </StackLayout>
       </frt:FrameTimer>

We'll get a simple Frame with a Label "Test" inside a StackLayout...

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 573 5/9/2020
1.0.1 377 11/22/2019
1.0.0 365 10/30/2019

Fixed issue: Duplicating start event call on page appearing.
Added Pause method and event.
Added ResetTimerOnAppearing property.