Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 11.72 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why the animation is working when i have 3 images and more on hard disk but when i have 2 images on hard disk it dosent work good?
  2. private void button3_Click(object sender, EventArgs e)
  3.         {
  4.             try
  5.             {
  6.                 wichButtonAnimationClickedForward = false;
  7.                 wichButtonAnimationClickedBackwards = true;
  8.                 button5.Text = "Pause Animation";
  9.                 file_array_check = Directory.GetFiles(sf, "radar*.png");
  10.                 if (file_array_check.Length == 0)
  11.                 {
  12.                     file_array_satellite = Directory.GetFiles(satellite_dir, "satellite*.png");
  13.                     DateTime[] creationTimes2 = new DateTime[file_array_satellite.Length];
  14.                     for (int i = 0; i < file_array_satellite.Length; i++)
  15.                         creationTimes2[i] = new FileInfo(file_array_satellite[i]).CreationTime;
  16.                     Array.Sort(creationTimes2, file_array_satellite);
  17.                     file_indxs_satellite = file_array_satellite.Length;
  18.                     file_indxs_satellite = file_array_satellite.Length - 1;
  19.                     timer3.Enabled = false;
  20.                     timer2.Enabled = true;
  21.                 }
  22.                 else
  23.                 {
  24.                     wichButtonAnimationClickedForward = false;
  25.                     wichButtonAnimationClickedBackwards = true;
  26.                     file_array = Directory.GetFiles(sf, "radar*.png");
  27.                     DateTime[] creationTimes3 = new DateTime[file_array.Length];
  28.                     for (int i = 0; i < file_array.Length; i++)
  29.                         creationTimes3[i] = new FileInfo(file_array[i]).CreationTime;
  30.                     Array.Sort(creationTimes3, file_array);
  31.                     file_indexs = file_array.Length;
  32.                     file_indexs = file_array.Length - 1;
  33.                     timer2.Enabled = true;
  34.                     timer3.Enabled = false;
  35.                 }
  36.             }
  37.             catch
  38.             {
  39.             }
  40.             try
  41.             {
  42.                 wichButtonAnimationClickedForward = false;
  43.                 wichButtonAnimationClickedBackwards = true;
  44.                 file_array_check = Directory.GetFiles(satellite_dir, "satellite*.png");
  45.                 if (file_array_check.Length == 0)
  46.                 {
  47.                     file_array = Directory.GetFiles(sf, "radar*.png");
  48.                     DateTime[] creationTimes5 = new DateTime[file_array.Length];
  49.                     for (int i = 0; i < file_array.Length; i++)
  50.                         creationTimes5[i] = new FileInfo(file_array[i]).CreationTime;
  51.                     Array.Sort(creationTimes5, file_array);
  52.                     file_indexs = file_array.Length;
  53.                     file_indexs = file_array.Length - 1;
  54.                     timer2.Enabled = true;
  55.                     timer3.Enabled = false;
  56.                 }
  57.                 else
  58.                 {
  59.                     wichButtonAnimationClickedForward = false;
  60.                     wichButtonAnimationClickedBackwards = true;
  61.                     file_array_satellite = Directory.GetFiles(satellite_dir, "satellite*.png");
  62.                     DateTime[] creationTimes6 = new DateTime[file_array_satellite.Length];
  63.                     for (int i = 0; i < file_array_satellite.Length; i++)
  64.                         creationTimes6[i] = new FileInfo(file_array_satellite[i]).CreationTime;
  65.                     Array.Sort(creationTimes6, file_array_satellite);
  66.                     file_indxs_satellite = file_array_satellite.Length;
  67.                     file_indxs_satellite = file_array_satellite.Length - 1;
  68.                     timer3.Enabled = false;
  69.                     timer2.Enabled = true;
  70.                     // לבדוק כפתור
  71.                     // Pause שממשיכים עושה רק קדימה
  72.                     // לעשות SORT גם לקבצים של הראדר והלוויין ביתר המקומות
  73.                 }
  74.             }
  75.             catch (Exception AnimationError)
  76.             {
  77.                 Logger.Write("Animation Error: " + AnimationError);
  78.             }
  79.         }
  80.  
  81.         private void timer2_Tick(object sender, EventArgs e)
  82.         {
  83.             try
  84.             {
  85.                 // לבדוק גם מדוע הוא מדי פעם אחורה ואולי גם קדימה אבל כרגע בספירה אחורה מראה מדי פעם תאריכים אחרים מחודש 11 קופץ ל 10 פתאום וחזרה ל 11.
  86.                 // לבדוק אנימציה קדימה לא עובד. לבדוק כשאחד מהספריות שהוא מראה תקבצים וסופר אחורה או קדימה הוא נעצר בקובץ האחרון במקום להתאפס ולהמשיך שוב ושוב ללכת אחורה או קדימה עד שעוצרים.
  87.                 // לבדוק עכשיו רק את הכפתור 5 של ה PAUSE
  88.                 // לבדוק את הכפתור ה 5 כשעושיפ עצירה וממשיכים הוא תמיד ממשיך קדימה באנימציה לבדוק שאם עוצרים וממשיכים כשהאנימציה אחורה הייתה פועלת שימשיך אחורה ואם קדימה אז קדימה! יתר הדברים באנימציה נפתרו!
  89.                 pictureBox2.Load(file_array_satellite[file_indxs_satellite]);
  90.                 label12.Visible = true;
  91.                 label12.Text = "Satellite files date and time: " + File.GetCreationTime(file_array_satellite[file_indxs_satellite]);
  92.                 file_indxs_satellite = file_indxs_satellite - 1;
  93.              /*   trackBar2_satellite_images.Minimum = 0;
  94.                 trackBar2_satellite_images.Maximum = file_array_satellite.Length;
  95.                 trackBar2_satellite_images.Value = file_indxs_satellite;*/
  96.                 pictureBox1.Load(file_array[file_indexs]);
  97.                 label10.Visible = true;
  98.                 label10.Text = "Radar files date and time: " + File.GetCreationTime(file_array[file_indexs]);
  99.                 file_indexs = file_indexs - 1;
  100.             /*   trackBar1_radar_images.Minimum = 0;
  101.                 trackBar1_radar_images.Maximum = file_array.Length;
  102.                 trackBar1_radar_images.Value = file_indexs;*/
  103.                 if (file_indxs_satellite < 0)
  104.                 {
  105.                     file_indxs_satellite = file_array_satellite.Length - 1;
  106.                 }
  107.                 if (file_indexs < 0)
  108.                 {
  109.                     file_indexs = file_array.Length - 1;
  110.                 }
  111.             }
  112.             catch
  113.             {
  114.                 timer2.Enabled = false;
  115.             }
  116.         }
  117.  
  118.         private void button4_Click(object sender, EventArgs e)
  119.         {
  120.             try
  121.             {
  122.                 wichButtonAnimationClickedForward = true;
  123.                 wichButtonAnimationClickedBackwards = false;
  124.                 button5.Text = "Pause Animation";
  125.                 file_array_check = Directory.GetFiles(sf, "radar*.png");
  126.                 if (file_array_check.Length == 0)
  127.                 {
  128.                     file_array_satellite = Directory.GetFiles(satellite_dir, "satellite*.png");
  129.                     DateTime[] creationTimes8 = new DateTime[file_array_satellite.Length];
  130.                     for (int i = 0; i < file_array_satellite.Length; i++)
  131.                         creationTimes8[i] = new FileInfo(file_array_satellite[i]).CreationTime;
  132.                     Array.Sort(creationTimes8, file_array_satellite);
  133.                     file_indxs_satellite = 0;
  134.                     file_indxs_satellite = file_array_satellite.Length - 1;
  135.                     timer3.Enabled = true;
  136.                     timer2.Enabled = false;
  137.                 }
  138.                 else
  139.                 {
  140.                     wichButtonAnimationClickedForward = true;
  141.                     wichButtonAnimationClickedBackwards = false;
  142.                     file_array = Directory.GetFiles(sf, "radar*.png");
  143.                     DateTime[] creationTimes9 = new DateTime[file_array.Length];
  144.                     for (int i = 0; i < file_array.Length; i++)
  145.                         creationTimes9[i] = new FileInfo(file_array[i]).CreationTime;
  146.                     Array.Sort(creationTimes9, file_array);
  147.                     file_indexs = 0;
  148.                     file_indexs = file_array.Length - 1;
  149.                     timer3.Enabled = true;
  150.                     timer2.Enabled = false;
  151.                 }
  152.             }
  153.             catch (Exception AnimationError)
  154.             {
  155.                 Logger.Write("Animation Error: " + AnimationError);
  156.             }
  157.             try
  158.             {
  159.                 wichButtonAnimationClickedForward = true;
  160.                 wichButtonAnimationClickedBackwards = false;
  161.                 file_array_check = Directory.GetFiles(satellite_dir, "satellite*.png");
  162.                 if (file_array_check.Length == 0)
  163.                 {
  164.                     file_array = Directory.GetFiles(sf, "radar*.png");
  165.                     DateTime[] creationTimes11 = new DateTime[file_array.Length];
  166.                     for (int i = 0; i < file_array.Length; i++)
  167.                         creationTimes11[i] = new FileInfo(file_array[i]).CreationTime;
  168.                     Array.Sort(creationTimes11, file_array);
  169.                     file_indexs = 0;
  170.                     file_indexs = file_array.Length - 1;
  171.                     timer3.Enabled = true;
  172.                     timer2.Enabled = false;
  173.                 }
  174.                 else
  175.                 {
  176.                     wichButtonAnimationClickedForward = true;
  177.                     wichButtonAnimationClickedBackwards = false;
  178.                     file_array_satellite = Directory.GetFiles(satellite_dir, "satellite*.png");
  179.                     DateTime[] creationTimes12 = new DateTime[file_array_satellite.Length];
  180.                     for (int i = 0; i < file_array_satellite.Length; i++)
  181.                         creationTimes12[i] = new FileInfo(file_array_satellite[i]).CreationTime;
  182.                     Array.Sort(creationTimes12, file_array_satellite);
  183.                     file_indxs_satellite = 0;
  184.                     file_indxs_satellite = file_array_satellite.Length - 1;
  185.                     timer3.Enabled = true;
  186.                     timer2.Enabled = false;
  187.                 }
  188.             }
  189.             catch (Exception AnimationError)
  190.             {
  191.                 Logger.Write("Animation Error: " + AnimationError);
  192.             }
  193.         }
  194.  
  195.         private void timer3_Tick(object sender, EventArgs e)
  196.         {
  197.             try
  198.             {
  199.                 pictureBox2.Load(file_array_satellite[file_indxs_satellite]);
  200.                 label12.Visible = true;
  201.                 label12.Text = "Satellite files date and time: " + File.GetCreationTime(file_array_satellite[file_indxs_satellite]);
  202.                 file_indxs_satellite = file_indxs_satellite + 1;
  203.               /*  trackBar2_satellite_images.Minimum = 0;
  204.                 trackBar2_satellite_images.Maximum = file_array_satellite.Length;
  205.                 trackBar2_satellite_images.Value = file_indxs_satellite;*/
  206.                 pictureBox1.Load(file_array[file_indexs]);
  207.                 label10.Visible = true;
  208.                 label10.Text = "Radar files date and time: " + File.GetCreationTime(file_array[file_indexs]);
  209.                 file_indexs = file_indexs + 1;
  210.                /* trackBar1_radar_images.Minimum = 0;
  211.                 trackBar1_radar_images.Maximum = file_array.Length;
  212.                 trackBar1_radar_images.Value = file_indexs;*/
  213.                 if (file_indxs_satellite == file_array_satellite.Length)
  214.                 {
  215.                     file_indxs_satellite = 0;
  216.                 }
  217.  
  218.                 if (file_indexs == file_array.Length)
  219.                 {
  220.                     file_indexs = 0;
  221.                 }
  222.             }
  223.             catch (Exception timer3Error)
  224.             {
  225.                 Logger.Write("Timer3 Error: " + timer3Error);
  226.                 timer3.Enabled = false;
  227.             }
  228.         }