473,804 Members | 3,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# - RectangleF will not Offset when used as Property

2 New Member
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.Re ctangle.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 1887

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

Similar topics

2
4454
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 offset when I resize the browser. Here's the modified code. I just don't want the link and frequently used link text are mixed when i resize the browser. Any workarounds to this problem? Please help!! <html> <head>
8
4072
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 problems getting my algorithm to work and in order to help me find the solution I decided to print each line to screen as I read them. Then, to my surprise, I noticed that there was a space between every character as I outputted the lines to the...
15
2717
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: In this statement, "0" has a signed int type, but occurs in a context that requires a pointer. (needpointer) Can anybody point out where the problem is ?
1
16724
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
2693
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 that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers, you will have built up a substantial inventory of code in that time. And if you've been following...
1
1886
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 height? Width is ok, but height is clearly wrong. This looks very much like a bug to me. Further, when you try to check Dim mybool as Boolean = Dimensions.Contains(50.0,50.0)
3
1795
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, MousePosition.Y)), if I then compare p to listviewitem.Position, where listviewitem is the icon the user clicked, then in some cases the two points aren't equal. Anyone that can explain why this offset exists and is there a way to know what this offset would...
12
4062
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 the shared memory. I run fedora 9 and gcc 4.2. I am able to insert values in to the list, remove values from the list, but the problem is in traversing the list. Atlease one or 2 list nodes disappear when traversing from the base of the list or...
2
3903
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
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.