1. If the user is moving the trackbar the bar it self to the left wich is the start it will stop if he is using the mouse or the mouse wheel or the keyboards it will stop on the most left and when he gets to the most right side it will stop there too.
2. I want that the user will be able to move the bar in three ways: with keyboards image by image with the mouse pointer drag it from side to side fast and by the nouse scroll button.
So using the mouse wheel i did a;;ready and the user can scroll throught the images with the mouse wheel. And i did it that only when the user click on the picturebox and its in fullscreen only then he can scroll between the images. Now i want to add the TrackBar.
So first this is the code of the event when the user click on the picturebox1 and make it on fullscreen:
Expand|Select|Wrap|Line Numbers
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- Button picturebox1button;
- picturebox1button = new Button();
- this.Controls.Add(picturebox1button);
- picturebox1button.Click+=new EventHandler(picturebox1button_Click);
- if (button_switch == true)
- {
- formInitialLocation = this.Location;
- formInitialSize = this.Size;
- this.FormBorderStyle = FormBorderStyle.None;
- this.Bounds = Screen.PrimaryScreen.Bounds;
- pictureBox1.Dock = DockStyle.Fill;
- pictureBox1.BringToFront();
- button_switch = false;
- this.button_legend_1.Visible = true;
- this.button_legend_1.Size = Properties.Resources.radar_scale_heb.Size;
- this.button_legend_1.Image = Properties.Resources.radar_scale_heb;
- this.button_legend_1.BringToFront();
- this.button_legend_1.Location = new Point(Screen.GetWorkingArea(this).Width - button_legend_1.Width, 24);
- this.button_legend_1.Enabled = true;
- this.button_legend_2.Visible = true;
- this.button_legend_2.Width = 350;
- this.button_legend_2.Location = new Point(Screen.GetWorkingArea(this).Width - button_legend_2.Width, button_legend_1.Height+30);
- picturebox1button.Visible = true;
- picturebox1button.BringToFront();
- picturebox1button.Location = new Point(Screen.GetWorkingArea(this).Width - 260 , 24+button_legend_1.Height+50);
- picturebox1button.Enabled = true;
- picturebox1button.Width = 260;
- picturebox1button.Text = "Save image as screen size resolution";
- this.trackBar1_radar_images.Visible = true;
- trackBar1_radar_images.Location = new Point(Screen.GetWorkingArea(this).Width - 250, 24 + button_legend_1.Height + 80);
- trackBar1_radar_images.Width = 250;
- trackBar1_radar_images.BringToFront();
- trackBar1_radar_images.SmallChange = 1;
- trackBar1_radar_images.LargeChange = 5;
- trackBar1_radar_images.TickStyle = TickStyle.BottomRight;
- trackBar1_radar_images.TickFrequency = 1;
- trackBar1_radar_images.BringToFront();
- trackBar1_radar_images.Show();
- if (sf == null)
- {
- }
- else
- {
- int it;
- string Next_File;
- it = last_image_file(); // ליישם גם על הלויין.
- Next_File = sf + @"\radar" + it.ToString("D3") + ".jpg";
- FileInfo myinf = new FileInfo(Next_File);
- DateTime time = myinf.CreationTime;
- this.button_legend_2.Text = "Last downloaded file is : " + myinf.Name + " At date : " + time;
- this.button_legend_2.BringToFront();
- this.button_legend_2.Enabled = true;
- }
- }
- else
- {
- this.FormBorderStyle = FormBorderStyle.FixedSingle;
- this.Dock = DockStyle.None;
- pictureBox1.Dock = DockStyle.None;
- button_switch = true;
- this.Location = formInitialLocation;
- this.Size = formInitialSize;
- this.button_legend_1.Enabled = false;
- this.button_legend_1.Visible = false;
- this.button_legend_2.Enabled = false;
- this.button_legend_2.Visible = false;
- trackBar1_radar_images.Visible = false;
- }
- }
Now the code of the onmousewheel event :
Expand|Select|Wrap|Line Numbers
- protected override void OnMouseWheel(MouseEventArgs e)
- {
- trackBar1_radar_images.Scroll+=new EventHandler(trackBar1_radar_images_Scroll);
- DirectoryInfo dir1 = new DirectoryInfo(sf);
- file_info_mouse_wheel = dir1.GetFiles("radar*.jpg");
- file_info_mouse_wheel = file_info_mouse_wheel.OrderBy((b) => b.LastWriteTime).ToArray();
- DirectoryInfo dir2 = new DirectoryInfo(satellite_dir);
- file_info_mouse_wheel_satellite = dir2.GetFiles("satellite*.jpg");
- file_info_mouse_wheel_satellite = file_info_mouse_wheel_satellite.OrderBy((b) => b.LastWriteTime).ToArray();
- base.OnMouseWheel(e);
- if (pictureBox1.Dock == DockStyle.Fill)
- {
- if (e.Delta > 0)
- {
- file_indexs--;
- if (file_indexs <= 0)
- file_indexs = file_info_mouse_wheel.Length - 1;
- /* trackBar1_radar_images.Minimum = 0;
- trackBar1_radar_images.Maximum = file_info_mouse_wheel.Length;
- trackBar1_radar_images.Value = file_info_mouse_wheel.Length - 1;*/
- LoadPictureAt(file_indexs);
- }
- else if (e.Delta < 0)
- {
- file_indexs++;
- if (file_indexs >= file_info_mouse_wheel.Length)
- file_indexs = 0;
- /* trackBar1_radar_images.Value = file_indexs;
- trackBar1_radar_images.Minimum = 0;
- trackBar1_radar_images.Maximum = file_info_mouse_wheel.Length;*/
- LoadPictureAt(file_indexs);
- }
- }
- if (pictureBox2.Dock == DockStyle.Fill)
- {
- if (e.Delta > 0)
- {
- satellite_file_indexs--;
- if (satellite_file_indexs <= 0)
- satellite_file_indexs = file_info_mouse_wheel_satellite.Length + 1;
- LoadPictureAtSatellite(satellite_file_indexs);
- }
- else if (e.Delta < 0)
- {
- satellite_file_indexs++;
- if (satellite_file_indexs >= file_info_mouse_wheel_satellite.Length)
- satellite_file_indexs = 0;
- LoadPictureAtSatellite(satellite_file_indexs);
- }
- }
- }
- private void trackBar1_radar_images_Scroll(object sender, EventArgs e)
- {
- trackBar1_radar_images.Value = file_indexs;
- trackBar1_radar_images.Minimum = 0;
- trackBar1_radar_images.Maximum = file_info_mouse_wheel.Length;
- }
The next two events im not sure if they are important:
Expand|Select|Wrap|Line Numbers
- private bool LoadPictureAt(int nIndex)
- {
- bool bRet = false;
- if (sf == null)
- {
- }
- else
- {
- if (nIndex >= 0 && nIndex < file_info_mouse_wheel.Length)
- {
- nindex_radar = nIndex;
- pictureBox1.Load(file_info_mouse_wheel[nIndex].FullName);
- bRet = true;
- }
- }
- return bRet;
- }
- private bool LoadPictureAtSatellite(int nIndexs)
- {
- bool aRet = false;
- if (nIndexs >= 0 && nIndexs < file_info_mouse_wheel_satellite.Length)
- {
- nindexs_satellite = nIndexs;
- pictureBox2.Load(file_info_mouse_wheel_satellite[nIndexs].FullName);
- aRet = true;
- }
- return aRet;
- }
First only on picturebox1 then i want to make the same with picturebox2
When i mean moving the trackbar the bar to the left so its the start so it will show the first image in the index 001 and when its to the mose of the right it will show the last image wich is the last image downloaded.
So on the most left it will be the oldest image and on the most right the most newest image.
And if its possible to use/fix/repair/use my code the one i copied/paste here.
Thanks a lot.