EDN Admin
Well-known member
I added this to the end of the constructor but it dosent sohw the correct file names:
<div style="color:Black;background-color:White; <pre>
numberOfFiles = mtpEnd - mtpStart;
label2.Text = numberOfFiles.ToString();
di = <span style="color:Blue; new DirectoryInfo(radar_images_download_directory);
fi = di.GetFiles(<span style="color:#A31515; "*.png");
nameOfStartFile = fi[mtpStart].Name.ToString();
nameOfEndFile = fi[mtpEnd].Name.ToString();
label6.Text = nameOfStartFile.ToString();
label4.Text = nameOfEndFile.ToString();
[/code]
<br/>
It show the correct number of files the user selected.
For example i marked the numbers 1427 as start and as end i marked 1710 so the number of files result is correct 283.
But when i click the button and see in the new form the start and end i see: number of files 283 but start file is 1428 and end file if 1711
The selection is made in a trackBar1 in the other form. And when i click a button in the other form its openning show this form and should show the information about what i selected.
di is the directoryinfo of the all the downloaded files so far. Not the files that are in the list in the dorwork event.
This is the first form where i click a button to open this form:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.IO;
<span style="color:Blue; using System.Diagnostics;
<span style="color:Blue; using DannyGeneral;
<span style="color:Blue; using unfreez_wrapper;
<span style="color:Blue; using System.Threading;
<span style="color:Blue; namespace mws
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class Picturebox1_Fullscreen : Form
{
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int mtp1Start;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int mtp1End;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; bool looping;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int animatedSpeed;
<span style="color:Blue; string path_exe;
DateTime creationTime;
<span style="color:Blue; public <span style="color:Blue; static Label[] labels;
<span style="color:Blue; private <span style="color:Blue; static <span style="color:Blue; double[] mm_per_hour_arr = { 200, 100, 50, 40, 30, 24, 18, 13, 9, 6, 4, 2, 1.2, 0.7, 0.2, 0.1 };
<span style="color:Blue; private <span style="color:Blue; static <span style="color:Blue; double[] hue_arr ={301.06,350.65,374.09,389.28,401.9,412.24,421.35,477.84,481.06,
487.5,492.58,500.38,519.56,538.13,540.64,574.85};
<span style="color:Blue; bool pb1_enabled;
Image lff;
<span style="color:Blue; int i;
<span style="color:Blue; string file;
BackgroundWorker backGroundWorker1;
Bitmap[] myBitmaps;
Bitmap pb11;
<span style="color:Blue; public <span style="color:Blue; static FileInfo[] file_info_mouse_wheel;
<span style="color:Blue; public <span style="color:Blue; string radar_images_download_directory;
<span style="color:Blue; private Bitmap[] file_info_trackBar2;
<span style="color:Blue; private <span style="color:Blue; bool _isDirty = <span style="color:Blue; false;
<span style="color:Blue; public Picturebox1_Fullscreen()
{
InitializeComponent();
path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; false;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; false;
trackBar1 = myTrackPanelss1.trackBar1;
label3.Visible = <span style="color:Blue; false;
label5.Visible = <span style="color:Blue; false;
label8.Visible = <span style="color:Blue; false;
label4.Visible = <span style="color:Blue; false;
label7.Visible = <span style="color:Blue; false;
button1.Visible = <span style="color:Blue; false;
trackBar1 = myTrackPanelss1.trackBar1;
<span style="color:Blue; if (Form1.automaticDoubleClick == <span style="color:Blue; true)
{
<span style="color:Green; //timer3.Enabled = true;
}
myBitmaps = <span style="color:Blue; null;
pb11 = <span style="color:Blue; null;
pb1_enabled = <span style="color:Blue; false;
<span style="color:Blue; int labels_X = 140;
<span style="color:Blue; float labels_Y = 10;
label3.Visible = <span style="color:Blue; false;
i = 0;
file = Form1.lf;
<span style="color:Blue; if (!File.Exists(file) || file == <span style="color:Blue; null)
{
trackBar1.Enabled = <span style="color:Blue; false;
trackBar2.Enabled = <span style="color:Blue; false;
timer1.Enabled = <span style="color:Blue; false;
<span style="color:Blue; return;
}
lff = Image.FromFile(file);
Logger.Write(<span style="color:#A31515; "pictureBox1 in the constructor of Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "files in the constructor of Picturebox1_Fullscreen is is >>> " + file);
pictureBox1.Image = lff;
trackBar1.Enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
backGroundWorker1 = <span style="color:Blue; new BackgroundWorker();
backGroundWorker1.WorkerSupportsCancellation = <span style="color:Blue; true;
<span style="color:Blue; this.backGroundWorker1.WorkerReportsProgress = <span style="color:Blue; true;
backGroundWorker1.ProgressChanged += <span style="color:Blue; new ProgressChangedEventHandler(backGroundWorker1_ProgressChanged);
backGroundWorker1.DoWork += <span style="color:Blue; new DoWorkEventHandler(backGroundWorker1_DoWork);
backGroundWorker1.RunWorkerCompleted += <span style="color:Blue; new RunWorkerCompletedEventHandler(backGroundWorker1_RunWorkerCompleted);
radar_images_download_directory = Options_DB.Get_Radar_Images_Download_Directory();
DirectoryInfo dir1 = <span style="color:Blue; new DirectoryInfo(radar_images_download_directory);
file_info_mouse_wheel = dir1.GetFiles(<span style="color:#A31515; "*.png");
<span style="color:Blue; if (file_info_mouse_wheel.Count() == 0 || file_info_mouse_wheel.Count() == 1)
{
trackBar1.Enabled = <span style="color:Blue; false;
trackBar2.Enabled = <span style="color:Blue; false;
checkBox1.Enabled = <span style="color:Blue; false;
<span style="color:Blue; if (file_info_mouse_wheel.Count() == 1)
{
trackBar2.Enabled = <span style="color:Blue; true;
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label5.Visible = <span style="color:Blue; true;
label3.Visible = <span style="color:Blue; true;
label8.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
label3.Visible = <span style="color:Blue; true;
label5.Visible = <span style="color:Blue; true;
label8.Visible = <span style="color:Blue; true;
label4.Visible = <span style="color:Blue; true;
label7.Visible = <span style="color:Blue; true;
StartWork();
}
}
<span style="color:Blue; else
{
checkBox1.Enabled = <span style="color:Blue; true;
trackBar1.Minimum = 0;
trackBar1.Maximum = file_info_mouse_wheel.Length - 1;
<span style="color:Blue; this.myTrackPanelss1.End = trackBar1.Maximum;
trackBar1.ValueChanged += <span style="color:Blue; new EventHandler(trackBar1_Scroll);
trackBar1.Value = file_info_mouse_wheel.Length - 1;
trackBar1.Enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
radar_images_download_directory = Options_DB.Get_Radar_Images_Download_Directory();
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label5.Visible = <span style="color:Blue; true;
label3.Visible = <span style="color:Blue; true;
label8.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
label3.Visible = <span style="color:Blue; true;
label5.Visible = <span style="color:Blue; true;
label8.Visible = <span style="color:Blue; true;
label4.Visible = <span style="color:Blue; true;
label7.Visible = <span style="color:Blue; true;
}
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
trackBar2.Enabled = <span style="color:Blue; false;
}
<span style="color:Green; //pictureBox1.Enabled = false;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
i = i + 1;
label1.Text = <span style="color:#A31515; "Processing Images Please Wait " + i;
StartWork(); <span style="color:Green; // TO CHECK STARTWORK() MAKING THE EXCEPTION !!!!!!!
<span style="color:Blue; this.FormClosing += <span style="color:Blue; new FormClosingEventHandler(Picturebox1_Fullscreen_FormClosing);
trackBar2.Maximum = ImagesComparison.ImagesLength;
labels = <span style="color:Blue; new Label[16];
<span style="color:Blue; for (<span style="color:Blue; int loop_through_lables = labels.Length - 1; loop_through_lables >= 0; loop_through_lables--)<span style="color:Green; // This one will create 15 lables start on top from 15 to 0.
<span style="color:Green; //This will create 15 labels start on top from 0 to 15 int loop_through_lables = 0; loop_through_lables < labels.Length; loop_through_lables++)
{
labels[loop_through_lables] = <span style="color:Blue; new Label();
labels[loop_through_lables].MouseMove += <span style="color:Blue; new MouseEventHandler(Picturebox1_Fullscreen_Labels_MouseMove);
splitContainer1.Panel2.Controls.Add(labels[loop_through_lables]);
labels[loop_through_lables].Size = <span style="color:Blue; new Size(35, 13);
labels[loop_through_lables].Location = <span style="color:Blue; new Point(labels_X,(<span style="color:Blue; int)labels_Y);
labels[loop_through_lables].BringToFront();
labels[loop_through_lables].Visible = <span style="color:Blue; true;
labels[loop_through_lables].Text = loop_through_lables.ToString();
labels_Y += 32.5f; <span style="color:Green; // to check there are 16 maximum on trackbar2 so to make also 16 labels.
}
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel1_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel2_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void pictureBox1_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (backGroundWorker1.IsBusy)
{
<span style="color:Green; //this.backGroundWorker1.CancelAsync();
}
<span style="color:Blue; else
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; bool LoadPictureAt(<span style="color:Blue; int nIndex, <span style="color:Blue; object c)
{
<span style="color:Blue; bool bRet = <span style="color:Blue; false;
<span style="color:Blue; if (nIndex >= 0 && nIndex < file_info_mouse_wheel.Length)
{
<span style="color:Blue; if (c.Equals(trackBar1))
pictureBox1.Load(file_info_mouse_wheel[nIndex].FullName);
bRet = <span style="color:Blue; true;
}
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
}
<span style="color:Blue; else
{
<span style="color:Blue; if (nIndex >= 0 && nIndex < file_info_trackBar2.Length)
{
<span style="color:Blue; if (c.Equals(trackBar2))
pictureBox1.Image = file_info_trackBar2[nIndex];
bRet = <span style="color:Blue; true;
}
}
<span style="color:Blue; return bRet;
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
LoadPictureAt(trackBar2.Value, sender);
label1.Text = <span style="color:#A31515; "Image Number: "+ trackBar2.Value.ToString();
pictureBox1.Refresh();
}
<span style="color:Blue; public PictureBox picturebox1(PictureBox pb1)
{
pictureBox1.Image = pb1.Image;
Logger.Write(<span style="color:#A31515; "pictureBox1 in the function picturebox1 in Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "pb1 in the function picturebox1 in Picturebox1_Fullscreen is >>> " + pb1.ToString());
<span style="color:Blue; return pictureBox1;
}
<span style="color:Blue; public <span style="color:Blue; string picturebox1_lastFile(<span style="color:Blue; string last_file)
{
pictureBox1.Load(last_file);
Logger.Write(<span style="color:#A31515; "pictureBox1 in the function picturebox1_lastFile in Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "last_file in the function picturebox1_lastFile in Picturebox1_Fullscreen is >>> " + last_file.ToString());
<span style="color:Blue; return last_file;
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_DoWork(<span style="color:Blue; object sender, DoWorkEventArgs e)
{
<span style="color:Blue; int f = (<span style="color:Blue; int)e.Argument;
Image img1;
img1 = Image.FromFile(file);
pb11 = <span style="color:Blue; new Bitmap(img1);
myBitmaps = ImagesComparison.get_images_with_clouds(pb11);
<span style="color:Blue; if (<span style="color:Blue; this.backGroundWorker1.CancellationPending)
{
e.Result = f;
<span style="color:Blue; return;
}
file_info_trackBar2 = myBitmaps;
e.Result = f;
pb11.Dispose();
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{
Form1.timer11.Enabled = <span style="color:Blue; true;
<span style="color:Blue; if (backGroundWorker1 != <span style="color:Blue; null)
backGroundWorker1.Dispose();
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_RunWorkerCompleted(<span style="color:Blue; object sender, RunWorkerCompletedEventArgs e)
{
<span style="color:Blue; if (file_info_trackBar2 != <span style="color:Blue; null)
{
label1.Text = <span style="color:#A31515; "Images Process Completed";
i = 0;
pb1_enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
}
<span style="color:Blue; if (<span style="color:Blue; this._isDirty)
{
<span style="color:Blue; this._isDirty = <span style="color:Blue; false;
StartWork();
}
<span style="color:Green; /* try
{
if (file_info_trackBar2 != null)
{
if (trackBar2 != null && trackBar2.IsDisposed == false)
trackBar2.Enabled = true;
label1.Text = "Images Process Completed";
i = 0;
if (pictureBox1.Image != null && pictureBox1.Image.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
pictureBox1.Enabled = true;
else
{
//assign here a picture you like
pictureBox1.Image = new Bitmap(@"dpl_look.jpg");
pictureBox1.Enabled = true;
}
pictureBox1.Refresh();
}
if (this._isDirty)
{
this._isDirty = false;
StartWork();
}
}
catch (Exception error)
{
Logger.Write("Error " + error);
}*/
<span style="color:Green; /* if (file_info_trackBar2 != null)
{
trackBar2.Enabled = true;
label1.Text = "Images Process Completed";
i = 0;
splitContainer1.Panel2.Enabled = true;
try
{
//try to get a property of the image
//and if it fails assign a new image to the pictureBox
int t = pictureBox1.Image.Width;
pictureBox1.Enabled = true;
}
catch
{
Image img = pictureBox1.Image;
//assign here a picture you like
pictureBox1.Image = new Bitmap(@"dpl_look.jpg");
pictureBox1.Enabled = true;
if (img != null)
img.Dispose();
}
pictureBox1.Refresh();
}
if (this._isDirty)
{
this._isDirty = false;
StartWork();
}*/
}
<span style="color:Blue; private <span style="color:Blue; void StartWork()
{
<span style="color:Blue; if (!<span style="color:Blue; this.backGroundWorker1.IsBusy)
{
<span style="color:Blue; this.backGroundWorker1.RunWorkerAsync(<span style="color:Blue; this.trackBar2.Value);
}
<span style="color:Blue; else
{
<span style="color:Blue; this._isDirty = <span style="color:Blue; true;
<span style="color:Blue; this.backGroundWorker1.CancelAsync();
}
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_ProgressChanged(<span style="color:Blue; object sender, ProgressChangedEventArgs e)
{
<span style="color:Green; //this.progressBar1.Value = e.ProgressPercentage;
<span style="color:Green; // int count = e.ProgressPercentage;
<span style="color:Green; // textBox1.Text = string.Format("{0} images processed.", count);
}
<span style="color:Blue; private <span style="color:Blue; void timer1_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (radar_images_download_directory == <span style="color:#A31515; "")
{
}
<span style="color:Blue; else
{
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
i = i + 1;
label1.Text = <span style="color:#A31515; "Processing Images Please Wait " + i;
<span style="color:Green; //pictureBox1.Enabled = false;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
}
}
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_Enter(<span style="color:Blue; object sender, EventArgs e)
{
trackBar2.BackColor = Color.DarkSlateGray;
trackBar1.BackColor = System.Drawing.SystemColors.Control;
label1.Text = <span style="color:#A31515; "Image Number: " + trackBar2.Value.ToString();
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_Load(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; //SetTextBoxes();
}
<span style="color:Blue; private <span style="color:Blue; void SetTextBoxes()
{
<span style="color:Green; /* foreach (Control c in splitContainer1.Panel2.Controls)
{
if (c is TextBox)
{
x = x + 1;
if (x < 4)
{
c.BackColor = Color.Red;
}
else
{
}
c.Text = mm_per_hour_arr[1].ToString();
}
}*/
<span style="color:Green; // x 249 y 015
Bitmap original_image = <span style="color:Blue; new Bitmap(Properties.Resources.radar_scale_heb);
Color originalColor;
Bitmap new_image1;
new_image1 = <span style="color:Blue; new Bitmap(356, 45);
<span style="color:Blue; int x;
<span style="color:Blue; int y = 15;
Bitmap new_image = original_image;
<span style="color:Blue; for (x = 133; x < 250; x++)<span style="color:Green; //x = 15; x < 250; x++)//x+=10)//new_image.Width; x++)
{
originalColor = new_image.GetPixel(x, y);
new_image1.SetPixel(x, y, originalColor);
}
<span style="color:Green; //new_image1.Save(@"d:tryingcolor.png");
<span style="color:Green; //Color c = RadarAnalysis.ColorFromAhsb(0, (float)421.35, 001,(float) 0.56);
<span style="color:Green; //textBox1.BackColor = c;
<span style="color:Green; /* textBox1.Text = mm_per_hour_arr[0].ToString();
textBox2.Text = mm_per_hour_arr[1].ToString();
textBox3.Text = mm_per_hour_arr[2].ToString();
textBox4.Text = mm_per_hour_arr[3].ToString();
textBox5.Text = mm_per_hour_arr[4].ToString();
textBox6.Text = mm_per_hour_arr[5].ToString();
textBox7.Text = mm_per_hour_arr[6].ToString();
textBox8.Text = mm_per_hour_arr[7].ToString();
textBox9.Text = mm_per_hour_arr[8].ToString();
textBox10.Text = mm_per_hour_arr[9].ToString();
textBox11.Text = mm_per_hour_arr[10].ToString();*/
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel2_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox1.Text = <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox2.Text = <span style="color:#A31515; "TrackBar2 " + <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_Labels_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox3.Text = <span style="color:#A31515; "Labels " + <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void timer2_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (pb1_enabled == <span style="color:Blue; true)
{
<span style="color:Green; //pictureBox1.Enabled = true;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
}
}
<span style="color:Blue; private <span style="color:Blue; void timer3_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (backGroundWorker1.IsBusy)
{
<span style="color:Green; //this.backGroundWorker1.CancelAsync();
}
<span style="color:Blue; else
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void trackBar1_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
label3.Visible = <span style="color:Blue; true;
i = 0;
LoadPictureAt(trackBar1.Value, sender);
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label3.Visible = <span style="color:Blue; true;
label3.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
file = file_info_mouse_wheel[trackBar1.Value].FullName;
file_info_trackBar2 = <span style="color:Blue; null;
trackBar2.Enabled = <span style="color:Blue; false;
pb1_enabled = <span style="color:Blue; false;
StartWork();
}
<span style="color:Blue; private <span style="color:Blue; void trackBar1_Enter(<span style="color:Blue; object sender, EventArgs e)
{
trackBar1.BackColor = Color.Red;
trackBar2.BackColor = System.Drawing.SystemColors.Control;
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer2_Panel2_Paint(<span style="color:Blue; object sender, PaintEventArgs e)
{
}
<span style="color:Blue; private <span style="color:Blue; void checkBox1_CheckedChanged(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (checkBox1.Checked)
{
label2.Visible = <span style="color:Blue; true;
numericUpDown1.Visible = <span style="color:Blue; true;
checkBox2.Visible = <span style="color:Blue; true;
button1.Visible = <span style="color:Blue; true;
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; true;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; true;
}
<span style="color:Blue; else
{
label2.Visible = <span style="color:Blue; false;
numericUpDown1.Visible = <span style="color:Blue; false;
checkBox2.Visible = <span style="color:Blue; false;
button1.Visible = <span style="color:Blue; false;
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; false;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; false;
}
}
<span style="color:Blue; private <span style="color:Blue; void numericUpDown1_ValueChanged(<span style="color:Blue; object sender, EventArgs e)
{
animatedSpeed = (<span style="color:Blue; int)numericUpDown1.Value;
}
<span style="color:Blue; private <span style="color:Blue; void checkBox2_CheckedChanged(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (checkBox2.Checked)
{
looping = checkBox2.Checked;
}
<span style="color:Blue; else
{
looping = checkBox2.Checked;
}
}
<span style="color:Blue; private <span style="color:Blue; void button1_Click(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; /* List<string> myGifList;
Image gifImages;
button1.Enabled = false;
Animation_Radar_Preview ap = new Animation_Radar_Preview();
ap.FormClosing += new FormClosingEventHandler(ap_FormClosing);
FileInfo[] fi;
DirectoryInfo dir1 = new DirectoryInfo(radar_images_download_directory);
fi = dir1.GetFiles("*.png");
myList = new List<string>();
myGifList = new List<string>();
for (int i = myTrackPanelss1.Start; i < myTrackPanelss1.End; i++)
{
myList.Add(fi.FullName);
}
for (int x = 0; x < myList.Count(); x++)
{
gifImages = Image.FromFile(myList[x]);
gifImages.Save(tempRadarPngToGifDirectory + "\" + x.ToString("D6") + ".Gif", System.Drawing.Imaging.ImageFormat.Gif);
}
myGifList = new List<string>();
dir1 = new DirectoryInfo(tempRadarPngToGifDirectory);
fi = dir1.GetFiles("*.gif");
nameOfStartFile = fi[0].Name;
for (int i = 0; i < fi.Length; i++)
{
myGifList.Add(fi.FullName);
nameOfEndFile = fi.Name.Length.ToString();
}
numberOfFiles = myGifList.Count();
unfreez.MakeGIF(myGifList, previewFileName, animatedGifSpeed, loop);*/
mtp1Start = myTrackPanelss1.Start;
mtp1End = myTrackPanelss1.End;
button1.Enabled = <span style="color:Blue; false;
Animation_Radar_Preview ap = <span style="color:Blue; new Animation_Radar_Preview();
ap.Show();
<span style="color:Green; //DialogResult rv = ap.ShowDialog();*/
}
<span style="color:Blue; private <span style="color:Blue; void ap_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{
button1.Enabled = <span style="color:Blue; true;
}
<span style="color:Green; // to fix/change/add also in the satellite preview form code like here \
<span style="color:Green; // To make/check when trackBar2 is on image 15 in the array so it will show automatic after process is finished the milimeters of the current image according to number 15 in the array of trackBar2
}
}
[/code]
myTrackPanelss1 is User Control :
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.Drawing.Drawing2D;
<span style="color:Blue; namespace mws
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class MyTrackPanelss : UserControl
{
<span style="color:Blue; public <span style="color:Blue; int Start { <span style="color:Blue; get; <span style="color:Blue; set; }
<span style="color:Blue; public <span style="color:Blue; int End { <span style="color:Blue; get; <span style="color:Blue; set; }
<span style="color:Blue; private <span style="color:Blue; int _tbPadding = 14;
<span style="color:Blue; private <span style="color:Blue; float _penWidth = 15F;
<span style="color:Blue; public <span style="color:Blue; int TBPadding { <span style="color:Blue; get { <span style="color:Blue; return _tbPadding; } }
<span style="color:Blue; public <span style="color:Blue; float PenWidth { <span style="color:Blue; get { <span style="color:Blue; return _penWidth; } }
<span style="color:Blue; public MyTrackPanelss()
{
InitializeComponent();
Start = 0;
End = <span style="color:Blue; this.trackBar1.Maximum;
}
<span style="color:Blue; private <span style="color:Blue; void panel1_Paint(<span style="color:Blue; object sender, PaintEventArgs e)
{
<span style="color:Blue; using (SolidBrush b = <span style="color:Blue; new SolidBrush(SystemColors.ControlDark))
e.Graphics.FillRectangle(b, <span style="color:Blue; this.ClientRectangle);
<span style="color:Blue; using (GraphicsPath gPath = <span style="color:Blue; new GraphicsPath())
{
gPath.AddLine(<span style="color:Blue; new Point(_tbPadding, 0), <span style="color:Blue; new Point(_tbPadding, panel1.ClientSize.Height - 2));
gPath.AddLine(<span style="color:Blue; new Point(<span style="color:Blue; this.trackBar1.ClientSize.Width - _tbPadding, panel1.ClientSize.Height - 2),
<span style="color:Blue; new Point(<span style="color:Blue; this.trackBar1.ClientSize.Width - _tbPadding, 0));
<span style="color:Blue; using (SolidBrush sb = <span style="color:Blue; new SolidBrush(SystemColors.ActiveCaption))
e.Graphics.FillPath(sb, gPath);
e.Graphics.DrawPath(Pens.Black, gPath);
}
<span style="color:Blue; int maxRange = <span style="color:Blue; this.trackBar1.Maximum - <span style="color:Blue; this.trackBar1.Minimum;
<span style="color:Green; //_tbPadding for end and start of ticks of trackbar
<span style="color:Blue; double rangeOne = ((<span style="color:Blue; this.panel1.ClientSize.Width - _tbPadding * 2.0) / (<span style="color:Blue; double)maxRange);
<span style="color:Blue; if (End < Start)
{
<span style="color:Blue; int tmp = End;
End = Start;
Start = tmp;
}
<span style="color:Blue; if (End == Start)
{
MessageBox.Show(<span style="color:#A31515; "You cannot select start point and end point on the same place");
}
<span style="color:Blue; float xVal = (<span style="color:Blue; float)(_tbPadding + (Start * rangeOne));
<span style="color:Blue; float xVal2 = (<span style="color:Blue; float)(_tbPadding + (End * rangeOne));
<span style="color:Blue; if (Start >= <span style="color:Blue; this.trackBar1.Minimum)
{
<span style="color:Blue; using (Pen greenPen = <span style="color:Blue; new Pen(Color.Green, _penWidth))
{
e.Graphics.DrawLine(greenPen, <span style="color:Blue; new PointF(xVal, 1), <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
<span style="color:Blue; using (Pen p = <span style="color:Blue; new Pen(Color.Black))
{
p.StartCap = LineCap.ArrowAnchor;
e.Graphics.DrawLine(p, <span style="color:Blue; new PointF(xVal, 1), <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
}
e.Graphics.DrawString((Start+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
}
}
<span style="color:Blue; if (End <= <span style="color:Blue; this.trackBar1.Maximum)
{
<span style="color:Blue; using (Pen redPen = <span style="color:Blue; new Pen(Color.Red, _penWidth))
{
SizeF s = e.Graphics.MeasureString(End.ToString(), <span style="color:Blue; this.Font);
e.Graphics.DrawLine(redPen, <span style="color:Blue; new PointF(xVal2, 1), <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
<span style="color:Blue; using (Pen p = <span style="color:Blue; new Pen(Color.Black))
{
p.StartCap = LineCap.ArrowAnchor;
e.Graphics.DrawLine(p, <span style="color:Blue; new PointF(xVal2, 1), <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
}
<span style="color:Blue; if (xVal2 - xVal > s.Width + redPen.Width)
e.Graphics.DrawString((End+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal2 - s.Width, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
<span style="color:Blue; else
e.Graphics.DrawString((End+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
}
}
<span style="color:Blue; string t = <span style="color:#A31515; "click left to specify start, right to specify end";
SizeF sz = e.Graphics.MeasureString(t, <span style="color:Blue; this.Font);
e.Graphics.DrawString(t, <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF((<span style="color:Blue; this.panel1.ClientSize.Width - sz.Width) / 2F, 0));
}
<span style="color:Blue; private <span style="color:Blue; void panel1_MouseClick(<span style="color:Blue; object sender, MouseEventArgs e)
{
<span style="color:Blue; int maxRange = <span style="color:Blue; this.trackBar1.Maximum - <span style="color:Blue; this.trackBar1.Minimum;
<span style="color:Green; //_tbPadding for end and start of ticks of trackbar
<span style="color:Blue; double rangeOne = ((<span style="color:Blue; this.panel1.ClientSize.Width - _tbPadding * 2.0) / (<span style="color:Blue; double)maxRange);
<span style="color:Blue; if (e.Button == MouseButtons.Left && e.X >= _tbPadding && e.X <= panel1.ClientSize.Width - _tbPadding)
{
<span style="color:Blue; int i = (<span style="color:Blue; int)((e.X - _tbPadding) / rangeOne);
Start = i;
trackBar1.Value = i;
<span style="color:Blue; this.panel1.Invalidate();
}
<span style="color:Blue; if (e.Button == MouseButtons.Right && e.X >= _tbPadding && e.X <= panel1.ClientSize.Width - _tbPadding + rangeOne)
{
<span style="color:Blue; int i = (<span style="color:Blue; int)((e.X - _tbPadding) / rangeOne);
End = i;
trackBar1.Value = i;
<span style="color:Blue; this.panel1.Invalidate();
}
}
}
}
[/code]
<hr class="sig danieli
View the full article
<div style="color:Black;background-color:White; <pre>
numberOfFiles = mtpEnd - mtpStart;
label2.Text = numberOfFiles.ToString();
di = <span style="color:Blue; new DirectoryInfo(radar_images_download_directory);
fi = di.GetFiles(<span style="color:#A31515; "*.png");
nameOfStartFile = fi[mtpStart].Name.ToString();
nameOfEndFile = fi[mtpEnd].Name.ToString();
label6.Text = nameOfStartFile.ToString();
label4.Text = nameOfEndFile.ToString();
[/code]
<br/>
It show the correct number of files the user selected.
For example i marked the numbers 1427 as start and as end i marked 1710 so the number of files result is correct 283.
But when i click the button and see in the new form the start and end i see: number of files 283 but start file is 1428 and end file if 1711
The selection is made in a trackBar1 in the other form. And when i click a button in the other form its openning show this form and should show the information about what i selected.
di is the directoryinfo of the all the downloaded files so far. Not the files that are in the list in the dorwork event.
This is the first form where i click a button to open this form:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.IO;
<span style="color:Blue; using System.Diagnostics;
<span style="color:Blue; using DannyGeneral;
<span style="color:Blue; using unfreez_wrapper;
<span style="color:Blue; using System.Threading;
<span style="color:Blue; namespace mws
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class Picturebox1_Fullscreen : Form
{
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int mtp1Start;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int mtp1End;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; bool looping;
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; int animatedSpeed;
<span style="color:Blue; string path_exe;
DateTime creationTime;
<span style="color:Blue; public <span style="color:Blue; static Label[] labels;
<span style="color:Blue; private <span style="color:Blue; static <span style="color:Blue; double[] mm_per_hour_arr = { 200, 100, 50, 40, 30, 24, 18, 13, 9, 6, 4, 2, 1.2, 0.7, 0.2, 0.1 };
<span style="color:Blue; private <span style="color:Blue; static <span style="color:Blue; double[] hue_arr ={301.06,350.65,374.09,389.28,401.9,412.24,421.35,477.84,481.06,
487.5,492.58,500.38,519.56,538.13,540.64,574.85};
<span style="color:Blue; bool pb1_enabled;
Image lff;
<span style="color:Blue; int i;
<span style="color:Blue; string file;
BackgroundWorker backGroundWorker1;
Bitmap[] myBitmaps;
Bitmap pb11;
<span style="color:Blue; public <span style="color:Blue; static FileInfo[] file_info_mouse_wheel;
<span style="color:Blue; public <span style="color:Blue; string radar_images_download_directory;
<span style="color:Blue; private Bitmap[] file_info_trackBar2;
<span style="color:Blue; private <span style="color:Blue; bool _isDirty = <span style="color:Blue; false;
<span style="color:Blue; public Picturebox1_Fullscreen()
{
InitializeComponent();
path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; false;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; false;
trackBar1 = myTrackPanelss1.trackBar1;
label3.Visible = <span style="color:Blue; false;
label5.Visible = <span style="color:Blue; false;
label8.Visible = <span style="color:Blue; false;
label4.Visible = <span style="color:Blue; false;
label7.Visible = <span style="color:Blue; false;
button1.Visible = <span style="color:Blue; false;
trackBar1 = myTrackPanelss1.trackBar1;
<span style="color:Blue; if (Form1.automaticDoubleClick == <span style="color:Blue; true)
{
<span style="color:Green; //timer3.Enabled = true;
}
myBitmaps = <span style="color:Blue; null;
pb11 = <span style="color:Blue; null;
pb1_enabled = <span style="color:Blue; false;
<span style="color:Blue; int labels_X = 140;
<span style="color:Blue; float labels_Y = 10;
label3.Visible = <span style="color:Blue; false;
i = 0;
file = Form1.lf;
<span style="color:Blue; if (!File.Exists(file) || file == <span style="color:Blue; null)
{
trackBar1.Enabled = <span style="color:Blue; false;
trackBar2.Enabled = <span style="color:Blue; false;
timer1.Enabled = <span style="color:Blue; false;
<span style="color:Blue; return;
}
lff = Image.FromFile(file);
Logger.Write(<span style="color:#A31515; "pictureBox1 in the constructor of Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "files in the constructor of Picturebox1_Fullscreen is is >>> " + file);
pictureBox1.Image = lff;
trackBar1.Enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
backGroundWorker1 = <span style="color:Blue; new BackgroundWorker();
backGroundWorker1.WorkerSupportsCancellation = <span style="color:Blue; true;
<span style="color:Blue; this.backGroundWorker1.WorkerReportsProgress = <span style="color:Blue; true;
backGroundWorker1.ProgressChanged += <span style="color:Blue; new ProgressChangedEventHandler(backGroundWorker1_ProgressChanged);
backGroundWorker1.DoWork += <span style="color:Blue; new DoWorkEventHandler(backGroundWorker1_DoWork);
backGroundWorker1.RunWorkerCompleted += <span style="color:Blue; new RunWorkerCompletedEventHandler(backGroundWorker1_RunWorkerCompleted);
radar_images_download_directory = Options_DB.Get_Radar_Images_Download_Directory();
DirectoryInfo dir1 = <span style="color:Blue; new DirectoryInfo(radar_images_download_directory);
file_info_mouse_wheel = dir1.GetFiles(<span style="color:#A31515; "*.png");
<span style="color:Blue; if (file_info_mouse_wheel.Count() == 0 || file_info_mouse_wheel.Count() == 1)
{
trackBar1.Enabled = <span style="color:Blue; false;
trackBar2.Enabled = <span style="color:Blue; false;
checkBox1.Enabled = <span style="color:Blue; false;
<span style="color:Blue; if (file_info_mouse_wheel.Count() == 1)
{
trackBar2.Enabled = <span style="color:Blue; true;
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label5.Visible = <span style="color:Blue; true;
label3.Visible = <span style="color:Blue; true;
label8.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
label3.Visible = <span style="color:Blue; true;
label5.Visible = <span style="color:Blue; true;
label8.Visible = <span style="color:Blue; true;
label4.Visible = <span style="color:Blue; true;
label7.Visible = <span style="color:Blue; true;
StartWork();
}
}
<span style="color:Blue; else
{
checkBox1.Enabled = <span style="color:Blue; true;
trackBar1.Minimum = 0;
trackBar1.Maximum = file_info_mouse_wheel.Length - 1;
<span style="color:Blue; this.myTrackPanelss1.End = trackBar1.Maximum;
trackBar1.ValueChanged += <span style="color:Blue; new EventHandler(trackBar1_Scroll);
trackBar1.Value = file_info_mouse_wheel.Length - 1;
trackBar1.Enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
radar_images_download_directory = Options_DB.Get_Radar_Images_Download_Directory();
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label5.Visible = <span style="color:Blue; true;
label3.Visible = <span style="color:Blue; true;
label8.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
label3.Visible = <span style="color:Blue; true;
label5.Visible = <span style="color:Blue; true;
label8.Visible = <span style="color:Blue; true;
label4.Visible = <span style="color:Blue; true;
label7.Visible = <span style="color:Blue; true;
}
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
trackBar2.Enabled = <span style="color:Blue; false;
}
<span style="color:Green; //pictureBox1.Enabled = false;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
i = i + 1;
label1.Text = <span style="color:#A31515; "Processing Images Please Wait " + i;
StartWork(); <span style="color:Green; // TO CHECK STARTWORK() MAKING THE EXCEPTION !!!!!!!
<span style="color:Blue; this.FormClosing += <span style="color:Blue; new FormClosingEventHandler(Picturebox1_Fullscreen_FormClosing);
trackBar2.Maximum = ImagesComparison.ImagesLength;
labels = <span style="color:Blue; new Label[16];
<span style="color:Blue; for (<span style="color:Blue; int loop_through_lables = labels.Length - 1; loop_through_lables >= 0; loop_through_lables--)<span style="color:Green; // This one will create 15 lables start on top from 15 to 0.
<span style="color:Green; //This will create 15 labels start on top from 0 to 15 int loop_through_lables = 0; loop_through_lables < labels.Length; loop_through_lables++)
{
labels[loop_through_lables] = <span style="color:Blue; new Label();
labels[loop_through_lables].MouseMove += <span style="color:Blue; new MouseEventHandler(Picturebox1_Fullscreen_Labels_MouseMove);
splitContainer1.Panel2.Controls.Add(labels[loop_through_lables]);
labels[loop_through_lables].Size = <span style="color:Blue; new Size(35, 13);
labels[loop_through_lables].Location = <span style="color:Blue; new Point(labels_X,(<span style="color:Blue; int)labels_Y);
labels[loop_through_lables].BringToFront();
labels[loop_through_lables].Visible = <span style="color:Blue; true;
labels[loop_through_lables].Text = loop_through_lables.ToString();
labels_Y += 32.5f; <span style="color:Green; // to check there are 16 maximum on trackbar2 so to make also 16 labels.
}
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel1_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel2_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void pictureBox1_DoubleClick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (backGroundWorker1.IsBusy)
{
<span style="color:Green; //this.backGroundWorker1.CancelAsync();
}
<span style="color:Blue; else
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; bool LoadPictureAt(<span style="color:Blue; int nIndex, <span style="color:Blue; object c)
{
<span style="color:Blue; bool bRet = <span style="color:Blue; false;
<span style="color:Blue; if (nIndex >= 0 && nIndex < file_info_mouse_wheel.Length)
{
<span style="color:Blue; if (c.Equals(trackBar1))
pictureBox1.Load(file_info_mouse_wheel[nIndex].FullName);
bRet = <span style="color:Blue; true;
}
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
}
<span style="color:Blue; else
{
<span style="color:Blue; if (nIndex >= 0 && nIndex < file_info_trackBar2.Length)
{
<span style="color:Blue; if (c.Equals(trackBar2))
pictureBox1.Image = file_info_trackBar2[nIndex];
bRet = <span style="color:Blue; true;
}
}
<span style="color:Blue; return bRet;
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
LoadPictureAt(trackBar2.Value, sender);
label1.Text = <span style="color:#A31515; "Image Number: "+ trackBar2.Value.ToString();
pictureBox1.Refresh();
}
<span style="color:Blue; public PictureBox picturebox1(PictureBox pb1)
{
pictureBox1.Image = pb1.Image;
Logger.Write(<span style="color:#A31515; "pictureBox1 in the function picturebox1 in Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "pb1 in the function picturebox1 in Picturebox1_Fullscreen is >>> " + pb1.ToString());
<span style="color:Blue; return pictureBox1;
}
<span style="color:Blue; public <span style="color:Blue; string picturebox1_lastFile(<span style="color:Blue; string last_file)
{
pictureBox1.Load(last_file);
Logger.Write(<span style="color:#A31515; "pictureBox1 in the function picturebox1_lastFile in Picturebox1_Fullscreen is >>> " + pictureBox1.ToString());
Logger.Write(<span style="color:#A31515; "last_file in the function picturebox1_lastFile in Picturebox1_Fullscreen is >>> " + last_file.ToString());
<span style="color:Blue; return last_file;
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_DoWork(<span style="color:Blue; object sender, DoWorkEventArgs e)
{
<span style="color:Blue; int f = (<span style="color:Blue; int)e.Argument;
Image img1;
img1 = Image.FromFile(file);
pb11 = <span style="color:Blue; new Bitmap(img1);
myBitmaps = ImagesComparison.get_images_with_clouds(pb11);
<span style="color:Blue; if (<span style="color:Blue; this.backGroundWorker1.CancellationPending)
{
e.Result = f;
<span style="color:Blue; return;
}
file_info_trackBar2 = myBitmaps;
e.Result = f;
pb11.Dispose();
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{
Form1.timer11.Enabled = <span style="color:Blue; true;
<span style="color:Blue; if (backGroundWorker1 != <span style="color:Blue; null)
backGroundWorker1.Dispose();
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_RunWorkerCompleted(<span style="color:Blue; object sender, RunWorkerCompletedEventArgs e)
{
<span style="color:Blue; if (file_info_trackBar2 != <span style="color:Blue; null)
{
label1.Text = <span style="color:#A31515; "Images Process Completed";
i = 0;
pb1_enabled = <span style="color:Blue; true;
trackBar2.Enabled = <span style="color:Blue; true;
}
<span style="color:Blue; if (<span style="color:Blue; this._isDirty)
{
<span style="color:Blue; this._isDirty = <span style="color:Blue; false;
StartWork();
}
<span style="color:Green; /* try
{
if (file_info_trackBar2 != null)
{
if (trackBar2 != null && trackBar2.IsDisposed == false)
trackBar2.Enabled = true;
label1.Text = "Images Process Completed";
i = 0;
if (pictureBox1.Image != null && pictureBox1.Image.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
pictureBox1.Enabled = true;
else
{
//assign here a picture you like
pictureBox1.Image = new Bitmap(@"dpl_look.jpg");
pictureBox1.Enabled = true;
}
pictureBox1.Refresh();
}
if (this._isDirty)
{
this._isDirty = false;
StartWork();
}
}
catch (Exception error)
{
Logger.Write("Error " + error);
}*/
<span style="color:Green; /* if (file_info_trackBar2 != null)
{
trackBar2.Enabled = true;
label1.Text = "Images Process Completed";
i = 0;
splitContainer1.Panel2.Enabled = true;
try
{
//try to get a property of the image
//and if it fails assign a new image to the pictureBox
int t = pictureBox1.Image.Width;
pictureBox1.Enabled = true;
}
catch
{
Image img = pictureBox1.Image;
//assign here a picture you like
pictureBox1.Image = new Bitmap(@"dpl_look.jpg");
pictureBox1.Enabled = true;
if (img != null)
img.Dispose();
}
pictureBox1.Refresh();
}
if (this._isDirty)
{
this._isDirty = false;
StartWork();
}*/
}
<span style="color:Blue; private <span style="color:Blue; void StartWork()
{
<span style="color:Blue; if (!<span style="color:Blue; this.backGroundWorker1.IsBusy)
{
<span style="color:Blue; this.backGroundWorker1.RunWorkerAsync(<span style="color:Blue; this.trackBar2.Value);
}
<span style="color:Blue; else
{
<span style="color:Blue; this._isDirty = <span style="color:Blue; true;
<span style="color:Blue; this.backGroundWorker1.CancelAsync();
}
}
<span style="color:Blue; private <span style="color:Blue; void backGroundWorker1_ProgressChanged(<span style="color:Blue; object sender, ProgressChangedEventArgs e)
{
<span style="color:Green; //this.progressBar1.Value = e.ProgressPercentage;
<span style="color:Green; // int count = e.ProgressPercentage;
<span style="color:Green; // textBox1.Text = string.Format("{0} images processed.", count);
}
<span style="color:Blue; private <span style="color:Blue; void timer1_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (radar_images_download_directory == <span style="color:#A31515; "")
{
}
<span style="color:Blue; else
{
<span style="color:Blue; if (file_info_trackBar2 == <span style="color:Blue; null)
{
i = i + 1;
label1.Text = <span style="color:#A31515; "Processing Images Please Wait " + i;
<span style="color:Green; //pictureBox1.Enabled = false;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
}
}
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_Enter(<span style="color:Blue; object sender, EventArgs e)
{
trackBar2.BackColor = Color.DarkSlateGray;
trackBar1.BackColor = System.Drawing.SystemColors.Control;
label1.Text = <span style="color:#A31515; "Image Number: " + trackBar2.Value.ToString();
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_Load(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; //SetTextBoxes();
}
<span style="color:Blue; private <span style="color:Blue; void SetTextBoxes()
{
<span style="color:Green; /* foreach (Control c in splitContainer1.Panel2.Controls)
{
if (c is TextBox)
{
x = x + 1;
if (x < 4)
{
c.BackColor = Color.Red;
}
else
{
}
c.Text = mm_per_hour_arr[1].ToString();
}
}*/
<span style="color:Green; // x 249 y 015
Bitmap original_image = <span style="color:Blue; new Bitmap(Properties.Resources.radar_scale_heb);
Color originalColor;
Bitmap new_image1;
new_image1 = <span style="color:Blue; new Bitmap(356, 45);
<span style="color:Blue; int x;
<span style="color:Blue; int y = 15;
Bitmap new_image = original_image;
<span style="color:Blue; for (x = 133; x < 250; x++)<span style="color:Green; //x = 15; x < 250; x++)//x+=10)//new_image.Width; x++)
{
originalColor = new_image.GetPixel(x, y);
new_image1.SetPixel(x, y, originalColor);
}
<span style="color:Green; //new_image1.Save(@"d:tryingcolor.png");
<span style="color:Green; //Color c = RadarAnalysis.ColorFromAhsb(0, (float)421.35, 001,(float) 0.56);
<span style="color:Green; //textBox1.BackColor = c;
<span style="color:Green; /* textBox1.Text = mm_per_hour_arr[0].ToString();
textBox2.Text = mm_per_hour_arr[1].ToString();
textBox3.Text = mm_per_hour_arr[2].ToString();
textBox4.Text = mm_per_hour_arr[3].ToString();
textBox5.Text = mm_per_hour_arr[4].ToString();
textBox6.Text = mm_per_hour_arr[5].ToString();
textBox7.Text = mm_per_hour_arr[6].ToString();
textBox8.Text = mm_per_hour_arr[7].ToString();
textBox9.Text = mm_per_hour_arr[8].ToString();
textBox10.Text = mm_per_hour_arr[9].ToString();
textBox11.Text = mm_per_hour_arr[10].ToString();*/
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer1_Panel2_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox1.Text = <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void trackBar2_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox2.Text = <span style="color:#A31515; "TrackBar2 " + <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void Picturebox1_Fullscreen_Labels_MouseMove(<span style="color:Blue; object sender, MouseEventArgs e)
{
textBox3.Text = <span style="color:#A31515; "Labels " + <span style="color:#A31515; "Position on X: " + e.X + <span style="color:#A31515; "Position on Y: " + e.Y;
}
<span style="color:Blue; private <span style="color:Blue; void timer2_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (pb1_enabled == <span style="color:Blue; true)
{
<span style="color:Green; //pictureBox1.Enabled = true;
splitContainer1.Panel2.Enabled = <span style="color:Blue; true;
}
}
<span style="color:Blue; private <span style="color:Blue; void timer3_Tick(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (backGroundWorker1.IsBusy)
{
<span style="color:Green; //this.backGroundWorker1.CancelAsync();
}
<span style="color:Blue; else
<span style="color:Blue; this.Close();
}
<span style="color:Blue; private <span style="color:Blue; void trackBar1_Scroll(<span style="color:Blue; object sender, EventArgs e)
{
label3.Visible = <span style="color:Blue; true;
i = 0;
LoadPictureAt(trackBar1.Value, sender);
label3.Text = <span style="color:#A31515; "Overall Number Of Images: ";
label5.Text = file_info_mouse_wheel.Length.ToString();
label3.Visible = <span style="color:Blue; true;
label3.Text = <span style="color:#A31515; "Image Name: ";
label4.Text = file_info_mouse_wheel[trackBar1.Value].Name;
creationTime = File.GetLastWriteTime(file_info_mouse_wheel[trackBar1.Value].FullName);
label7.Text = creationTime.ToString(<span style="color:#A31515; "h:mm tt, dddd, MMMM d, yyyy");
file = file_info_mouse_wheel[trackBar1.Value].FullName;
file_info_trackBar2 = <span style="color:Blue; null;
trackBar2.Enabled = <span style="color:Blue; false;
pb1_enabled = <span style="color:Blue; false;
StartWork();
}
<span style="color:Blue; private <span style="color:Blue; void trackBar1_Enter(<span style="color:Blue; object sender, EventArgs e)
{
trackBar1.BackColor = Color.Red;
trackBar2.BackColor = System.Drawing.SystemColors.Control;
}
<span style="color:Blue; private <span style="color:Blue; void splitContainer2_Panel2_Paint(<span style="color:Blue; object sender, PaintEventArgs e)
{
}
<span style="color:Blue; private <span style="color:Blue; void checkBox1_CheckedChanged(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (checkBox1.Checked)
{
label2.Visible = <span style="color:Blue; true;
numericUpDown1.Visible = <span style="color:Blue; true;
checkBox2.Visible = <span style="color:Blue; true;
button1.Visible = <span style="color:Blue; true;
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; true;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; true;
}
<span style="color:Blue; else
{
label2.Visible = <span style="color:Blue; false;
numericUpDown1.Visible = <span style="color:Blue; false;
checkBox2.Visible = <span style="color:Blue; false;
button1.Visible = <span style="color:Blue; false;
myTrackPanelss1.panel1.Enabled = <span style="color:Blue; false;
myTrackPanelss1.panel1.Visible = <span style="color:Blue; false;
}
}
<span style="color:Blue; private <span style="color:Blue; void numericUpDown1_ValueChanged(<span style="color:Blue; object sender, EventArgs e)
{
animatedSpeed = (<span style="color:Blue; int)numericUpDown1.Value;
}
<span style="color:Blue; private <span style="color:Blue; void checkBox2_CheckedChanged(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (checkBox2.Checked)
{
looping = checkBox2.Checked;
}
<span style="color:Blue; else
{
looping = checkBox2.Checked;
}
}
<span style="color:Blue; private <span style="color:Blue; void button1_Click(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Green; /* List<string> myGifList;
Image gifImages;
button1.Enabled = false;
Animation_Radar_Preview ap = new Animation_Radar_Preview();
ap.FormClosing += new FormClosingEventHandler(ap_FormClosing);
FileInfo[] fi;
DirectoryInfo dir1 = new DirectoryInfo(radar_images_download_directory);
fi = dir1.GetFiles("*.png");
myList = new List<string>();
myGifList = new List<string>();
for (int i = myTrackPanelss1.Start; i < myTrackPanelss1.End; i++)
{
myList.Add(fi.FullName);
}
for (int x = 0; x < myList.Count(); x++)
{
gifImages = Image.FromFile(myList[x]);
gifImages.Save(tempRadarPngToGifDirectory + "\" + x.ToString("D6") + ".Gif", System.Drawing.Imaging.ImageFormat.Gif);
}
myGifList = new List<string>();
dir1 = new DirectoryInfo(tempRadarPngToGifDirectory);
fi = dir1.GetFiles("*.gif");
nameOfStartFile = fi[0].Name;
for (int i = 0; i < fi.Length; i++)
{
myGifList.Add(fi.FullName);
nameOfEndFile = fi.Name.Length.ToString();
}
numberOfFiles = myGifList.Count();
unfreez.MakeGIF(myGifList, previewFileName, animatedGifSpeed, loop);*/
mtp1Start = myTrackPanelss1.Start;
mtp1End = myTrackPanelss1.End;
button1.Enabled = <span style="color:Blue; false;
Animation_Radar_Preview ap = <span style="color:Blue; new Animation_Radar_Preview();
ap.Show();
<span style="color:Green; //DialogResult rv = ap.ShowDialog();*/
}
<span style="color:Blue; private <span style="color:Blue; void ap_FormClosing(<span style="color:Blue; object sender, FormClosingEventArgs e)
{
button1.Enabled = <span style="color:Blue; true;
}
<span style="color:Green; // to fix/change/add also in the satellite preview form code like here \
<span style="color:Green; // To make/check when trackBar2 is on image 15 in the array so it will show automatic after process is finished the milimeters of the current image according to number 15 in the array of trackBar2
}
}
[/code]
myTrackPanelss1 is User Control :
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.Drawing.Drawing2D;
<span style="color:Blue; namespace mws
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class MyTrackPanelss : UserControl
{
<span style="color:Blue; public <span style="color:Blue; int Start { <span style="color:Blue; get; <span style="color:Blue; set; }
<span style="color:Blue; public <span style="color:Blue; int End { <span style="color:Blue; get; <span style="color:Blue; set; }
<span style="color:Blue; private <span style="color:Blue; int _tbPadding = 14;
<span style="color:Blue; private <span style="color:Blue; float _penWidth = 15F;
<span style="color:Blue; public <span style="color:Blue; int TBPadding { <span style="color:Blue; get { <span style="color:Blue; return _tbPadding; } }
<span style="color:Blue; public <span style="color:Blue; float PenWidth { <span style="color:Blue; get { <span style="color:Blue; return _penWidth; } }
<span style="color:Blue; public MyTrackPanelss()
{
InitializeComponent();
Start = 0;
End = <span style="color:Blue; this.trackBar1.Maximum;
}
<span style="color:Blue; private <span style="color:Blue; void panel1_Paint(<span style="color:Blue; object sender, PaintEventArgs e)
{
<span style="color:Blue; using (SolidBrush b = <span style="color:Blue; new SolidBrush(SystemColors.ControlDark))
e.Graphics.FillRectangle(b, <span style="color:Blue; this.ClientRectangle);
<span style="color:Blue; using (GraphicsPath gPath = <span style="color:Blue; new GraphicsPath())
{
gPath.AddLine(<span style="color:Blue; new Point(_tbPadding, 0), <span style="color:Blue; new Point(_tbPadding, panel1.ClientSize.Height - 2));
gPath.AddLine(<span style="color:Blue; new Point(<span style="color:Blue; this.trackBar1.ClientSize.Width - _tbPadding, panel1.ClientSize.Height - 2),
<span style="color:Blue; new Point(<span style="color:Blue; this.trackBar1.ClientSize.Width - _tbPadding, 0));
<span style="color:Blue; using (SolidBrush sb = <span style="color:Blue; new SolidBrush(SystemColors.ActiveCaption))
e.Graphics.FillPath(sb, gPath);
e.Graphics.DrawPath(Pens.Black, gPath);
}
<span style="color:Blue; int maxRange = <span style="color:Blue; this.trackBar1.Maximum - <span style="color:Blue; this.trackBar1.Minimum;
<span style="color:Green; //_tbPadding for end and start of ticks of trackbar
<span style="color:Blue; double rangeOne = ((<span style="color:Blue; this.panel1.ClientSize.Width - _tbPadding * 2.0) / (<span style="color:Blue; double)maxRange);
<span style="color:Blue; if (End < Start)
{
<span style="color:Blue; int tmp = End;
End = Start;
Start = tmp;
}
<span style="color:Blue; if (End == Start)
{
MessageBox.Show(<span style="color:#A31515; "You cannot select start point and end point on the same place");
}
<span style="color:Blue; float xVal = (<span style="color:Blue; float)(_tbPadding + (Start * rangeOne));
<span style="color:Blue; float xVal2 = (<span style="color:Blue; float)(_tbPadding + (End * rangeOne));
<span style="color:Blue; if (Start >= <span style="color:Blue; this.trackBar1.Minimum)
{
<span style="color:Blue; using (Pen greenPen = <span style="color:Blue; new Pen(Color.Green, _penWidth))
{
e.Graphics.DrawLine(greenPen, <span style="color:Blue; new PointF(xVal, 1), <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
<span style="color:Blue; using (Pen p = <span style="color:Blue; new Pen(Color.Black))
{
p.StartCap = LineCap.ArrowAnchor;
e.Graphics.DrawLine(p, <span style="color:Blue; new PointF(xVal, 1), <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
}
e.Graphics.DrawString((Start+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
}
}
<span style="color:Blue; if (End <= <span style="color:Blue; this.trackBar1.Maximum)
{
<span style="color:Blue; using (Pen redPen = <span style="color:Blue; new Pen(Color.Red, _penWidth))
{
SizeF s = e.Graphics.MeasureString(End.ToString(), <span style="color:Blue; this.Font);
e.Graphics.DrawLine(redPen, <span style="color:Blue; new PointF(xVal2, 1), <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
<span style="color:Blue; using (Pen p = <span style="color:Blue; new Pen(Color.Black))
{
p.StartCap = LineCap.ArrowAnchor;
e.Graphics.DrawLine(p, <span style="color:Blue; new PointF(xVal2, 1), <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height - 2));
}
<span style="color:Blue; if (xVal2 - xVal > s.Width + redPen.Width)
e.Graphics.DrawString((End+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal2 - s.Width, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
<span style="color:Blue; else
e.Graphics.DrawString((End+1).ToString(), <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF(xVal2, <span style="color:Blue; this.panel1.ClientSize.Height / 2F));
}
}
<span style="color:Blue; string t = <span style="color:#A31515; "click left to specify start, right to specify end";
SizeF sz = e.Graphics.MeasureString(t, <span style="color:Blue; this.Font);
e.Graphics.DrawString(t, <span style="color:Blue; this.Font, Brushes.Black, <span style="color:Blue; new PointF((<span style="color:Blue; this.panel1.ClientSize.Width - sz.Width) / 2F, 0));
}
<span style="color:Blue; private <span style="color:Blue; void panel1_MouseClick(<span style="color:Blue; object sender, MouseEventArgs e)
{
<span style="color:Blue; int maxRange = <span style="color:Blue; this.trackBar1.Maximum - <span style="color:Blue; this.trackBar1.Minimum;
<span style="color:Green; //_tbPadding for end and start of ticks of trackbar
<span style="color:Blue; double rangeOne = ((<span style="color:Blue; this.panel1.ClientSize.Width - _tbPadding * 2.0) / (<span style="color:Blue; double)maxRange);
<span style="color:Blue; if (e.Button == MouseButtons.Left && e.X >= _tbPadding && e.X <= panel1.ClientSize.Width - _tbPadding)
{
<span style="color:Blue; int i = (<span style="color:Blue; int)((e.X - _tbPadding) / rangeOne);
Start = i;
trackBar1.Value = i;
<span style="color:Blue; this.panel1.Invalidate();
}
<span style="color:Blue; if (e.Button == MouseButtons.Right && e.X >= _tbPadding && e.X <= panel1.ClientSize.Width - _tbPadding + rangeOne)
{
<span style="color:Blue; int i = (<span style="color:Blue; int)((e.X - _tbPadding) / rangeOne);
End = i;
trackBar1.Value = i;
<span style="color:Blue; this.panel1.Invalidate();
}
}
}
}
[/code]
<hr class="sig danieli
View the full article