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

  • SEARCH
  • Home
  • 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 6974111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:11:41+00:00 2026-05-27T17:11:41+00:00

There isn’t one called Pens , that’s for sure, but it’s too odd not

  • 0

There isn’t one called Pens, that’s for sure, but it’s too odd not to find it. Is it really absent, or am I being blind?

(I’m just looking for a convenience class – for example, Colors.Red and Brushes.Red is there, but for pens the shortest appears to be new Pen(Brushes.Red, 1))

  • 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-27T17:11:42+00:00Added an answer on May 27, 2026 at 5:11 pm

    There is not the associated Pens class because a Pen is identified by both a Brush and a Thickness rather than just one property.

    If you have a need for a set of standard pens (based on some thickness) then you will have to create your own. Another approach would be to create a code generator to supply the appropriate pens.

    Here is an example of a class which adds a Pen for each default Brush:

    public class DefaultPens
    {
        private Dictionary<Brush, Pen> pens;
    
        public double Thickness
        {
            get;
            private set;
        }
    
        // used like defaultPens[Brushes.Red]
        public Pen this[Brush brush]
        {
            get { return this.pens[brush]; }
        }
    
        public DefaultPens(double thickness)
        {
            this.pens = typeof(Brushes).GetProperties(BindingFlags.Static)
                                       .Where(pi => pi.PropertyType == typeof(Brush))
                                       .Select(pi => pi.GetValue(null, null))
                                       .ToDictionary(
                                           b => b,
                                           b => new Pen(b, thickness));
            this.Thickness = thickness;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot find one online and I am surprised there isn't one... but is
I know there is a question about that, but there isn't any good answer(for
I haven't found an answer to this particular question; perhaps there isn't one. But
I've tried searching around but there isn't something that is a fairly concrete example
I'm pretty shocked I can't find an answer to this (maybe there isn't one).
I'm not quite sure what I am doing wrong and there isn't any indication
I'm sure there isn't but I was hoping somebody could help me to work
I have a hard time believing that there isn't an answer here but it
I haven't, but I don't say there isn't one. All of the C# developers
And of course I want to do this code-wise. It's not that there isn't

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.