public void TopCreateOneShortcut(bool bJpegAlreadyExists)
        {
            string sUrl = InputBoxForm.GetStrInput("Enter URL:", "http://example");

            if (!BookmarkBucketCore.looksLikeAUrl(sUrl))
            {
                return;
            }

            if (bJpegAlreadyExists)
            {
                string sInputJpeg = ImageHelper.GetOpenString("jpeg", "Select a jpeg:");
                if (sInputJpeg == null || !File.Exists(sInputJpeg))
                {
                    return;
                }
                BookmarkBucketCore.StripAllExifData(sInputJpeg);
                BookmarkBucketCore.SetExifData(sInputJpeg, sUrl, Path.GetFileNameWithoutExtension(sInputJpeg));
            }
            else
            {
                string sOutJpeg = ImageHelper.GetSaveString("jpeg", "Save jpeg to:");
                if (sOutJpeg == null)
                {
                    return;
                }
                string             sDir = Path.GetDirectoryName(sOutJpeg);
                BookmarkBucketItem item = new BookmarkBucketItem {
                    sFile = Path.GetFileNameWithoutExtension(sOutJpeg), sUrl = sUrl
                };
                ModelItemToJpeg(item, sDir);
            }
        }
Пример #2
0
        private void ConvertOldToNewWithoutRedownloading()
        {
            string sDir = InputBoxForm.GetStrInput("All from this directory:", "c:\\example");

            if (sDir == null || !Directory.Exists(sDir))
            {
                MessageBox.Show("Not a valid directory."); return;
            }

            DirectoryInfo di = new DirectoryInfo(sDir);

            FileInfo[] rgFiles = di.GetFiles("*.jpg");
            foreach (FileInfo fi in rgFiles)
            {
                string sNewname = Path.GetFileNameWithoutExtension(fi.Name.Replace("555 ", "")) + ".png";
                if (File.Exists(sDir + "\\" + sNewname))
                {
                    throw new BookmarkBucketException("exists png" + fi.Name);
                }
                File.Move(sDir + "\\" + fi.Name, sDir + "\\" + sNewname);
            }

            // set the exifs...
            FileInfo[] rgFilesPng = di.GetFiles("*.png");
            foreach (FileInfo fi in rgFilesPng)
            {
                string sOldUrl = BookmarkBucketCore.GetExifData(fi.FullName, "Comment");
                if (!BookmarkBucketCore.looksLikeAUrl(sOldUrl))
                {
                    throw new BookmarkBucketException("couldnot read url" + fi.Name);
                }

                // convert it to a jpg.
                string sJpeg = sDir + "\\" + Path.GetFileNameWithoutExtension(fi.Name) + ".jpeg";
                using (Bitmap b = new Bitmap(fi.FullName))
                {
                    ImageHelper.BitmapSaveJpegQuality(b, sJpeg, 85);
                }
                if (!File.Exists(sJpeg))
                {
                    throw new BookmarkBucketException("no jpeg created?");
                }
                File.Delete(fi.FullName);

                BookmarkBucketCore.StripAllExifData(sJpeg);
                BookmarkBucketCore.SetExifData(sJpeg, sOldUrl, Path.GetFileNameWithoutExtension(fi.Name));

                // download the htm!
                string sHtmlName = sDir + "\\" + Path.GetFileNameWithoutExtension(fi.Name) + ".html";
                if (File.Exists(sHtmlName))
                {
                    throw new BookmarkBucketException("exists html" + fi.Name);
                }
                BookmarkBucketImplementation.DownloadFile(sOldUrl, sHtmlName);
                File.AppendAllText(sHtmlName, strHtmlStamp + sOldUrl + "-->"); // will create file.
            }
        }
        public void TopCreateManualShortcut(string sFilename)
        {
            string sUrl = InputBoxForm.GetStrInput("Stamp URL on a file - Enter URL:", "http://example");

            if (!BookmarkBucketCore.looksLikeAUrl(sUrl))
            {
                return;
            }
            if (sFilename.ToLowerInvariant().EndsWith(".html"))
            {
                File.AppendAllText(sFilename, strHtmlStamp + sUrl + "-->");
            }
            else if (sFilename.ToLowerInvariant().EndsWith(".jpeg"))
            {
                BookmarkBucketCore.StripAllExifData(sFilename);
                BookmarkBucketCore.SetExifData(sFilename, sUrl, Path.GetFileNameWithoutExtension(sFilename));
            }
            else
            {
                MessageBox.Show("Try a .html or .jpeg file");
            }
        }