|
Heath, thanks again for your help.
Sorry for the index gaffe. I was aware of that, but was obviously not paying attention while typing.
Could you please explain the following code:
WaveSegment[] segments = new WaveSegment[17]; and
WaveSegment[] innerSegments = segments[0];
What is WaveSegment[] here? A class, a function or a jagged array?
I'm new to all this, and apologize for the dumb questions.
|
|
|
|
|
I don't know - you used it in your code fragment so I thought I'd reuse it. Maybe I'm using wrong in your context, but the idea is the same. WaveSegment could be anything: a class, struct, enum, or even a delegate! All you're doing is making an array of an array of something (no, I didn't stutter! ). The first line made an array of WaveSegment with 17 elements. In my code fragment, I then created a new array of 256 elements within each of those 17 elements. The second line above merely gets that 256-element array from the first array element from the array with 17 elements.
See Arrays[^] in the C# Language Features reference on MSDN, or more specifically Jagged Arrays[^] for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath, thanks for your detailed replies!
Ok, here's what I've done, incorporating your suggestions and that of my anonymous helper.
public class Segmentation
{
private static void Main()
{
Random R = new Random();
int[] inArray = new int[1280];
for(int i = 0; i < 1280; i++)
inArray[i] = i;
int[][] arrSegmentArray = new int[17][];
for(int i = 0; i < 17; i++)
{
arrSegmentArray[i] = new int[256];
Array.Copy(inArray, 64*i, arrSegmentArray[i], 0, 256);
Console.WriteLine(arrSegmentArray[i].ToString());
Console.ReadLine();
}
}
}
However, where I expect arrSegmentArray[i] to be printed as a 256 element array, all I see is System.Int32[];
What do I need to fix here?
|
|
|
|
|
Heath, thanks for your detailed replies!
Ok, here's what I've done, incorporating your suggestions and that of my anonymous helper.
public class Segmentation
{
private static void Main()
{
Random R = new Random();
int[] inArray = new int[1280];
for(int i = 0; i < 1280; i++)
inArray[i] = i;
int[][] arrSegmentArray = new int[17][];
for(int i = 0; i < 17; i++)
{
arrSegmentArray[i] = new int[256];
Array.Copy(inArray, 64*i, arrSegmentArray[i], 0, 256);
Console.WriteLine(arrSegmentArray[i].ToString());
Console.ReadLine();
}
}
}
However, where I expect arrSegmentArray[i] to be printed as a 256 element array, all I see is System.Int32[];
What do I need to fix here?
|
|
|
|
|
Glad you solved it, but just for future benefit, the line Console.WriteLine(arrSegmentArray[i].ToString()); is calling ToString on a Int32[] array. The default implementation of Array.ToString() (inherited from Object.ToString ) is to simply print the namespace-qualified class name.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What I did was this:
for (int i =0; i < 17; i++)
{
for (int j=0; j < 256; j++)
{
Console.Write(arrSegmentArray[i][j].ToString()+" ");
}
Console.WriteLine(); Console.ReadLine();
}
Is that alright?
|
|
|
|
|
Sure, why not?! It just depends on your requirements and implementation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Solved it. Thanks for your help!
|
|
|
|
|
Is it possible to customize the open dialog box to show a preview of the selected file?
|
|
|
|
|
If the OS supports it, a user can switch to the Thumbnail view. Other than that, the two derivatives of FileDialog (OpenFileDialog and SaveFileDialog ) cannot easily be modified. In fact, this is a major problem that many people have faced. These two dialog classes encapsulate the OPENFILENAME struct and the GetOpenFileName and SaveOpenFileName Win32 functions. In order to customize dialogs using the struct, you have to provide a Dialog resource - a Win32 resource, not a .NET resource. This can be very difficult even with native applications.
The typical solution is to make your own form and use various controls for the tree and list views. Another option is to make a mixed mode Managed C++ class that can use dialog resources and encapsulate all this in a .NET class that you can use from a different .NET language like C#.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I wanted to develop an application through which a user could submit images (from their hard disks) through a website.
I've tried reading certain posts but they seem very confusing and ultimately scary....
I haven't even been able to map out the steps on where to start and which way to proceed.
Can anyone please suggest the starting point for this project.
Regards,
Tiruvan
|
|
|
|
|
You can write a webservice which receive FileStream and save it on the sever. You can pass that stream as an argument of a method to webservice.
Mazy
No sig. available now.
|
|
|
|
|
Tiruvan wrote:
through a website
Oh,I thought you want it from win application Why did you post it here. You can do it easily. Read this article. There are some others i CP which you can serach for them too.
http://www.codeproject.com/aspnet/multiuploads.asp[^]
Mazy
No sig. available now.
|
|
|
|
|
Mazdak,
Thanks for the prompt response and for the link. The article in that link was well written and worked fine for me.
My GOAL is to set up a webpage through which a user should be able to upload image files and by clicking "Upload" should be able to send it directly into my SQL Server database.
For a start this article was really good. Me being new to this field I would like to split my goal (which to me is a complicated one) into several small parts and start working on each.
These were the steps I could think off:
1. Learn how to upload files (onto a local machine itself)
2. Try uploading files into the SQL Server (remote) database instead of the local machine.
3. If there should be any difference in the loading process between regular text files and image files, what should be done to upload image files?
4. Re-arrange images to set width and height without distortion.
Am I in the right direction?....PLEASE suggest any other articles that could help me in this path.
Regards,
Tiruvan
|
|
|
|
|
Tiruvan wrote:
1. Learn how to upload files (onto a local machine itself)
There is no difference for local machine or your real server. You should only have the write prmission to create files there.
Tiruvan wrote:
2. Try uploading files into the SQL Server (remote) database instead of the local machine.
http://www.codeproject.com/aspnet/fileupload.asp[^]
There are other ways to store file and images into sqlserver which use better way. You can use them after you upload files into your server,like this article:
http://www.codeproject.com/cs/database/albumviewer.asp[^]
Tiruvan wrote:
3. If there should be any difference in the loading process between regular text files and image files, what should be done to upload image files?
No difference. You can use that codes for every files.
For any topics you can serach this site, search textbox is at the top of page,below the homepage image. There are so many useful articles for these tops here.
Mazy
No sig. available now.
|
|
|
|
|
plz i wanna to create dynamic number of threads according to some number i calculate in my program
i need to create a number of objects from the class which have the function which will be running when the threads start
quick help plz
thanx for caring
prog_ega
|
|
|
|
|
As just a simple example:
int max = calculate number;
for (int i=0; i < max; i++)
{
MyClass o = new MyClass();
Thread t = new Thread(new ThreadStart(o.SomeMethod));
t.Start();
} For more information about threading in .NET, see http://msdn.microsoft.com/library/en-us/cpguide/html/cpconthreading.asp[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey
I'm trying to make an exit button from my main application at the "startup" with the command
this.Close();
but I get
An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll
Additional information: Cannot access a disposed object named "FCMain".
and debug stops at
[STAThread]
static void Main()
{
Application.Run(new FCMain());
}
What must i do to exit from my main windows application at "startup"?
Thanks
Thomas
|
|
|
|
|
You cannot call Form.Close while the form is being loaded. If you really need to exit the application before the form is loaded, use Application.Exit . Once the form is loaded, Form.Close is okay to call but won't work (due to bugs in the message pump, apparently) if exceptions were thrown in the UI thread while the form was loading. Instead, call Application.Exit in the event this problem occurs. Otherwise, calling Form.Close on the main application window will close the Form and continue with any statements in the Main entry point.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Application.Exit(); did not work, it didn't exit at all.
My data is like this:
public FCMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
.
.
.
if(bExit)
{
Application.Exit();
}
}
[STAThread]
static void Main()
{
Application.Run(new FCMain());
}
Thanks
Thomas
|
|
|
|
|
You can't call it in the constructor, either. You should read about Windows Forms programming in the .NET Framework SDK. Some previous experience with Win32 and the Windows Management APIs would be helpful with understanding the message pump. In this case, however, the application pump hasn't started. See the line:
Application.Run(new FCMain()); This is actually broken down to something similar to the following when compiled:
FCMain form = new FCMain();
Application.Run(form); Therefore, you should throw an exception from your constructor and handle put a try/catch around the statement above. This will not, however, catch other exceptions unless a SystemException is thrown that causes the main form to crash and returns execution to the entry point.
A better design, however, is to move whatever code causes the need to exit out of the FCMain form's constructor and put it in the entry point (or a method that the entry point calls).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What I see? the code project is hacked!
|
|
|
|
|
What exactly do you see? You surely aren't referring to the Austalia Day banner, are you? If so, it's not a hack, the admin of this site actually have personallity.
Fear not my insanity, fear the mind it protects.
|
|
|
|
|
Not to mention he's originally from Australia.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
And what about those aweful sexual advertisements? are they the new strategy for making money? If so, I am sorry!
|
|
|
|