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");
            }
        }
예제 #4
0
        private void createFromURLShortcutsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sDir = InputBoxForm.GetStrInput("All URL shortcuts from this directory:", "c:\\example");

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

            // create bg thread.
            g_busy = true; this.btn1.Enabled = false;
            Thread oThread = new Thread(delegate()
            {
                CallAndCatchExceptions.Call(delegate(object param)
                {
                    new BookmarkBucket().TopUrlShortcutsToJpegs((string)param);
                }, sDir);
                g_busy = false; g_status = "";
            });

            oThread.Start();
        }
예제 #5
0
        public void TopRunUnitTests()
        {
            //string sTestDir = @"C:\Users\diamond\Desktop\-frommain\delldev\bookmarkbuckets\bookmarkbuckets_cs\bookmarkbucket\bookmarkbucket_console\bookmarkbucket_ui\test";
            //string s1 = BookmarkBucketCore.GetExifDataSoftware(sTestDir + "\\k.jpeg");
            //string s2 = BookmarkBucketCore.GetExifDataTitle(sTestDir + "\\k.jpeg");
            //string s3 = BookmarkBucketCore.GetExifDataUrl(sTestDir + "\\k.jpeg");
            //MessageBox.Show(String.Format("{0}\n{1}\n{2}\n", s1,s2,s3));

            // convert from old to new.
            //bool b = ThreadPool.SetMaxThreads(4, 4);
            //System.Diagnostics.Debug.Assert(b);

            DialogResult dr = MessageBox.Show("Create new jpgs?", "bb", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
            {
                ConvertOldToNewWithoutRedownloading(); return;
            }

            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);
            }

            // make a Model
            BookmarkBucketObjectModel model = new BookmarkBucketObjectModel();

            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);
                }

                model.list.Add(new BookmarkBucketItem {
                    sFile = Path.GetFileNameWithoutExtension(fi.Name), sUrl = sOldUrl
                });
            }

            Form1.g_busy = true;
            Thread oThread = new Thread(delegate()
            {
                CallAndCatchExceptions.Call(delegate(object o)
                {
                    this.ModelToJpegs(model, sDir);
                    Form1.g_busy = false; Form1.g_status = "";
                }, null);
            });

            oThread.Start();
        }