|
I've changed how I was handeling the IsDirty notificaiton and the problem has gone away. My best guess is that I had a few objects that were setting this property fighting over what the value should be. Under normal circumstances this would be easy to detect, but for some reason my debugger wasn't stopping in my Set statement when it was being called from these other objects. I even setup some debug.writeline statements in my set that said: "Being Set True", "Being set false". As soon as I would set Foo.IsDirty = true I would see:
Being Set True
Being set false
in the immediate window. So something was running right along behind me setting the value back to false and ignoring my break points as it did so. I could have probably resolved this issue in a few minutes if my breakpoint was being hit each time the value changed.
I've never even heard of anybody experiencing this problem before. I certantly hope I never get to experience it again.
thanks.
|
|
|
|
|
Not sure what the problem could be, however, you should not be allowing another object to set the isDirty property--bad design. A better idea is for the object to decide when it is dirty and the property should be readonly. In your design your object might not be dirty and another object can easily set it to dirty and then "Houston, we have a problem!". So do the following:
public string Name
{
get
{
return _name;
}
set
{
_name = value;
// Now I am dirty since I am changed so I will set myself as dirty since I am a smart object
_isDirty = true;
}
}
|
|
|
|
|
CodingYoshi wrote: allowing another object to set the isDirty property--bad design.
Yeah, this problem is making me question my current design all right. The way I have it right now the property can be changed from my Foo object when one of it's properties like name changes. Foo however has children objects that can also be dirty. If a child is dirty I have it mark Foo as dirty so I don't have to go searching the whole child hierarchy each time I check the property.
grumble..........
|
|
|
|
|
You have a good attitude and will go far in life! Especially if this is the kind of attitude you have when you are clearly asking for help and someone used their valuable time to help you out. BTW it is still a bad design and there is a better solution but I doubt you will get it with that attitude.
|
|
|
|
|
CodingYoshi wrote: I doubt you will get it with that attitude.
This problem has me frazzled but I wasn't trying to give any attitude. My apologies if that's how I came off.
|
|
|
|
|
Okay. I would make all the children fire an event when they are dirty and the parent can handle the event and do whatever it needs--mark itself dirty. This design is better because it offers encapsulation. You can even create a list and keep track of all the children which are dirty during handling your event and now you do not have to go down the hierarchy to fine which child is dirty.
|
|
|
|
|
Hi,
having the internal keyword makes your property available to the entire assembly; I would not do that at all. Maybe lots of classes need to be able to set mIsDirty true, but the usage of IsDirty=false; should be very restricted.
Hence I would use the private or protected attribute and if needed also provide a public void MarkDirty(); method.
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:17 PM
|
|
|
|
|
Greetings!
Does anyone know a way to show (the parent of) a ToolStripDropDownButton as pressed or not pressed? As in, I should be able to *set* the value of such a property. I'm guessing this is something similar to ToolStripButton.Checked - I've scoured MSDN & Google but nobody's ever wanted to do it, by the looks of it (or I'm just not getting it!)
I want my ToolStripDropDownButton to show up as "pressed" up until I press some other button.
Any help or tips you might be able to give is highly appreciated
|
|
|
|
|
I don't think there is such a property. You can use a different icon to represent pressed and unpressed states and will be more clear. You can also change the background color when pressed and unpressed.
|
|
|
|
|
Hi! I'm wondering is there some algorithm to calculate a math function's limit: Wikipedia[^]
Still learning...
|
|
|
|
|
Hi,
nike_arh wrote: calculate a math function's limit
numerically? yes
analytically/symbolically? yes, much harder though
Google!
modified on Sunday, January 18, 2009 5:32 PM
modified on Friday, June 10, 2011 12:17 PM
|
|
|
|
|
Hey guys.
What are the differences between int? and int ?
Thank you
|
|
|
|
|
Nullable types can represent all the values of an underlying type, and an additional null value. Nullable types are declared in one of two ways:
System.Nullable<t> variable
-or-
T? variable
see more:
http://msdn.microsoft.com/en-us/library/2cf62fcy(VS.80).aspx[^]
Human knowledge belongs to the world
http://www.rad.pasfu.com/index.php
|
|
|
|
|
A good response Reza.
Thank you
|
|
|
|
|
Hi guys,
I am working on a tool to test a website. Here is a short version of the code to highlight where I am having issues:
namespace Tao
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string Refresh()
{
this.webBrowser1.Url = new System.Uri("www.someURL.com", System.UriKind.Absolute);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
string PageText = this.webBrowser1.DocumentText.ToString();
return PageText;
}
public void button1_Click(object sender, EventArgs e)
{
string Page = Refresh();
webBrowser1.Document.GetElementById("submit").InvokeMember("click");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
Thread.Sleep(5000);
}
}
}
I have removed a lot of code to simplify this post. Basically, the form has a button that starts a loop around the browser refresh and the button click for submit. When the Refresh() object executes, because of the WebBrowserReadyState.Complete & DoEvents() objects, the webpage loads completely before the submit button is clicked. My problem is that I cannot get the brower to wait after I send the click element before the refresh action executes again. To be more clear, I hear it submit the click command, but the page does not refresh to the redirected page either before, during, or after the Thread.Sleep(5000) executes. I would like to see the redirect page after I click submit and I would like it to fully load before I execute the entire loop again. Can someone please suggest how I can make this happen?
If this description needs to be clarified, please chime in and thank you for anyone that can help me with this,
Joe
|
|
|
|
|
Hello,
In my application I scan image (by C# code) and I save in local disc (by C# code),but problem is: the image is very large with size 1.50MB after it is saved in local disc.
How can I decrease size of scaned image by C# code?
Regards.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
You could compress it using GZip[^].
/ravi
|
|
|
|
|
Hi,
Image.Save has many overloads, don't just use myImage.Save(myFilename);
the file size depends on many things:
- the image size in pixels (width and height); do you actually need that resolution?
- the number of bits per pixel (e.g. 24 bpp);
- the image format (see ImageFormat class).
It all depends on what you want or need. You can reduce the number of pixels (by resampling the image), you can reduce the number of bits per pixel, or you can choose an image format with high(er) compression.
Some formats have no compression, some can compress but don't do so by default, some (e.g. JPEG) perform
compression and allow a choice from best quality to most compact.
Another way to reduce image size is reducing the number of different colors to 256 and use an
indexed image, that way it takes 1 byte per pixel.
|
|
|
|
|
Thank you for your answer,I figured out based on your suggestions.
Finally I used ImageFormat and it works good.
My best regards.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
You're welcome.
|
|
|
|
|
I have a project where I'm using SetWindowPos through pinvoke to show a frameless window. In Windows Vista, when the window would load, there would be no window opening animation, but now that I'm running the project in Windows 7 the animation is there.
I'm now trying to use AnimateWindow to change the opening animation so that the length is 0. But I'm having trouble accomplishing anything with AnimateWindow except changing the behavior to hiding the window instead of showing it.
Is there anyone who can help?
Do we have any forum here specifically for Win32 API discussions?
|
|
|
|
|
Given the following code:
namespace WinServices
{
public enum SC_ACTION_TYPE
{
SC_ACTION_NONE=0,
SC_ACTION_RESTART=1,
SC_ACTION_REBOOT=2,
SC_ACTION_RUN_COMMAND=3
}
}
using WinServices;
public class MyClass
{
private static WinServices.SC_ACTION_TYPE m_actionType1 =
WinServices.SC_ACTION_TYPE.SC_ACTION_NONE;
private static WinServices.SC_ACTION_TYPE m_actionType2 =
WinServices.SC_ACTION_TYPE.SC_ACTION_NONE;
private static WinServices.SC_ACTION_TYPE m_actionType3 =
WinServices.SC_ACTION_TYPE.SC_ACTION_NONE;
}
Why am I getting a CLS compliance warning with this code (the property name - bolded, italicized, and underlined - is where the warning is happening)?
using WinServices;
public class MyClass
{
public static WinServices.SC_ACTION_TYPE ActionType1
{ get { return m_actionType1; } }
public static WinServices.SC_ACTION_TYPE ActionType2
{ get { return m_actionType2; } }
public static WinServices.SC_ACTION_TYPE ActionType3
{ get { return m_actionType3; } }
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Are both the enum and the class in the same assembly? If they are, is the assembly marked CLSCompliant ( the default is false ).
Have you tried explicitly marking the enum as compliant?
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Nick Butler wrote: Are both the enum and the class in the same assembly
No. Why should that matter?
Nick Butler wrote: Have you tried explicitly marking the enum as compliant?
No. I didn't know I could. Is that really a "good idea" (tm)?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If the enum is in an assembly that is marked not compliant ( or not explicitly marked as the default is false ), and you try to use it in an assembly that *is* marked as compliant, you will get this warning.
If you don't want to set the whole assembly that contains the enum as compliant, you can just mark the enum as compliant. It's just an option.
Nick
----------------------------------
Be excellent to each other
|
|
|
|