|
I'm not sure that you've added any info that I can use.
1 - what do you mean by 'raw', where did it come from ?
2 - why can't you just use the bitmap class to do this for you ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
1 - what do you mean by 'raw', where did it come from ?
2 - why can't you just use the bitmap class to do this for you ?
raw means its unknown file format its not standard ..its coming from DICOM (dcm ) medical image file
|
|
|
|
|
OK - well, adding a header won't remotely help you, why would you want to do that, you'd basically break the file.
The DICOM format does support raw data, but it also supports about 20 different types of compression, including JPEG. You should do one of two things
1 - pass the file into a Bitmap to see if it can work it out, and if not, forget about being able to view it. Adding a 16 bit header sure as hell won't turn the data into a 16 bit bitnmap
2 - buy the Atalasoft DICIOM library, it will decode DICOM images for you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have 2 forms, Form1 and Form2.
When I select the item from listbox in Form2 and press 'OK', I would like to show the selected item in the textbox in Form1.
Thank you very much in advance. 
|
|
|
|
|
Form2 should expose a delegate on which Form1 will subscribe. When item is selected in list box, you call this delegate instance.
Best wishes,
Navaneeth
|
|
|
|
|
Thank you for your fast response Navaneeth. Really appreciate that.
But care to explain about the delegation? I am a programming noob. Just became a programmer last week.
Thank you..
|
|
|
|
|
You'd do something like:
delegate void ListItemChangedHandler(string newItemText);
class Form2 : Form
{
public ListItemChangedHandler ListItemChanged = null;
void onListItemChange(object sender,...)
{
if(ListItemChanged != null)
ListItemChanged(listbox1.Text);
}
}
class Form1 : Form
{
void ShowForm2()
{
Form2 frm2 = new Form2();
frm2.ListItemChanged += ListBoxValueChanged;
}
void ListBoxValueChanged(string text)
{
yourTextBox.Text = text;
}
} A good book will help you to get started.
Best wishes,
Navaneeth
|
|
|
|
|
ok..thank you again..
|
|
|
|
|
I am tryng to access a comboBox control from a different Thread of the Main Thread (in which it is created), how can access it´s propertys like Text, SelectedItem... not only for setting but also for recover it`s contain.
I know that I need to use delegates and Invoke Methods, but I don´t know the logic of the creation of the methods and I don´t get the correct one.
Best Regards
|
|
|
|
|
So you should read up on the topic. This[^] explains it.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Your recomended page give me a solution for the set property but not when I Try to get the value contained by any property ofthe control so I've created the following code which give me an error, could you please check it ?
public delegate string DelegadoTexto2(Control ct);
string getText(Control C)
{
if (!InvokeRequired)
return C.Text;
else
return (string)Invoke(new DelegadoTexto2(getText), C.Text);
}
I still receive the error telling that I'm using the control from other Thread different of the creation Thread.
Best Regards
|
|
|
|
|
it is the same principle:
public delegate string stringGetter(Control c);
public string GetText(Control c) {
if (c.InvokeRequired) {
return (string)c.Invoke(new stringGetter(GetText), new object[] { c });
} else {
return c.Text;
}
}
And please do use PRE tags to show code.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
AFAIK, you don't need Invoke /BeginInvoke always just for reading a control's properties from a worker thread. I believe it is only required when the call accesses control's handle. It is required in the case of ComboBox .
Thread worker = new Thread((ThreadStart)delegate
{
string str = button1.Text;
string str1 = comboBox1.Text;
});
worker.Start(); Do you think Invoke /BeginInvoke should be used always when reading properties of a control from a worker thread or use it only when it requires?
Any thoughts?
Best wishes,
Navaneeth
|
|
|
|
|
N a v a n e e t h wrote: only required when the call accesses control's handle
I don't know. If all the property does is return the value of a class member, then that would make sense. However, AFAIK the documentation doesn't say which control properties do or don't access Handle? So should I gamble on this?
[ADDED]A little experiment confirms a thread can get a button's text without a cross-thread exception being thrown, but not a combobox text. [/ADDED]
If the rule were "reading a property is always fine, independent of handles", that would be nice. But it isn't.
Any references that shed a light?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
modified on Monday, October 26, 2009 7:51 AM
|
|
|
|
|
Luc Pattyn wrote: [ADDED]A little experiment confirms a thread can get a button's text without a cross-thread exception being thrown, but not a combobox text. [/ADDED]
That was my point. ComboBox.Text is using the handle. Watch the stack trace and you will see error thrown at the point where it touches handle.
But after investigating further, I too think that its kind of gambling. As you said using Invoke/BeginInvoke would be safe as the documentation doesn't say anything about how the properties are implemented.
Best wishes,
Navaneeth
|
|
|
|
|
I now have extended my article[^] accordingly.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I have a MDI project with a few child forms, and each child form is performing a function, some of which are dependant on nother.
It is a CAN bus reader, so I have a form which sets up and configures the hardware (connected by USB), another one to read the data and put it in a table, another form which can graph some of the data packets in a plot, etc...
My question is in the example above, most of the forms need access to the HW defined in the setup form.
I find myself unable to get data from the table in form 1 to the plot in form 2.
I am new at this, but I got it all working in a single form with tabs, and decided that I would like to have the look and feel of MDI so I can see multiple windowns together, and hit this road block. I thought it would be as simple as calling this for example from FormData --> if(FormSetup.CheckBox == True), but it seems I cannot access an object in another form to check its status or its text, etc...
And the same does not work if I am trying to cal a function.
Is there a place in C# Express I can declare all my valiables and functions so they can be accessed by everyone from the Parent to the Child form? All my objects are set to Internal, and so are my functions. I am just stuck on probably a simple details.
Any help or pointer?
Thanks,
H-
|
|
|
|
|
If any child contains data that may be needed by another sibling, it should send that data when it changes via an event to the parent. The parent should hold a reference to each child (in a MDI WinForms app it already has a MdiChildren property) and on handling these events, notify any others that need to know via a method call or property set.
This will keep all your forms properly separated as they do not need to know about each other directly and be a much cleaner design.
Dave
"My code works, but I don't understand why!" - DaveyM69 (Me) BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Well, generally, how can an object call a mrthod of an other object? Well, the calling object must have a reference to the other object and with this reference it can call any public method of the referenced object. Your two forms are objects, so this will work for them too.
C# does not have anything like global variables for a good reason. There are some things which come close, like static methods and variables, but these things should be used with some caution. Using them carelessly can easily result in a program which is buggy, hard to correct and maintain and generally a pain to work on. I understand that a beginner tries to focus on getting the job done, but when you have been in code hell a few times you will see that that reaching the goal is not all.
As a rule of thumb: If you have to tweak your code, there always is something wrong with your design. Object oriented design in this case. Now let's see...
This is the simplest but certainly not the best way to do it: Let's say there is form A which must be notified when a certain thing happens to form B. When form B is opened it receives a reference to it's partner, form A. Whenever something happens to form B which form A must get to know about, form B can use this reference to call methods of form A.
Edit: I just saw the reply before mine. Notifying the parent with an event which in turn decides which children are to be notified is indeed a much cleaner design. It also probably will involve a little more reading articles and learning.
modified on Sunday, October 25, 2009 3:50 PM
|
|
|
|
|
Thanks for the replies. I will read up on the method of going through the parent. This way, the parent can have all the "global" parameters which I need.
So in non-good-SW-design language, I can pass all parameters (whatever they are from text to check box, etc...) to the parent, and the parent can keep them and pass them to the next child.
Do I get it right?
I will have to read up on how to do it now. Thanks for the direction.
H-
|
|
|
|
|
On thing I failed to ask:
- Is there a good article on codeproject.com which goes through this? Or would you recommend a beginner's book which can help get started on C# the right way?
Thanks,
H-
|
|
|
|
|
|
I am in the final year of my studing
and I must make Project and I do'nt have any new idea for making the project
please help me to make not defficult and easy project 50:50
my email: action57392@hotmail.com
Thanks
|
|
|
|
|
Abdaqader wrote: and I must make Project and I do'nt have any new idea for making the project
Take a look here[^], where you will find hundreds of articles with excellent ideas and suggestions.
|
|
|
|
|
It is very hard to help u that way. Better you should read basic books to grow your knowledgebase and then try yourself...
After that if you still find problems, ask specific problems. We would glad to help you that time.
By this way, you will also learn basics of .NET.
|
|
|
|