Click here to Skip to main content
15,895,799 members
Home / Discussions / C#
   

C#

 
GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri8-Apr-11 22:44
Anubhava Dimri8-Apr-11 22:44 
AnswerRe: PolyGon To Shift Right Pin
Richard MacCutchan8-Apr-11 23:22
mveRichard MacCutchan8-Apr-11 23:22 
AnswerRe: PolyGon To Shift Right Pin
OriginalGriff8-Apr-11 23:29
mveOriginalGriff8-Apr-11 23:29 
GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri8-Apr-11 23:51
Anubhava Dimri8-Apr-11 23:51 
AnswerRe: PolyGon To Shift Right Pin
OriginalGriff9-Apr-11 0:04
mveOriginalGriff9-Apr-11 0:04 
GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri9-Apr-11 0:39
Anubhava Dimri9-Apr-11 0:39 
GeneralRe: PolyGon To Shift Right Pin
dan!sh 9-Apr-11 1:03
professional dan!sh 9-Apr-11 1:03 
AnswerRe: PolyGon To Shift Right Pin
OriginalGriff9-Apr-11 1:07
mveOriginalGriff9-Apr-11 1:07 
So, find the minimum X coordinate of your polygon, and use a negative version of that as the xOffset.

Point[] shape = new Point[] { new Point(50, 50),
                              new Point(100, 250),
                              new Point(200, 5),
                              new Point(250, 50),
                              new Point(300, 100),
                              new Point(350, 200),
                              new Point(250, 250)};

public void DrawPolygonPoint(PaintEventArgs e)
    {
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
    Pen redPen = new Pen(Color.Red, 1);
    e.Graphics.DrawPolygon(redPen, shape);
    int minX = int.MaxValue;
    foreach (Point p in shape)
        {
        if (p.X < minX)
            {
            minX = p.X;
            }
        }
    // Create points that define polygon.
    Point[] curvePoints = new Point[shape.Length];
    int i = 0;
    foreach (Point p in shape)
        {
        curvePoints[i++] = AddOffset(p, - minX, 0);
        }

    // Draw polygon to screen.
    e.Graphics.DrawPolygon(blackPen, curvePoints);
    redPen.Dispose();
    blackPen.Dispose();
    }
Draws the original in red, and a left aligned version in black. Note that I have moved your individual points into an array to make it easier to work with.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

Manfred R. Bihy: "Looks as if OP is learning resistant."

GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri9-Apr-11 1:10
Anubhava Dimri9-Apr-11 1:10 
GeneralRe: PolyGon To Shift Right Pin
OriginalGriff9-Apr-11 1:15
mveOriginalGriff9-Apr-11 1:15 
GeneralRe: PolyGon To Shift Right Pin
Luc Pattyn9-Apr-11 5:52
sitebuilderLuc Pattyn9-Apr-11 5:52 
GeneralRe: PolyGon To Shift Right Pin
OriginalGriff9-Apr-11 5:55
mveOriginalGriff9-Apr-11 5:55 
GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri10-Apr-11 18:17
Anubhava Dimri10-Apr-11 18:17 
GeneralRe: PolyGon To Shift Right [modified] Pin
GlobX10-Apr-11 18:32
GlobX10-Apr-11 18:32 
GeneralRe: PolyGon To Shift Right Pin
David198710-Apr-11 20:26
David198710-Apr-11 20:26 
JokeRe: PolyGon To Shift Right Pin
GlobX10-Apr-11 20:31
GlobX10-Apr-11 20:31 
AnswerRe: PolyGon To Shift Right Pin
Luc Pattyn9-Apr-11 5:55
sitebuilderLuc Pattyn9-Apr-11 5:55 
GeneralRe: PolyGon To Shift Right Pin
Anubhava Dimri10-Apr-11 18:16
Anubhava Dimri10-Apr-11 18:16 
QuestionC# session Pin
adrian salas8-Apr-11 18:09
adrian salas8-Apr-11 18:09 
AnswerRe: C# session Pin
OriginalGriff8-Apr-11 20:36
mveOriginalGriff8-Apr-11 20:36 
GeneralRe: C# session Pin
adrian salas9-Apr-11 3:33
adrian salas9-Apr-11 3:33 
AnswerRe: C# session Pin
Anubhava Dimri8-Apr-11 20:50
Anubhava Dimri8-Apr-11 20:50 
AnswerRe: C# session Pin
dan!sh 9-Apr-11 5:34
professional dan!sh 9-Apr-11 5:34 
AnswerRe: C# session Pin
Ganesh Kumar Kaki13-Apr-11 1:21
Ganesh Kumar Kaki13-Apr-11 1:21 
QuestionWebserver only sending text occasionally? [modified] Pin
venomation8-Apr-11 16:38
venomation8-Apr-11 16:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.