FrameTimerX 1.0.2

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 and Polyglot Notebooks. 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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 829 5/9/2020
1.0.1 519 11/22/2019
1.0.0 505 10/30/2019

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