Click here to Skip to main content
15,900,461 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# program doesnt run on some machines Pin
Dan Mos5-Aug-11 11:53
Dan Mos5-Aug-11 11:53 
GeneralRe: C# program doesnt run on some machines Pin
HighlanderGreen8-Aug-11 11:32
HighlanderGreen8-Aug-11 11:32 
QuestionDatagridView, COMBOBOX COLUMN, Event does not happen immediately, Pin
ThorTheBraveGod5-Aug-11 3:11
ThorTheBraveGod5-Aug-11 3:11 
QuestionLocation Translation Logic Pin
cjb1105-Aug-11 0:48
cjb1105-Aug-11 0:48 
AnswerRe: Location Translation Logic Pin
V.5-Aug-11 1:34
professionalV.5-Aug-11 1:34 
GeneralRe: Location Translation Logic Pin
cjb1105-Aug-11 1:40
cjb1105-Aug-11 1:40 
GeneralRe: Location Translation Logic Pin
V.5-Aug-11 1:46
professionalV.5-Aug-11 1:46 
GeneralRe: Location Translation Logic Pin
cjb1105-Aug-11 2:02
cjb1105-Aug-11 2:02 
mmm, that might be difficult (and confuse things)...but I'll give it a go.

I've got an array of controls NodeLayout which are moved about by a Force-Based Graph Layout algorithim, which starts of setting the locations to a random value (-50,50), then shifting them about as it iterates. I've also got the following function:
C#
private Rectangle GetDiagramBounds()
        {
            int minX = Int32.MaxValue, minY = Int32.MaxValue;
            int maxX = Int32.MinValue, maxY = Int32.MinValue;
            foreach (NodeUI node in GraphUI.NodeUIs)
            {
                if (node.Location.X < minX)
                    minX = node.Location.X;
                if (node.Location.X > maxX)
                    maxX = node.Location.X;
                if (node.Location.Y < minY)
                    minY = node.Location.Y;
                if (node.Location.Y > maxY)
                    maxY = node.Location.Y;
            }
            return Rectangle.FromLTRB(minX, minY, maxX, maxY);
        }

Which returns the bounds of the resultant locations.
When this routine runs, that GetDiagramBounds returns values like (-2000, -6000, 3000, 5000).

I would like to draw these controls on a panel (although if that's the wrong control then I'm happy to change). But when I do, nothing appears, I'm thinking because the panel has a drawable area, and I'm drawing outside that area.

So I need to shift/translate all the positions so that they appear within the panel, but without altering their relative positions. I thought that meant shifiting so their location is > 0,0...

So at the moment I've got as the final step for each control in the array (nodeUI is the control):
Point newLoc = nodeUI.Location;
newLoc.X += Math.Abs(logicalBounds.X);
newLoc.Y += Math.Abs(logicalBounds.Y);
nodeUI.Location = newLoc;

logicalBounds being the result of that GetDiagramBounds function above.

But the locations are still < 0,0 for most of them.
GeneralRe: Location Translation Logic Pin
V.5-Aug-11 2:11
professionalV.5-Aug-11 2:11 
GeneralRe: Location Translation Logic Pin
cjb1105-Aug-11 2:19
cjb1105-Aug-11 2:19 
GeneralRe: Location Translation Logic Pin
V.5-Aug-11 2:25
professionalV.5-Aug-11 2:25 
GeneralRe: Location Translation Logic Pin
cjb1106-Aug-11 0:29
cjb1106-Aug-11 0:29 
GeneralRe: Location Translation Logic Pin
V.6-Aug-11 0:50
professionalV.6-Aug-11 0:50 
AnswerRe: Location Translation Logic Pin
BillWoodruff6-Aug-11 9:12
professionalBillWoodruff6-Aug-11 9:12 
QuestionSomething for beginners Pin
Qlex4-Aug-11 22:39
Qlex4-Aug-11 22:39 
AnswerRe: Something for beginners Pin
Blue_Boy4-Aug-11 22:59
Blue_Boy4-Aug-11 22:59 
AnswerRe: Something for beginners Pin
Richard MacCutchan4-Aug-11 23:09
mveRichard MacCutchan4-Aug-11 23:09 
GeneralRe: Something for beginners Pin
Qlex4-Aug-11 23:53
Qlex4-Aug-11 23:53 
GeneralRe: Something for beginners Pin
Richard MacCutchan4-Aug-11 23:57
mveRichard MacCutchan4-Aug-11 23:57 
GeneralRe: Something for beginners Pin
Qlex5-Aug-11 0:22
Qlex5-Aug-11 0:22 
GeneralRe: Something for beginners Pin
Richard MacCutchan5-Aug-11 3:31
mveRichard MacCutchan5-Aug-11 3:31 
AnswerRe: Something for beginners Pin
V.5-Aug-11 3:01
professionalV.5-Aug-11 3:01 
GeneralRe: Something for beginners Pin
Qlex5-Aug-11 3:08
Qlex5-Aug-11 3:08 
GeneralRe: Something for beginners Pin
V.5-Aug-11 3:18
professionalV.5-Aug-11 3:18 
AnswerRe: Something for beginners Pin
Eddy Vluggen5-Aug-11 6:19
professionalEddy Vluggen5-Aug-11 6:19 

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.