Esempio n. 1
0
            public int CompareTo(object _rhs)
            {
                ImageEntry rhs = _rhs as ImageEntry;

                if (rhs == null)
                {
                    return(1);
                }

                ImageValidatorData.ImageEntryColumnData columnThis = new ImageValidatorData.ImageEntryColumnData(Name);
                ImageValidatorData.ImageEntryColumnData columnRhs  = new ImageValidatorData.ImageEntryColumnData(rhs.Name);

                try
                {
                    float timeThis = float.Parse(columnThis.Time);
                    float timeRhs  = float.Parse(columnRhs.Time);

                    int x = timeThis.CompareTo(timeRhs);

                    if (x != 0)
                    {
                        return(x);
                    }
                }
                catch (Exception)
                {
                    // if time is not part of the name we cannot sort by it
                }

                return(Name.CompareTo(rhs.Name));
            }
Esempio n. 2
0
        private void UpdateListView()
        {
            // select first element if no element is currently selected
            int SelectedImageIndex = 0;

            if (listView1.SelectedIndices.Count == 1)
            {
                SelectedImageIndex = listView1.Items[listView1.SelectedIndices[0]].ImageIndex;
                listView1.SelectedIndices.Clear();
            }

            listView1.Items.Clear();

            ImageValidatorSettings settings = GetSettings();

            int Index = 0;

            foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
            {
                ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                string ResultString = "?";

                if (entry.testResult != null)
                {
                    ResultString = entry.testResult.GetString(ref settings);
                }
                ListViewItem item = new ListViewItem(ResultString, Index++);
                item.SubItems.Add(columnData.Time);
//                item.SubItems.Add((1.0f + 0.1f * Index).ToString());
//                item.SubItems.Add(columnData.Actor);
//                item.SubItems.Add(columnData.Map);
//                item.SubItems.Add(columnData.Platform);
                item.SubItems.Add(Path.GetDirectoryName(entry.Name));
                item.SubItems.Add(Path.GetFileName(entry.Name));
                if (entry.testResult != null)
                {
                    item.BackColor = entry.testResult.GetColor(ref settings);
                }

                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                listView1.SelectedIndices.Add(FindListViewIndexFromImageIndex(SelectedImageIndex));
            }
        }
        public void ExportHTML(string SettingsFileName, ref ImageValidatorData data, ref ImageValidatorSettings settings, string FileName, bool bSilent, bool bThumbnails)
        {
            ValidationSummary validationSummary = new ValidationSummary(ref data, ref settings);

            string Folder = Path.GetDirectoryName(FileName) + "\\" + Path.GetFileNameWithoutExtension(FileName) + "_Thumbnails";

            if (bThumbnails)
            {
                Directory.CreateDirectory(Folder);
            }

            // Note C# string literals can span multiple lines, " need to be converted to ""
            string template = @"
<!DOCTYPE HTML PUBLIC \""-//W3C//DTD HTML 4.01 Transitional//EN\"" \""http://www.w3.org/TR/html4/loose.dtd\"">
<html>
<head>
<title>ImageValidator Report</title>
</head>
<body>
<h1>ImageValidator Report</h1>

<br>
<h4>ImageValidator Settings ""%SETTINGSFILENAME%"":</h4>
<div style=""margin:10px;margin-left:40px"" >%SETTINGS% </div>
<br>

<h4>Summary:</h4>
<div style=""margin:10px;margin-left:40px""> %SUMMARY% </div>
<br>

<h4>Output:</h4>
<div style=""margin:10px;margin-left:40px""> %OUTPUT% </div>
<br>

<br>
<b>Generated by Application:</b> ImageValidator.exe (part of UnrealEngine by Epic Games)<br>
<b>Application Version:</b> %VERSION%<br>
<b>Generated by User:</b> %USER%<br>
<b>Generated Date:</b> %DATE%<br>

<style type=""text/css"">
//body { background-color:#000000; color:#E0E0E0 }

* {
    font-family: ?Times New Roman?, Times, serif;
 //   font-weight: bold;
    
}

h1 { color:#555555; font-size:32px; border-bottom:solid thin black; }

table, hd, th {
    border:0px; color:#000000; padding:4px; border-spacing:0px;
    border-collapse:collapse;
    }
   
td { padding:2px; padding-right:7px }
td.Output { padding:7px; border:1px solid #cccccc; }

th {
    background-color:#E0E0E0;
    color: #000000;
    text-align: left;
    border: 1px solid #c0c0c0;
}

a.prefix {
    border: 0px solid;
    padding: 3px;
    padding-left: 5px;
    padding-right: 5px;
    font-weight: bold;
    text-decoration:none;
    margin:4px;
    white-space: nowrap;
}

a.prefix:link {
    border:1px solid #7777FF;
    background-color:#ddddff;
    color: #7777FF;
}


a.prefix:hover {
    background-color:#7777FF;
    color: #ddddff;
}

</style>
    
</body>
</html>";

            // we can change this if needed:
            //ImageFormat imageFormat = ImageFormat.Jpeg;   // small file size?
            //ImageFormat imageFormat = ImageFormat.Gif;   // dither artifacts
            ImageFormat imageFormat = ImageFormat.Png;    // good compromise

            // we derive the extension from imageFormat e.g. ".jpg"
            string imageFormatExtension = "";
            {
                if (imageFormat == ImageFormat.Jpeg)
                {
                    imageFormatExtension = ".jpg";
                }
                else if (imageFormat == ImageFormat.Gif)
                {
                    imageFormatExtension = ".gif";
                }
                else if (imageFormat == ImageFormat.Png)
                {
                    imageFormatExtension = ".Png";
                }

                Debug.Assert(imageFormatExtension != "");
            }

            // todo: how to repro, Date, IVxml file attached?, thumbnails

            string Output = "<table class=Output><tr>";

            Output += "<th>Result (pixels failed)</th>";

            if (bThumbnails)
            {
                Output += "<th>Thumbnails (test/diff/ref)</th>";
            }
            Output += "<th>Matinee Location (in sec)</th>";
            //            Output += "<th>Actor</th>";
            //            Output += "<th>Map</th>";
            //            Output += "<th>Platform</th>";
            Output += "<th>Folder Name</th>";
            Output += "<th>File Name</th></tr>\n";
            {
                uint Index = 0;
                foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
                {
                    TestResult test = entry.testResult;
                    bool       bShowDiffAndRefThumbnails = !test.IsPassed(ref settings);

                    // open table row
                    Output += "<tr class=Output>";

                    Color BackColor = Color.White;

                    string ThumbnailTest = Folder + "\\Test" + Index + imageFormatExtension;
                    string ThumbnailDiff = Folder + "\\Diff" + Index + imageFormatExtension;
                    string ThumbnailRef  = Folder + "\\Ref" + Index + imageFormatExtension;

                    if (test != null)
                    {
                        BackColor = test.GetColor(ref settings);

                        if (bThumbnails)
                        {
                            test.ThumbnailTest.Save(ThumbnailTest, imageFormat);

                            if (bShowDiffAndRefThumbnails)
                            {
                                test.ThumbnailDiff.Save(ThumbnailDiff, imageFormat);
                                test.ThumbnailRef.Save(ThumbnailRef, imageFormat);
                            }
                        }
                    }

                    ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                    string ResultString = "?";

                    if (entry.testResult != null)
                    {
                        ResultString = entry.testResult.GetString(ref settings);
                    }

                    Output += "<td class=Output bgcolor=" + ColorTranslator.ToHtml(BackColor) + ">" + ResultString + "</td>";

                    // thumbnails
                    if (bThumbnails)
                    {
                        Output += "<td class=Output>";

                        if (test != null)
                        {
                            Output += "<img src=\"" + ThumbnailTest + "\" width=" + test.ThumbnailTest.Width + " height=" + test.ThumbnailTest.Height + ">";

                            if (bShowDiffAndRefThumbnails)
                            {
                                Output += "<img src=\"" + ThumbnailDiff + "\" width=" + test.ThumbnailDiff.Width + " height=" + test.ThumbnailDiff.Height + ">";
                                Output += "<img src=\"" + ThumbnailRef + "\" width=" + test.ThumbnailRef.Width + " height=" + test.ThumbnailRef.Height + ">";
                            }
                        }

                        Output += "</td>";
                    }

                    Output += "<td class=Output>" + columnData.Time + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Actor + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Map + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Platform + "</td>";
                    Output += "<td class=Output>" + Path.GetDirectoryName(entry.Name) + "</td>";
                    Output += "<td class=Output>" + Path.GetFileName(entry.Name) + "</td>";

                    // close table row
                    Output += "</tr>\n";
                    ++Index;
                }
                Output += "</table>\n";
            }

            string SettingsString = "";
            {
                SettingsString +=
                    "<table>\n" +
                    "<tr><td>Test Directory:</td> <td>" + settings.TestDir + "</td></tr>\n" +
                    "<tr><td>Reference Directory:</td> <td>" + settings.RefDir + "</td></tr>\n" +
                    "<tr><td>Threshold (in 0..255 range):</td> <td>" + settings.Threshold + "</td></tr>\n" +
                    "<tr><td>PixelCountToFail:</td> <td>" + settings.PixelCountToFail + "</td></tr>\n" +
                    "</table>\n";
            }

            string SummaryString = "";

            {
                bool bPassed = validationSummary.Failed == 0;

                string FailedColor   = "";
                string SuceededColor = "";

                if (bPassed)
                {
                    SuceededColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(true));
                }
                else
                {
                    FailedColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(false));
                }

                SummaryString +=
                    "<table>\n" +
//                    "<tr><td>Files processed:</td> <td>" + (validationSummary.Failed + validationSummary.Succeeded) + "</td></tr>\n" +
                    "<tr><td" + FailedColor + ">Failed:</td> <td" + FailedColor + ">" + validationSummary.Failed + "</td></tr>\n" +
                    "<tr><td" + SuceededColor + ">Succeeded:</td> <td" + SuceededColor + ">" + validationSummary.Succeeded + "</td></tr>\n" +
                    "</table>\n";
            }

            template = template.Replace("%DATE%", DateTime.Now.ToString());
            template = template.Replace("%SETTINGSFILENAME%", SettingsFileName);

            template = template.Replace("%SETTINGS%", SettingsString);
            template = template.Replace("%SUMMARY%", SummaryString);

            template = template.Replace("%OUTPUT%", Output);
            template = template.Replace("%USER%", Environment.UserName);
            template = template.Replace("%VERSION%", ImageValidatorSettings.GetVersionString());


            System.IO.File.WriteAllText(FileName, template);

            if (!bSilent)
            {
                MessageBox.Show("Export to HTML successful", "ImageValidator", MessageBoxButtons.OK);
            }
        }
Esempio n. 4
0
        private void UpdateListView()
        {
            // select first element if no element is currently selected
            int SelectedImageIndex = 0;

            if (listView1.SelectedIndices.Count == 1)
            {
                SelectedImageIndex = listView1.Items[listView1.SelectedIndices[0]].ImageIndex;
                listView1.SelectedIndices.Clear();
            }

            listView1.Items.Clear();
            
            ImageValidatorSettings settings = GetSettings();

            int Index = 0;
            foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
            {
                ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                string ResultString = "?";

                if (entry.testResult != null)
                {
                    ResultString = entry.testResult.GetString(ref settings);
                }
                ListViewItem item = new ListViewItem(ResultString, Index++);
                item.SubItems.Add(columnData.Time);
//                item.SubItems.Add((1.0f + 0.1f * Index).ToString());
//                item.SubItems.Add(columnData.Actor);
//                item.SubItems.Add(columnData.Map);
//                item.SubItems.Add(columnData.Platform);
                item.SubItems.Add(Path.GetDirectoryName(entry.Name));
                item.SubItems.Add(Path.GetFileName(entry.Name));
                if (entry.testResult != null)
                {
                    item.BackColor = entry.testResult.GetColor(ref settings);
                }
              
                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                listView1.SelectedIndices.Add(FindListViewIndexFromImageIndex(SelectedImageIndex));
            }
        }
        public void ExportHTML(string SettingsFileName, ref ImageValidatorData data, ref ImageValidatorSettings settings, string FileName, bool bSilent, bool bThumbnails)
        {
            ValidationSummary validationSummary = new ValidationSummary(ref data, ref settings);

            string Folder = Path.GetDirectoryName(FileName) + "\\" + Path.GetFileNameWithoutExtension(FileName) + "_Thumbnails";

            if (bThumbnails)
            {
                Directory.CreateDirectory(Folder);
            }

            // Note C# string literals can span multiple lines, " need to be converted to ""
            string template = @"
<!DOCTYPE HTML PUBLIC \""-//W3C//DTD HTML 4.01 Transitional//EN\"" \""http://www.w3.org/TR/html4/loose.dtd\"">
<html>
<head>
<title>ImageValidator Report</title>
</head>
<body>
<h1>ImageValidator Report</h1>

<br>
<h4>ImageValidator Settings ""%SETTINGSFILENAME%"":</h4>
<div style=""margin:10px;margin-left:40px"" >%SETTINGS% </div>
<br>

<h4>Summary:</h4>
<div style=""margin:10px;margin-left:40px""> %SUMMARY% </div>
<br>

<h4>Output:</h4>
<div style=""margin:10px;margin-left:40px""> %OUTPUT% </div>
<br>

<br>
<b>Generated by Application:</b> ImageValidator.exe (part of UnrealEngine by Epic Games)<br>
<b>Application Version:</b> %VERSION%<br>
<b>Generated by User:</b> %USER%<br>
<b>Generated Date:</b> %DATE%<br>

<style type=""text/css"">
//body { background-color:#000000; color:#E0E0E0 }

* {
    font-family: ?Times New Roman?, Times, serif;
 //   font-weight: bold;
    
}

h1 { color:#555555; font-size:32px; border-bottom:solid thin black; }

table, hd, th {
    border:0px; color:#000000; padding:4px; border-spacing:0px;
    border-collapse:collapse;
    }
   
td { padding:2px; padding-right:7px }
td.Output { padding:7px; border:1px solid #cccccc; }

th {
    background-color:#E0E0E0;
    color: #000000;
    text-align: left;
    border: 1px solid #c0c0c0;
}

a.prefix {
    border: 0px solid;
    padding: 3px;
    padding-left: 5px;
    padding-right: 5px;
    font-weight: bold;
    text-decoration:none;
    margin:4px;
    white-space: nowrap;
}

a.prefix:link {
    border:1px solid #7777FF;
    background-color:#ddddff;
    color: #7777FF;
}


a.prefix:hover {
    background-color:#7777FF;
    color: #ddddff;
}

</style>
    
</body>
</html>";

            // we can change this if needed:
            //ImageFormat imageFormat = ImageFormat.Jpeg;   // small file size?
            //ImageFormat imageFormat = ImageFormat.Gif;   // dither artifacts
            ImageFormat imageFormat = ImageFormat.Png;    // good compromise

            // we derive the extension from imageFormat e.g. ".jpg"
            string imageFormatExtension = "";
            {
                if (imageFormat == ImageFormat.Jpeg)
                {
                    imageFormatExtension = ".jpg";
                }
                else if (imageFormat == ImageFormat.Gif)
                {
                    imageFormatExtension = ".gif";
                }
                else if (imageFormat == ImageFormat.Png)
                {
                    imageFormatExtension = ".Png";
                }

                Debug.Assert(imageFormatExtension != "");
            }

            // todo: how to repro, Date, IVxml file attached?, thumbnails

            string Output = "<table class=Output><tr>";

            Output += "<th>Result (pixels failed)</th>";

            if (bThumbnails)
            {
                Output += "<th>Thumbnails (test/diff/ref)</th>";
            }
            Output += "<th>Matinee Location (in sec)</th>";
            //            Output += "<th>Actor</th>";
            //            Output += "<th>Map</th>";
            //            Output += "<th>Platform</th>";
            Output += "<th>Folder Name</th>";
            Output += "<th>File Name</th></tr>\n";
            {
                uint Index = 0;
                foreach (ImageValidatorData.ImageEntry entry in data.imageEntries)
                {
                    TestResult test = entry.testResult;
                    bool bShowDiffAndRefThumbnails = !test.IsPassed(ref settings);

                    // open table row
                    Output += "<tr class=Output>";

                    Color BackColor = Color.White;

                    string ThumbnailTest = Folder + "\\Test" + Index + imageFormatExtension;
                    string ThumbnailDiff = Folder + "\\Diff" + Index + imageFormatExtension;
                    string ThumbnailRef = Folder + "\\Ref" + Index + imageFormatExtension;

                    if (test != null)
                    {
                        BackColor = test.GetColor(ref settings);

                        if (bThumbnails)
                        {
                            test.ThumbnailTest.Save(ThumbnailTest, imageFormat);

                            if (bShowDiffAndRefThumbnails)
                            {
                                test.ThumbnailDiff.Save(ThumbnailDiff, imageFormat);
                                test.ThumbnailRef.Save(ThumbnailRef, imageFormat);
                            }
                        }
                    }

                    ImageValidatorData.ImageEntryColumnData columnData = new ImageValidatorData.ImageEntryColumnData(entry.Name);

                    string ResultString = "?";

                    if (entry.testResult != null)
                    {
                        ResultString = entry.testResult.GetString(ref settings);
                    }

                    Output += "<td class=Output bgcolor=" + ColorTranslator.ToHtml(BackColor) + ">" + ResultString + "</td>";

                    // thumbnails
                    if (bThumbnails)
                    {
                        Output += "<td class=Output>";

                        if (test != null)
                        {
                            Output += "<img src=\"" + ThumbnailTest + "\" width=" + test.ThumbnailTest.Width + " height=" + test.ThumbnailTest.Height + ">";

                            if (bShowDiffAndRefThumbnails)
                            {
                                Output += "<img src=\"" + ThumbnailDiff + "\" width=" + test.ThumbnailDiff.Width + " height=" + test.ThumbnailDiff.Height + ">";
                                Output += "<img src=\"" + ThumbnailRef + "\" width=" + test.ThumbnailRef.Width + " height=" + test.ThumbnailRef.Height + ">";
                            }
                        }

                        Output += "</td>";
                    }

                    Output += "<td class=Output>" + columnData.Time + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Actor + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Map + "</td>";
                    //                    Output += "<td class=Output>" + columnData.Platform + "</td>";
                    Output += "<td class=Output>" + Path.GetDirectoryName(entry.Name) + "</td>";
                    Output += "<td class=Output>" + Path.GetFileName(entry.Name) + "</td>";

                    // close table row
                    Output += "</tr>\n";
                    ++Index;
                }
                Output += "</table>\n";
            }

            string SettingsString = "";
            {
                SettingsString +=
                    "<table>\n" +
                    "<tr><td>Test Directory:</td> <td>" + settings.TestDir + "</td></tr>\n" +
                    "<tr><td>Reference Directory:</td> <td>" + settings.RefDir + "</td></tr>\n" +
                    "<tr><td>Threshold (in 0..255 range):</td> <td>" + settings.Threshold + "</td></tr>\n" +
                    "<tr><td>PixelCountToFail:</td> <td>" + settings.PixelCountToFail + "</td></tr>\n" +
                    "</table>\n";
            }

            string SummaryString = "";
            {
                bool bPassed = validationSummary.Failed == 0;

                string FailedColor = "";
                string SuceededColor = "";

                if (bPassed)
                {
                    SuceededColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(true));
                }
                else
                {
                    FailedColor = " bgcolor=" + ColorTranslator.ToHtml(TestResult.GetColor(false));
                }
                
                SummaryString +=
                    "<table>\n" +
//                    "<tr><td>Files processed:</td> <td>" + (validationSummary.Failed + validationSummary.Succeeded) + "</td></tr>\n" +
                    "<tr><td" + FailedColor + ">Failed:</td> <td" + FailedColor + ">" + validationSummary.Failed + "</td></tr>\n" +
                    "<tr><td" + SuceededColor + ">Succeeded:</td> <td" + SuceededColor + ">" + validationSummary.Succeeded + "</td></tr>\n" +
                    "</table>\n";
            }

            template = template.Replace("%DATE%", DateTime.Now.ToString());
            template = template.Replace("%SETTINGSFILENAME%", SettingsFileName);

            template = template.Replace("%SETTINGS%", SettingsString);
            template = template.Replace("%SUMMARY%", SummaryString);

            template = template.Replace("%OUTPUT%", Output);
            template = template.Replace("%USER%", Environment.UserName);
            template = template.Replace("%VERSION%", ImageValidatorSettings.GetVersionString());


            System.IO.File.WriteAllText(FileName, template);

            if (!bSilent)
            {
                MessageBox.Show("Export to HTML successful", "ImageValidator", MessageBoxButtons.OK);
            }
        }
            public int CompareTo(object _rhs)
            {
                ImageEntry rhs = _rhs as ImageEntry;

                if (rhs == null)
                    return 1;

                ImageValidatorData.ImageEntryColumnData columnThis = new ImageValidatorData.ImageEntryColumnData(Name);
                ImageValidatorData.ImageEntryColumnData columnRhs = new ImageValidatorData.ImageEntryColumnData(rhs.Name);

                try
                {
                    float timeThis = float.Parse(columnThis.Time);
                    float timeRhs = float.Parse(columnRhs.Time);

                    int x = timeThis.CompareTo(timeRhs);

                    if(x != 0)
                        return x;
                }
                catch (Exception)
                {
                    // if time is not part of the name we cannot sort by it
                }

                return Name.CompareTo(rhs.Name);
            }