Şimdi Ara

C# İLE İLGİLENENLER BURADA TOPLANSIN (3. sayfa)

Bu Konudaki Kullanıcılar:
2 Misafir - 2 Masaüstü
5 sn
340
Cevap
14
Favori
51.145
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: önceki 12345
Sayfaya Git
Git
sonraki
Giriş
Mesaj
  • Transact-SQL
    ilgili herşey tüm terimler tam bir kaynak resimli örnekler içeriyor


    http://www.hemenpaylas.com/download/350993/T-SQL.doc.html

    ( h e m e n p a y l a s )



    < Bu mesaj bu kişi tarafından değiştirildi toshare -- 30 Mart 2006; 11:53:59 >
  • quote:

    Orjinalden alıntı: by_ram

    Güzel konu olmuş açan ve destekleyenler sağolsunlar.Ben de ufak bir soru sormak istiyorum.

    Sorum metotlar hakkında.Metotlardan "return" komutu ile bir değer çıkartıyoruz.1 den fazla değer çıkartmak istersek bunu nasıl yapıcaz.Ana metotdaki değişkenler "public" mi tanımlanacak veya referans atanarak mı olacak.Ya da bunlardan farklı bir yöntemi var mı(return kullanılarak).

    Daha yeni başladım sorularım belki de saçma ve kolay olabilir ama yardım ederseniz çok sevinirim.Öğrendikçe ben de yardım etmeye bildiklerimi paylaşmaya çalışırım.

    return ile göndermek istediğin değerleri bir dizide gönderebilirsin. Yada en iyisi veri aktarımını referans tipli bir değişkenle yaparsan yada referans tipli olmayan bir değişkenin referansını gönderirsen metotdan geriye göndermen gerekmez.metotda yapılan değişiklik direkt olarak o değişken yada değişkenler üzerinde de etkili olur.Hem bu şekilde veri taşıması olmaz ve programın daha hızlı çalışır.Tabi bu hız artışını küçük verilerde pek anlayamazsın ama olsun

    referans tipli olmayan değişkenleri referans olarak göndermek için

    METOTUN KENDİSİ :


    static void metot_ismi(ref int deger1, ref int deger2)
    {
    .
    deger1=10;
    .
    deger2=10;
    .
    //return kullanmaya gerek yok,ki saten bir veriyle beraber kullanılmaz çünki void metotu.
    }

    Çağırıken:

    int sayi1=50, sayi2=50;

    metot_ismi(ref sayi1,ref sayi2);

    Console.Write(sayi1); Console.Write(sayi2);

    Burada ekrana 50 50 yazılmaz 10 10 yazılır.
  • DarKHaCK çok saol
  • quote:

    Orjinalden alıntı: by_ram

    DarKHaCK çok saol

    Rica ederim kardeş yardımım dokunduysa ne mutlu bana
  • ya bu XML şemalarını nasıl çizerim bi fikri olan varmı

    xsd şemasından class (cs,cpp whatever) üretmek yada tam tersi bir sınıfın xsd şemasını çıkartmak
  • Arkadaşlar uzun ve karmaşık bişi değilse aşağıdaki konuda bana yardımcı olabilir misiniz?



    Arkadaşlar, bugün okulda hocamız bir ödev verdi. Ödev şöyle bişey.

    Verilen belli değerler girildiğinde, bu değerleri ilgili formüllerden yararlanarak bulduğu bazı sonuçları bir daire ve lineer çizgilerden oluşan bir diyagrama ölçekli olarak aktaracak bir program. Aşağıda ki gibi bir diyagram oluşturacak.

     C# İLE İLGİLENENLER BURADA TOPLANSIN


    Birkaç sene önce azda olsa C ve C++ öğrenmiştik ama bu program bu dillerle yapılacak bişeye benzemiyor. Açık konuşmak gerekirse programcılık hakkında fazla bir bilgim yok. Ve 1-2 yıldır, dersler yüzünden programcılıkla hiç ilgilenemedim. Bu programında hangi dilde nasıl yapılacağı konusunda bir bilgim yok. Bana yardımcı olursanız çook sevinirim
  • KaRaCHaY C# .NET in System.Drawing diye bir sınıfı var bu sınıfın fonksiyonlarını biraz araştırırsan eminim yaparsın .
    ki bunu mecburen windows uygulaması olarak yapacaksın ingilizcen varsa bu kaynak başlangıç için yeterli olacaktır. Kolay Gelsin

     
    The designers of .NET, and especially of Visual Studio .NET, clearly had in mind a
    model in which you could write sophisticated Windows Applications using only the
    controls available in the Toolbox. This approach is very successful, and many Windows
    programmers will never need to go beyond the Toolbox and forms model for
    building powerful user interfaces.
    As discussed elsewhere in this book, the Toolbox includes controls for displaying
    data (labels, DataGrids, Calendars, listboxes, etc.) as well as for offering the user
    choices (radio buttons, checkboxes, listboxes, etc.) and for gathering data (text
    boxes, etc.) In addition, several controls and components manage date and time
    (Timer, etc.) or the form itself (splitter, etc.).
    From time to time, however, you will want to display data in a way that is not possible
    with just the controls offered in the Toolbox. You might wish to draw on a control,
    or directly on the form itself, and for that you’ll need the tools made available
    through GDI+ and the Graphics object.
    To get an idea of what you can accomplish with these tools, this chapter first covers
    the basics with simple demonstration programs. It then focuses on a small but complete
    project, in which you will create an analog clock.
    The Drawing Namespace
    The System.Drawing namespace includes several classes and structures. The most
    important of them are summarized, briefly, in Table 10-1.
    Table 10-1. Drawing namespace classes and structures
    Class Description
    Bitmap Encapsulates a GDI+ bitmap, i.e., pixel data representing an image.
    Brush Abstract base class. Used to fill the interiors of graphical shapes.
    Brushes Provides static brush definitions for all standard colors.
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 343
    Arguably the most important class for graphics programming is (surprise!) the
    Graphics class. The other classes will be described as they are encountered, but
    before proceeding, let’s examine the Graphics class in detail.
    The Graphics Class
    The Graphics class represents a GDI+ drawing surface. A Graphics object maintains
    the state of the drawing surface, including the scale and units, as well as the orientation
    of the drawing surface.
    The Graphics class provides many properties. The most commonly used properties
    are listed in Table 10-2, most of which will be demonstrated later in this chapter.
    Color Structure representing colors, e.g., Color.Green.
    Font Defines a format for text, including font face, and sizeEncapsulates a typeface, size, style, and effects.
    FontFamily Group of type faces with the same basic design.
    Graphics Encapsulates a GDI+ drawing surface.
    Icon Transparent bitmaps used for Windows icons.
    Image Abstract base class common to the Bitmap, Icon, and Metafile classes.
    Pen Defines an object used to draw lines and curves.
    Pens Provides static Pen definitions for all the standard colors.
    Point Structure used to represent an ordered pair of integers. Typically used to specify two-dimensional Cartesian
    coordinates.
    PointF Same as Point, but uses a floating-point number (float in C#, Single in VB.NET) rather than an integer.
    Rectangle Structure that represents the location and size of a rectangular region.
    RectangleF Same as Rectangle, but uses floating-point values (float in C#, single in VB.NET) rather than integers.
    Size Structure that represents the size of a rectangular region as an order pair (Point) representing width
    and height.
    SizeF Same as Size, but uses PointF rather than Point.
    SystemBrushes A utility class with 21 static, read-only properties that return objects of type Brush (each of a different
    color).
    SystemPens A utility class with 15 static, read-only properties that return objects of type Pen (each of a different
    color).
    Table 10-2. Graphics properties
    Property Type Description
    Clip Region Read/write. Specifies the area available for drawing.
    DpiX / DpiY Float / single Read/write. The horizontal and vertical resolution (respectively) of the
    Graphics object in dots per inch.
    Table 10-1. Drawing namespace classes and structures (continued)
    Class Description
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    344 | Chapter 10: Drawing and GDI+
    The PageScale sets the scaling between the world units and the page units. To understand
    these concepts, you must first understand coordinates.
    Coordinates
    The French philosopher René Descartes (1596-1650) is best known today for stating
    that while he may doubt, he can not doubt that he exists. This is summarized in his
    oft-quoted statement Cogito Ergo Sum (I think, therefore I am).*
    Among mathematicians, Descartes may be best known for inventing Analytical
    Geometry and what are now called Cartesian coordinates. In a classic Cartesian
    coordinate system, you envision an x axis and a y axis, as shown in Figure 10-1, with
    the origin (0,0) at the center. The values to the right of the origin and above the origin
    are positive, and the values to the left and below are negative.
    In most graphical programming environments, like in Windows, the coordinate system
    has its origin at the upper-lefthand corner, rather than in the center, and you count
    upward to the right and down, as shown in Figure 10-2. The coordinates you pass to
    the various drawing methods of the Graphics class are called world coordinates.
    Transforms introduced
    These world coordinates are transformed into page coordinates by world transformations.
    You’ll use these world transformations (e.g., TranslateTransform, ScaleTransform,
    and RotateTransform) later in this chapter to set the center and the orientation
    of your coordinate system. When drawing a clock face, for example, setting the origin
    (0,0) to the center of the clock is more convenient.
    Page transforms convert page coordinates into device coordinates: pixels relative to
    the upper-lefthand corner of the client area on your monitor, bitmap, page, etc. The
    page transforms are the PageUnit and PageScale properties of the Graphics object,
    which were listed in Table 10-2.
    The PageUnit property chooses the unit in which you will make your transformations
    and scale your drawings. These Units are one of the GraphicsUnits-enumerated
    values shown in Table 10-3.
    PageScale Float / single Read/write. The scaling between world units and page units for this Graphics
    object.
    PageUnit GraphicsUnit Read/write. The unit of measure for page coordinates. Valid values are members
    of the GraphicsUnit enumeration, listed in Table 10-3.
    * Philosopher joke: Rene Descartes goes into McDonald’s and orders a Big Mac. The person behind the
    counter asks, “You want fries with that?” Descartes replies “I think not,” and immediately disappears.
    Table 10-2. Graphics properties (continued)
    Property Type Description
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 345
    Figure 10-1. Cartesian coordinates
    Figure 10-2. World coordinates
    Table 10-3. GraphicsUnits enumeration
    Enumerated value Unit of measure
    Display 1/75 of an inch
    Document 1/300 of an inch
    Inch 1 inch
    Millimeter 1 millimeter
    Pixel 1 Pixel
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    346 | Chapter 10: Drawing and GDI+
    Using the unit described by the PageUnit, you can set the PageScale that specifies the
    value for scaling between world units and page units for the current Graphics object.
    You’ll see this at work later in this chapter when you’ll create a scale of 2000 units by
    2,000 units—that is, rather than working in pixels or inches, you’ll create an arbitrary
    unit that is 1/2000 of the width (or height) of your screen.
    Graphics Methods
    The Graphics class has many methods for drawing to the graphics device. They
    include methods that begin with Draw, shown here:
    They also include methods that begin with Fill, shown here:
    (Draw methods draw the outline of the figure; Fill methods fill the interior with the
    color of the current brush).
    The methods you’ll use in this chapter, and other commonly used methods, are summarized
    in Table 10-4.
    Point 1/72 of an inch
    World World unit
    DrawArc DrawIcon DrawPath
    DrawBezier DrawIconUnstretched DrawPie
    DrawBeziers DrawImage DrawPolygon
    DrawClosedCurve DrawImageUnscaled DrawRectangle
    DrawCurve DrawLine DrawRectangles
    DrawEllipse DrawLines DrawString
    FillClosedCurve FillPie FillRectangles
    FillEllipse FillPolygon FillRegion
    FillPath FillRectangle
    Table 10-4. Graphics methods
    Method Description
    Clear Clear the drawing area and fill it with the specified color.
    DrawString Draw a string at a particular location using a particular brush and font.
    DrawLine Draw a line connecting two points.
    FillEllipse Fill an ellipse defined by a bounding rectangle.
    MeasureString Return the size of a string when drawn with a specific font within the context of the current
    Graphics object.
    Restore Restore the state of a Graphics object (see Save, below).
    Table 10-3. GraphicsUnits enumeration (continued)
    Enumerated value Unit of measure
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 347
    Create the second hand dot shown in Figure 10-5 using the FillElipse method, and
    create the clock hands using the DrawLine method. Write characters using the
    DrawString method. You can learn more about this process below.
    Save and Restore are two important methods in the Graphics class. The Save method
    saves the current state of the Graphics class and returns that state in a GraphicsState
    object. You do not need to know anything about the internal mechanism of the
    GraphicsState object. It can be treated as a token that you pass into Restore, which
    restores the saved state of the Graphics object. Thus, you might write code that looks
    like this:
    GraphicsState state = myGraphicsObject.Save( );
    // make transformations here
    myGraphicsObject.Restore(state);
    dim state as GraphicsState = myGraphicsObject.Save( )
    '' make transformations here
    myGraphicsObject.Restore(state)
    Using Save and Restore allows you to change the scale or orientation of your Graphics
    object, and then set it back to the way it was before you transformed it.
    The transformation methods are detailed later in this chapter.
    Obtaining a Graphics Object
    You can obtain a Graphics object in many different ways. Two of the ways involve
    the Paint event, which is described in detail in the next section. You can add an event
    handler to the Paint event delegate or override the OnPaint event handler method. In
    either case, the event handler method takes a PaintEventArgs parameter, which has a
    property that returns a Graphics object.
    protected override void OnPaint ( PaintEventArgs e )
    {
    Graphics g = e.Graphics;
    protected override sub OnPaint (e as PaintEventArgs)
    dim g as Graphics = e.Graphics
    RotateTransform Apply a rotation to the transformation matrix of a Graphics object.
    Save Save the state of a Graphics object.
    ScaleTransform Apply a scaling operation to the transformation matrix of a Graphics object.
    TransformPoints Transform an array of points from one coordinate space to another, using the current world
    and page transformations.
    TranslateTransform Apply a translation operation on the transformation matrix.
    Table 10-4. Graphics methods (continued)
    Method Description
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    348 | Chapter 10: Drawing and GDI+
    If you override the OnPaint method, you should always finish by
    chaining up to the base class, forcing it to be invoked. To do so, use
    the following line of code:
    base.OnPaint(e);
    myBase.OnPaint(e)
    Another way to obtain a Graphics object is to call the CreateGraphics method on a
    control or form:
    Graphics g = this.CreateGraphics( );
    dim g as Graphics = me.CreateGraphics( )
    If you do create a Graphics object using CreateGraphics, be sure to
    call the Dispose method of the Graphics object when you are done
    with it. Never store a Graphics object as a member variable of your
    own class. Create or obtain the Graphics object when you need it and
    then dispose of it properly. The C# using keyword can help automate
    this process for you.
    Color Structure
    The System.Drawing namespace provides a Color structure to represent standard
    system-defined colors. Whenever a color is needed, you can use any of the 141 public
    static properties of the Color structure. These properties include such standbys as
    Red, Blue, Green, Gray, and Black; variations on the standards such as LightBlue,
    LightGreen, LightPink, and DarkOrange; and gems such as LightGoldenRodYellow,
    MediumSlateBlue, and PapayaWhip. The complete list of standard colors is provided
    in the Appendix.
    In addition to the standard colors, 26 members of the SystemColor enumeration represent
    the colors used for various elements of the Windows desktop. They include
    such items as ActiveBorder, Desktop, and WindowFrame. The complete System-
    Color enumeration is also shown in the Appendix.
    The combination of the standard colors and the SystemColors comprise the Known-
    Color enumeration.
    The color system is based on the ARGB model, where A stands for Alpha, or the
    transparency of the color, and RGB stands for Red-Green Blue. One byte is allocated
    each for the Alpha and the three primary colors. An Alpha value of 0 is transparent
    and FF is opaque. Likewise, a zero value for a color (R, G, or B) indicates that none
    of that color is present, while a value of FF indicates that the color is full on.
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 349
    In addition to the static properties representing the standard colors, several commonly
    used instance properties of the Color structure are listed in Table 10-5.
    Geometric Structures—Points, Rectangles, and Sizes
    The System.Drawing namespace provides several structures for representing a location
    (Point and PointF), a rectangular area (Rectangle and RectangleF), and a size
    (Size and SizeF).
    All of these structures consist of a pair of read/write ordered pair of numbers. The
    versions without the trailing F in the name take an ordered pair of ordered pairs of
    integers (four integers in total) and the versions with the trailing F take an ordered
    pair of ordered pairs of floating-point numbers (float in C# or single in VB.NET).
    The numbers typically represent pixels. They can also represent other units, such as
    Inch or Millimeter, hence the need for floating-point as well as integer values.
    The integer versions of these structures can be cast to the floating-point version:
    PointF ptf;
    Point pt = null;
    ptf = pt;
    dim ptf as PointF
    dim pt as Point
    ptf = pt
    You cannot cast in the opposite direction, since information may be lost. However,
    all three integer versions provide static methods (Ceiling, Round, and Truncate) for
    converting from the floating-point version to the integer version.
    In the Point/PointF structure, the first number represents the x, or horizontal coordinate
    in a two-dimensional Cartesian coordinate system. The second number represents
    the y, or vertical coordinate.
    The Size/SizeF structures are similar to the Point/PointF structures, except that the
    ordered pair of numbers represent the Width and Height properties of a rectangular
    region.
    Table 10-5. Color structure instance properties
    Value Description
    A Returns byte value of Alpha component
    R Returns byte value of red component
    G Returns byte value of green component
    B Returns byte value of blue component
    Name Returns the name of the color, either user-defined, a known color, or an RGB value
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    350 | Chapter 10: Drawing and GDI+
    The Rectangle and RectangleF structures represent a rectangular region. Each has
    two constructors, listed in Table 10-6. The first constructor takes a Point (or PointF)
    structure and a Size (or SizeF) structure. The second constructor takes four numbers,
    either integers or float/singles. The first two numbers represent the x and y
    coordinates of the upper-left corner of the rectangle, and the second two numbers
    represent the width and height of the rectangle.
    The Rectangle and RectangleF structures also provide several properties for either
    getting information about the rectangle or setting properties. These properties are
    listed in Table 10-7.
    Table 10-6. Rectangle and RectangleF constructors
    Rectangle Point, Size
    Integer, Integer, Integer, Integer
    RectangleF PointF, SizeF
    Integer, Integer, Integer, Integer
    Table 10-7. Rectangle and RectangleF properties
    Property Type Description
    Bottom Integer
    Float/single
    Read-only. Returns the y coordinate of the bottom edge of the rectangle.
    Height Integer
    Float/single
    Read/write. The height of the rectangle.
    IsEmpty Boolean Read-only. Returns true if all numeric properties have a value of zero.
    Left Integer
    Float/single
    Read-only. Returns the x coordinate of the left edge of the rectangle.
    Location Point/PointF Read/write. The point at the upper-left corner of the rectangle.
    Right Integer
    Float/single
    Read-only. Returns the x coordinate of the right edge of the rectangle.
    Size Size/SizeF Read/write. The size of the rectangle.
    Top Integer
    Float/single
    Read-only. Returns the y coordinate of the top edge of the rectangle.
    Width Integer
    Float/single
    Read/write. The width of the rectangle.
    X Integer
    Float/single
    Read/write. The x coordinate of the upper-left corner of the rectangle.
    Y Integer
    Float/single
    Read/write. The y coordinate of the upper-left corner of the rectangle.
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 351
    Brush and Brushes
    A Brush object is used to fill the interior spaces of graphical shapes. The Brush class
    is abstract (MustInherit), and five different classes are derived from Brush, listed in
    Table 10-8.
    For easy access to the colored brushes, a Brushes class (note the plural) contains only
    static (shared), read-only properties of type Brush corresponding to each standard
    color. This Brushes class often provides the Brush object used in calls to the Draw-
    String method.
    If you explicitly create a Brush (or Pen), you must explicitly dispose of
    it, but you must not dispose of any brushes returned to you by
    Brushes, SystemBrushes, Pens, or SystemPens.
    Pen and Pens
    The Pen and Pens classes are similar to the Brush and Brushes classes, except they
    are used for drawing lines and curves rather than filling graphical shapes. The constructors
    of the Pen class take either a Brush object or a Color as an argument. Additionally,
    you can pass in a floating-point number (float in C#, single in VB.NET) that
    specifies the width of the Pen object.
    As with the Brushes class, there is a Pens class (note the plural) for easy access to a
    Pen object of a standard color. The Pens class contains static members corresponding
    to each standard color. The following code snippet demonstrates one way to
    instantiate and use a Pen object.
    Pen pn = Pens.LimeGreen;
    pn.EndCap = LineCap.ArrowAnchor;
    pn.Width = 20;
    g.DrawLine(pn,0,0,0,50);
    Table 10-8. Brush-derived classes
    Class Description
    HatchBrush A rectangular brush with a hatch style from the HatchStyle enumeration, such as BackwardDiagonal,
    DarkVertical, Divot, and Percent60. The ForegroundColor property gets the color of the lines
    and the BackgroundColor property gets the color of the space behind the lines.
    LinearGradientBrush A brush with a linear gradient. Properties such as Blend, GammaCorrection, and Transform allow
    you to change the appearance programatically.
    PathGradientBrush A brush that fills a graphical shape with a gradient. Properties such as Blend, CenterColor, and
    Transform allow you to change the appearance programatically.
    SolidBrush A brush that fills a graphical shape with a color. Valid colors are members of the Color structure.
    TextureBrush A brush that fills a graphical shape with a texture. The texture can come from an Image object,
    either a bitmap or a metafile.
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    352 | Chapter 10: Drawing and GDI+
    Dim pn as Pen = Pens.LimeGreen
    pn.EndCap = LineCap.ArrowAnchor
    pn.Width = 20
    g.DrawLine(pn, 0, 0, 0, 50)
    Table 10-9 lists many of the most commonly used properties of the Pen class. Many
    of them will be demonstrated in the Analog Clock project later in this chapter.
    Table 10-9. Pen properties
    Property Type Description
    Alignment PenAlignment Read/write. Specifies the alignment for this Pen object relative to a theoretical
    line. Valid values are members of the PenAlignment enumeration, listed in
    Table 10-10.
    Brush Brush Read/write. The Brush object that controls attributes of the pen (e.g., does the pen
    draw a solid or a pattern?).
    Color Color Read/write. The color of the Pen. Legal values are members of the Color structure,
    e.g., Color.DarkGoldenrod.
    DashCap DashCap Read/write. The cap style used at the beginning and end of the dashes that comprise
    a dashed line. Valid values are Flat, Round, and Triangle.
    DashPattern float[ ] / single( ) Read/write. An array of numbers specifying the lengths of alternating dashes and
    spaces.
    DashStyle DashStyle Read/write. The style used for dashed lines. Valid values are members of the Dash-
    Style enumeration, listed in Table 10-11.
    EndCap LineCap Read/write. The enumerated arrow type. Valid values are members of the LineCap
    enumeration, listed in Table 10-12.
    StartCap LineCap Read/write. The enumerated arrow type. Valid values are members of the LineCap
    enumeration, listed in Table 10-12.
    Width Float The thickness of the drawn line.
    Table 10-10. PenAlignment enumeration values
    Value Description
    Center Centered over the theoretical line
    Inset Positioned to the inside of the theoretical line
    Left Positioned to the left of the theoretical line
    Outset Positioned to the outside of the theoretical line
    Right Positioned to the right of the theoretical line
    Table 10-11. DashStyle enumeration values
    Value Description
    Custom Custom style
    Dash Dashes
    DashDot Repeating pattern of dash-dot
    DashDotDot Repeating pattern of dash-dot-dot
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 353
    Paint Event
    All controls have a Paint event, which is raised when the control is about to be
    drawn. You can add an event handler to the Paint event delegate to dictate how the
    control is drawn. Using the Paint event, for example, you can draw a string of text
    directly onto the client area of a form, as shown in Example 10-1 (in C#) and in
    Example 10-2 (in VB.NET).
    For a complete discussion of delegates and events, see Chapter 4.
    Dot Dots
    Solid Solid line
    Table 10-12. LineCap enumeration values
    Value Description
    AnchorMask Mask to check if cap is an anchor cap
    ArrowAnchor Arrow-shaped anchor cap
    Custom Custom line cap
    DiamondAnchor Diamond-shaped anchor cap
    Flat Flat line cap
    NoAnchor No anchor
    Round Round line cap
    RoundAnchor Round anchor cap
    Square Square cap
    SquareAnchor Square anchor cap
    Triangle Triangular line cap
    Example 10-1. Drawing a string with Paint event using C# (PaintDemo.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    {
    public class PaintDemo : Form
    {
    public PaintDemo( )
    {
    Text = "Paint Demonstration";
    Table 10-11. DashStyle enumeration values (continued)
    Value Description
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    354 | Chapter 10: Drawing and GDI+
    When either program in Example 10-1 or Example 10-2 is compiled and run, you
    will get the form shown in Figure 10-3.
    Both versions of the PaintDemo program start by referencing the required
    namespaces: System, System.Drawing, and System.Windows.Forms. Inside the constructor
    of each program, the Text and Size properties are set, and the PaintHandler
    method is added to the delegate for the Paint event:
    Size = new Size(300,200);
    Paint += new PaintEventHandler(PaintHandler);
    }
    static void Main( )
    {
    Application.Run(new PaintDemo( ));
    }
    private void PaintHandler(object sender, PaintEventArgs e)
    {
    Graphics g = e.Graphics;
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75);
    }
    }
    }
    Example 10-2. Drawing a string with Paint event using VB.NET (PaintDemo.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintDemo : inherits Form
    public sub New( )
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    AddHandler Paint, AddressOf PaintHandler
    end sub
    public shared sub Main( )
    Application.Run(new PaintDemo( ))
    end sub
    private sub PaintHandler(ByVal sender as object, _
    ByVal e as PaintEventArgs)
    dim g as Graphics = e.Graphics
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75)
    end sub
    end class
    end namespace
    Example 10-1. Drawing a string with Paint event using C# (PaintDemo.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 355
    Text = "Paint Demonstration";
    Size = new Size(300,200);
    Paint += new PaintEventHandler(PaintHandler);
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    AddHandler Paint, AddressOf PaintHandler
    Remember that all of these properties (and events) are implicitly members of the
    class—i.e., the PaintDemo form. You can make this explicit by using the appropriate
    lines of code:
    this.Text = "Paint Demonstration";
    this.Size = new Size(300,200);
    this.Paint += new PaintEventHandler(PaintHandler);
    Me.Text = "Paint Demonstration"
    Me.Size = new Size(300,200)
    Me.AddHandler Paint, AddressOf PaintHandler
    The PaintHandler method is a typical event handler, taking two arguments. The first
    is of type object and the second is of type PaintEventArgs, which has the two readonly
    properties listed in Table 10-13.
    A new Graphics object is instantiated from the PaintEventArgs argument.
    Figure 10-3. Paint event demonstration
    Table 10-13. PaintEventArgs properties
    Property Type Description
    ClipRectangle Rectangle The rectangle to paint
    Graphics Graphics The Graphics object used to paint
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    356 | Chapter 10: Drawing and GDI+
    Graphics g = e.Graphics;
    dim g as Graphics = e.Graphics
    Then the DrawString method is invoked to render the desired text string on the form
    client area. The DrawString method has several overloaded versions, but all of them
    take at least the string to draw, the font to use, the brush to use (which controls the
    color and appearance of the characters), and a location:
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75);
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75)
    In this example, the font used is the current font for the form (it also could have been
    written as this.Font in C# or me.Font in VB.NET), the brush is Black, and the location
    of the upper-left corner of the text string is 50 units in from the left edge of the
    client area and 75 units down from the top.
    Overriding the OnPaint method
    The programs shown in Examples 10-1 and 10-2 worked by adding an event handler
    method to the Paint event. You can accomplish the same outcome by overriding the
    OnPaint event directly just as you might override any virtual method. The Control
    class defines the OnPaint method as follows:
    protected virtual void OnPaint( PaintEventArgs e );
    Overridable Protected Sub OnPaint( ByVal e As PaintEventArgs )
    Example 10-3 (in C#) and in Example 10-4 (in VB.NET) demonstrate how to override
    the OnPaint event. The differences from the previous examples are highlighted.
    Example 10-3. Overriding the OnPaint event in C# (PaintOverride.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    {
    public class PaintOverride : Form
    {
    public PaintOverride( )
    {
    Text = "Paint Demonstration";
    C#
    VB
    C#
    VB
    C#
    VB
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 357
    In Examples 10-3 and 10-4, no methods are added to any event delegates. Instead,
    the protected OnPaint method is overridden. When overriding an event handler, the
    only required argument is the event argument—in this case, PaintEventArgs.
    The last line in the overridden method chains up to the base method (invokes the
    base method) to ensure that all the base class functionality will be implemented and
    Size = new Size(300,200);
    }
    static void Main( )
    {
    Application.Run(new PaintOverride( ));
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    Graphics g = e.Graphics;
    g.DrawString("Look Ma, I'm overridden!", Font, Brushes.Black, 50, 75);
    base.OnPaint(e);
    }
    }
    }
    Example 10-4. Overriding the OnPaint event in VB.NET (PaintOverride.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintOverride : inherits Form
    public sub New( )
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    end sub
    public shared sub Main( )
    Application.Run(new PaintOverride( ))
    end sub
    protected overrides sub OnPaint(ByVal e as PaintEventArgs)
    myBase.OnPaint(e)
    dim g as Graphics = e.Graphics
    g.DrawString("Look Ma, I'm overridden!", _
    Font, Brushes.Black, 50, 75)
    end sub
    end class
    end namespace
    Example 10-3. Overriding the OnPaint event in C# (PaintOverride.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    358 | Chapter 10: Drawing and GDI+
    that any other methods registered with the delegate will be notified. This is done
    with the line:
    base.OnPaint(e);
    myBase.OnPaint(e)
    The remaining two lines in the overridden method are the same as in the previous
    examples.
    Forcing a paint event—the Invalidate method
    You can force a region to redraw by calling the Invalidate method on a control. This
    method does not actually raise the Paint event, but invalidates the area of the control
    or a region within the control. Once an area or region has been invalidated, it will be
    redrawn. This will occur when all current events are finished processing. If you want
    the redraw to occur immediately, call the Update method after calling the Invalidate
    method.
    The Invalidate method is overloaded with six different versions. The parameters supplied
    to the method dictate exactly what part of the control will be invalidated. The
    overloaded versions are listed in Table 10-14.
    Use of the Invalidate method is shown in Example 10-5 (in C#) and in Example 10-6
    (in VB.NET). The lines of code differing from the basic examples in Examples 10-1
    and 10-2 are highlighted.
    Table 10-14. Invalidate methods
    Method Call Description
    Invalidate( ) Invalidates the region of the control
    Invalidate(Boolean) If Boolean is true, invalidates the child controls
    Invalidate(Rectangle) Invalidates the region specified by the Rectangle
    Invalidate(Region) Invalidates the specified Region
    Invalidate(Rectangle, Boolean) Invalidates the region specified by the Rectangle, and if Boolean is true, invalidates
    the child controls
    Invalidate(Region, Boolean) Invalidates the specified Region, and if Boolean is true, invalidates the child
    controls
    Example 10-5. Invalidate method in C# (PaintInvalidate.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    C#
    VB
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 359
    {
    public class PaintInvalidate : Form
    {
    private Button btn;
    public PaintInvalidate( )
    {
    Text = "Paint Invalidate Demonstration";
    Size = new Size(300,200);
    btn = new Button( );
    btn.Parent = this;
    btn.Location = new Point(25,25);
    btn.Text = "Update";
    btn.Click += new System.EventHandler(btn_Click);
    }
    static void Main( )
    {
    Application.Run(new PaintInvalidate( ));
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    Graphics g = e.Graphics;
    String str = "Look Ma, I'm overridden!";
    str += "\nThe time is " + DateTime.Now.ToLongTimeString( );
    g.DrawString(str, Font, Brushes.Black, 50, 75);
    }
    private void btn_Click(object sender, EventArgs e)
    {
    Invalidate( );
    }
    }
    }
    Example 10-6. Invalidate method in VB.NET (PaintInvalidate.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintInvalidate : inherits Form
    private WithEvents btn as Button
    public sub New( )
    Example 10-5. Invalidate method in C# (PaintInvalidate.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    360 | Chapter 10: Drawing and GDI+
    When either program is compiled and run, you get something similar to that shown
    in Figure 10-4. Clicking on the button updates the time displayed in the client area of
    the form.
    The Invalidate method is called against the Form object. The line:
    Invalidate( )
    Text = "Paint Invalidate Demonstration"
    Size = new Size(300,200)
    btn = new Button( )
    btn.Parent = me
    btn.Location = new Point(25,25)
    btn.Text = "Update"
    end sub
    public shared sub Main( )
    Application.Run(new PaintInvalidate( ))
    end sub
    protected overrides sub OnPaint(ByVal e as PaintEventArgs)
    myBase.OnPaint(e)
    dim g as Graphics = e.Graphics
    dim str as string = "Look Ma, I'm overridden!"
    str += vbCrLf + "The time is " + DateTime.Now.ToLongTimeString( )
    g.DrawString(str, Font, Brushes.Black, 50, 75)
    end sub
    private sub btn_Click(ByVal sender as object, _
    ByVal e as EventArgs) _
    Handles btn.Click
    Invalidate( )
    end sub
    end class
    end namespace
    Figure 10-4. Paint Invalidate program
    Example 10-6. Invalidate method in VB.NET (PaintInvalidate.vb) (continued)
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Analog Clock Project | 361
    is implicitly the same as:
    this.Invalidate( );
    me.Invalidate( )
    Another way to force a Form to invalidate itself and cause the Paint event to be
    raised is to set the ResizeRedraw property to true. This will cause the object, the
    Form in this case, to redraw itself every time the object is resized. In fact, if an application
    is not behaving the way you might expect when resizing, then setting this
    property to true might alleviate the problem.
    The Analog Clock Project
    To illustrate the use of the Graphics object and GDI+ methods, you’ll create a clock
    face with conventional hour and minute hands and a green dot in lieu of a second
    hand. You will also display the date rotating around the clock face, as shown in
    Figure 10-5. (If your copy of the book does not display the moving text, you may
    need to run the program itself, which you will find in Examples 10-11 or 10-12).
    Figure 10-5. Analog Clock (first image)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    362 | Chapter 10: Drawing and GDI+
    Notice the button marked “24 Hours” in the upper-lefthand corner. Clicking that
    button changes the clock to a 24 hour display, as shown in Figure 10-6. Notice that
    in 24 hour mode, the minute hand maintains its position, but the hour hand must be
    adjusted.
    This project presents a number of challenges including those listed next.
    • How do you draw a clock face?
    • How do you redraw the clock face for 24 hours?
    • How do you determine the position of and draw the hands (and the dot for the
    second hand?)
    • How do you draw the date around the outer circumference, and how do you
    move it so that it rotates around the clock?
    As is often the case, each problem has many good solutions, and solving these problems
    will allow you to explore many details of GDI+ programming.
  • quote:

    Orjinalden alıntı: koray1983

    KaRaCHaY C# .NET in System.Drawing diye bir sınıfı var bu sınıfın fonksiyonlarını biraz araştırırsan eminim yaparsın .
    ki bunu mecburen windows uygulaması olarak yapacaksın ingilizcen varsa bu kaynak başlangıç için yeterli olacaktır. Kolay Gelsin

     
    The designers of .NET, and especially of Visual Studio .NET, clearly had in mind a
    model in which you could write sophisticated Windows Applications using only the
    controls available in the Toolbox. This approach is very successful, and many Windows
    programmers will never need to go beyond the Toolbox and forms model for
    building powerful user interfaces.
    As discussed elsewhere in this book, the Toolbox includes controls for displaying
    data (labels, DataGrids, Calendars, listboxes, etc.) as well as for offering the user
    choices (radio buttons, checkboxes, listboxes, etc.) and for gathering data (text
    boxes, etc.) In addition, several controls and components manage date and time
    (Timer, etc.) or the form itself (splitter, etc.).
    From time to time, however, you will want to display data in a way that is not possible
    with just the controls offered in the Toolbox. You might wish to draw on a control,
    or directly on the form itself, and for that you’ll need the tools made available
    through GDI+ and the Graphics object.
    To get an idea of what you can accomplish with these tools, this chapter first covers
    the basics with simple demonstration programs. It then focuses on a small but complete
    project, in which you will create an analog clock.
    The Drawing Namespace
    The System.Drawing namespace includes several classes and structures. The most
    important of them are summarized, briefly, in Table 10-1.
    Table 10-1. Drawing namespace classes and structures
    Class Description
    Bitmap Encapsulates a GDI+ bitmap, i.e., pixel data representing an image.
    Brush Abstract base class. Used to fill the interiors of graphical shapes.
    Brushes Provides static brush definitions for all standard colors.
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 343
    Arguably the most important class for graphics programming is (surprise!) the
    Graphics class. The other classes will be described as they are encountered, but
    before proceeding, let’s examine the Graphics class in detail.
    The Graphics Class
    The Graphics class represents a GDI+ drawing surface. A Graphics object maintains
    the state of the drawing surface, including the scale and units, as well as the orientation
    of the drawing surface.
    The Graphics class provides many properties. The most commonly used properties
    are listed in Table 10-2, most of which will be demonstrated later in this chapter.
    Color Structure representing colors, e.g., Color.Green.
    Font Defines a format for text, including font face, and sizeEncapsulates a typeface, size, style, and effects.
    FontFamily Group of type faces with the same basic design.
    Graphics Encapsulates a GDI+ drawing surface.
    Icon Transparent bitmaps used for Windows icons.
    Image Abstract base class common to the Bitmap, Icon, and Metafile classes.
    Pen Defines an object used to draw lines and curves.
    Pens Provides static Pen definitions for all the standard colors.
    Point Structure used to represent an ordered pair of integers. Typically used to specify two-dimensional Cartesian
    coordinates.
    PointF Same as Point, but uses a floating-point number (float in C#, Single in VB.NET) rather than an integer.
    Rectangle Structure that represents the location and size of a rectangular region.
    RectangleF Same as Rectangle, but uses floating-point values (float in C#, single in VB.NET) rather than integers.
    Size Structure that represents the size of a rectangular region as an order pair (Point) representing width
    and height.
    SizeF Same as Size, but uses PointF rather than Point.
    SystemBrushes A utility class with 21 static, read-only properties that return objects of type Brush (each of a different
    color).
    SystemPens A utility class with 15 static, read-only properties that return objects of type Pen (each of a different
    color).
    Table 10-2. Graphics properties
    Property Type Description
    Clip Region Read/write. Specifies the area available for drawing.
    DpiX / DpiY Float / single Read/write. The horizontal and vertical resolution (respectively) of the
    Graphics object in dots per inch.
    Table 10-1. Drawing namespace classes and structures (continued)
    Class Description
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    344 | Chapter 10: Drawing and GDI+
    The PageScale sets the scaling between the world units and the page units. To understand
    these concepts, you must first understand coordinates.
    Coordinates
    The French philosopher René Descartes (1596-1650) is best known today for stating
    that while he may doubt, he can not doubt that he exists. This is summarized in his
    oft-quoted statement Cogito Ergo Sum (I think, therefore I am).*
    Among mathematicians, Descartes may be best known for inventing Analytical
    Geometry and what are now called Cartesian coordinates. In a classic Cartesian
    coordinate system, you envision an x axis and a y axis, as shown in Figure 10-1, with
    the origin (0,0) at the center. The values to the right of the origin and above the origin
    are positive, and the values to the left and below are negative.
    In most graphical programming environments, like in Windows, the coordinate system
    has its origin at the upper-lefthand corner, rather than in the center, and you count
    upward to the right and down, as shown in Figure 10-2. The coordinates you pass to
    the various drawing methods of the Graphics class are called world coordinates.
    Transforms introduced
    These world coordinates are transformed into page coordinates by world transformations.
    You’ll use these world transformations (e.g., TranslateTransform, ScaleTransform,
    and RotateTransform) later in this chapter to set the center and the orientation
    of your coordinate system. When drawing a clock face, for example, setting the origin
    (0,0) to the center of the clock is more convenient.
    Page transforms convert page coordinates into device coordinates: pixels relative to
    the upper-lefthand corner of the client area on your monitor, bitmap, page, etc. The
    page transforms are the PageUnit and PageScale properties of the Graphics object,
    which were listed in Table 10-2.
    The PageUnit property chooses the unit in which you will make your transformations
    and scale your drawings. These Units are one of the GraphicsUnits-enumerated
    values shown in Table 10-3.
    PageScale Float / single Read/write. The scaling between world units and page units for this Graphics
    object.
    PageUnit GraphicsUnit Read/write. The unit of measure for page coordinates. Valid values are members
    of the GraphicsUnit enumeration, listed in Table 10-3.
    * Philosopher joke: Rene Descartes goes into McDonald’s and orders a Big Mac. The person behind the
    counter asks, “You want fries with that?” Descartes replies “I think not,” and immediately disappears.
    Table 10-2. Graphics properties (continued)
    Property Type Description
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 345
    Figure 10-1. Cartesian coordinates
    Figure 10-2. World coordinates
    Table 10-3. GraphicsUnits enumeration
    Enumerated value Unit of measure
    Display 1/75 of an inch
    Document 1/300 of an inch
    Inch 1 inch
    Millimeter 1 millimeter
    Pixel 1 Pixel
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    346 | Chapter 10: Drawing and GDI+
    Using the unit described by the PageUnit, you can set the PageScale that specifies the
    value for scaling between world units and page units for the current Graphics object.
    You’ll see this at work later in this chapter when you’ll create a scale of 2000 units by
    2,000 units—that is, rather than working in pixels or inches, you’ll create an arbitrary
    unit that is 1/2000 of the width (or height) of your screen.
    Graphics Methods
    The Graphics class has many methods for drawing to the graphics device. They
    include methods that begin with Draw, shown here:
    They also include methods that begin with Fill, shown here:
    (Draw methods draw the outline of the figure; Fill methods fill the interior with the
    color of the current brush).
    The methods you’ll use in this chapter, and other commonly used methods, are summarized
    in Table 10-4.
    Point 1/72 of an inch
    World World unit
    DrawArc DrawIcon DrawPath
    DrawBezier DrawIconUnstretched DrawPie
    DrawBeziers DrawImage DrawPolygon
    DrawClosedCurve DrawImageUnscaled DrawRectangle
    DrawCurve DrawLine DrawRectangles
    DrawEllipse DrawLines DrawString
    FillClosedCurve FillPie FillRectangles
    FillEllipse FillPolygon FillRegion
    FillPath FillRectangle
    Table 10-4. Graphics methods
    Method Description
    Clear Clear the drawing area and fill it with the specified color.
    DrawString Draw a string at a particular location using a particular brush and font.
    DrawLine Draw a line connecting two points.
    FillEllipse Fill an ellipse defined by a bounding rectangle.
    MeasureString Return the size of a string when drawn with a specific font within the context of the current
    Graphics object.
    Restore Restore the state of a Graphics object (see Save, below).
    Table 10-3. GraphicsUnits enumeration (continued)
    Enumerated value Unit of measure
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 347
    Create the second hand dot shown in Figure 10-5 using the FillElipse method, and
    create the clock hands using the DrawLine method. Write characters using the
    DrawString method. You can learn more about this process below.
    Save and Restore are two important methods in the Graphics class. The Save method
    saves the current state of the Graphics class and returns that state in a GraphicsState
    object. You do not need to know anything about the internal mechanism of the
    GraphicsState object. It can be treated as a token that you pass into Restore, which
    restores the saved state of the Graphics object. Thus, you might write code that looks
    like this:
    GraphicsState state = myGraphicsObject.Save( );
    // make transformations here
    myGraphicsObject.Restore(state);
    dim state as GraphicsState = myGraphicsObject.Save( )
    '' make transformations here
    myGraphicsObject.Restore(state)
    Using Save and Restore allows you to change the scale or orientation of your Graphics
    object, and then set it back to the way it was before you transformed it.
    The transformation methods are detailed later in this chapter.
    Obtaining a Graphics Object
    You can obtain a Graphics object in many different ways. Two of the ways involve
    the Paint event, which is described in detail in the next section. You can add an event
    handler to the Paint event delegate or override the OnPaint event handler method. In
    either case, the event handler method takes a PaintEventArgs parameter, which has a
    property that returns a Graphics object.
    protected override void OnPaint ( PaintEventArgs e )
    {
    Graphics g = e.Graphics;
    protected override sub OnPaint (e as PaintEventArgs)
    dim g as Graphics = e.Graphics
    RotateTransform Apply a rotation to the transformation matrix of a Graphics object.
    Save Save the state of a Graphics object.
    ScaleTransform Apply a scaling operation to the transformation matrix of a Graphics object.
    TransformPoints Transform an array of points from one coordinate space to another, using the current world
    and page transformations.
    TranslateTransform Apply a translation operation on the transformation matrix.
    Table 10-4. Graphics methods (continued)
    Method Description
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    348 | Chapter 10: Drawing and GDI+
    If you override the OnPaint method, you should always finish by
    chaining up to the base class, forcing it to be invoked. To do so, use
    the following line of code:
    base.OnPaint(e);
    myBase.OnPaint(e)
    Another way to obtain a Graphics object is to call the CreateGraphics method on a
    control or form:
    Graphics g = this.CreateGraphics( );
    dim g as Graphics = me.CreateGraphics( )
    If you do create a Graphics object using CreateGraphics, be sure to
    call the Dispose method of the Graphics object when you are done
    with it. Never store a Graphics object as a member variable of your
    own class. Create or obtain the Graphics object when you need it and
    then dispose of it properly. The C# using keyword can help automate
    this process for you.
    Color Structure
    The System.Drawing namespace provides a Color structure to represent standard
    system-defined colors. Whenever a color is needed, you can use any of the 141 public
    static properties of the Color structure. These properties include such standbys as
    Red, Blue, Green, Gray, and Black; variations on the standards such as LightBlue,
    LightGreen, LightPink, and DarkOrange; and gems such as LightGoldenRodYellow,
    MediumSlateBlue, and PapayaWhip. The complete list of standard colors is provided
    in the Appendix.
    In addition to the standard colors, 26 members of the SystemColor enumeration represent
    the colors used for various elements of the Windows desktop. They include
    such items as ActiveBorder, Desktop, and WindowFrame. The complete System-
    Color enumeration is also shown in the Appendix.
    The combination of the standard colors and the SystemColors comprise the Known-
    Color enumeration.
    The color system is based on the ARGB model, where A stands for Alpha, or the
    transparency of the color, and RGB stands for Red-Green Blue. One byte is allocated
    each for the Alpha and the three primary colors. An Alpha value of 0 is transparent
    and FF is opaque. Likewise, a zero value for a color (R, G, or B) indicates that none
    of that color is present, while a value of FF indicates that the color is full on.
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 349
    In addition to the static properties representing the standard colors, several commonly
    used instance properties of the Color structure are listed in Table 10-5.
    Geometric Structures—Points, Rectangles, and Sizes
    The System.Drawing namespace provides several structures for representing a location
    (Point and PointF), a rectangular area (Rectangle and RectangleF), and a size
    (Size and SizeF).
    All of these structures consist of a pair of read/write ordered pair of numbers. The
    versions without the trailing F in the name take an ordered pair of ordered pairs of
    integers (four integers in total) and the versions with the trailing F take an ordered
    pair of ordered pairs of floating-point numbers (float in C# or single in VB.NET).
    The numbers typically represent pixels. They can also represent other units, such as
    Inch or Millimeter, hence the need for floating-point as well as integer values.
    The integer versions of these structures can be cast to the floating-point version:
    PointF ptf;
    Point pt = null;
    ptf = pt;
    dim ptf as PointF
    dim pt as Point
    ptf = pt
    You cannot cast in the opposite direction, since information may be lost. However,
    all three integer versions provide static methods (Ceiling, Round, and Truncate) for
    converting from the floating-point version to the integer version.
    In the Point/PointF structure, the first number represents the x, or horizontal coordinate
    in a two-dimensional Cartesian coordinate system. The second number represents
    the y, or vertical coordinate.
    The Size/SizeF structures are similar to the Point/PointF structures, except that the
    ordered pair of numbers represent the Width and Height properties of a rectangular
    region.
    Table 10-5. Color structure instance properties
    Value Description
    A Returns byte value of Alpha component
    R Returns byte value of red component
    G Returns byte value of green component
    B Returns byte value of blue component
    Name Returns the name of the color, either user-defined, a known color, or an RGB value
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    350 | Chapter 10: Drawing and GDI+
    The Rectangle and RectangleF structures represent a rectangular region. Each has
    two constructors, listed in Table 10-6. The first constructor takes a Point (or PointF)
    structure and a Size (or SizeF) structure. The second constructor takes four numbers,
    either integers or float/singles. The first two numbers represent the x and y
    coordinates of the upper-left corner of the rectangle, and the second two numbers
    represent the width and height of the rectangle.
    The Rectangle and RectangleF structures also provide several properties for either
    getting information about the rectangle or setting properties. These properties are
    listed in Table 10-7.
    Table 10-6. Rectangle and RectangleF constructors
    Rectangle Point, Size
    Integer, Integer, Integer, Integer
    RectangleF PointF, SizeF
    Integer, Integer, Integer, Integer
    Table 10-7. Rectangle and RectangleF properties
    Property Type Description
    Bottom Integer
    Float/single
    Read-only. Returns the y coordinate of the bottom edge of the rectangle.
    Height Integer
    Float/single
    Read/write. The height of the rectangle.
    IsEmpty Boolean Read-only. Returns true if all numeric properties have a value of zero.
    Left Integer
    Float/single
    Read-only. Returns the x coordinate of the left edge of the rectangle.
    Location Point/PointF Read/write. The point at the upper-left corner of the rectangle.
    Right Integer
    Float/single
    Read-only. Returns the x coordinate of the right edge of the rectangle.
    Size Size/SizeF Read/write. The size of the rectangle.
    Top Integer
    Float/single
    Read-only. Returns the y coordinate of the top edge of the rectangle.
    Width Integer
    Float/single
    Read/write. The width of the rectangle.
    X Integer
    Float/single
    Read/write. The x coordinate of the upper-left corner of the rectangle.
    Y Integer
    Float/single
    Read/write. The y coordinate of the upper-left corner of the rectangle.
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 351
    Brush and Brushes
    A Brush object is used to fill the interior spaces of graphical shapes. The Brush class
    is abstract (MustInherit), and five different classes are derived from Brush, listed in
    Table 10-8.
    For easy access to the colored brushes, a Brushes class (note the plural) contains only
    static (shared), read-only properties of type Brush corresponding to each standard
    color. This Brushes class often provides the Brush object used in calls to the Draw-
    String method.
    If you explicitly create a Brush (or Pen), you must explicitly dispose of
    it, but you must not dispose of any brushes returned to you by
    Brushes, SystemBrushes, Pens, or SystemPens.
    Pen and Pens
    The Pen and Pens classes are similar to the Brush and Brushes classes, except they
    are used for drawing lines and curves rather than filling graphical shapes. The constructors
    of the Pen class take either a Brush object or a Color as an argument. Additionally,
    you can pass in a floating-point number (float in C#, single in VB.NET) that
    specifies the width of the Pen object.
    As with the Brushes class, there is a Pens class (note the plural) for easy access to a
    Pen object of a standard color. The Pens class contains static members corresponding
    to each standard color. The following code snippet demonstrates one way to
    instantiate and use a Pen object.
    Pen pn = Pens.LimeGreen;
    pn.EndCap = LineCap.ArrowAnchor;
    pn.Width = 20;
    g.DrawLine(pn,0,0,0,50);
    Table 10-8. Brush-derived classes
    Class Description
    HatchBrush A rectangular brush with a hatch style from the HatchStyle enumeration, such as BackwardDiagonal,
    DarkVertical, Divot, and Percent60. The ForegroundColor property gets the color of the lines
    and the BackgroundColor property gets the color of the space behind the lines.
    LinearGradientBrush A brush with a linear gradient. Properties such as Blend, GammaCorrection, and Transform allow
    you to change the appearance programatically.
    PathGradientBrush A brush that fills a graphical shape with a gradient. Properties such as Blend, CenterColor, and
    Transform allow you to change the appearance programatically.
    SolidBrush A brush that fills a graphical shape with a color. Valid colors are members of the Color structure.
    TextureBrush A brush that fills a graphical shape with a texture. The texture can come from an Image object,
    either a bitmap or a metafile.
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    352 | Chapter 10: Drawing and GDI+
    Dim pn as Pen = Pens.LimeGreen
    pn.EndCap = LineCap.ArrowAnchor
    pn.Width = 20
    g.DrawLine(pn, 0, 0, 0, 50)
    Table 10-9 lists many of the most commonly used properties of the Pen class. Many
    of them will be demonstrated in the Analog Clock project later in this chapter.
    Table 10-9. Pen properties
    Property Type Description
    Alignment PenAlignment Read/write. Specifies the alignment for this Pen object relative to a theoretical
    line. Valid values are members of the PenAlignment enumeration, listed in
    Table 10-10.
    Brush Brush Read/write. The Brush object that controls attributes of the pen (e.g., does the pen
    draw a solid or a pattern?).
    Color Color Read/write. The color of the Pen. Legal values are members of the Color structure,
    e.g., Color.DarkGoldenrod.
    DashCap DashCap Read/write. The cap style used at the beginning and end of the dashes that comprise
    a dashed line. Valid values are Flat, Round, and Triangle.
    DashPattern float[ ] / single( ) Read/write. An array of numbers specifying the lengths of alternating dashes and
    spaces.
    DashStyle DashStyle Read/write. The style used for dashed lines. Valid values are members of the Dash-
    Style enumeration, listed in Table 10-11.
    EndCap LineCap Read/write. The enumerated arrow type. Valid values are members of the LineCap
    enumeration, listed in Table 10-12.
    StartCap LineCap Read/write. The enumerated arrow type. Valid values are members of the LineCap
    enumeration, listed in Table 10-12.
    Width Float The thickness of the drawn line.
    Table 10-10. PenAlignment enumeration values
    Value Description
    Center Centered over the theoretical line
    Inset Positioned to the inside of the theoretical line
    Left Positioned to the left of the theoretical line
    Outset Positioned to the outside of the theoretical line
    Right Positioned to the right of the theoretical line
    Table 10-11. DashStyle enumeration values
    Value Description
    Custom Custom style
    Dash Dashes
    DashDot Repeating pattern of dash-dot
    DashDotDot Repeating pattern of dash-dot-dot
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 353
    Paint Event
    All controls have a Paint event, which is raised when the control is about to be
    drawn. You can add an event handler to the Paint event delegate to dictate how the
    control is drawn. Using the Paint event, for example, you can draw a string of text
    directly onto the client area of a form, as shown in Example 10-1 (in C#) and in
    Example 10-2 (in VB.NET).
    For a complete discussion of delegates and events, see Chapter 4.
    Dot Dots
    Solid Solid line
    Table 10-12. LineCap enumeration values
    Value Description
    AnchorMask Mask to check if cap is an anchor cap
    ArrowAnchor Arrow-shaped anchor cap
    Custom Custom line cap
    DiamondAnchor Diamond-shaped anchor cap
    Flat Flat line cap
    NoAnchor No anchor
    Round Round line cap
    RoundAnchor Round anchor cap
    Square Square cap
    SquareAnchor Square anchor cap
    Triangle Triangular line cap
    Example 10-1. Drawing a string with Paint event using C# (PaintDemo.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    {
    public class PaintDemo : Form
    {
    public PaintDemo( )
    {
    Text = "Paint Demonstration";
    Table 10-11. DashStyle enumeration values (continued)
    Value Description
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    354 | Chapter 10: Drawing and GDI+
    When either program in Example 10-1 or Example 10-2 is compiled and run, you
    will get the form shown in Figure 10-3.
    Both versions of the PaintDemo program start by referencing the required
    namespaces: System, System.Drawing, and System.Windows.Forms. Inside the constructor
    of each program, the Text and Size properties are set, and the PaintHandler
    method is added to the delegate for the Paint event:
    Size = new Size(300,200);
    Paint += new PaintEventHandler(PaintHandler);
    }
    static void Main( )
    {
    Application.Run(new PaintDemo( ));
    }
    private void PaintHandler(object sender, PaintEventArgs e)
    {
    Graphics g = e.Graphics;
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75);
    }
    }
    }
    Example 10-2. Drawing a string with Paint event using VB.NET (PaintDemo.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintDemo : inherits Form
    public sub New( )
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    AddHandler Paint, AddressOf PaintHandler
    end sub
    public shared sub Main( )
    Application.Run(new PaintDemo( ))
    end sub
    private sub PaintHandler(ByVal sender as object, _
    ByVal e as PaintEventArgs)
    dim g as Graphics = e.Graphics
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75)
    end sub
    end class
    end namespace
    Example 10-1. Drawing a string with Paint event using C# (PaintDemo.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 355
    Text = "Paint Demonstration";
    Size = new Size(300,200);
    Paint += new PaintEventHandler(PaintHandler);
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    AddHandler Paint, AddressOf PaintHandler
    Remember that all of these properties (and events) are implicitly members of the
    class—i.e., the PaintDemo form. You can make this explicit by using the appropriate
    lines of code:
    this.Text = "Paint Demonstration";
    this.Size = new Size(300,200);
    this.Paint += new PaintEventHandler(PaintHandler);
    Me.Text = "Paint Demonstration"
    Me.Size = new Size(300,200)
    Me.AddHandler Paint, AddressOf PaintHandler
    The PaintHandler method is a typical event handler, taking two arguments. The first
    is of type object and the second is of type PaintEventArgs, which has the two readonly
    properties listed in Table 10-13.
    A new Graphics object is instantiated from the PaintEventArgs argument.
    Figure 10-3. Paint event demonstration
    Table 10-13. PaintEventArgs properties
    Property Type Description
    ClipRectangle Rectangle The rectangle to paint
    Graphics Graphics The Graphics object used to paint
    C#
    VB
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    356 | Chapter 10: Drawing and GDI+
    Graphics g = e.Graphics;
    dim g as Graphics = e.Graphics
    Then the DrawString method is invoked to render the desired text string on the form
    client area. The DrawString method has several overloaded versions, but all of them
    take at least the string to draw, the font to use, the brush to use (which controls the
    color and appearance of the characters), and a location:
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75);
    g.DrawString("Look Ma, no label!", Font, Brushes.Black, 50, 75)
    In this example, the font used is the current font for the form (it also could have been
    written as this.Font in C# or me.Font in VB.NET), the brush is Black, and the location
    of the upper-left corner of the text string is 50 units in from the left edge of the
    client area and 75 units down from the top.
    Overriding the OnPaint method
    The programs shown in Examples 10-1 and 10-2 worked by adding an event handler
    method to the Paint event. You can accomplish the same outcome by overriding the
    OnPaint event directly just as you might override any virtual method. The Control
    class defines the OnPaint method as follows:
    protected virtual void OnPaint( PaintEventArgs e );
    Overridable Protected Sub OnPaint( ByVal e As PaintEventArgs )
    Example 10-3 (in C#) and in Example 10-4 (in VB.NET) demonstrate how to override
    the OnPaint event. The differences from the previous examples are highlighted.
    Example 10-3. Overriding the OnPaint event in C# (PaintOverride.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    {
    public class PaintOverride : Form
    {
    public PaintOverride( )
    {
    Text = "Paint Demonstration";
    C#
    VB
    C#
    VB
    C#
    VB
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 357
    In Examples 10-3 and 10-4, no methods are added to any event delegates. Instead,
    the protected OnPaint method is overridden. When overriding an event handler, the
    only required argument is the event argument—in this case, PaintEventArgs.
    The last line in the overridden method chains up to the base method (invokes the
    base method) to ensure that all the base class functionality will be implemented and
    Size = new Size(300,200);
    }
    static void Main( )
    {
    Application.Run(new PaintOverride( ));
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    Graphics g = e.Graphics;
    g.DrawString("Look Ma, I'm overridden!", Font, Brushes.Black, 50, 75);
    base.OnPaint(e);
    }
    }
    }
    Example 10-4. Overriding the OnPaint event in VB.NET (PaintOverride.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintOverride : inherits Form
    public sub New( )
    Text = "Paint Demonstration"
    Size = new Size(300,200)
    end sub
    public shared sub Main( )
    Application.Run(new PaintOverride( ))
    end sub
    protected overrides sub OnPaint(ByVal e as PaintEventArgs)
    myBase.OnPaint(e)
    dim g as Graphics = e.Graphics
    g.DrawString("Look Ma, I'm overridden!", _
    Font, Brushes.Black, 50, 75)
    end sub
    end class
    end namespace
    Example 10-3. Overriding the OnPaint event in C# (PaintOverride.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    358 | Chapter 10: Drawing and GDI+
    that any other methods registered with the delegate will be notified. This is done
    with the line:
    base.OnPaint(e);
    myBase.OnPaint(e)
    The remaining two lines in the overridden method are the same as in the previous
    examples.
    Forcing a paint event—the Invalidate method
    You can force a region to redraw by calling the Invalidate method on a control. This
    method does not actually raise the Paint event, but invalidates the area of the control
    or a region within the control. Once an area or region has been invalidated, it will be
    redrawn. This will occur when all current events are finished processing. If you want
    the redraw to occur immediately, call the Update method after calling the Invalidate
    method.
    The Invalidate method is overloaded with six different versions. The parameters supplied
    to the method dictate exactly what part of the control will be invalidated. The
    overloaded versions are listed in Table 10-14.
    Use of the Invalidate method is shown in Example 10-5 (in C#) and in Example 10-6
    (in VB.NET). The lines of code differing from the basic examples in Examples 10-1
    and 10-2 are highlighted.
    Table 10-14. Invalidate methods
    Method Call Description
    Invalidate( ) Invalidates the region of the control
    Invalidate(Boolean) If Boolean is true, invalidates the child controls
    Invalidate(Rectangle) Invalidates the region specified by the Rectangle
    Invalidate(Region) Invalidates the specified Region
    Invalidate(Rectangle, Boolean) Invalidates the region specified by the Rectangle, and if Boolean is true, invalidates
    the child controls
    Invalidate(Region, Boolean) Invalidates the specified Region, and if Boolean is true, invalidates the child
    controls
    Example 10-5. Invalidate method in C# (PaintInvalidate.cs)
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    namespace ProgrammingWinApps
    C#
    VB
    C#
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Drawing Namespace | 359
    {
    public class PaintInvalidate : Form
    {
    private Button btn;
    public PaintInvalidate( )
    {
    Text = "Paint Invalidate Demonstration";
    Size = new Size(300,200);
    btn = new Button( );
    btn.Parent = this;
    btn.Location = new Point(25,25);
    btn.Text = "Update";
    btn.Click += new System.EventHandler(btn_Click);
    }
    static void Main( )
    {
    Application.Run(new PaintInvalidate( ));
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    Graphics g = e.Graphics;
    String str = "Look Ma, I'm overridden!";
    str += "\nThe time is " + DateTime.Now.ToLongTimeString( );
    g.DrawString(str, Font, Brushes.Black, 50, 75);
    }
    private void btn_Click(object sender, EventArgs e)
    {
    Invalidate( );
    }
    }
    }
    Example 10-6. Invalidate method in VB.NET (PaintInvalidate.vb)
    imports System
    imports System.Drawing
    imports System.Windows.Forms
    namespace ProgrammingWinApps
    public class PaintInvalidate : inherits Form
    private WithEvents btn as Button
    public sub New( )
    Example 10-5. Invalidate method in C# (PaintInvalidate.cs) (continued)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    360 | Chapter 10: Drawing and GDI+
    When either program is compiled and run, you get something similar to that shown
    in Figure 10-4. Clicking on the button updates the time displayed in the client area of
    the form.
    The Invalidate method is called against the Form object. The line:
    Invalidate( )
    Text = "Paint Invalidate Demonstration"
    Size = new Size(300,200)
    btn = new Button( )
    btn.Parent = me
    btn.Location = new Point(25,25)
    btn.Text = "Update"
    end sub
    public shared sub Main( )
    Application.Run(new PaintInvalidate( ))
    end sub
    protected overrides sub OnPaint(ByVal e as PaintEventArgs)
    myBase.OnPaint(e)
    dim g as Graphics = e.Graphics
    dim str as string = "Look Ma, I'm overridden!"
    str += vbCrLf + "The time is " + DateTime.Now.ToLongTimeString( )
    g.DrawString(str, Font, Brushes.Black, 50, 75)
    end sub
    private sub btn_Click(ByVal sender as object, _
    ByVal e as EventArgs) _
    Handles btn.Click
    Invalidate( )
    end sub
    end class
    end namespace
    Figure 10-4. Paint Invalidate program
    Example 10-6. Invalidate method in VB.NET (PaintInvalidate.vb) (continued)
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    The Analog Clock Project | 361
    is implicitly the same as:
    this.Invalidate( );
    me.Invalidate( )
    Another way to force a Form to invalidate itself and cause the Paint event to be
    raised is to set the ResizeRedraw property to true. This will cause the object, the
    Form in this case, to redraw itself every time the object is resized. In fact, if an application
    is not behaving the way you might expect when resizing, then setting this
    property to true might alleviate the problem.
    The Analog Clock Project
    To illustrate the use of the Graphics object and GDI+ methods, you’ll create a clock
    face with conventional hour and minute hands and a green dot in lieu of a second
    hand. You will also display the date rotating around the clock face, as shown in
    Figure 10-5. (If your copy of the book does not display the moving text, you may
    need to run the program itself, which you will find in Examples 10-11 or 10-12).
    Figure 10-5. Analog Clock (first image)
    C#
    VB
    This is the Title of the Book, eMatter Edition
    Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
    362 | Chapter 10: Drawing and GDI+
    Notice the button marked “24 Hours” in the upper-lefthand corner. Clicking that
    button changes the clock to a 24 hour display, as shown in Figure 10-6. Notice that
    in 24 hour mode, the minute hand maintains its position, but the hour hand must be
    adjusted.
    This project presents a number of challenges including those listed next.
    • How do you draw a clock face?
    • How do you redraw the clock face for 24 hours?
    • How do you determine the position of and draw the hands (and the dot for the
    second hand?)
    • How do you draw the date around the outer circumference, and how do you
    move it so that it rotates around the clock?
    As is often the case, each problem has many good solutions, and solving these problems
    will allow you to explore many details of GDI+ programming.





    Bilgi için çook saol @koray1983 Fazla bi ingilizce bilmiyorum ama bi çaresine bakarım artık
  • Accessde, Urunler tablosundan Marka diye bir kolonum var, buradan verileri çekip comboBox a nasıl aktarıcam,
    baştan yazabilirmisiniz?Bağlantı falan dahil.
  • Evet arkadaşlar yine ben.Arkadaşlarla toplandık projeyi yapıyoruz size ufak bi soru sormak istiyorum.Şimdi bi windows application yapıyoruz.Şimdi yazdık classs diye bi class ve ogrenci adında (classs tipinde) bi dizi oluşturduk.Bu ogrenci ile ilgili her türlü değişikliği felan yaptık.Sonra bi kaç buton yaparak bu ogrencideki değerleri kullanacaz ama butonun metodunda ogrenciyi tanımıyor.public felan bişiyler yazdık ama olmadı.Bunu nasıl halledebilirim.Yardımlarınız için şimdiden teşekkürler...



    public static void Main()  
    {
    Application.Run(new Form1());
    classs[] ogrenci=new classs[50];
    }

    public void button1_Click(object sender, System.EventArgs e)
    {
    richTextBox1.Text=ogrenci[1].ad;
    }
  • quote:

    Orjinalden alıntı: by_ram

    Evet arkadaşlar yine ben.Arkadaşlarla toplandık projeyi yapıyoruz size ufak bi soru sormak istiyorum.Şimdi bi windows application yapıyoruz.Şimdi yazdık classs diye bi class ve ogrenci adında (classs tipinde) bi dizi oluşturduk.Bu ogrenci ile ilgili her türlü değişikliği felan yaptık.Sonra bi kaç buton yaparak bu ogrencideki değerleri kullanacaz ama butonun metodunda ogrenciyi tanımıyor.public felan bişiyler yazdık ama olmadı.Bunu nasıl halledebilirim.Yardımlarınız için şimdiden teşekkürler...



    public static void Main()  
    {
    Application.Run(new Form1());
    classs[] ogrenci=new classs[50];
    }

    public void button1_Click(object sender, System.EventArgs e)
    {
    richTextBox1.Text=ogrenci[1].ad;
    }



    tanımaması çok normal çünkü diziyi main fonksiyonu içinde yaratıyosun bunu diziyi en yukarda değişkenleri tanımlarken yaratırsan belki olur bi onu dene
  • quote:

    Orjinalden alıntı: XmysticX

    Accessde, Urunler tablosundan Marka diye bir kolonum var, buradan verileri çekip comboBox a nasıl aktarıcam,
    baştan yazabilirmisiniz?Bağlantı falan dahil.


    oledbConnection conn=new oledbConnection(baglantı sorgusu);
    conn.Open();
    string sorgu="SELECT Marka FROM Urunler
    oledbDataAdapter adt=new oledbDataAdapter(sorgu,conn);
    DataSet ds=new DataSet();
    adt.Fill(ds,"Urunler");
    DropDownList1.DataSource =ds.Tables[0] ;
    DropDownList1.DataTextField =ds.Tables[0].Columns["Marka"].ColumnName.ToString();
    DropDownList1.DataBind () ;
    conn.Close()
  • quote:

    Orjinalden alıntı: koray1983


    quote:

    Orjinalden alıntı: by_ram

    Evet arkadaşlar yine ben.Arkadaşlarla toplandık projeyi yapıyoruz size ufak bi soru sormak istiyorum.Şimdi bi windows application yapıyoruz.Şimdi yazdık classs diye bi class ve ogrenci adında (classs tipinde) bi dizi oluşturduk.Bu ogrenci ile ilgili her türlü değişikliği felan yaptık.Sonra bi kaç buton yaparak bu ogrencideki değerleri kullanacaz ama butonun metodunda ogrenciyi tanımıyor.public felan bişiyler yazdık ama olmadı.Bunu nasıl halledebilirim.Yardımlarınız için şimdiden teşekkürler...



    public static void Main()  
    {
    Application.Run(new Form1());
    classs[] ogrenci=new classs[50];
    }

    public void button1_Click(object sender, System.EventArgs e)
    {
    richTextBox1.Text=ogrenci[1].ad;
    }



    tanımaması çok normal çünkü diziyi main fonksiyonu içinde yaratıyosun bunu diziyi en yukarda değişkenleri tanımlarken yaratırsan belki olur bi onu dene




    ilgin için saol.Bu en yukarda dediğin yer tam olarak neresi (windows applicationda) ?
  • public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.DataGrid dataGrid1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.Button button3;

    classs[] ogrenci=new classs[50]; // işte burası demek istemiştim form öğelerinin declare edildiği yer

    .
    .
    .
    .
    .
    .
    }
  • slmlar herkese...bende kendi çapında program yazmaya çalısan(buna mecbur olan) biriyim.(bölümüm bilgisayar çünkü).ve ve bana ACİL olarak sudoku nun kodu lazım.eger ilgilenirseniz çok memnun olucam.beni büyük bi dertten kurtarmıs olacaksınız!!!

    şimdiden tesekkürler arkadaslar
  • arkadaslar program c#ta olursa çok iyi olur.ve bana en gec bugün aksama lazım...
  • arkadaşlar bende c ile pic control ediyorum ancak görsel programlamayada geçmek istiyorum ve c den uzaklaşmakta istemiyorum ,bu bağlamda visual c++ mı yoksa c# mı öğrenmeye çalışim,c# da java dan baya karışım varmıs heralde ,ne önerirsiniz?
    herkeze teşekkürler.
  • Arkadaşlar şu bitmap sınıfı ile ilgili türkçe kaynak önerebilir misiniz ?? Filtrelerle ilgili bir proje yapmam gerekio da kaynak ver bilgi sorunum var
  • Cyristal Reportlar la ilgilenen varmı ben öğrenmek istiyorum ama hiç bir önbilgim yok kullanan varsa aranızda yardımcı olabilirmi bi başlangıç fikri edinmek için. Ne zaman işimize yarar cyristal reportlar. Sınıfları ve kullanı şekilleri ................................
    Örnek uygulama olursa daha iyi olur .
  • güzel olmus bu C# basligi ama gördügüm kadariyla cok aktif diil.
    yavas yavas C++ / ORACLE ikilisinden kurtulmaya basladim:)
    sanirim bundan sonra baya C# ve .NET'le ilgilenecegim yani
    umarim faydali olur bu baslik benim icin.gerci biraz bilgim var,kendimce bikac
    proje yaptim.herneyse Koray'in sorusuna gelince,herhalde simdi ben
    anlatmaya kalksam yeniyim diye yazdigim icin ciddiye almaz:))
    bak bikac link var burda inceldim biraz baya iiler ve anlasilir.
    belki isine yarar.bide elimde professional CrystalReports
    eBook var istersen yaz mailini atayim onuda.herneyse herkese kolay gelsin;)



    türkce
    http://www.msakademik.net/makaleler_detay.aspx?id=480
    http://www.csharpnedir.com/makalegoster.asp?MId=261
    http://www.csharpnedir.com/makalegoster.asp?MId=284

    english
    http://www.c-sharpcorner.com/CrystalReports.asp (baya ii)
    http://www.codeproject.com/useritems/CrystalWin.asp (eger burda CrystalReports diye aratirsan cok makale var)



    < Bu mesaj bu kişi tarafından değiştirildi tamers -- 13 Nisan 2006; 3:10:47 >
  • 
Sayfa: önceki 12345
Sayfaya Git
Git
sonraki
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.