/// <summary> /// show huge cover art in cPic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picturebox_albumart_Click(object sender, EventArgs e) { //represents the a unique time stamp for use as name of form / image long long_unique_timestamp = DateTime.Now.Ticks; string file = picturebox_albumart.Tag.ToString(); //get cover art WebClient Client = new WebClient(); //the only exception is connection failed, so just abort. try { Client.DownloadFile(file, SETTINGS_LOCATION + "tmp"); Client.Dispose(); } catch (Exception) { return; } //make directory System.IO.Directory.CreateDirectory(SETTINGS_LOCATION + long_unique_timestamp.ToString()); System.IO.File.Move(SETTINGS_LOCATION + "tmp", SETTINGS_LOCATION + long_unique_timestamp.ToString() + "\\" + DateTime.Now.Ticks.ToString()); cPic cPic_new = new cPic(); cPic_new.Name = long_unique_timestamp.ToString(); cPic_new.Location = new Point(10, 25); cPic_new.Size = new Size(640, 640); cPic_new.TopLevel = false; cPic_new.Parent = this.Parent; cPic_new.Tag = 1; //properly name, randomize files randomizeFiles(cPic_new.Name); //set cPic_new's background image equal to image number 1 from the folder cPic_new.BackgroundImage = Image.FromFile(SETTINGS_LOCATION + cPic_new.Name + "\\1"); //changed default behavior to zoom cPic_new.BackgroundImageLayout = ImageLayout.Zoom; this.Parent.Controls.Add(cPic_new); cPic_new.Show(); cPic_new.BringToFront(); //add the cPic to settings System.IO.StreamWriter sw = new System.IO.StreamWriter(SETTINGS_LOCATION + "cDash Settings.cDash", true); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";FolderName;" + long_unique_timestamp.ToString()); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";Size;350;400"); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";Location;10;25"); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";ImageLayout;Zoom"); sw.Close(); }
/// <summary> /// Creates a new cPic child form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newCPicToolStripMenuItem_Click(object sender, EventArgs e) { //represents the a unique time stamp for use as name of form / image long long_unique_timestamp = DateTime.Now.Ticks; //set multiselect to true openFileDialog1.Multiselect = true; //setup the OpenFileDialog to only accept images openFileDialog1.Filter = "Image Files (*.bmp, *.jpg, *.png, *.tiff, *.gif)|*.bmp;*.jpg;*.png;*.tiff;*.gif"; //change title of openFileDialog1 openFileDialog1.Title = "Select image(s) for cPic..."; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { //make directory System.IO.Directory.CreateDirectory(SETTINGS_LOCATION + long_unique_timestamp.ToString()); foreach (string file in openFileDialog1.FileNames) { System.IO.File.Copy(file, SETTINGS_LOCATION + file.Substring(file.LastIndexOf("\\") + 1), false); //sleeping for 1 millisecond eliminates chance of multiple completion on same tick System.Threading.Thread.Sleep(1); System.IO.File.Move(SETTINGS_LOCATION + file.Substring(file.LastIndexOf("\\") + 1), SETTINGS_LOCATION + long_unique_timestamp.ToString() + "\\" + DateTime.Now.Ticks.ToString()); } cPic cPic_new = new cPic(); cPic_new.Name = long_unique_timestamp.ToString(); cPic_new.Location = new Point(10, 25); cPic_new.Size = new Size(350, 400); cPic_new.TopLevel = false; cPic_new.Parent = this; cPic_new.Tag = 1; //properly name, randomize files randomizeFiles(cPic_new.Name); //set cPic_new's background image equal to image number 1 from the folder cPic_new.BackgroundImage = Image.FromFile(SETTINGS_LOCATION + cPic_new.Name + "\\1"); //changed default behavior to zoom cPic_new.BackgroundImageLayout = ImageLayout.Zoom; Controls.Add(cPic_new); cPic_new.Show(); cPic_new.BringToFront(); //add the cPic to settings System.IO.StreamWriter sw = new System.IO.StreamWriter(SETTINGS_LOCATION + "cDash Settings.cDash", true); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";FolderName;" + long_unique_timestamp.ToString()); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";Size;350;400"); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";Location;10;25"); sw.WriteLine("cPic;" + long_unique_timestamp.ToString() + ";ImageLayout;Zoom"); sw.Close(); } }