|
You need to modify your code as below:
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics pg = e.Graphics;
pg.DrawEllipse(new Pen(Color.Black ), 0, 0,
this.panel1.Width,this.panel1.Height);
pg.FillEllipse( new SolidBrush( Color.Red ), 0, 0,
this.panel1.Width, this.panel1.Height);
}
|
|
|
|
|
In this way, how i ll get the mouse position to draw?
|
|
|
|
|
Moon Boy wrote:
In this way, how i ll get the mouse position to draw?
Thats windows job! Not yours....
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi MoonBoy,
You want me to write the entire code and logic, then below is it:
int mouseX =0, mouseY =0;
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics pg = e.Graphics;
pg.DrawEllipse(new Pen(Color.Black ), mouseX, mouseY, 50,50);
pg.FillEllipse( new SolidBrush( Color.Red ),mouseX, mouseY, 50, 50);
}
private void panel1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.mouseX = e.X;
this.mouseY = e.Y;
this.panel1.Invalidate();
}
Do revert back whether it could solve your purpose or not?
Regards,
Jay.
|
|
|
|
|
Hi,
I am learning C# Express and have hit a roadblock with UserControl.
What is the minimum set of steps needed to create and display a dialog derived from UserControl?
So far, I think that I have created a form derived from UserControl.
From the IDE:
Project > Add Windows Form > User Control
This gives me a form and a .cs file.
namespace MyPropertiesDialog
{
public partial class MyPropertiesControl : UserControl
{
public MyPropertiesControl()
{
InitializeComponent();
}
private void MyPropertiesControl_Load(object sender, EventArgs e)
{
}
}
}
How do I invoke this dialog from the main application??
Since this works for message box,
MessageBox.Show("Hello!", "Greeting Box", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
I tried variations on this theme, but no success yet.
Thanks for your help,
Mark
|
|
|
|
|
It's a UserControl , so for example you could place a series of Button 's on it that have specific functionality and then make sure your Form class accesses the Controls collection and Add 's your control, then it should work. Do you have something specific you are trying to do?
- Nick Parker My Blog | My Articles
|
|
|
|
|
A Form is a top-level control that can be displayed directly on the screen. A UserControl is a control which can contain other controls and is placed on a Form . A UserControl is not directly shown on the screen which it seems is what you're trying to do.
So, you'd need to derive from Form and add your MyPropertiesControl to it.
public class MyDialog : Form
{
public MyDialog()
{
Controls.Add(new MyPropertiesControl());
}
} And then show it...
MyDialog dialog = new MyDialog();
dialog.ShowDialog();
Charlie
if(!curlies){ return; }
|
|
|
|
|
Thank you Nick and Charlie,
That was exactly what I was looking for!
I am thinking about doing some data collection via the serial port.
It will be a translation and enhancement of something I wrote in Borland Builder to access RS-485 devices. So far, C# Express seems to have a lot in common with Builder.
Mark
|
|
|
|
|
Salut everyone, i have done lotz of seaching but i haven't find much. Anyhelp is greatly appreciate.
I export a report into a csv file onto the webserver folder, now what i would like to do is zip that file that i just saved and allow the user to download it when they click a button.
Anyone know what class .NET support for zipping a file?
or any sample code on C# is great because i'm stuck here.
merci beaucoup ;)
*HyVong*
|
|
|
|
|
|
|
using java.util.zip;
using java.io;
..
..
i created method to zip the file based on the codes have given.
<br />
private void ZipFile(string fileName, string ExpType)<br />
{<br />
string extType = "zip";<br />
string zipFileName = fileName + "." + extType; <br />
string soureFileName = fileName + "." + ExpType;<br />
<br />
FileOutputStream fos = new FileOutputStream(zipFileName); <br />
<br />
ZipOutputStream zos = new ZipOutputStream(fos); <br />
<br />
FileInputStream fis = new FileInputStream(soureFileName); <br />
<br />
ZipEntry ze = new ZipEntry(soureFileName); <br />
<br />
zos.putNextEntry(ze); <br />
sbyte[] buffer = new sbyte[1024]; <br />
int len; <br />
<br />
while((len = fis.read(buffer)) >= 0) <br />
{ <br />
zos.write(buffer, 0, len); <br />
}<br />
<br />
zos.closeEntry(); <br />
fis.close(); <br />
zos.close(); <br />
fos.close();<br />
}<br />
I have the folder that held the file temporary has full access for users.
I don't know if i have to give the path for it to be able to zip too? Please help, i have no clue why it says access is denied. And is the code above correct?
I haven't had a chance to test the whole codes since the first line had some error. hope to hear from everyone soon. thank you so much.
*HyVong*
oh and when i tried to delete the file after it's being zipped, but i can't, 'File' is an ambiguous reference, how do i delete the file after being zipped?
File.Delete(Server.MapPath(@"~\import\\" + soureFileName));
Thanx so much for all your help.
|
|
|
|
|
actually i got this work, thank you so much for all your help
i changed <code
file.delete(server.mappath(@"~\import\\" +="" sourefilename));="">
to
System.IO.File.Delete(Server.MapPath(@"~\import\\" + soureFileName));<br />
and the file did got zip, i gave it a path for specific folder
FileInputStream fis = new FileInputStream(Server.MapPath(@"~\import\\" + soureFileName));
FileOutputStream fos = new FileOutputStream(Server.MapPath(@"~\import\\" + zipFileName));
ZipOutputStream zos = new ZipOutputStream(fos);
once again, thank you for all your help
*HyVong*
|
|
|
|
|
Search for a library called SharpZipLib.dll on google
|
|
|
|
|
I have discussed this topic in this forum before, but check out #ziplib[^], it should do what you are looking for.
- Nick Parker My Blog | My Articles
|
|
|
|
|
it workssssssss yeeeeaaaahhhh
thank you so much for all your help every one
cheersssssss!!
*HyVong*
|
|
|
|
|
Hi,
I'm working on a project in which I have the GUI and audio I/O programmed in C# .NET (and DirectSound using C#), and the DSP algorithms programmed in Visual C++.
I have no experience in integrating code written in these two languages. Am I correct in understanding that Visual C++ code in a C# program is called Managed C++.
Could anybody give me links to pages that deal with this issue in detail?
Thanks!
|
|
|
|
|
Not quite. Managed C++ is just C++ code with the managed extensions enables. that means that it's C++ that does the garbage collecting and can call into the .Net framework. You can load up a DLL and call functions from it in your C# code. This will involve marshalling your data back and forth between the managed C# code and the unmanaged C++.
What you want to do is to call normal C++ or unsafe code from inside of your C# code. Here is one article on it, but you can also search for unsafe code in C# and you should be able to find more. You can also look for C# and marshalling for more.
Mixing Managed and Unmanaged code
Steve Maier, MCSD MCAD
|
|
|
|
|
Why should he lookup unsafe code in C#? This is a grossly overused feature of C# and the CLI in general and is almost never necessary. It really only improves performance in walking memory (array iteration, image manipulation, etc.). It's not necessary for marshaling at all. Effective use of the MarshalAsAttribute and a good understanding of unmanaged and managed types will help ensure you'll never need unsafe code.
Another good reference is in the .NET Framework SDK itself. Read Interoperating with Unmanaged Code[^] in the .NET Framework SDK documentation. There's information about COM interop, P/Invoke, and marshalling.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
That is a rather broad topic, depending on what type of integration you are looking for. Managed C++ is an extension of C++ that target's the CLR, however you can also perform mixed mode compilation to mix both managed and unmanaged code (#pragma managed and #pragma unmanaged ). Are you having specific problems getting your application to *talk* to each other across the language boundary?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Firstly, thank you all for your replies!
Heath, I'll go over the link to the SDK documentation now.
Considering that most DSP routines require a lot of array iteration and manipulation would unsafe code improve my program's performance?
Nick, I don't have any specific problems just yet as I haven't started integrating (what is the correct term? I might be using the wrong terms here) the C++ code into the C# code. I'm sure I'll have a ton of problems once I do start
I was just trying to ensure that I started down the right track.
|
|
|
|
|
crushinghellhammer wrote:
Considering that most DSP routines require a lot of array iteration and manipulation would unsafe code improve my program's performance?
More than likely, yes, but I wouldn't recommend writing your DSP in managed code. For one, you need a shim (using regasm.exe will automatically register mscoree.dll as the shim, which marshals calls to your assembly). This requires that the CLR and any dependent assemblies be loaded and JIT'd as need (which means an initially longer load time). It's probably best to stick with native code to write your DSP.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
My DSP code is in Visual C++ and has no code written in assembler.
However, I have used pointers extensively.
Would using such code with my C# code qualify it as "unsafe" or "unmanaged" code?
|
|
|
|
|
What exactly are you trying to do?
C# is one of many languages that target the CLR. Managed C++ (targets the CLR and has equal access to .NET assemblies, as well as native APIs) is another. But VC++ (unmanaged) is entirely different.
When you expose your DSP as a COM control (which it already is by nature), you're merely using it in your C# project.
I really don't understand what your problem is. If your DSP is written in VC++, then what are you trying to do in managed code (i.e., C#). If you're trying to use it, you declare the interfaces (as you have) and have to be able to instantiate the object. If your DSP has a typelib, you can use tlbimp.exe to generate an RCW (Runtime Callable Wrapper) or in Visual Studio .NET select Add Reference, click on the COM tab and either find your typelib in the list (if registered properly) or click the Browse button to find it. Either way will generate an interop library (the RCW) then you just use it.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
What I'm trying to do is this:
I have an application that I've written in C# using DirectSound. It allows for PLAYBACK of a pre-recorded .wav file, RECORDING of a .wav file and STREAMING of audio input from the soundcard.
Now, I would like to be able to process this audio input by sending the audio data through a DSP routine.
My DSP routines are coded in C++.
My signal flow would be as follows:
*input* -> DSP routine -> *output*
The input and output have already been implemented in C# .NET.
The DSP routine has been coded in C++. I could write it in C# if I absolutely HAD to, but I'm trying to avoid that.
What is the best way to get this working?
|
|
|
|