コード例 #1
0
        private void cmdCreate_Click(object sender, EventArgs e)
        {
            // ask for output file
            string fileName = new System.IO.DirectoryInfo(txtRoot.Text + @"\").Name;

            char[] invalid = System.IO.Path.GetInvalidFileNameChars();
            for (int i = 0; i < invalid.Length; i++)
            {
                fileName = fileName.Replace(invalid[i].ToString(), "");
            }

            saveFileDialog1.DefaultExt = "html";
            if (!fileName.ToLower().EndsWith(".html"))
            {
                fileName += ".html";
            }
            saveFileDialog1.FileName         = fileName;
            saveFileDialog1.Filter           = "HTML files (*.html)|*.html|All files (*.*)|*.*";
            saveFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName(txtRoot.Text);
            saveFileDialog1.CheckPathExists  = true;
            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (!saveFileDialog1.FileName.ToLower().EndsWith(".html"))
            {
                saveFileDialog1.FileName += ".html";
            }

            // begin generating html
            var settings = new SnapSettings()
            {
                rootFolder      = txtRoot.Text,
                title           = txtTitle.Text,
                outputFile      = saveFileDialog1.FileName,
                skipHiddenItems = !chkHidden.Checked,
                skipSystemItems = !chkSystem.Checked,
                openInBrowser   = chkOpenOutput.Checked,
                linkFiles       = chkLinkFiles.Checked,
                linkRoot        = txtLinkRoot.Text,
            };

            StartProcessing(settings);
        }
コード例 #2
0
ファイル: Eval.cs プロジェクト: lkuich/tuck
        public static List <Report> ReportEvalDir(string dir, string labelsFile, string model)
        {
            var t = new ImageTensor(model, DIO.File.ReadAllLines(labelsFile));

            var finalReport = new List <Report>();

            foreach (var subDir in DIO.Directory.GetDirectories(dir))
            {
                var    files      = DIO.Directory.GetFiles(subDir);
                string subDirName = new System.IO.DirectoryInfo(subDir).Name.Trim().ToLower();

                int    evalSize = files.Length / 2;
                Report report   = new Report()
                {
                    Name = subDirName.ToLower(), Size = evalSize
                };

                Console.WriteLine($"Evaluating {evalSize} files in {subDirName}...");
                for (int fi = 0; fi < evalSize; fi++)
                {
                    var file   = files[fi];
                    var tensor = ImageUtil.CreateTensorFromImageFile(file);
                    var match  = t.Parse(tensor)[0];

                    bool isMatch = match.Name.Trim().ToLower() == subDirName;
                    if (isMatch)
                    {
                        report.Successes++;
                        report.AvgConfidence += match.Confidence;
                    }
                    Console.WriteLine($"{System.IO.Path.GetFileName(file)} | TF name: {match.Name}, confidence: {match.Confidence}, match: {isMatch}");
                }
                report.AvgConfidence /= evalSize;
                finalReport.Add(report);
            }

            return(finalReport);
        }
コード例 #3
0
        static void DirSearch(string dst, string root, string sDir, string filter, bool bBelowesp = false)
        {
            try
            {
                foreach (string f in System.IO.Directory.GetFiles(sDir, "*.*"))
                {
                    if (bBelowesp)
                    {
                        if (dst == "") // dont copy we dont have a destination, just report it, for testing.
                        {
                            System.Console.WriteLine(f);
                        }
                        else
                        {
                            CopyFile(root, dst, f);
                        }
                    }
                }

                // Recurse down the tree if we find another directory
                foreach (string d in System.IO.Directory.GetDirectories(sDir))
                {
                    var dirName = new System.IO.DirectoryInfo(d).Name;
                    if (dirName.ToLower() == filter.ToLower())
                    {
                        DirSearch(dst, root, d, filter, true);
                    }
                    else
                    {
                        DirSearch(dst, root, d, filter, bBelowesp);
                    }
                }
            }
            catch (System.Exception excpt)
            {
                System.Console.WriteLine(excpt.Message);
            }
        }
コード例 #4
0
        private void cmdCreate_Click(object sender, EventArgs e)
        {
            // ensure source path format
            txtRoot.Text = System.IO.Path.GetFullPath(txtRoot.Text);
            if (txtRoot.Text.EndsWith(@"\"))
            {
                txtRoot.Text = txtRoot.Text.Substring(0, txtRoot.Text.Length - 1);
            }
            if (IsWildcardMatch("?:", txtRoot.Text, false))
            {
                txtRoot.Text += @"\";                                                   // add backslash to path if only letter and colon eg "c:"
            }
            // add slash or backslash to end of link (in cases where it is clearthat we we can)
            if (!txtLinkRoot.Text.EndsWith(@"/") && txtLinkRoot.Text.ToLower().StartsWith(@"http"))                     // web site
            {
                txtLinkRoot.Text += @"/";
            }
            if (!txtLinkRoot.Text.EndsWith(@"\") && IsWildcardMatch("?:*", txtLinkRoot.Text, false))                    // local disk
            {
                txtLinkRoot.Text += @"\";
            }

            // get output file
            if (outFile == "")
            {
                string fileName = new System.IO.DirectoryInfo(txtRoot.Text + @"\").Name;
                char[] invalid  = System.IO.Path.GetInvalidFileNameChars();
                for (int i = 0; i < invalid.Length; i++)
                {
                    fileName = fileName.Replace(invalid[i].ToString(), "");
                }

                saveFileDialog1.DefaultExt = "html";
                if (!fileName.ToLower().EndsWith(".html"))
                {
                    fileName += ".html";
                }
                saveFileDialog1.FileName         = fileName;
                saveFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName(txtRoot.Text);
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else // command line
            {
                saveFileDialog1.FileName = outFile;
            }

            if (!saveFileDialog1.FileName.ToLower().EndsWith(".html"))
            {
                saveFileDialog1.FileName += ".html";
            }

            // make sure output path exists
            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(saveFileDialog1.FileName)))
            {
                MessageBox.Show("The output folder does not exists...\n\n" + System.IO.Path.GetDirectoryName(saveFileDialog1.FileName), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // begin generating html
            Cursor.Current      = Cursors.WaitCursor;
            this.Text           = "Snap2HTML (Working... Press Escape to Cancel)";
            tabControl1.Enabled = false;
            backgroundWorker.RunWorkerAsync();
        }