private void button2_Click_1(object sender, EventArgs e)
        {
            var processImagesDelegate = new ProcessImagesDelegate(ProcessImages);
            var allimages             = ent.ImageTables.ToList();

            OpenFileDialog newfile = new OpenFileDialog();

            if (newfile.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(@"C:\Users\chuan\source\repos\AudioVideoPlayer\SHANUAudioVedioPlayListPlayer\bin\Debug\Image\temp.jpg"))
                {
                    File.Delete(@"C:\Users\chuan\source\repos\AudioVideoPlayer\SHANUAudioVedioPlayListPlayer\bin\Debug\Image\temp.jpg");
                }

                File.Copy(newfile.FileName, @"C:\Users\chuan\source\repos\AudioVideoPlayer\SHANUAudioVedioPlayListPlayer\bin\Debug\Image\temp.jpg");

                for (int i = 0; i < allimages.Count; i++)
                {
                    byte[] bytes = (byte[])allimages[i].Image;

                    MemoryStream memStream = new MemoryStream(bytes);

                    try
                    {
                        Bitmap MyImage = new Bitmap(memStream);

                        MyImage = new Bitmap(MyImage);

                        MyImage.Save(allimages[i].ID + ".jpg", ImageFormat.Jpeg);
                    }
                    catch (Exception ex)
                    {
                    }
                }


                var folder = @"C:\Users\chuan\source\repos\AudioVideoPlayer\SHANUAudioVedioPlayListPlayer\bin\Debug\Image\";

                DirectoryInfo directoryInfo;
                FileInfo[]    files;
                try
                {
                    directoryInfo = new DirectoryInfo(folder);

                    files = directoryInfo.GetFiles("*.jpg", SearchOption.AllDirectories);
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                processImagesDelegate.BeginInvoke(files, null, null);
            }
        }
Beispiel #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            lvClusters.Items.Clear();
            lvClusters.Refresh();
            int    k         = Application.StartupPath.IndexOf("\\bin");
            string sub       = Application.StartupPath.Substring(k);
            string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length) + "\\AnhData";

            //DirectoryInfo directoryInfo;
            //FileInfo[] files;
            try
            {
                //directoryInfo = new DirectoryInfo(ImagePath);
                //files = directoryInfo.GetFiles("*.png", SearchOption.AllDirectories);
                //exit = false;
                Database  db = new Database();
                DataTable dt = db.RunProcedureGet("usp_ImageGetAll");
                var       processImagesDelegate = new ProcessImagesDelegate(ProcessImages);
                processImagesDelegate.BeginInvoke(dt, null, null);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #3
0
        private void FindButtonClick(object sender, EventArgs e)
        {
            var folder = folderTextBox.Text;

            DirectoryInfo directoryInfo;

            FileInfo[] files;
            try
            {
                directoryInfo         = new DirectoryInfo(folder);
                files                 = directoryInfo.GetFiles("*.jpg||*.png", SearchOption.AllDirectories);
                exit                  = false;
                findButton.Enabled    = false;
                cancelButton.Enabled  = !findButton.Enabled;
                folderTextBox.Enabled = findButton.Enabled;
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                folderTextBox.Enabled = true;
                return;
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var processImagesDelegate = new ProcessImagesDelegate(ProcessImages);

            processImagesDelegate.BeginInvoke(files, null, null);
        }
		/// <summary>
		/// Создаёт экземпляр класса <b>TextFormatter</b>
		/// </summary>
		/// <param name="imagesDelegate">Делегат для обработки картинок.
		/// Если null - используется делегат по умолчанию <see cref="DefaultProcessImagesDelegate"/>.
		/// </param>
		public TextFormatter(ProcessImagesDelegate imagesDelegate)
		{
			using (var r = ResourceProvider.ReadResource("hiddentext.htm"))
				_hiddenTextSnippet = ((String)r.Read()).Replace("\r\n", String.Empty);

			// initialize image handlers
			ImagesDelegate = imagesDelegate ?? DefaultProcessImagesDelegate;

			// initialize URLs formatting handlers
			SchemeFormatting["ms-help"] = ProcessMsHelpLink;

			HostFormatting["rsdn.ru"]
				= HostFormatting["www.rsdn.ru"]
				= HostFormatting["rsdn.rsdn.ru"]
				= HostFormatting["rsdn3.rsdn.ru"]
				= HostFormatting["gzip.rsdn.ru"]
				= FormatRsdnURLs;

			HostFormatting["amazon.com"]
				= HostFormatting["www.amazon.com"]
				= ProcessAmazonLink;

			foreach (var partnerHost in _partnresIDs.Keys)
				HostFormatting[partnerHost] = ProcessPartnerLink;

			HostFormatting["www.piter.com"]
				= HostFormatting["piter.com"]
				= HostFormatting["shop.piter.com"]
				= ProcessPiterLink;
		}
Beispiel #5
0
		/// <summary>
		/// Создаёт экземпляр класса <b>TextFormatter</b>
		/// </summary>
		/// <param name="imagesDelegate">Делегат для обработки картинок.
		/// Если null - используется делегат по умолчанию <see cref="DefaultProcessImagesDelegate"/>.
		/// </param>
		public TextFormatter(ProcessImagesDelegate imagesDelegate)
		{
			using (var r = ResourceProvider.ReadResource("hiddentext.htm"))
				_hiddenTextSnippet = ((string)r.Read()).Replace("\r\n", string.Empty);

			// initialize image handlers
			ImagesDelegate = imagesDelegate ?? DefaultProcessImagesDelegate;

			// initialize URLs formatting handlers
			SchemeFormatting["ms-help"] = ProcessMsHelpLink;

			HostFormatting["rsdn.ru"]
				= HostFormatting["www.rsdn.ru"]
				= HostFormatting["rsdn.rsdn.ru"]
				= HostFormatting["rsdn3.rsdn.ru"]
				= HostFormatting["gzip.rsdn.ru"]
				= FormatRsdnURLs;
		}
Beispiel #6
0
        private void btnSearch_Click(object sender, EventArgs e)
        {

            lvClusters.Items.Clear();
            lvClusters.Refresh();
            int k = Application.StartupPath.IndexOf("\\bin");
            string sub = Application.StartupPath.Substring(k);
            string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length) + "\\AnhData";
            //DirectoryInfo directoryInfo;
            //FileInfo[] files;
            try
            {
                //directoryInfo = new DirectoryInfo(ImagePath);
                //files = directoryInfo.GetFiles("*.png", SearchOption.AllDirectories);
                //exit = false;
                Database db = new Database();
                DataTable dt = db.RunProcedureGet("usp_ImageGetAll");
                var processImagesDelegate = new ProcessImagesDelegate(ProcessImages);
                processImagesDelegate.BeginInvoke(dt, null, null);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }