Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6543619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:22:07+00:00 2026-05-25T11:22:07+00:00

I’m trying unsuccessfully to draw ‘P’ inside a circle. I’m using DrawingConntext due to

  • 0

I’m trying unsuccessfully to draw ‘P’ inside a circle.
I’m using DrawingConntext due to performance issues.

This is what I get:

enter image description here

MainWindow XAML:

 <StackPanel Background="LightGray">
    <WrapPanel x:Name="panel">
        <Image Width="100" Height="100">
            <Image.Source>
                <MultiBinding Converter="{StaticResource @con2}">
                </MultiBinding>
            </Image.Source>
        </Image>
    </WrapPanel>
</StackPanel>

The Convert method:

 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        Geometry circlePath = Geometry.Parse("M 12.5,1 A 11,11 0 1 0 13.5,1 Z");

        var dGroup = new DrawingGroup();

        using (DrawingContext dc = dGroup.Open())
        {
            dc.DrawGeometry(Brushes.LightBlue, new Pen(Brushes.Black, 1.5), circlePath);

            //Draw letter 'P'
            var x =
                Geometry.Parse(
                    "F1 M 0,15.4L 0,0L 5.0665,0C 6.98703,0 8.23807,0.0767822 8.81958,0.230591C 9.71523,0.46228 10.4655,0.966919 11.0704,1.74451C 11.6753,2.52209 11.9778,3.52576 11.9778,4.75574C 11.9778,5.70251 11.8001,6.49963 11.4447,7.14685C 11.0894,7.79407 10.6387,8.30212 10.0929,8.67078C 9.54701,9.03955 8.99112,9.28406 8.42522,9.40442C 7.65878,9.55139 6.547,9.625 5.08989,9.625L 2.99445,9.625L 2.99445,15.4L 0,15.4 Z M 2.99445,2.56665L 2.99445,7.05835L 4.8526,7.05835C 6.19164,7.05835 7.08673,6.97534 7.5379,6.80933C 7.98907,6.64343 8.34277,6.3844 8.599,6.03235C 8.85522,5.6803 8.98334,5.27039 8.98334,4.80249C 8.98334,4.22546 8.80342,3.74976 8.4436,3.37537C 8.08377,3.0011 7.62869,2.76721 7.07838,2.67358C 6.67288,2.60229 5.85855,2.56665 4.63538,2.56665L 2.99445,2.56665 Z ");
            dc.DrawGeometry(Brushes.Black, new Pen(Brushes.Black, 0), x);
        }

        return new DrawingImage(dGroup);
    }
  • UPDATE:

Changing the path is not something I want to get into,
is there a way setting it with MARGIN/ STRECH/ TRANSFORM etc. ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:22:07+00:00Added an answer on May 25, 2026 at 11:22 am

    You can center the “P” in respect to the Circle.

    To do this, push a TranslateTransform to the DrawingContext. To get the right X value, use the Width of the Circle / 2.0 and then subtract the Width of “P” / 2.0. The same goes for Y.

    enter image description here

    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        Geometry circlePath = Geometry.Parse("M 12.5,1 A 11,11 0 1 0 13.5,1 Z");
    
        var dGroup = new DrawingGroup();
    
        using (DrawingContext dc = dGroup.Open())
        {
            dc.DrawGeometry(Brushes.LightBlue, new Pen(Brushes.Black, 1.5), circlePath);
            //Draw letter 'P'
            var x = Geometry.Parse("F1 M 0,15.4L 0,0L 5.0665,0C 6.98703,0 8.23807,0.0767822 8.81958,0.230591C 9.71523,0.46228 10.4655,0.966919 11.0704,1.74451C 11.6753,2.52209 11.9778,3.52576 11.9778,4.75574C 11.9778,5.70251 11.8001,6.49963 11.4447,7.14685C 11.0894,7.79407 10.6387,8.30212 10.0929,8.67078C 9.54701,9.03955 8.99112,9.28406 8.42522,9.40442C 7.65878,9.55139 6.547,9.625 5.08989,9.625L 2.99445,9.625L 2.99445,15.4L 0,15.4 Z M 2.99445,2.56665L 2.99445,7.05835L 4.8526,7.05835C 6.19164,7.05835 7.08673,6.97534 7.5379,6.80933C 7.98907,6.64343 8.34277,6.3844 8.599,6.03235C 8.85522,5.6803 8.98334,5.27039 8.98334,4.80249C 8.98334,4.22546 8.80342,3.74976 8.4436,3.37537C 8.08377,3.0011 7.62869,2.76721 7.07838,2.67358C 6.67288,2.60229 5.85855,2.56665 4.63538,2.56665L 2.99445,2.56665 Z ");
    
            double centerX = circlePath.Bounds.Left + circlePath.Bounds.Width / 2;
            double pWidth = x.Bounds.Width / 2;
            double centerY = circlePath.Bounds.Top + circlePath.Bounds.Height / 2;
            double pHeight = x.Bounds.Height / 2;
            TranslateTransform translateTransform = new TranslateTransform(centerX - pWidth, centerY - pHeight);
            dc.PushTransform(translateTransform);
    
            dc.DrawGeometry(Brushes.Black, new Pen(Brushes.Black, 0), x);
        }
    
        return new DrawingImage(dGroup);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.