:: Home

  login:         
  passwords:  

Winforms Interview Questions

Windows Forms Deployment
Windows Forms Controls
Windows Forms Data Binding
Windows Forms Datagrid
Windows Forms Docking
Windows Forms Keyboard Handling
Windows Forms Layout
Windows Forms Licensing
Windows Forms Menus
Windows Forms Mouse Handling
Windows Forms from MFC
Windows Forms from VB6
Windows Forms Patterns
Windows Forms Printing
Windows Forms Resources
Windows Form Scrolling
Windows Forms Tips
Windows Forms Common Dialogs
Windows Forms Listbox
Windows Forms ComboBox
Windows Forms Rich TextBox
Windows Forms ListView
Windows Forms TreeView
Windows Forms Button
Windows Forms TabControl
Windows Forms TextBox
Windows Forms MDI
Windows Forms Cursors
Windows Forms WebBrowser
Windows Forms PictureBox
Windows Forms Form
Windows Forms MDI
Windows Forms In IE
GDI+Bitmaps&Images
GDI+Font
GDI+Color
GDI+Brushes
GDI Drawing Tips
GDI+ from GDI
GDI Paths Regions
GDI+Pens
Interioerability WIn32
Tools Metadata Viewers
Design Time Serialization
Design Time Custom Designers
Design Time Tips
Design Time Type Editors
Vs.Net Tips
Vs.Net Debugging
Vs.Net Macros
Framework Tips General
Framework Tips Events
Framework Tips General IO
Framework Tips Strings
Framework Tips Threading
Tool Resource Editor
Design Time UI
Framework Tips CGI
Framework Tips XML

WPF Interview Qs

SilverLight Interview Qs

SAP Interview Questions

Oracle Interview Questions

PHP Interview Questions

Ajax Interview Questions

IIS 7.0

OOP Interview Questions

Ruby Interview Questions

Sql Server Interview Questions

SharePoint 2007 Questions

Microsoft Crm Questions

GDI+ Pens

The General Winforms Interview Questions consists the most frequently asked questions in Winforms. This list of 100+ questions guage your familiarity with the Winforms platform. The q&a have been collected over a period of time from various blogs, forums and other similar Winforms sites

40. GDI+ Pens

    40.1 What is a GraphicsPath?
    40.2 How can I create non-rectangular windows?

40.1 Using a wide pen, how do I draw a series of line segments with rounded corners?

The LineJoin property of the Pen class allows you to specify how two lines should be joined. The following code segment produces the picture below.

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Pen redPen = new Pen(Color.Red, 20);
int startX = 20;
int startY = 60;
int width = this.ClientSize.Width / 17;
int height = this.ClientSize.Height / 2;
foreach(LineJoin LJ in new LineJoin[] { LineJoin.Bevel,
LineJoin.Miter,
LineJoin.Round})
{
redPen.LineJoin = LJ;
Point[] points = {new Point(startX, startY),
new Point(startX + width, startY + height),
new Point(startX + 2 * width, startY),
new Point(startX + 3 * width, startY + height),
new Point(startX + 4 * width, startY)};

e.Graphics.DrawLines(redPen, points);
e.Graphics.DrawString( LJ.ToString(), new Font("Arial Black", 13),
new SolidBrush(Color.Blue), startX - 5, startY - 50);
startX += 4 * width + 40;
}
}

40.2 With a wide pen, how can I control how the endpoints of my line appear?

The LineCap property of the Pen class controls how the ends of your line segments appear. You can set each end independently using the StartCap and EndCap properties of the Pen class. The following code segment produces the picture below. $$c private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Pen redPen = new Pen(Color.LightSalmon, 20); int startX = 80; int startY = 30; int width = this.ClientSize.Width - 2 * startX; Font _font = new Font("Arial Black", 13); foreach(LineCap LC in new

LineCap[] { LineCap.ArrowAnchor, LineCap.DiamondAnchor, LineCap.Flat, LineCap.Round, LineCap.RoundAnchor, LineCap.Square, LineCap.SquareAnchor, LineCap.Triangle}) { redPen.StartCap = LC; redPen.EndCap = LC; Point p1 = new Point(startX, startY); Point p2 = new Point(startX + width, startY); e.Graphics.DrawLine(redPen, p1, p2); e.Graphics.DrawString( LC.ToString(), _font, new SolidBrush(Color.Blue), startX + 40, startY - 13 ); startY += 50; } }$$

Copyright 2007, Megasolutions Ltd