첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.15MB

▶ GraphicsDrawable.cs

namespace TestProject;

/// <summary>
/// 그래픽스 그리기 가능형
/// </summary>
public class GraphicsDrawable : IDrawable
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 그리기 - Draw(canvas, dirtyRectangle)

    /// <summary>
    /// 그리기
    /// </summary>
    /// <param name="canvas">캔버스</param>
    /// <param name="dirtyRectangle">더티 사각형</param>
    public void Draw(ICanvas canvas, RectF dirtyRectangle)
    {
        canvas.FillColor = Colors.Yellow;

        canvas.FillRectangle(dirtyRectangle);

        canvas.Font      = Microsoft.Maui.Graphics.Font.Default;
        canvas.FontSize  = 18;
        canvas.FontColor = Colors.Blue;

        canvas.DrawString("테스트 문자열 입니다.", 20, 20 , 310, 100, HorizontalAlignment.Left  , VerticalAlignment.Top);
        canvas.DrawString("테스트 문자열 입니다.", 20, 60 , 310, 100, HorizontalAlignment.Center, VerticalAlignment.Top);
        canvas.DrawString("테스트 문자열 입니다.", 20, 100, 310, 100, HorizontalAlignment.Right , VerticalAlignment.Top);

        canvas.Font = Microsoft.Maui.Graphics.Font.DefaultBold;

        canvas.DrawString("테스트 문자열 입니다.", 20, 140, 310, 100, HorizontalAlignment.Left, VerticalAlignment.Top);

        canvas.Font      = new Microsoft.Maui.Graphics.Font("Arial");
        canvas.FontColor = Colors.Black;

        canvas.SetShadow(new SizeF(6, 6), 4, Colors.Gray);

        canvas.DrawString("테스트 문자열 입니다.", 20, 200, 310, 100, HorizontalAlignment.Left, VerticalAlignment.Top);
    }

    #endregion
}

 

728x90

 

▶ MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="TestProject.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:TestProject">
    <ContentPage.Resources>
        <local:GraphicsDrawable x:Key="GraphicsDrawableKey" />
    </ContentPage.Resources>
    <GraphicsView
        HorizontalOptions="Center"
        VerticalOptions="Center"
        WidthRequest="350"
        HeightRequest="350"
        Drawable="{StaticResource GraphicsDrawableKey}" />
</ContentPage>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요