c# - Constraining windows wpf -


i have window needs constrained within window. in order this, hook sizechanged event on top level window....and in event need adjust second window aligned nearest edge if there intersection between 2 i.e if smaller window gets outside boundary of bigger window. lot of math calculation this...and im still not near solution!

im having trouble doing because involves lot of messy code wondering if of guys had easier solution this?

basically im dealing 2 rectangles , need ensure when size of bigger rectangle changes...if there intersection between two, smaller rectangle should align edge of bigger rectangle smaller rectangle within bigger rectangle.

could simple math problem in c# forms?

any suggestions welcome thanks!

for both windows need x , y coordinates of location of window in systemcoordinates.

how in wpf can found here http://blogs.msdn.com/b/llobo/archive/2006/05/02/code-for-getting-screen-relative-position-in-wpf.aspx

next need have 2 windows react on each others sizechanged events 1 window gets notified when others size has changed.

then following math job: (assuming window 1 in bounds of window 2 , window 2 size changes , want resize window instead of moving when possible)

//pseudocode //case1 (left bound changes) if(window2.x > window1.x) {     window1.x = window2.x; } //case2 (top bound changes) if(window2.y > window1.y) {     window1.y = window2.y; } //case3 (right bound changes) if(window2.x + window2.width < window1.x + window1.width) {     window1.width = window2.x + window2.width - window1.x; } //case4 (bottom bound changes) if(window2.y + window2.height < window1.y + window1.height) {     window1.height = window2.y + window2.height - window1.y; }         

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -