ABA


"סיימתי את התוכנה שלי הנה הקוד מקור עם התוכנה :"
גירסת הדפסה        
קבוצות דיון פיתוח, תיכנות ובניית אתרים נושא #15829 מנהל    סגן המנהל    מפקח   Winner    צל"ש   מומחה  
אשכול מספר 15829
Nexus

   13:01   19.04.10   
אל הפורום  
  סיימתי את התוכנה שלי הנה הקוד מקור עם התוכנה :  
 
   ערכתי לאחרונה בתאריך 19.04.10 בשעה 13:10 בברכה, Nexus
 
Form1


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 System.Net;
using System.IO;
using AboutIt;
using General_utility;
using DannyGeneral;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
bool Check_For_Closing;
OptionsFile setting_file;

string satellite_time;

string satellite_dir;

string settings_dir;
string settings_file;
string testing_file;
string bad_file_test_dir;
string temp_dir;
string path_exe;
string remote_image_on_server;
Int64 time_left;
Int64 numbers;
string file_array;

int Numbers_Timer;
About ab;
string temp_file;
string last_file;
string file_array_dl;

int file_indexs;
bool button_switch;
WebClient Client = new WebClient();
FolderBrowserDialog fb = new FolderBrowserDialog();
string sf;


public Form1()
{

SplashForm splash = new SplashForm();
splash.Show();
splash.Update();
satellite_time = DateTime.Now.ToString("yyyyMMddHHmm");
Numbers_Timer = 0;

testing_file="\\testing_file.jpg";
temp_file = "\\untitled.jpg";
settings_file = "\\settings.txt";

path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
satellite_dir = path_exe + @"\satellite";
temp_dir = path_exe + @"\temp";
bad_file_test_dir = path_exe + @"\Bad_File-Test";
settings_dir = path_exe + @"\settings";

Directory.CreateDirectory(temp_dir);
Directory.CreateDirectory(bad_file_test_dir);
Directory.CreateDirectory(settings_dir);
Directory.CreateDirectory(satellite_dir);

setting_file = new OptionsFile(settings_dir + settings_file);

sf=setting_file.GetKey("Set-Directory");

setting_file.GetKey("Set_Time");

button_switch = true;
//a = 0;
ab = new About();
remote_image_on_server = "http://www.ims.gov.il/Ims/Pages/RadarImage.aspx?Row=9&TotalImages=10&LangID=1&Location=";
Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
// string selectedFolder = fb.SelectedPath;
ProgressBar prgBar = new ProgressBar();
PictureBox pb = new PictureBox();

InitializeComponent();



}

/* private void timer4_Tick(object sender, EventArgs e)
{
int a;
a = 0;
a = a + 1;
pictureBox2.Load(@"d:\Weather_Michmoret.jpg");
if (a == 5)
{
pictureBox2.Enabled = false;
}
}*/
private void button1_Click(object sender, EventArgs e)
{
/* The stream str do nothing its good for reading files */
// Stream strm = Client.OpenRead("http://www.ims.gov.il/Ims/Pages/RadarImage.aspx?Row=9&TotalImages=10&LangID=1&Location=");
// StreamReader sr = new StreamReader(strm);

if (sf == null)
{

MessageBox.Show("You haven't choose a directory to save the pictures into yet, please press Set Download Directory first, then press Start Download .");

textBox1.Clear();
button1.Enabled = true;
}

else
{
label4.Text = "Current Download Directory Is :" + sf;
if (textBox1.Text == "0" | textBox1.Text == "")
{
textBox1.Text = "";
MessageBox.Show("Please enter time in seconds to the Box first");
}
else
{

// File_Utility.File_Comparison(sf + "\\untitled.jpg", temp_file);

textBox1.Enabled = false;
button3.Enabled = true;
button4.Enabled = true;
// filesdownload();
button1.Enabled = false;
timer1.Enabled = true;


// Bitmap image1 = new Bitmap(@"d:\testfile\untitled.jpg", true);
// pictureBox1.Image = image1;
}

// image1 = new Bitmap(@"d:\testfile\untitled.jpg", true);
// pictureBox1.Image = image1;

// image1.Dispose();
// pictureBox1.Dispose();

}
}

private void progressBar1_Click(object sender, EventArgs e)
{
}

/* private void button2_Click(object sender, EventArgs e)
{
// FileInfo MyFile = new FileInfo(@"d:\testfile\*.jpg");


// FileInfo MyFile = new FileInfo(sf+@"\");


// MyFile.Delete();


string temp ;
temp = Path.GetDirectoryName(Application.ExecutablePath);

Path.GetDirectoryName((Application.ExecutablePath)+@"d:\tree");


Directory.CreateDirectory(temp);

// string temp_path = Application.CommonAppDataPath;


}

*/

private void timer1_Tick(object sender, EventArgs e)
{

try
{


numbers = Convert.ToInt64(textBox1.Text);


if (numbers < 0)
{

timer1.Stop();

button1.Enabled = true;
textBox1.Enabled = true;
MessageBox.Show("Value cannot be below zero");
textBox1.Text = "";
}
else
{
Numbers_Timer = Numbers_Timer + 1;
if (Numbers_Timer == numbers)
{

filesdownload();

button1.Enabled = false;
Numbers_Timer = 0;

}
// String str = string.Format("Hours {0} Minutes {1} Seconds {2}", c, d, e);


time_left = numbers-Numbers_Timer;

label1.Text = "Time left for next download: " + time_left;


// y = numbers - 1;
// label1.Text = "Time left for next download: " +y;
/* if (a == 1)
{
a=numbers;
button1.Enabled = false;
} */
//String str = string.Format("Hours {0} Minutes {1} Seconds {2}", c, d, e);
// this.label1.Text = str;
/* String str = string.Format("{0} {1}", c, d);
this.textBox1.Text = str;
c = c - 1;
d = d - 1; */
}

}
catch (Exception err1)
{
timer1.Stop();
MessageBox.Show(err1.ToString());

textBox1.Clear();
button1.Enabled = true;
textBox1.Enabled = true;

}

}

private void filesdownload()
{

string Next_File;
bool file_compare;
int i;
bool bad_file;


Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
progressBar1.Maximum = 10;
progressBar1.Minimum = 0;
progressBar1.TabIndex = 0;
progressBar1.Value = 0;

progressBar1.Step = 10;

progressBar1.PerformStep();
button1.Enabled = true;

file_array_dl = Directory.GetFiles(sf, "radar*.jpg");


if (file_array_dl.Length == 0)
{
File.Copy(temp_dir + temp_file, sf + @"\radar001.jpg");
}
else
{
i = file_array_dl.Length;
last_file = sf + @"\radar" + i.ToString("D3") + ".jpg";
File.Copy(last_file, bad_file_test_dir + testing_file);
bad_file = Bad_File_Testing(bad_file_test_dir + testing_file);
if (bad_file == true)
{

File.Delete(bad_file_test_dir+testing_file);
if (File.Exists(last_file))
{
file_compare = File_Utility.File_Comparison(temp_dir + temp_file, last_file);
if (file_compare == true)
{

return;
}
i = 0;
i = file_array_dl.Length + 1;
Next_File = sf + @"\radar" + i.ToString("D3") + ".jpg";
File.Copy(temp_dir + temp_file, Next_File);
progressBar1.Maximum = 10;
progressBar1.Minimum = 0;
progressBar1.TabIndex = 0;
progressBar1.Value = 0;

progressBar1.Step = 10;

progressBar1.PerformStep();
button1.Enabled = true;
}
/* else
{
Next_File = last_file;
}*/


}
else
{
File.Delete(last_file);

File.Delete(bad_file_test_dir+testing_file);
}
}
}
private void label1_Click(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e)
{

file_array = Directory.GetFiles(sf + @"\\");
file_indexs = file_array.Length - 1;


timer2.Enabled = true;
timer3.Enabled = false;

}

private void timer2_Tick(object sender, EventArgs e)
{

pictureBox1.Load(file_array);
file_indexs = file_indexs - 1;

if (file_indexs == 0)
{
file_indexs = file_array.Length - 1;
}
}

private void button4_Click(object sender, EventArgs e)
{

file_array = Directory.GetFiles(sf + @"\\");

file_indexs = 0;
file_indexs = file_array.Length - 1;

timer3.Enabled = true;
timer2.Enabled = false;
}

private void timer3_Tick(object sender, EventArgs e)
{
pictureBox1.Load(file_array);
file_indexs = file_indexs + 1;

if (file_indexs == file_array.Length)
{
file_indexs = 1;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{

if (button_switch == true)
{

pictureBox1.Dock = DockStyle.Fill;
pictureBox1.BringToFront();
button_switch = false;
}
else
{
pictureBox1.Dock = DockStyle.None;
button_switch = true;

}
}

private void button5_Click(object sender, EventArgs e)
{
timer2.Stop();
timer3.Stop();
}

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{

WindowState = FormWindowState.Normal;
Activate();
}
private void ProgramAbout()
{
MessageBox.Show("Image Downloader Version 1.0");
}
private void Form1_Load(object sender, EventArgs e)
{


if (sf == null)
{
label4.Text = "Directory haven't chosen yet.";
}
else
{
label4.Text = "Current Download Directory Is :" + sf;
}
try
{

// ab.AboutProgram();

// ProgramAbout();
// MessageBox.Show("Testing Website if picture is available, press ok to continue . ");




pictureBox1.Load(temp_dir+temp_file);
//File.Delete(temp_dir + "\\untitled1.jpg");

}
catch
{
MessageBox.Show("There was a problem downloading the first picture, please try again later.");
textBox1.Text = "";
Check_For_Closing = true;
Close();
}
}

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
ProgramAbout();
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{

Application.Exit();


}

private void Exit_Click(object sender, EventArgs e)
{



Application.Exit();

}

private void StopDownload_Click(object sender, EventArgs e)
{

progressBar1.Value = 0;
Numbers_Timer = 0;
timer1.Stop();
button1.Enabled = true;
textBox1.Enabled = true;

}

private void fgfdgfgfToolStripMenuItem_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Normal;
Activate();
}

private void button6_Click(object sender, EventArgs e)
{

this.fb.Description = "Select the directory that you want to use as the default.";


if (fb.ShowDialog() == DialogResult.OK)
{
string message = "Are you sure you want to download the images to this location ?";
string caption = "Operation cancelled";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result= MessageBox.Show(message,caption,buttons);

if (result == System.Windows.Forms.DialogResult.Yes)
{
sf = fb.SelectedPath;
label4.Text = "Current Download Directory Is :" + sf;
setting_file.SetKey("Set-Directory", sf);
Logger.Write("Current Download Directory Is :" + sf);
}
}
}




/* private void store_files(string source_file , string destination_dir ,string destination_name)
{

} */

private bool Bad_File_Testing(string file_test)
{

try
{

// FileStream fs= File.OpenRead(bad_file_test_dir+testing_file);

Image jpg =Bitmap.FromFile(bad_file_test_dir + testing_file);

//Bitmap.FromFile(bad_file_test_dir + testing_file);
jpg.Dispose();
return true;

}
catch
{
MessageBox.Show("Last image was damaged and have been deleted");
return false;
}
}

private void button2_Click(object sender, EventArgs e)
{

pictureBox1.Load(temp_dir+temp_file);
}

private void label4_Click(object sender, EventArgs e)
{

}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (Check_For_Closing == true)
{
}
else
{
if (MessageBox.Show("Are you Sure you want to Exit. Click Yes to Confirm and No to continue", "WinForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
e.Cancel = true;
}
}
}







private void textBox1_TextChanged(object sender, EventArgs e)
{
setting_file.SetKey("Set_Time",textBox1.Text);
}


/* private void gif_animated()
{
String imageFilePaths = new String { sf,"*.jpg" };
String outputFilePath = "c:\\test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start(outputFilePath);
e.SetDelay(500);
//-1:no repeat,0:always repeat
e.SetRepeat(0);
for (int i = 0, count = imageFilePaths.Length; i < count; i++)
{
e.AddFrame(Image.FromFile(imageFilePaths));
}
e.Finish();

}*/



}


}








// To make double click again to bring the picturebox to original size .
// To make comparing between first picture everytime and the last
// picture and if they are the same so to delete one of them .
// To try to make backwords wnimation of the pictures !!!
// To try using picturebox and make animation of all pictures.
// And to try the file name idea .
// Make a play button and timer load a picture to this picturebox instance
/*
string my_file_name;
my_file_name = @"weather"+my_running_number;
and use my_file_name as the file ?
*/


File_Utility

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 System.Net;
using System.IO;
using WindowsFormsApplication1;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace General_utility
{


static class File_Utility
{


static public bool File_Comparison(string Filename_1, string Filename_2)
{
int i;
byte a,b;
a=File.ReadAllBytes(Filename_1);
b=File.ReadAllBytes(Filename_2);

if (a.Length != b.Length)
{


return false;

}


else
{
for (i = 0; i < a.Length; i++)
{
if (a != b)
return false;

}
}
return true;




}

}

}


Logger

/*----------------------------------------------------------------
* Module Name : Logger
* Description : A logger
* Author : Danny
* Date : 10/02/2010
* Revision : 1.00
* --------------------------------------------------------------*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using WindowsFormsApplication1;
/*
* Introduction :
*
* This module is a logger. any module can use this
* module to log its actions.
*
*
* */

/*----------------------------------------
* P R I V A T E D E F I N I T I O N S
* ---------------------------------------*/


namespace DannyGeneral
{
class Logger
{
/*----------------------------------------
* P R I V A T E C O N S T A N T S
* ---------------------------------------*/

static string log_file_name = @"\logger.txt";
static string full_path_log_file_name;
static string path_log;
/*----------------------------------------
* P R I V A T E V A R I A B L E S
* ---------------------------------------*/

/*---------------------------------
* P U B L I C M E T H O D S
* -------------------------------*/


/*----------------------------------------------------------
* Function : Logger
* Description : static Constructor
* Parameters : none
* Return : none
* --------------------------------------------------------*/
static Logger()
{
path_log = Path.GetDirectoryName(Application.LocalUserAppDataPath)+ @"\log";
if (!Directory.Exists(path_log))
{
Directory.CreateDirectory(path_log);
}
full_path_log_file_name = path_log + log_file_name;
}

/*----------------------------------------------------------
* Function : Write
* Description : writes a string to the log file
* This functions will add time and date and
* end of line chars to the string written to
* the file.
* Parameters : string to write to the file.
* Return : none
* --------------------------------------------------------*/
public static void Write(string str)
{
StreamWriter sw = new StreamWriter(full_path_log_file_name, true);
str = DateTime.Now.ToString() + " -> " + str;
sw.WriteLine(str);
sw.Close();
}

/*---------------------------------
* P R I V A T E M E T H O D S
* -------------------------------*/

}

}

OptionsFile

/*----------------------------------------------------------------
* Module Name : OptionsFile
* Description : Saves and retrievs application options
* Author : Danny
* Date : 10/02/2010
* Revision : 1.00
* --------------------------------------------------------------*/

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 System.Net;
using System.IO;
using AboutIt;
using General_utility;
using WindowsFormsApplication1;
using System.Configuration;


/*
* Introduction :
*
* This module helps in saving application options
*
*
* Typical file could look like this:
* user_color=Red
* time_left=30
*
*
*
*
*
* */

namespace DannyGeneral
{
class OptionsFile
{
/*----------------------------------------
* P R I V A T E V A R I A B L E S
* ---------------------------------------*/

/*---------------------------------
* P U B L I C M E T H O D S
* -------------------------------*/
string path_exe;
string temp_settings_file;
string temp_settings_dir;
string Options_File;
StreamWriter sw;
StreamReader sr;


/*----------------------------------------------------------
* Function : OptionsFile
* Description : Constructor
* Parameters : file_name is the name of the file to use
* Return : none
* --------------------------------------------------------*/
public OptionsFile(string settings)
{

if (File.Exists(settings))
{

}
else
{
FileStream fs=File.Create(settings);

fs.Close();
}

path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
Options_File = settings;

}

/*----------------------------------------------------------
* Function : GetKey
* Description : gets the value of the key.
* Parameters : key
* Return : value of the key if key exist, null if not exist
* --------------------------------------------------------*/
public string GetKey(string key)
{

// string value_of_each_key;
string key_of_each_line;
string line;
int index;
string key_value;
key_value = null;

sr = new StreamReader(Options_File);
while (null != (line = sr.ReadLine()))
{


index = line.IndexOf("=");


// value_of_each_key = line.Substring(index+1);

if (index >= 1)
{
key_of_each_line = line.Substring(0, index);
if (key_of_each_line == key)
{
key_value = line.Substring(key.Length + 1);
}

}
else
{
}

}
sr.Close();
return key_value;

}



/*----------------------------------------------------------
* Function : SetKey
* Description : sets a value to the specified key
* Parameters : key and a value
* Return : none
* --------------------------------------------------------*/
public void SetKey(string key , string value)
{
bool key_was_found_inside_the_loop;
string value_of_each_key;
string key_of_each_line ;
string line;
int index;
key_was_found_inside_the_loop = false;

temp_settings_file = "\\temp_settings_file.txt";
temp_settings_dir = path_exe + @"\temp_settings";
if (!Directory.Exists(temp_settings_dir))
{
Directory.CreateDirectory(temp_settings_dir);
}

sw = new StreamWriter(temp_settings_dir+temp_settings_file);
sr = new StreamReader(Options_File);
while (null != (line = sr.ReadLine()))
{

index = line.IndexOf("=");
key_of_each_line = line.Substring(0, index);
value_of_each_key = line.Substring( index + 1);
// key_value = line.Substring(0,value.Length);
if (key_of_each_line == key)
{
sw.WriteLine(key + "=" + value);
key_was_found_inside_the_loop = true;

}
else
{
sw.WriteLine(key_of_each_line+"="+value_of_each_key);
}

}

if (!key_was_found_inside_the_loop)
{
sw.WriteLine(key + "=" + value);
}
sr.Close();
sw.Close();
File.Delete(Options_File);
File.Move(temp_settings_dir + temp_settings_file, Options_File);
return;

}

/*---------------------------------
* P R I V A T E M E T H O D S
* -------------------------------*/


}

}


SplashForm

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 System.IO;
namespace WindowsFormsApplication1
{
public partial class SplashForm : Form
{
int a;

public SplashForm()
{

InitializeComponent();


}

private void timer1_Tick(object sender, EventArgs e)
{



a = a + 1;
if (a == 2)
{

Close();


}

}


}
}


                                שתף        
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד

  האשכול     מחבר     תאריך כתיבה     מספר  
  קישור לתוכנה להורדה : Nexus 19.04.10 13:17 1
  תעלה קובץ WINRAR שמכיל את הפרויקט במקום להדביק פה את הקוד ronen333  19.04.10 13:46 2
     צודק הנה הפרוייקט : Nexus 19.04.10 15:43 3
  שתהיה בריא... כמעט הקרסת את השרתים מרוב השאשכול ארוך ldan192  19.04.10 17:18 4
     מצתרף לשאלה shy327  19.04.10 17:45 5
     היית מוריד את התוכנה היית יודע פשוט מאוד : Nexus 19.04.10 18:40 6

       
Nexus

   13:17   19.04.10   
אל הפורום  
  1. קישור לתוכנה להורדה :  
בתגובה להודעה מספר 0
 
   http://www.megaupload.com/?d=NZ4X08SA


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד
ronen333 
חבר מתאריך 20.2.03
6069 הודעות
   13:46   19.04.10   
אל הפורום  
  2. תעלה קובץ WINRAR שמכיל את הפרויקט במקום להדביק פה את הקוד  
בתגובה להודעה מספר 0
 
  


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד
Nexus

   15:43   19.04.10   
אל הפורום  
  3. צודק הנה הפרוייקט :  
בתגובה להודעה מספר 2
 
   http://www.megaupload.com/?d=EG795W0X

תגידו לי אם זה עובד תקלות ועוד.....


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד
ldan192 
חבר מתאריך 14.9.08
95119 הודעות
   17:18   19.04.10   
אל הפורום  
  4. שתהיה בריא... כמעט הקרסת את השרתים מרוב השאשכול ארוך  
בתגובה להודעה מספר 0
 

ועכשיו לשאלה - מה בנית בדיוק?


בברכה,
עידן


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד
shy327  לחץ כאן להצגת דירוג המשתמש
חבר מתאריך 11.8.12
1480 הודעות, 20 פידבק
   17:45   19.04.10   
אל הפורום  
  5. מצתרף לשאלה  
בתגובה להודעה מספר 4
 
  


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד
Nexus

   18:40   19.04.10   
אל הפורום  
  6. היית מוריד את התוכנה היית יודע פשוט מאוד :  
בתגובה להודעה מספר 4
 
   תוכנה שמוריד אוטומטית מהאינטרנט תמונות מכ"ם של מזג האוויר שומר לך את התמונות על הדיסק הקשיח אתה יכול תוך כדי בתוכנה לעשות אנימציה לתמונות לראות אותן להגדיל אותן .

הרעיון זה בעיקר לסטיסטיקה וכאלה שרוצים לשמור תמונות לאחר אירועים של מזג האוויר .


                                                         (ניהול: מחק תגובה)
מכתב זה והנלווה אליו, על אחריות ועל דעת הכותב בלבד

תגובה מהירה  למכתב מספר: 
 
___________________________________________________________________

___________________________________________________________________
למנהלים:  נעל | תייק בארכיון | מחק | העבר לפורום אחר | מחק תגובות | עגן אשכול
       



© כל הזכויות שמורות ל-רוטר.נט בע"מ rotter.net