Giter Club home page Giter Club logo

maui-samples's Introduction

.NET and MAUI samples

This is a sample repository to demonstrate and experiment with various C# .NET and MAUI features, many of which will also be covered in my blog: https://blog.ewers-peters.de

Features currently being explored

  • App Themes (Dark/Light mode): Blog Post
  • Splash Screen (incl. platform differences): Blog Post
  • Built-in Multi-Targeting: Blog Post
  • Advanced Multi-Targeting: Blog Post
  • Platform-specific APIs: Blog Post 1, Blog Post 2
  • Platform-specific XAML: Blog Post
  • MVVM Code Generation (simple scenarios): Blog Post
  • MVVM Code Generation (advanced scenarios): Blog Post 1, Blog Post 2
  • Events and Behaviors (e.g. EventToCommandBehavior)
  • Compiled Bindings: Blog Post
  • Device Orientation (Portrait/Landscape) and Responsive Design: Blog Post
  • Custom TitleView: Blog Post
  • Dependency Injection using Shell: Blog Post
  • Expander & Accordion: Blog Post
  • Video Reel Blog Post
  • Foreground Services
  • File Download
  • App Directories
  • Localization
  • Unit Tests
  • Guard Clauses / Input Validation
  • Fullscreen / Immersive Mode
  • Status Bar Themes (Android)
  • App Preferences
  • Background Services
  • Media Playback (Audio, Video)
  • Recording Media
  • ...

This list is not final and will be extended and updated frequently.

Your Requests

I'm happy to cover any interesting and challenging topic. Just let me know about your ideas and wishes and might pick it up in my blog and in this repository.

Sponsorship

You can support me by sharing my blog and this repository, and you can sponsor me or buy me a coffee.

Whatever you decide, thank you for being here and reading this ❤️

Buy Me A Coffee

Acknowledgements

Frog Video by Ivan from Pixabay
Big Buck Bunny Video from sample-videos.com

maui-samples's People

Contributors

ewerspej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

maui-samples's Issues

Can't use GraphicsView

Hi I'm trying to make a simple GraphicsView like you did, but when I run the app it throws System.Reflection.TargetInvocationException
My code:

WaveformGraphicsView

public class WaveformGraphicsView : GraphicsView
{
    public string Path { get => (string)GetValue(PathProperty); set => SetValue(PathProperty, value); }
    public static readonly BindableProperty PathProperty = BindableProperty.Create(nameof(Path), typeof(Path), typeof(WaveformGraphicsView), string.Empty, propertyChanged: PathPropertyChanged);

    public static void PathPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        if (bindable is not WaveformGraphicsView { Drawable: WaveformDrawable drawable } view)
        {
            return;
        }

        drawable.Path = newValue as string;
        view.Invalidate();
    }
}

WaveformDrawable

public class WaveformDrawable : IDrawable
{
    public string Path { get; set; }
    public void Draw(ICanvas canvas, RectF dirtyRect)
    {
        //var reader = new AudioFileReader(Path);
        canvas.StrokeColor = Colors.Red;
        canvas.StrokeSize = 4;
        canvas.DrawEllipse(10, 10, 100, 50);
    }
}

MainPage.xaml

<?xml version="1.0" encoding="utf-8"?>

<ContentPage
    x:Class="AudioButtons.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:components="clr-namespace:CA.Maui.Components;assembly=CA.Maui"
    xmlns:converters="clr-namespace:AudioButtons.Converters"
    xmlns:font="clr-namespace:AudioButtons.FontModels"
    xmlns:models="clr-namespace:AudioButtons.Models"
    xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    xmlns:viewModels="clr-namespace:AudioButtons.ViewModels"
    Title="{Binding Title}"
    x:DataType="viewModels:ButtonsViewModel"
    NavigatedTo="MainPage_OnNavigatedTo">

    <Page.Behaviors>
        <toolkit:StatusBarBehavior StatusBarColor="{StaticResource Primary}" StatusBarStyle="LightContent" />
    </Page.Behaviors>

    <ContentPage.Resources>
        <ResourceDictionary>
            <converters:RgbToStringConverter x:Key="RgbStringToColorConverter" />
            <converters:TextColorConverter x:Key="TextColorConverter" />

            <Style
                x:Key="FontAwesomeIcon"
                ApplyToDerivedTypes="True"
                TargetType="Label">
                <Setter Property="FontFamily" Value="FaSolid" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
                <Setter Property="VerticalTextAlignment" Value="Center" />
                <Setter Property="FontSize" Value="20" />
                <Setter Property="TextColor" Value="{StaticResource White}" />
                <Setter Property="Margin" Value="5" />
            </Style>

            <Style ApplyToDerivedTypes="True" TargetType="ContentPage">
                <Setter Property="BackgroundColor" Value="{StaticResource Background}" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>

    <Grid RowDefinitions="*,70,0">
        <CollectionView
            x:Name="buttonsCollection"
            Grid.Row="0"
            Margin="20"
            ItemsSource="{Binding Buttons}"
            SelectionMode="None">
            <CollectionView.ItemsLayout>
                <LinearItemsLayout ItemSpacing="10" Orientation="Vertical" />
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate x:DataType="models:ButtonAudio">
                    <HorizontalStackLayout>
                        <!--<components:CaButton
                            BackgroundColor="{Binding Color, Converter={StaticResource RgbStringToColorConverter}}"
                            HorizontalOptions="Start"
                            LongPressed="CaButton_OnLongPressed"
                            LongCommandParameter="{Binding .}"
                            ShortPressed="Button_OnPressed"
                            TextColor="{Binding Color, Converter={StaticResource TextColorConverter}}"
                            Text="{Binding Name}"
                            WidthRequest="{Binding Width, Source={RelativeSource AncestorType={x:Type CollectionView}}}">
                            <components:CaButton.Triggers>
                                <DataTrigger
                                    Binding="{Binding .}"
                                    TargetType="Button"
                                    Value="{x:Type models:ButtonAudio}">
                                    <Setter Property="Command"
                                            Value="{Binding PlayButtonAsyncCommand, 
                                            Source={RelativeSource AncestorType={x:Type viewModels:ButtonsViewModel}}}" />
                                    <Setter Property="CommandParameter" Value="{Binding .}" />
                                </DataTrigger>
                            </components:CaButton.Triggers>
                        </components:CaButton>-->
                        <components:WaveformGraphicsView 
                            Path="{Binding FilePath}"
                            HeightRequest="300"
                            HorizontalOptions="Center"
                            VerticalOptions="Center"
                            WidthRequest="300">
                            <components:WaveformGraphicsView.Drawable>
                                <components:WaveformDrawable />
                            </components:WaveformGraphicsView.Drawable>
                        </components:WaveformGraphicsView>
                        <Label
                            IsVisible="{Binding IsPauseButtonVisible, Mode=TwoWay, 
                                Source={RelativeSource AncestorType={x:Type viewModels:ButtonsViewModel}}}"
                            Style="{StaticResource FontAwesomeIcon}"
                            Text="{x:Static font:FaSolidIcons.Pause}">
                            <Label.GestureRecognizers>
                                <TapGestureRecognizer Tapped="PauseButton" />
                            </Label.GestureRecognizers>
                        </Label>
                        <Label
                            IsVisible="{Binding IsPlayButtonVisible, Mode=TwoWay, Source={RelativeSource AncestorType={x:Type viewModels:ButtonsViewModel}}}"
                            Style="{StaticResource FontAwesomeIcon}"
                            Text="{x:Static font:FaSolidIcons.Play}">
                            <Label.GestureRecognizers>
                                <TapGestureRecognizer Tapped="PlayButton" />
                            </Label.GestureRecognizers>
                        </Label>
                        <Label
                            IsVisible="{Binding IsStopButtonVisible, Mode=TwoWay, Source={RelativeSource AncestorType={x:Type viewModels:ButtonsViewModel}}}"
                            Style="{StaticResource FontAwesomeIcon}"
                            Text="{x:Static font:FaSolidIcons.Stop}">
                            <Label.GestureRecognizers>
                                <TapGestureRecognizer Tapped="StopButton" />
                            </Label.GestureRecognizers>
                        </Label>
                    </HorizontalStackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
        

        <Button
            Grid.Row="1"
            Margin="10"
            BackgroundColor="{StaticResource Primary}"
            Command="{Binding AddNewButtonCommand}"
            Text="Aggiungi" />
        <toolkit:MediaElement
            x:Name="MediaElement"
            Grid.Row="2"
            MediaEnded="MediaElement_OnMediaEnded"
            ShouldAutoPlay="False"
            Source="{Binding MediaSource}" />
    </Grid>

</ContentPage>

Can you help me to solve this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.