I am trying to read in data from two serial ports, and plot each curve over time, on the same graph. However, when I do this, it connects the curves. How do I keep the two data sets separate but on the same graph? I've seen a lot of solutions using masterPane, however, when I try to use it, my program says that there is no materpane in zedgraph.
Here is the relevant code:
GraphPane myPane2;
PointPairList Oz1time = new PointPairList();
myPane2 = zedGraphControl2.GraphPane;
myPane2.Title = "Data vs Time Plots";
myPane2.XAxis.Title = "Elapsed Minutes";
myPane2.YAxis.Title = "Ozone Data";
private void UpdateData3(string line)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new UpdateDataDelegate(UpdateData3), new object[] { line });
}
else
{
if (chk_DISPLAY_3.Checked == true)
{
timer3.Interval = (30000);
timer3.Start();
OZ1lastdatatime = DateTime.Now;
count++;
if (count > 7)
{
count = 0;
TextBox_3.Text = "";
TextBox_3.AppendText(line);
}
else
{
TextBox_3.AppendText(line);
}
}
if (chk_SAVE_FILE_3.Checked == true)
{
StoreData3.Write(line);
StoreData3.Flush();
}
if (chk_PLOT_1.Checked == true)
{
string[] blahArray = line.Split(new char[] { ',' });
//string blaharray = Convert.ToDouble(blahArray[2]).ToString("F4");
int column_data = Convert.ToInt32(textBox3.Text);
double oz1 = Convert.ToDouble(blahArray[column_data]);
//TextBox_3.Text = Convert.ToString(oz1);
TimeSpan span = DateTime.UtcNow - startDateTimeOfProgram;
double elapsedMinutes = span.TotalMinutes;
Oz1time.Add(elapsedMinutes,oz1);
zedGraphControl2.AxisChange();
zedGraphControl2.GraphPane.AddCurve("", Oz1time , Color.Blue);
zedGraphControl2.Refresh();
}
}
}
private void UpdateData4(string line)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new UpdateDataDelegate(UpdateData4), new object[] { line });
}
else
{
Console.WriteLine(line);
if (chk_DISPLAY_4.Checked == true)
{
timer4.Interval = (30000);
timer4.Start();
OZ2lastdatatime = DateTime.Now;
count++;
if (count > 7)
{
count = 0;
TextBox_4.Text = "";
TextBox_4.AppendText(line);
}
else
{
TextBox_4.AppendText(line);
}
}
if (chk_SAVE_FILE_4.Checked == true)
{
StoreData4.Write(line);
StoreData4.Flush();
}
if (chk_PLOT_2.Checked == true)
{
string[] blahArray = line.Split(new char[] { ',' });
//string blaharray = Convert.ToDouble(blahArray[2]).ToString("F4");
int column_data = Convert.ToInt32(textBox4.Text);
double oz2 = Convert.ToDouble(blahArray[column_data]);
//TextBox_3.Text = Convert.ToString(oz1);
TimeSpan span = DateTime.UtcNow - startDateTimeOfProgram;
double elapsedMinutes = span.TotalMinutes;
Oz1time.Add(elapsedMinutes, oz2);
zedGraphControl2.AxisChange();
zedGraphControl2.GraphPane.AddCurve("", Oz1time, Color.Green);
zedGraphControl2.Refresh();
}
}
}
The main problem appears to be that you are using the same PointPairList, Oz1time, to create both curves. Instead, try creating two separate PointPairLists, one for each curve.
Some relevant code bits:
PointPairList Oz2time = new PointPairList();
...
Oz2time.Add(elapsedMinutes, oz2);
...
zedGraphControl2.GraphPane.AddCurve("", Oz2time, Color.Green);
Related
I am charting live data (ekg) from a vital sign monitor. The monitor outputs 500 data points per second which represent a single ekg waveform. I parse these in a backgroundWorker to display them in a chart without freezing the controls. The typical case lasts about an hour, which equals about 1.8 million data points that I have to display.
Here is the backgroundWorker code:
private void BackgroundWorker1_DoWork (object sender, DoWorkEventArgs e) {
backgroundWorker1.WorkerSupportsCancellation = true;
backgroundWorker1.WorkerReportsProgress = true;
if (backgroundWorker1.CancellationPending == true) {
e.Cancel = true;
}
for (int i = 0; i <= 100; i++) {
backgroundWorker1.ReportProgress(i);
if (i % 25 == 1) {
Thread.Sleep(500);
}
}
try {
Action action = () =>
FillChartEKG();
Invoke(action);
}
catch {
backgroundWorker1.CancelAsync();
MessageBox.Show("No EKG waveform data availaible to parse. Does your vital sign monitor support export of EKG wavedorm data?", "EKG waveform status", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
And here is the long running method that charts the EKG data points:
public async void FillChartEKG() {
List<AnesthWaveformData> waveformData = AnesthWaveformDatas.CreateWaveformObjects(anestheticRecordNum);
var series1 = new Series {
Name = "EKG",
Color = Color.LawnGreen,
IsVisibleInLegend = false,
IsXValueIndexed = true,
ChartType = SeriesChartType.Line,
};
chartEKG.Series.Clear();
chartEKG.Series.Add(series1);
string timeStamp = DateTime.Now.ToString();
DateTime time = new DateTime();
int counter = 0;
int loopCount = 0;
int loopToStopAt = 0;
//await System.Threading.Tasks.Task.Run(() => {
for (int j = 0; j < waveformData.Count; j++) {
if (waveformData[j].EKGWaveform == String.Empty || waveformData[j].EKGWaveform.StartsWith("32767")) {
continue;
}
counter = counter + 1; //there are 500 data points in each EKG waveform HL7 message; counter is the number of valid EKG waveforms in waveFormData
try {
timeStamp = waveformData[j].VSTimeStamp + "000"; //get first VSTimeStamp in series
string format = "yyyyMMddHHmmssfff";
time = DateTime.ParseExact(timeStamp, format, CultureInfo.InvariantCulture);
}
catch { MessageBox.Show("No waveform data to display", "Waveform data status", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
string strEKG = String.Empty;
strEKG = strEKG + "^" + string.Join("^", waveformData[j].EKGWaveform.ToString());
strEKG = strEKG.Remove(0, 1); //remove leading ^
string[] count = strEKG.Split('^');
foreach (string point in count) {
try {
time = time.AddMilliseconds(2);
//await System.Threading.Tasks.Task.Run(() => {
chartEKG.Invoke(new Action(() => series1.Points.AddXY(time, Convert.ToDouble(point) * 0.61)));
//});
}
catch (ArgumentException) { }
loopCount = loopCount + 1;
string timeFormat = "yyyyMMddHHmmssfff";
string timeNow = DateTime.Now.ToString(timeFormat);
if (time == DateTime.ParseExact(DateTime.Now.ToString(timeNow), timeFormat, CultureInfo.InvariantCulture)) {
loopToStopAt = loopCount;
}
}
chartEKG.Invoke(new Action(() => chartEKG.ChartAreas[0].AxisX.Maximum = counter * 500));
}
//});
chartEKG.Invoke(new Action(() => chartEKG.ChartAreas[0].AxisX.ScaleView.Scroll(chartEKG.ChartAreas[0].AxisX.Maximum - Convert.ToDouble(loopToStopAt))));
}
The problem is the chart draws reaalllly slowly. If I remove the async from the method it draws really rapidly (what I want) but freezes the GUI while the drawing is completing. I've tried adjusting the Thread.Sleep in the _DoWork eventhandler but doesn't make an appreciable difference in speed. Any suggestions are appreciated.
Here is a YouTube video that shows the output:
https://youtu.be/CmlIScjowFc
Thanks,
-Will
I want to add a dynamic micro chart to my application but it doesn't work. After a call from a method a value gets added and it makes a completely new micro chart for my chart to have the new values, but the change isn't visible in the app. So the old Values stayed and there is no new one. Thanks for helping me.
WeightList = new List<float>();
WeightList.Add(0);
WeightList.Add((float)74.3);
entries = new ChartEntry[30];
SyncArray();
private void SyncArray()
{
if (WeightList.Count != entries.Length)
{
entries = new ChartEntry[WeightList.Count];
}
for (int i = 0; i <= WeightList.Count - 1; i++)
{
if (i == WeightList.Count - 1 || i == 0)
{
entries[i] = new ChartEntry(WeightList[i]) { Label = "" + i, ValueLabel = "" + WeightList[i] };
}
else
{
entries[i] = new ChartEntry(WeightList[i]) { Label = "" + i };
}
}
chart = new LineChart() { Entries = entries, BackgroundColor = SKColors.Transparent };
Chart = chart;
}
public LineChart Chart
{
get => chart;
set => SetProperty(ref chart, value);
}
public float Weight
{
get => weight;
set
{
weight = value;
WeightList.Add(weight);
SyncArray();
}
}
Credits: #Jason
What to change:
private void SyncArray()
{
if (WeightList.Count != entries.Length)
{
entries = new ChartEntry[WeightList.Count];
}
for (int i = 0; i <= WeightList.Count - 1; i++)
{
if (i == WeightList.Count - 1 || i == 0)
{
entries[i] = new ChartEntry(WeightList[i]) { Label = "" + i, ValueLabel = "" + WeightList[i] };
}
else
{
entries[i] = new ChartEntry(WeightList[i]) { Label = "" + i };
}
}
Chart = new LineChart() { Entries = entries, BackgroundColor = SKColors.Transparent };
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there a simple method to write these lines of code??
if(character == "Orc Lord")
{
int hp = Character.hp = 100;
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
Console.WriteLine(hp);
Console.SetCursorPosition(90, 0);
Console.Write("Robot: " + BotChar[BotIndex]);
Console.SetCursorPosition(90, 2);
Console.WriteLine(hpp);
while (hpp != 0)
{
string attack = Functionality.Select(new string[] { "attack" });
if(BotChar[BotIndex] == "Dog Lord")
{
if (attack == "attack")
{
Console.SetCursorPosition(108, 0);
Console.Write(hpp - str);
}
}
}
if(hpp == 0)
{
Environment.Exit(0);
}
}
Instead of write if(character == "another game character") on every character fight opportunity I want to write it in less code.
if (character == "Human Lord")
{
int hp = Character.hp = 100;
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
Console.WriteLine(hp);
Console.SetCursorPosition(90, 0);
Console.Write("Robot: " + BotChar[BotIndex]);
Console.SetCursorPosition(90, 2);
Console.WriteLine(hpp);
while (hpp != 0)
{
string attack = Functionality.Select(new string[] { "attack" });
if (BotChar[BotIndex] == "Dog Lord")
{
if (attack == "attack")
{
Console.SetCursorPosition(108, 0);
Console.Write(hpp - str);
}
}
}
if (hpp == 0)
{
Environment.Exit(0);
}
}
Just for more text
if (character == "Elf Lord")
{
int hp = Character.hp = 100;
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
Console.WriteLine(hp);
Console.SetCursorPosition(90, 0);
Console.Write("Robot: " + BotChar[BotIndex]);
Console.SetCursorPosition(90, 2);
Console.WriteLine(hpp);
while (hpp != 0)
{
string attack = Functionality.Select(new string[] { "attack" });
if (BotChar[BotIndex] == "Dog Lord")
{
if (attack == "attack")
{
Console.SetCursorPosition(108, 0);
Console.Write(hpp - str);
}
}
}
if (hpp == 0)
{
Environment.Exit(0);
}
}
if (character == "Dog Lord")
{
int hp = Character.hp = 100;
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
Console.WriteLine(hp);
Console.SetCursorPosition(90, 0);
Console.Write("Robot: " + BotChar[BotIndex]);
Console.SetCursorPosition(90, 2);
Console.WriteLine(hpp);
while (hpp != 0)
{
string attack = Functionality.Select(new string[] { "attack" });
if (BotChar[BotIndex] == "Dog Lord")
{
if (attack == "attack")
{
Console.SetCursorPosition(108, 0);
Console.Write(hpp - str);
}
}
}
if (hpp == 0)
{
Environment.Exit(0);
}
}
if (character == "Cat Lord")
{
int hp = Character.hp = 100;
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
Console.WriteLine(hp);
Console.SetCursorPosition(90, 0);
Console.Write("Robot: " + BotChar[BotIndex]);
Console.SetCursorPosition(90, 2);
Console.WriteLine(hpp);
while (hpp != 0)
{
string attack = Functionality.Select(new string[] { "attack" });
if (BotChar[BotIndex] == "Dog Lord")
{
if (attack == "attack")
{
Console.SetCursorPosition(108, 0);
Console.Write(hpp - str);
}
}
}
if (hpp == 0)
{
Environment.Exit(0);
}
}
I'm thinking of doing this dynamically, but I don't know how to do it.
First start by identifying all the duplication. I've added a comment in front of those lines. With few exceptions, most copy'n'pasted code is duplicated code that can be reduced.
if (character == "Elf Lord")
{
int hp = Character.hp = 100; // this is written "oddly"
int str = Character.MaxHit = 20;
int hpp = Character.hpElf = 100;
// Console.WriteLine(hp);
// Console.SetCursorPosition(90, 0);
// Console.Write("Robot: " + BotChar[BotIndex]);
// Console.SetCursorPosition(90, 2);
// Console.WriteLine(hpp);
// while (hpp != 0)
// {
// string attack = Functionality.Select(new string[] { "attack" });
// if (BotChar[BotIndex] == "Dog Lord")
// {
// if (attack == "attack")
// {
// Console.SetCursorPosition(108, 0);
// Console.Write(hpp - str);
// }
// }
// }
// if (hpp == 0)
// {
// Environment.Exit(0);
// }
}
So, the "non duplicate" code that currently exists is that a different character (presumably) has different stats. Let's start by categorizing the common features:
class Stats {
string Name { get; set; }
int MaxHp { get; set; }
int Strength { get; set; }
int CurrentHp { get; set; }
}
Now, let's imagine there is only a single character and bot to fight to start:
var elfLord = new Stats { Name = "Elf Lord", MaxHp = 100, Strength = 10 };
var dogLord = new Stats { Name = "Dog Lord", MaxHp = 50, Strength = 4 };
And they fight:
Fight(elfLord, dogLord);
Then all all repetitive and duplicated code can move to a method:
void Fight(Stats f1, Stats f2) {
Console.WritLine(f1.Name + " vs. " + f2.Name);
// Do whatever calculations, ONLY using the two parameters supplied.
// In the called case, f1.Name == "Elf Lord" (given from caller),
// and f2.Name == "Dog Lord" given (given from caller)
// (Assuming full-heals at the start..)
f1.CurrentHp = f1.MaxHp;
f2.CurrentHp = f2.MaxHp;
int turnsLeft = 10;
// Use >= as check on != 0 will loop forever on OVERDAMAGE
while (f1.CurrentHp > 0 && f2.CurrentHp > 0 && turnsLeft-- > 0) {
// Pseudo code showing how this can get complex, yet remain in little chunks, handling a small part of the task.
// Perhaps the order of f1/f2 is reversed each round based on an initiative roll..
// ..but just as in a more complex game, rules can be broken down.
// And the best part is, NO COPY AND PASTE TO MAINTAIN/FIX THIS CODE!
// "mX" = Move Order. These are also Stats objects and thus effectively aliases.
// For a 3+ battle system, movements should be handled as a collection.
Stats m1, m2;
if (InitiativeSuccess(f1, f2)) {
m1 = f1; m2 = f2;
} else {
m1 = f2; m2 = f1;
}
var m1Attack = GetAttack(GetRandomAttack(), m1, m2);
var m2Attack = GetAttack(m1Attack /* allow counter */, m2, m1);
ApplyAttack(m1Attack, m1, m2);
ApplyAttack(m2Attack, m2, m1);
}
if (f1.CurrentHp <= 0 && f2.CurrentHp <= 0) {
Console.WritLine("Mutual defeat.");
} else if (f1.CurrentHp <= 0) {
Console.WriteLine(f1.Name + " defeated.");
} else if (f2.CurrentHp <= 0) {
Console.WriteLine(f2.Name + " defeated.");
} else { // draw (no more turns)
Console.WriteLine("Both fighters give up.")
}
}
Now, the non-duplicated code can be moved out, and it might look something like this:
// One of many approaches, a simple switch here would also suffice.
// Methods break up logic and unify (reduce duplication of) code.
Stats CreateLordFromName(string lordName) {
var elfLord = new Stats { Name = "Elf Lord", MaxHp = 100, Strength = 10 };
var catLord = new Stats { Name = "Meowth Lord", MaxHp = 9, Strength = 999 };
var namesToLords = new [] { elfLord, catLord }.ToDictionary(v => v.Name, v => v);
return namesToLords[lordName];
}
Stats hero = CreateLordFromName(character);
Stats bot = CreateLordFromName(BotChar[BotIndex]);
Fight(hero, bot);
It becomes slightly more interesting when adding interactions between different entities. However, it's an extension of above: categorizing the similarities.
Additional similarities might be the attacks a character has. Consider how this is really an extension of the same. As the complexity of the domain increases, new types and categorization might be useful.
var slash = new SlashAttack(); // class SlashAttack : IAttack
var stab = new StabAttack(); // class StabAttack : IAttack
var hero = new Character {
Stats = ..,
Attacks = new [] { slash, stab } // IAttack[] array/collection
};
var catLord = new Character {
Stats = ..,
Attacks = new [] { meow, hiss, loveLicks }
};
Fight(hero, ..);
For an interesting interaction, consider that there might also be a "Pet" attack that would work against a "Cat Lord" causing a Cat Nap (+1 HP, sleep for one round). There are multiple ways of continuing the model above to support such.. and such is beyond the scope of this answer.
I have implemented functionality using pdfbox to extract words from any pdf. It extracts the words line by line. Below is the class that I am using for this purpose:
class PDFTextLocationStripper : PDFTextStripper
{
public string textWithPostion = "";
public Dictionary<float, Dictionary<float, PdfWord>> pdfWordsByXByY;
public PDFTextLocationStripper(): base()
{
try
{
textWithPostion = "";
pdfWordsByXByY = new Dictionary<float, Dictionary<float, PdfWord>>();
}
catch (Exception ex)
{
}
}
protected override void processTextPosition(TextPosition text)
{
try
{
float textX = text.getXDirAdj();
float textY = text.getYDirAdj();
if (!String.IsNullOrWhiteSpace(text.getUnicode()))
{
if (pdfWordsByXByY.ContainsKey(textY))
{
Dictionary<float, PdfWord> wordsByX = pdfWordsByXByY[textY];
if (wordsByX.ContainsKey(textX))
{
PdfWord word = wordsByX[textX];
wordsByX.Remove(word.Right);
word.EndCharWidth = text.getWidthDirAdj();
if (text.getHeightDir() > word.Height)
{
word.Height = text.getHeightDir();
}
word.EndX = textX;
word.Text += text.getUnicode();
if (!wordsByX.Keys.Contains(word.Right))
{
wordsByX.Add(word.Right, word);
}
}
else
{
float requiredX = -1;
float minDiff = float.MaxValue;
for (int index = 0; index < wordsByX.Keys.Count; index++)
{
float key = wordsByX.Keys.ElementAt(index);
float diff = key - textX;
if (diff < 0)
{
diff = -diff;
}
if (diff < minDiff)
{
minDiff = diff;
requiredX = key;
}
}
if (requiredX > -1 && minDiff <= 1)
{
PdfWord word = wordsByX[requiredX];
wordsByX.Remove(requiredX);
word.EndCharWidth = text.getWidthDirAdj();
if (text.getHeightDir() > word.Height)
{
word.Height = text.getHeightDir();
}
word.EndX = textX;
word.Text += text.getUnicode();
if (!wordsByX.ContainsKey(word.Right))
{
wordsByX.Add(word.Right, word);
}
}
else
{
PdfWord word = new PdfWord();
word.Text = text.getUnicode();
word.EndX = word.StartX = textX;
word.Y = textY;
word.EndCharWidth = word.StartCharWidth = text.getWidthDirAdj();
word.Height = text.getHeightDir();
if (!wordsByX.ContainsKey(word.Right))
{
wordsByX.Add(word.Right, word);
}
pdfWordsByXByY[textY] = wordsByX;
}
}
}
else
{
Dictionary<float, PdfWord> wordsByX = new Dictionary<float, PdfWord>();
PdfWord word = new PdfWord();
word.Text = text.getUnicode();
word.EndX = word.StartX = textX;
word.Y = textY;
word.EndCharWidth = word.StartCharWidth = text.getWidthDirAdj();
word.Height = text.getHeightDir();
wordsByX.Add(word.Right, word);
pdfWordsByXByY.Add(textY, wordsByX);
}
}
}
catch (Exception ex)
{
}
}
}
Here, is the code to call this class:
private Dictionary<float, Dictionary<float, PdfWord>> ExtractTextWithLocation(PDDocument doc)
{
try
{
PDFTextLocationStripper textStripper = new PDFTextLocationStripper();
textStripper.setSortByPosition(true);
textStripper.getText(doc);
return textStripper.pdfWordsByXByY;
}
catch (Exception ex)
{
return null;
}
}
This code extracts words which are aligned horizontally fine, but how do I implement functionality to detect words which are vertical or slanting?
public void read_file(string fname)
{
filepath = fname;
TextReader input = File.OpenText(filepath);
line = input.ReadLine();
int[] ID = new int[6];
int[] x = new int[6];
int[] y = new int[6];
int xx, yy;
int i = 0;
image = AForge.Imaging.Image.FromFile(filename);
smal1 = AForge.Imaging.Image.FromFile(smallimg1);
smal2 = AForge.Imaging.Image.FromFile(smallimg2);
smal3 = AForge.Imaging.Image.FromFile(smallimg3);
smal4 = AForge.Imaging.Image.FromFile(smallimg4);
smal5 = AForge.Imaging.Image.FromFile(smallimg5);
smal6 = AForge.Imaging.Image.FromFile(smallimg6);
// int index = 0;
while (line != null && line != " ")
{
if (line == "change")
{
while (line != "end")
{
line = input.ReadLine();
line = line.Trim();
if (line != "end")
{
string[] parts = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
xx = int.Parse(parts[0]);
yy = int.Parse(parts[1]);
image.SetPixel(xx, yy, Color.Blue);
}
}
line = input.ReadLine();
}
else
{
string[] parts2 = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
ID[i] = int.Parse(parts2[0]);
x[i] = int.Parse(parts2[1]);
y[i] = int.Parse(parts2[2]);
line = input.ReadLine();
if(ID[i]==1)
{
pictureBox2.Size = smal1.Size;
pictureBox2.Image = smal1;
}
else if (ID[i] == 2)
{
pictureBox3.Size = smal2.Size;
pictureBox3.Image = smal2;
}
else if (ID[i] == 3)
{
pictureBox4.Size = smal3.Size;
pictureBox4.Image = smal3;
}
else if (ID[i] == 4)
{
pictureBox5.Size = smal4.Size;
pictureBox5.Image = smal4;
}
else if (ID[i] == 5)
{
pictureBox6.Size = smal5.Size;
pictureBox6.Image = smal5;
}
else if (ID[i] == 6)
{
pictureBox7.Size = smal6.Size;
pictureBox7.Image = smal6;
}
i++;
}
}
// pictureBox2.BackColor = Color.SteelBlue;
// pictureBox2.Image = smal;
// pictureBox2.Size = smal.Size;
pictureBox1.Image = image;
pictureBox1.Size = image.Size;
//pictureBox2.Hide();
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Start_Click(object sender, EventArgs e)
{
capture_flag = true;
start_reading();
}
private void Stop_Click(object sender, EventArgs e)
{
capture_flag = false;
}
private void start_reading()
{
string filen = "F:/4th year/1st Term/sensor network/proj/reconstructscene/stream.txt";
read_file(filen);
filen = "F:/4th year/1st Term/sensor network/proj/reconstructscene/stream1.txt";
read_file(filen);
filen = "F:/4th year/1st Term/sensor network/proj/reconstructscene/stream2.txt";
read_file(filen);
}
private void close_Click(object sender, EventArgs e)
{
this.Dispose();
}
in the above code i'm trying to call the function read_file several times but it's not working
the form just wait until the end then draw once .
note in the original project i'll take the file name from another part of the poject and i may call the function like
while (capture_flag)
{
filen = file;
read_file(filen);
}
which not working for the same reason
The reason that the changes doesn't show up whlie the method is running, is that the main thread is busy running the method so it's not listening to messages. The updates happens in the form of messages that are placed on the message queue, so when the main thread can't handle the messages, there are no updates.
You can use the Refresh method to force a redraw of the control while in the middle of the method:
pictureBox2.Size = smal1.Size;
pictureBox2.Image = smal1;
pictureBox2.Refresh();