EDN Admin
Well-known member
For example in the trackBar1 i have now 2255 frames.
I can move with the arrows left and right between the frames/images in the trackBar1 one by one.
But if i use the mouse wheel to move the trackBar1 fast to the right or left i see it jump by 3 or 2 numbrs each time. For example from 134 to 137 or 145 to 147...And not moving like if im using the arrows keys one by one.
This is the scroll event code:
<pre class="prettyprint private void trackBar1_Scroll(object sender, EventArgs e)
{
trackbarCounter++;
if (manualDone == true)
{
if (_fi.Length > 0)
{
myTrackPanelss1.trackBar1.Minimum = 0;
myTrackPanelss1.trackBar1.Maximum = _fi.Length - 1;
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
if (automaticDone == true)
{
if (fiAutomatic.Length > 0)
{
myTrackPanelss1.trackBar1.Minimum = 0;
myTrackPanelss1.trackBar1.Maximum = fiAutomatic.Length - 1;
if (list_of_histograms.Count > 0)
{
tt = list_of_histograms[myTrackPanelss1.trackBar1.Value];
HistogramGraphs1.DrawHistogram(tt);
long res = GetTopLumAmount(tt, 1000);
long max = GetHistogramMaximum(tt);
GetHistogramAverage(tt);
}
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
if (HistogramLoadedFile == true)
{
if (_fi.Length > 0)
{
tt = list_of_histograms[myTrackPanelss1.trackBar1.Value];
HistogramGraphs1.DrawHistogram(tt);
long res = GetTopLumAmount(tt, 1000);
long max = GetHistogramMaximum(tt);
GetHistogramAverage(tt);
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
}[/code]
<br/>
How can i fix it ?
Second problem is when in the scroll event its getting to this line:
<pre class="prettyprint HistogramGraphs1.DrawHistogram(tt);
[/code]
And the HistogramGraphs Form is open/show then when im moving the arrows keys left or right and the mouse wheel its jumping over numbers/frames and not moving one by one.
It will move one by one only if i click one by one on the arrows keys.
This is the code of how i show the new Form HistogramGraphs:
<pre class="prettyprint private void histogramGraphsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Location = new Point(0, 0);
HistogramGraphs1 = new Lightnings_Extractor.Histogram_Graphs();
HistogramGraphs1.Show(this);
myTrackPanelss1.trackBar1.Focus();
HistogramGraphs1.FormClosing += new FormClosingEventHandler(HistogramGraphs1_FormClosing);
histogramGraphsToolStripMenuItem.Enabled = false;
}[/code]
And this is the HistogramGraphs Form in the bottom Code:
<pre class="prettyprint public long[] DrawHistogram(long[] Values)
{
histogram = Values;
CreateGraph_GradientByZBars(zedGraphControl1);
zedGraphControl1.Invalidate();
zedGraphControl1.Refresh();
zedGraphControl1.AxisChange();
return histogram;
}[/code]
And the top code:
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;
using Extracting_Frames;
namespace Lightnings_Extractor
{
public partial class Histogram_Graphs : Form
{
public long[] histogram;
private List<long> histogramsList = new List<long>();
private int maxNumber;
public Histogram_Graphs()
{
InitializeComponent();
maxNumber = 0;
if (histogram == null)
{
if (Form1.GetHistogramValue == null)
{
Form1.GetHistogramValue = new long[0];
return;
}
else
{
if (Form1.GetHistogramValue.Length > 0)
{
histogram = Form1.GetHistogramValue;
}
if (Form1.tt != null)
{
histogram = Form1.tt;
}
}
}
this.DoubleBuffered = true;
for (int i = 0; i < Form1.list_of_histograms.Count(); i++)
{
long[] t = Form1.list_of_histograms;
for (int x = 0; x < t.Length; x++)
{
histogramsList.Add(t[x]);
}
}
maxNumber = (int)histogramsList.Max();
CreateGraph_GradientByZBars(zedGraphControl1);
}
private void Histogram_Graphs_Load(object sender, EventArgs e)
{
this.Size = new Size(1900, 435);
this.Location = new Point(6, 606);
label2.Text = this.Size.ToString();
}
private void CreateGraph_GradientByZBars(ZedGraphControl z1)
{
GraphPane myPane = z1.GraphPane;
if (myPane != null)
{
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();
myPane.Title.Text = "Demonstration of Multi-Colored Bars with a Single BarItem";
myPane.XAxis.Title.Text = "Bar Number";
myPane.YAxis.Title.Text = "Value";
myPane.XAxis.Scale.MaxAuto = false;
myPane.XAxis.Scale.MinAuto = false;
myPane.YAxis.Scale.MaxAuto = false;
myPane.YAxis.Scale.MinAuto = false;
myPane.XAxis.Scale.Min = 0;
myPane.XAxis.Scale.Max = 255;
myPane.YAxis.Scale.Min = 0;
myPane.YAxis.Scale.Max = maxNumber;
PointPairList list = new PointPairList();
// Random rand = new Random();
for (int i = 0; i < histogram.Length; i++)
{
double x = (double)i;
double y = (double)histogram;
double z = 1;
list.Add(x, y, z);
}
BarItem myCurve = myPane.AddBar("Multi-Colored Bars", list, Color.Blue);
Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple };
myCurve.Bar.Fill = new Fill(colors);
myCurve.Bar.Fill.Type = FillType.GradientByZ;
myCurve.Bar.Fill.RangeMin = 0;
myCurve.Bar.Fill.RangeMax = 4;
myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
myPane.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 225), 45);
// Tell ZedGraph to calculate the axis ranges
z1.AxisChange();
}
}[/code]
The first problem is when the HistogramGraphs Form is closed ! Then using the arrows keys is ok but the wheel mouse is not good.
The second problem is when the HistogramGraphs Form is open/show then the arrows keys and the mouse wheel not working good.
<hr class="sig danieli
View the full article
I can move with the arrows left and right between the frames/images in the trackBar1 one by one.
But if i use the mouse wheel to move the trackBar1 fast to the right or left i see it jump by 3 or 2 numbrs each time. For example from 134 to 137 or 145 to 147...And not moving like if im using the arrows keys one by one.
This is the scroll event code:
<pre class="prettyprint private void trackBar1_Scroll(object sender, EventArgs e)
{
trackbarCounter++;
if (manualDone == true)
{
if (_fi.Length > 0)
{
myTrackPanelss1.trackBar1.Minimum = 0;
myTrackPanelss1.trackBar1.Maximum = _fi.Length - 1;
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
if (automaticDone == true)
{
if (fiAutomatic.Length > 0)
{
myTrackPanelss1.trackBar1.Minimum = 0;
myTrackPanelss1.trackBar1.Maximum = fiAutomatic.Length - 1;
if (list_of_histograms.Count > 0)
{
tt = list_of_histograms[myTrackPanelss1.trackBar1.Value];
HistogramGraphs1.DrawHistogram(tt);
long res = GetTopLumAmount(tt, 1000);
long max = GetHistogramMaximum(tt);
GetHistogramAverage(tt);
}
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
if (HistogramLoadedFile == true)
{
if (_fi.Length > 0)
{
tt = list_of_histograms[myTrackPanelss1.trackBar1.Value];
HistogramGraphs1.DrawHistogram(tt);
long res = GetTopLumAmount(tt, 1000);
long max = GetHistogramMaximum(tt);
GetHistogramAverage(tt);
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
}
}[/code]
<br/>
How can i fix it ?
Second problem is when in the scroll event its getting to this line:
<pre class="prettyprint HistogramGraphs1.DrawHistogram(tt);
[/code]
And the HistogramGraphs Form is open/show then when im moving the arrows keys left or right and the mouse wheel its jumping over numbers/frames and not moving one by one.
It will move one by one only if i click one by one on the arrows keys.
This is the code of how i show the new Form HistogramGraphs:
<pre class="prettyprint private void histogramGraphsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Location = new Point(0, 0);
HistogramGraphs1 = new Lightnings_Extractor.Histogram_Graphs();
HistogramGraphs1.Show(this);
myTrackPanelss1.trackBar1.Focus();
HistogramGraphs1.FormClosing += new FormClosingEventHandler(HistogramGraphs1_FormClosing);
histogramGraphsToolStripMenuItem.Enabled = false;
}[/code]
And this is the HistogramGraphs Form in the bottom Code:
<pre class="prettyprint public long[] DrawHistogram(long[] Values)
{
histogram = Values;
CreateGraph_GradientByZBars(zedGraphControl1);
zedGraphControl1.Invalidate();
zedGraphControl1.Refresh();
zedGraphControl1.AxisChange();
return histogram;
}[/code]
And the top code:
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;
using Extracting_Frames;
namespace Lightnings_Extractor
{
public partial class Histogram_Graphs : Form
{
public long[] histogram;
private List<long> histogramsList = new List<long>();
private int maxNumber;
public Histogram_Graphs()
{
InitializeComponent();
maxNumber = 0;
if (histogram == null)
{
if (Form1.GetHistogramValue == null)
{
Form1.GetHistogramValue = new long[0];
return;
}
else
{
if (Form1.GetHistogramValue.Length > 0)
{
histogram = Form1.GetHistogramValue;
}
if (Form1.tt != null)
{
histogram = Form1.tt;
}
}
}
this.DoubleBuffered = true;
for (int i = 0; i < Form1.list_of_histograms.Count(); i++)
{
long[] t = Form1.list_of_histograms;
for (int x = 0; x < t.Length; x++)
{
histogramsList.Add(t[x]);
}
}
maxNumber = (int)histogramsList.Max();
CreateGraph_GradientByZBars(zedGraphControl1);
}
private void Histogram_Graphs_Load(object sender, EventArgs e)
{
this.Size = new Size(1900, 435);
this.Location = new Point(6, 606);
label2.Text = this.Size.ToString();
}
private void CreateGraph_GradientByZBars(ZedGraphControl z1)
{
GraphPane myPane = z1.GraphPane;
if (myPane != null)
{
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();
myPane.Title.Text = "Demonstration of Multi-Colored Bars with a Single BarItem";
myPane.XAxis.Title.Text = "Bar Number";
myPane.YAxis.Title.Text = "Value";
myPane.XAxis.Scale.MaxAuto = false;
myPane.XAxis.Scale.MinAuto = false;
myPane.YAxis.Scale.MaxAuto = false;
myPane.YAxis.Scale.MinAuto = false;
myPane.XAxis.Scale.Min = 0;
myPane.XAxis.Scale.Max = 255;
myPane.YAxis.Scale.Min = 0;
myPane.YAxis.Scale.Max = maxNumber;
PointPairList list = new PointPairList();
// Random rand = new Random();
for (int i = 0; i < histogram.Length; i++)
{
double x = (double)i;
double y = (double)histogram;
double z = 1;
list.Add(x, y, z);
}
BarItem myCurve = myPane.AddBar("Multi-Colored Bars", list, Color.Blue);
Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple };
myCurve.Bar.Fill = new Fill(colors);
myCurve.Bar.Fill.Type = FillType.GradientByZ;
myCurve.Bar.Fill.RangeMin = 0;
myCurve.Bar.Fill.RangeMax = 4;
myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
myPane.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 225), 45);
// Tell ZedGraph to calculate the axis ranges
z1.AxisChange();
}
}[/code]
The first problem is when the HistogramGraphs Form is closed ! Then using the arrows keys is ok but the wheel mouse is not good.
The second problem is when the HistogramGraphs Form is open/show then the arrows keys and the mouse wheel not working good.
<hr class="sig danieli
View the full article