Click here to Skip to main content
15,886,026 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to find the maximize & minimum points from List ? Pin
Luc Pattyn21-Aug-10 23:17
sitebuilderLuc Pattyn21-Aug-10 23:17 
GeneralRe: How to find the maximize & minimum points from List ? Pin
Yanshof21-Aug-10 23:21
Yanshof21-Aug-10 23:21 
GeneralRe: How to find the maximize & minimum points from List ? Pin
Luc Pattyn21-Aug-10 23:36
sitebuilderLuc Pattyn21-Aug-10 23:36 
GeneralRe: How to find the maximize & minimum points from List ? Pin
OriginalGriff21-Aug-10 23:37
mveOriginalGriff21-Aug-10 23:37 
AnswerRe: How to find the maximize & minimum points from List ? Pin
Eddy Vluggen22-Aug-10 0:48
professionalEddy Vluggen22-Aug-10 0:48 
GeneralRe: How to find the maximize & minimum points from List ? Pin
Luc Pattyn22-Aug-10 8:53
sitebuilderLuc Pattyn22-Aug-10 8:53 
GeneralRe: How to find the maximize & minimum points from List ? Pin
Eddy Vluggen22-Aug-10 9:51
professionalEddy Vluggen22-Aug-10 9:51 
AnswerRe: How to find the maximize & minimum points from List ? [modified] Pin
cechode22-Aug-10 10:08
cechode22-Aug-10 10:08 
How about something like this

// distance = Pythagorean 
Func<Point, Point, double> distanceToken = new Func<Point, Point, double>((p1, p2) => { return ((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)); });

            Point TopLeft = new Point() { X = 0, Y = 0 };  // or however you want to define it. 
            Point BottomRight = new Point() { X = 100, Y = 100 };  // or however you want to define it.


//assuming that you can measure the desired distance with 1 point ( nearest top left and farthest top left ( which is bottom right )
            var t = (from pt in points
                    select new { p=pt, d= distanceToken (TopLeft, pt) }).OrderBy(a=>a.d);

            Console.WriteLine("nearest topleft:" + t.First().ToString());
            Console.WriteLine("farthest topleft:" + t.Last().ToString());

//othewise using two points 
            var t = (from pt in points
                     select new { p = pt, DistToA = distanceToken (TopLeft, pt), DistToB = distanceToken(BottomRight, pt) });


modified on Sunday, August 22, 2010 4:46 PM

GeneralRe: How to find the maximize & minimum points from List ? Pin
harold aptroot22-Aug-10 10:33
harold aptroot22-Aug-10 10:33 
GeneralRe: How to find the maximize & minimum points from List ? Pin
cechode22-Aug-10 10:42
cechode22-Aug-10 10:42 
Questionmoving a rectangle with in a pannel Pin
prasadbuddhika21-Aug-10 21:36
prasadbuddhika21-Aug-10 21:36 
AnswerRe: moving a rectangle with in a pannel Pin
OriginalGriff21-Aug-10 22:07
mveOriginalGriff21-Aug-10 22:07 
AnswerRe: moving a rectangle with in a pannel Pin
Luc Pattyn21-Aug-10 23:18
sitebuilderLuc Pattyn21-Aug-10 23:18 
QuestionHas anyone make the decorator pattern working in c# ? Pin
588321-Aug-10 16:24
588321-Aug-10 16:24 
AnswerRe: Has anyone make the decorator pattern working in c# ? Pin
Not Active21-Aug-10 16:42
mentorNot Active21-Aug-10 16:42 
AnswerRe: Has anyone make the decorator pattern working in c# ? Pin
Pete O'Hanlon21-Aug-10 21:24
mvePete O'Hanlon21-Aug-10 21:24 
AnswerRe: Has anyone make the decorator pattern working in c# ? Pin
Shani Natav22-Aug-10 2:26
Shani Natav22-Aug-10 2:26 
Questionprevent form resizing on titlebar double clicks Pin
Jassim Rahma21-Aug-10 11:58
Jassim Rahma21-Aug-10 11:58 
AnswerRe: prevent form resizing on titlebar double clicks Pin
Not Active21-Aug-10 12:12
mentorNot Active21-Aug-10 12:12 
GeneralRe: prevent form resizing on titlebar double clicks Pin
Jassim Rahma21-Aug-10 13:03
Jassim Rahma21-Aug-10 13:03 
AnswerRe: prevent form resizing on titlebar double clicks Pin
Ravi Bhavnani21-Aug-10 13:23
professionalRavi Bhavnani21-Aug-10 13:23 
GeneralRe: prevent form resizing on titlebar double clicks Pin
Not Active21-Aug-10 13:34
mentorNot Active21-Aug-10 13:34 
GeneralRe: prevent form resizing on titlebar double clicks Pin
Ravi Bhavnani22-Aug-10 4:42
professionalRavi Bhavnani22-Aug-10 4:42 
GeneralRe: prevent form resizing on titlebar double clicks Pin
Not Active21-Aug-10 13:29
mentorNot Active21-Aug-10 13:29 
Questioncombobox Tab problem Pin
Jassim Rahma21-Aug-10 11:55
Jassim Rahma21-Aug-10 11:55 

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.