473,394 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# - RectangleF will not Offset when used as Property

When I run the following tests (In NUnit):

Expand|Select|Wrap|Line Numbers
  1.     [Test]
  2.     public void ShouldOffsetRectangle() {
  3.       RectangleF standAloneRect = new RectangleF(0, 0, 10, 10);
  4.       standAloneRect.Offset(1, 1);
  5.       Assert.AreEqual(1, standAloneRect.X, "standAlone failed");
  6.     }
  7.  
  8.     [Test]
  9.     public void ShouldOffsetRectangleAsProperty() {
  10.       TestRect propertyRect = new TestRect();
  11.       propertyRect.Rectangle = new RectangleF(0, 0, 10, 10);
  12.       propertyRect.Rectangle.Offset(1, 1);
  13.       Assert.AreEqual(1, propertyRect.Rectangle.X, "propertyRect failed");
  14.     }
  15.  
  16.     private class TestRect {
  17.       public RectangleF Rectangle { get; set; }
  18.     }
The second test fails... it says that the propertyRect.Rectangle.X is still 0.

Any ideas why this behavior might be? I am stumped at this point.

Obviously I can get around it by offsetting the Rectangle before assigning it, I am just trying to figure out why I am seeing this behavior.

Thanks,

Matt
Aug 15 '08 #1
0 1867

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
I posted a question before regarding the offset positions when I used CSS. Some people suggested I should use percentage instead of pixels? I tried many different ways, but the position still...
8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
15
by: junky_fellow | last post by:
I am trying to find the offset of a member "mbr" inside a structure "str" as follows: offset = &(struct str *)0->mbr; But, on compilation I get the following error: cc: Error: m1.c, line 55:...
1
by: Yaron | last post by:
Hi Is there any EASY way to convert RectangleF to a Rectangle object? Casting doesnt work, and it doesn't have a ToRectangle function or anything like that (although it should! Thanks Yaron
5
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all...
1
by: Hypnotron | last post by:
Dim Dimensions as RectangleF = RectangleF.FromLTRB(-100, 100, 100, -100) debug.writeline( "Height = " & RectangleF.Height.ToString) Why the heck is height -200 ? How can you have a negative...
3
by: lior_kovarsky | last post by:
I have a listview with large icons. When user clicks, say the top left of an icon, and in the mouse down event i have Point p = listview1.PointToClient(new Point(MousePosition.X,...
12
by: kalyan | last post by:
Hi, I am using Linux + SysV Shared memory (sorry, but my question is all about offset + pointers and not about linux/IPC) and hence use offset's instead on pointers to store the linked list in...
2
by: GTalbot | last post by:
Hello fellow comp.infosystems.www.authoring.stylesheets colleagues, Imagine this situation: #grand-parent-abs-pos { height: 400px; position: absolute; width: 600px; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.