|
I want to draw a rectangle while moving the mouse. But the event handlers below would preserve all the intermediate rectangles in the window. How to erase the intermediate rectangles and only show the last rectangle?
Thanks.
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
firstpoint = new Point(e.X,e.Y);
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen dotPen = new Pen(Color.Black, 1);dotPen.DashStyle=DashStyle.Dot;
g.DrawRectangle(dotPen,firstpoint.X,firstpoint.Y,e.X-firstpoint.X,e.Y-firstpoint.Y);
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
secondpoint=new Point(e.X,e.Y);
Graphics g = this.CreateGraphics();
Pen dotPen = new Pen(Color.Black, 1);dotPen.DashStyle=DashStyle.Dot;
g.DrawRectangle(dotPen,firstpoint.X,firstpoint.Y,e.X-firstpoint.X,e.Y-firstpoint.Y);
}
|
|
|
|
|
I think you should draw your rectangle in the Form's Paint event
As per my knowledge using the CreateGraphics() draws a drawing permanently
-- modified at 8:18 Thursday 13th October, 2005
|
|
|
|
|
Hi All,
I wondered if anyone could make sense of this undocumented object (System.Runtime.Remoting.Proxies.__TransparentProxy) being returned from the static method call to System.Appdomain.CreateDomain(...).
Normally (in my mono-assembly testing application), System.Appdomain.CreateDomain(...) returns the documented System.Appdomain that is expected.
When I stitch the code into my multi-project solution, however, the call returns a __TransparentProxy object that raises exception further on in code when I call a member on it (of what is supposed to be the System.Appdomain object). The exception demands that all sorts of classes (and their members!) be marked as serializable. I'm not interested in doing that for various reasons.
Any help is greatly appreciated.
Rein
|
|
|
|
|
Rein_Petersen wrote:
I wondered if anyone could make sense of this undocumented object (System.Runtime.Remoting.Proxies.__TransparentProxy) being returned from the static method call to System.Appdomain.CreateDomain(...).
It makes sense. It returns a remoted object.
Rein_Petersen wrote:
Normally (in my mono-assembly testing application), System.Appdomain.CreateDomain(...) returns the documented System.Appdomain that is expected.
Mono either doesnt support real remoting or they have it implemented incorrectly or their debugger displays the 'real' type of the transparent proxy.
Rein_Petersen wrote:
I'm not interested in doing that for various reasons.
You will have to. Remember you can use the Nonserializable attribute on fields that dont require to be serialized. I know its a pain, but you have to do, what you have to do.
xacc-ide 0.0.99-preview2 (now with integrated debugger)
|
|
|
|
|
Hi Leppie,
Thanks very much for responding. I realize that my wording was somewhat ambiguous and I think you mistook my reference to my "mono" assembly test appplication was to the mono project [ http://www.mono-project.com ]. I was trying to indicate that the testing application (which I often use to break down more complicated code into it's most fundamental bits for my own better understanding) was a single (mono) assembly.
My actual application has several projects constituting the entire solution. It is that distinction that I believe causes System.Appdomain.CreateDomain(...) to return the __TransparentProxy instead of the desired|expected System.Appdomain (as it does in the single project test app).
I'm still stymied on that.
Rein
|
|
|
|
|
Hello again everyone. I am writing this function that checks when a string has a blank in it, and if it does, I want to replace it with an underscore, but when I compile my program I get this error:
Property or indexer 'string.this[int]' cannot be assigned to -- it is read only.
Here is my function, it is very simple:
<br />
public void File_Fix_Spaces(string original_file, string text)<br />
{<br />
bool done = false;<br />
<br />
string new_filename = "";<br />
<br />
for(int i=0; i<original_file.Length; i++)<br />
{<br />
if(original_file[i]==' ')<br />
{<br />
original_file[i] = '_';<br />
done = true;<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Yep, that's right. Strings are immutable in the .NET Framework. You'll have to recode your function to convert the string to a StringBuilder object instead. StringBuilder will hold your string as an array of bytes or characters that you can then manipulate any way you want, then, at any time, you can have the StringBuilder recompile the array back into a String simply by calling it's .ToString() method.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What Dave said is correct but just as a hint: The .Net framework has a function to do what you want:
string newFileName = oldFileName.Replace(' ', '_');
|
|
|
|
|
Very true! I've been getting a little tunnel vision lately. Work stress is getting to me...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Iam just starting to try and use resource files to embed images and icons rather than have them as files that need to be available when running the application.
I have tried many different examples of code in my application but can not get any of them to work. The best I have managed is to create the resource file, add some code to the application and compile it without error, when I try to run it I get a :
Application has generated an exception that could not be handled
error every time.
Please could someone point me in the right direction.
I have created a 'MyRes.rs' file with the following text :
MyResImage1 IMAGE Image1.jpg
MyResIcon ICON MyIcon.ICO
used rc.exe to build the res file and that created a 'MyRes.RES' file
The trouble now is that I do not know how to access the resourse in my application to, for example:
use the Image1.jpg in an image list
use the MyIcon.ICO as an icon for the application in the status bar
Please could someone help (example code, or pointers to example code, would be very helpfull as I am fairly new to C# programming)
Thank you
Paul
-- modified at 15:25 Wednesday 12th October, 2005
|
|
|
|
|
Hello,
Is there a way of assigning null value to a decimal. Or, do I have to declare it as a string, and keep converting it to the decimal?
Thank you
|
|
|
|
|
C# 2.0 supports nullable types, if you;re using an older version you'll have to kluge it in one way or annother.
|
|
|
|
|
Thank you.
String conversion it is then.
|
|
|
|
|
If you're using .NET 1.x, then no, you can't assign null to a decimal. .NET 2.0 has nullable types, which means you can. However, that would require you to develop for 2.0 only, which will be released in November. So...it's up to you.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
This doesn't result in a null value. This results in the decimal type have a value of 0. Value types cannot be null in the .NET Framework 1.0 and 1.1.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i've just posted a question like this, but i've got an answer not adapted at what i mean...
I explain better.
I can open a .avi file using this:
string file_path = @"c:\myfile.avi";
string sComand = "open \"" + file_path + "\" type mpegvideo alias...";
mciSendString(sComand, null, 0, IntPtr.Zero);
OK it just works, but i need to open a file from memory stream (System.IO.Stream, otherwise byte[] ) instead to load a file from the HardDisk.
How???
|
|
|
|
|
Well, you can't really hand off a stream to whatever you're using to play an AVI file because it probably doesn't understand streams. However, you could use the System.IO.IsolatedStorage classes to store the stream to a file in a temporary location and then open it from there. Just a thought...
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
i can't do it becouse i can't allow the user can get freely that file.
other ways? Are you sure about the not possibility to use tht function with a source stream?
|
|
|
|
|
If you're really that concerned about not letting the person at the data, then you may want to look into setting up a Windows Media Server then and just serving up the files as streams. That would seem to be the best way to go about doing it.
As for whether or not the player you're using can understand the System.IO.FileStream class, it would have to be written in .NET, or at least have .NET based functions...which none of the major players I've seen are. So that answer is no.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
i've found aviStreamRead() function
Now i world to use it in c#, how?
|
|
|
|
|
What player are you using? How is this function defined? Could you give me a link to the SDK documentation for the player you're using?
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
If you have to stream comming from a Windows Media Server and are using the MediaPlayer control on your form, you've got nothing to worry about. Just point the MediaPlayer at the URL for the stream you want.
You never said anything about where the stream was coming from or what type it is...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
to make that the user have to have installed on its computer windows media player, and i'm forced to use windows media player gui.
I want just play a avi file but now calling it from a path as c:\myfile.avi but using a FileStream or a Byte[].
I think it is possible in some way, but how? DirectShow?
|
|
|
|
|
OK. The stream isn't from a file and it isn't comming from a server. So, where is this stream comming from?
Maybe you can come up with something from this[^] sample.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
the file stream came from the embedded source.
|
|
|
|