|
According to A Simple C# Wrapper for the AviFile Library[^] you cannot add compressed images directly. It seems that you have to create a new Stream add them to that, then add the new stream. Anyway the article explains it better than I can.
Although, from a very quick read, it does not seem to use BITMAPINFOHEADER.Compressed it seems to manage the whole thing.
Once again, I hope that if it is not sufficient by itself, that it gives you some ideas.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas? - Because 31 Oct = 25 Dec.
Business Myths of the Geek #4 'What you think matters.'
|
|
|
|
|
Hi all,
I got small trobule with randomize
her my code for starting randomize
private void lblStart_Click(object sender, EventArgs e)
{
bool run;
run = true;
Random d = new Random();
Application.DoEvents();
while (run == true)
{
Application.DoEvents();
int rnd = d.Next(0, lst.Count - 1);
lblNumber.Text = lst[rnd].ToString();
}
}
here for stop randomize and show result in messagebox and Label
private void lblStop_Click(object sender, EventArgs e)
{
run = false;
MessageBox.Show(lblNumber.Text);
}
after I click stop button in label and messagebox it show the same text, but after I clcik OK button in label show another number?
Can anyone help to correct this?
Thanks
Socheat
|
|
|
|
|
All you are doing there is clogging up your processor, to no good end. Do it this way:
Create a class level Timer, call it randomTimer.
Move your Random to class level.
In your Start_Click event handler, check if there is an existing Timer in randomTimer. If not, create an instance, set the interval to 1/10th second, and set a handler for the Tick event. In all cases, start the timer.
In the Tick event, set the lblNumber.Text to your random value.
In your Stop_Click event handler, stop the timer.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Hi,
Can you write me example?
Thanks
Socheat
|
|
|
|
|
Here code I just used timer control but still can't use
bool run = true;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = true;
this.Text = System.DateTime.Now.ToString();
run = true;
Random rnd = new Random();
int i = 0;
while (run == true)
{
Application.DoEvents();
i = rnd.Next(0, 1000);
textBox1.Text = i.ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
timer1_Tick(sender, e);
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
run = false;
MessageBox.Show(textBox1.Text);
}
Socheat
|
|
|
|
|
No.
Read up on Timer.
private Timer timer = new Timer();
private void buttonStart_Click(object sender, EventArgs e)
{
timer.Interval = 1000 / 100;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
... Do a single instance of your Random stuff.
}
private void buttonStop_Click(object sender, EventArgs e)
{
timer.Stop();
}
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
BTW: You don't need to send me an email as well as replying - the reply automatically sends an email. Just like this one, in fact...
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Hi,
your code contains a couple of mistakes against general rules, including:
1. event handlers (such as a Click handler) should execute and be done with in less than say 20 milliseconds; anything that takes longer needs a different approach, maybe a timer (a System.Windows.Forms.Timer is best for GUI related stuff), maybe a separate thread;
2. don't abuse Application.DoEvents(), there are a few situations where its use would be OK, yours isn't one of them.
3. avoid "busy loops", such as your while(run) construct, whenever there is an elegant alternative.
Obeying (1) often makes (2) moot.
Griff's approach is fine.
PS: please use PRE tags when including code snippets.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hey Luc, what situations are there where Application.DoEvents() would be OK?
|
|
|
|
|
I allow myself to use DoEvents() inside an event handler when I am sure there is no risk of the event handler being re-entered by doing so, and I want the GUI to settle before I continue. Case in point would be a MenuItem.Click handler on say an "Open File..." menu item, where I want the menu to disappear and the GUI restored ASAP before opening the dialog that was ordered.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
|
Hi all,
I can do it now.
I no need to remove Application.DoEvent(); otherwise my application will hang.
I just remove my while loop and add it in timer class, it OK now.
Thanks.
Socheat
|
|
|
|
|
If you have removed your while loop, and put the code into the timer, then you do not need Application.DoEvents(). If your app hangs without it, then you are still doing something very wrong!
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Random d = new Random((int)(DateTime.Now().Interval));
Application.DoEvents();
while (run == true)
{
Application.DoEvents();
int rnd = d.Next(0, lst.Count - 1);
lblNumber.Text = lst[rnd].ToString();
}
}
|
|
|
|
|
Hi!! I really need help with this.
This is my first time programming using a database and I'm doing a system for a clinical laboratory... Each test belongs to a section, there are a total of five sections and each one is has its own table... There's also a "exam" table that relates all sections to the patient... Example:
Exam table has these fields:
ExamId
PatientId
HematologyId
ChemistryId
Hematology table has:
HematologyId
ExamId
Test1
Test2... etc.
Same for chemistry and all the five sections.
So basically what I need is to print the exam that is gonna be given to the patient... f.e: let's assume there are 10 hematology tests and 10 chemistry tests, and the patient needs the test #1, #4 and #6 from hematology and the tests #7 and #9 from chemistry... What I need to print is something like this:
Date
Patient Name
Age
Hematology:
Test #1: result
Test #4: result
Test #6: result
Chemistry:
Test #7: result
Test #9: result
I hope you could help me, I'm really lost and can't find the way to do that.. I need this to finish my degree and the only thing left is what I'm asking here...
Thanks in advance for your help.
modified on Friday, June 11, 2010 1:52 AM
|
|
|
|
|
|
Yeah... sorry... I'm from Venezuela so english is not my first language
|
|
|
|
|
Well, otherwise, your English is quite excellent. It is good enough that I couldn't tell it was not your first!
|
|
|
|
|
Thank you!! I use to check the spelling when I'm writing in english because I hate to feel that I'm writing bad whatever the language it is... Don't know how I missed that one... I already edited it so it's fixed.
Any recommendations on the report I'm asking about? I'm completely lost...
Thank you again.
|
|
|
|
|
When you connect your database to create a report add the tables and link the added tables on the id's. Then you should be able to drag/drop fields of those tables onto the report.
I wouldn't recommend using VS2008 for creating reports though (although this one is not really complex), if you have a Crystal Reports application, that would be much better.
Do you have a full understanding of the sections in the report, because of not you should try to understand that first.
Best of luck.
V.
|
|
|
|
|
I suspect your data structure is screwed, this is what indicates the problem. If there is a new test type Test11 will you need to add another column?
HematologyId
ExamId
Test1
Test2... etc.
I would suggest you stop now and get an experienced data designer to create your database for you. It sound like you know your business (clinical laboratory), so get a professional to design your data structures (make sure he/she explains the reasons for the database design so you can learn from it). This will make it possible to create your application without continually running into data issues
As for the report you need to design a query in the database with all the required data, then design the report to present the data and finally put them together in you app by instantiating the report and passing the dataset with your query results in it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi everybody:
I am relatively new in C#, I am working with visual studio 2008, I am making an application with winforms with
reports.
I need to show in a report a details screen for a person of the database, one of the fields of a person is the
image path relative to the root of the aplication , I am using in the Report.rdlc an Image object placed in the
report with the following properties: Source = External, Value = First(Fields!picture.Value, "Personas_persona")
but the problem is that when I run the aplication the image is not show in the report.
Could somebody please help me ???
I woulds thanks any help.
REgards
Ariel
|
|
|
|
|
I'm trying to build a treeview of 4 layers, using 4 tables in the database.
Layer 1: Departments
Layer 2: Groups
Layer 3: Products
Layer 4: Barcodes
No I've had a go at getting the 4 tables in as a dataset, and tried to populate the treeview, but only the first 2 layers will show up in my tree view.
If I make layer 2 my first layer, only layer 2 and 3 will show up.
<br />
private void Load_tree()<br />
{<br />
DataSet ds = new DataSet();<br />
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CCS_HOConnectionString"].ConnectionString);<br />
SqlDataAdapter daDepts = new SqlDataAdapter("barcodePrinter_get_Departments", conn);<br />
SqlDataAdapter daGroups = new SqlDataAdapter("barcodePrinter_get_Groups", conn);<br />
SqlDataAdapter daProducts = new SqlDataAdapter("barcodePrinter_get_Products", conn);<br />
SqlDataAdapter daBarcode = new SqlDataAdapter("barcodePrinter_get_Barcode", conn);<br />
<br />
<br />
daDepts.Fill(ds, "DEPTS");<br />
daGroups.Fill(ds, "PRODGRP");<br />
daProducts.Fill(ds, "PRODUCT");<br />
daBarcode.Fill(ds, "product_barcode");<br />
<br />
<br />
ds.Relations.Add("Depts_Group", ds.Tables["DEPTS"].Columns["DEPTCODE"], ds.Tables["PRODGRP"].Columns["PGRPDEPT"]);<br />
ds.Relations.Add("Group_Product", ds.Tables["PRODGRP"].Columns["PGRPID"], ds.Tables["PRODUCT"].Columns["PRODGRP"]);<br />
ds.Relations.Add("ProdBarcode", ds.Tables["PRODUCT"].Columns["PRODCODE"], ds.Tables["product_barcode"].Columns["prodcode"]);<br />
<br />
dataGridView1.DataSource = ds.Tables["DEPTS"];<br />
dataGridView2.DataSource = ds.Tables["PRODGRP"];<br />
dataGridView3.DataSource = ds.Tables["PRODUCT"];<br />
dataGridView4.DataSource = ds.Tables["product_barcode"];<br />
<br />
foreach (DataRow dr in ds.Tables["DEPTS"].Rows)<br />
{<br />
TreeNode tn = new TreeNode(dr["DEPTSHORT"].ToString());<br />
foreach (DataRow drGroup in dr.GetChildRows("Depts_Group"))<br />
{<br />
TreeNode tnn = new TreeNode(drGroup["PGRPSHORT"].ToString());<br />
foreach (DataRow drProduct in dr.GetChildRows("Group_Product"))<br />
{<br />
TreeNode tnnn = new TreeNode(drProduct["PRODSHORT"].ToString());<br />
foreach (DataRow drBarcode in dr.GetChildRows("Product_Barcode"))<br />
{<br />
tnnn.Nodes.Add(drBarcode["barcode"].ToString());<br />
}<br />
tnn.Nodes.Add(tnnn);<br />
}<br />
tn.Nodes.Add(tnn);<br />
}<br />
trvBarcodes.Nodes.Add(tn);<br />
}<br />
trvBarcodes.ExpandAll();<br />
}<br />
I'm looking for a solution that will make all 4 layers show in the treeview.
Like
+Department 1
-+Group 1
--+Product 1
----Barcode 1
----Barcode 2
-+Group 2
--+Product 2
----Barcode 3
--+Product 3
----Barcode 4
I never know how many layers there will be within the child node, this is decided by the list in the database and that one can change.
modified 4-Nov-20 21:00pm.
|
|
|
|
|
Do a search in the articles for treeview, there are a number of strategies for this, I have done one suing the heirarchyid, there are a number using relationships in datasets and some using a single table with a calculated relationship field.
This is too big a question to be answered by a forum post!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have two methods used to compate Lists, and I would like to combine them if possible. The purpose is to ensure that all elements in two lists match.
private bool matchList_DateTime(List<DateTime> List1, List<DateTime> List2)
{
if (List1.Count != List2.Count) return false;
foreach (DateTime L1 in List1) if (!List2.Contains(L1)) return false;
return true;
}
private bool matchList_String(List<string> List1, List<string> List2)
{
if (List1.Count != List2.Count) return false;
foreach (string L1 in List1) if (!List2.Contains(L1)) return false;
return true;
}
modified on Tuesday, June 15, 2010 4:29 PM
|
|
|
|
|