Add feature to export events to a file for diffing

This commit is contained in:
baldurk
2016-06-22 16:09:57 +01:00
parent e13173ac2b
commit af3e57e79c
3 changed files with 96 additions and 1 deletions
+22 -1
View File
@@ -60,6 +60,8 @@
this.bookmarkStrip = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toggleBookmark = new System.Windows.Forms.ToolStripButton();
this.export = new System.Windows.Forms.ToolStripButton();
this.exportDialog = new System.Windows.Forms.SaveFileDialog();
toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
toolStripLabel4 = new System.Windows.Forms.ToolStripLabel();
this.toolStripContainer1.ContentPanel.SuspendLayout();
@@ -196,7 +198,8 @@
this.jumpEventButton,
this.timeDraws,
this.selectColumnsButton,
this.toggleBookmark});
this.toggleBookmark,
this.export});
this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
@@ -370,6 +373,22 @@
this.toggleBookmark.Text = "Toggle Bookmark";
this.toggleBookmark.Click += new System.EventHandler(this.toggleBookmark_Click);
//
// export
//
this.export.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.export.Image = global::renderdocui.Properties.Resources.save;
this.export.ImageTransparentColor = System.Drawing.Color.Magenta;
this.export.Name = "export";
this.export.Size = new System.Drawing.Size(23, 22);
this.export.Text = "Export";
this.export.Click += new System.EventHandler(this.export_Click);
//
// exportDialog
//
this.exportDialog.DefaultExt = "txt";
this.exportDialog.Filter = "Text Files (*.txt)|*.txt";
this.exportDialog.Title = "Save Event List";
//
// EventBrowser
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -428,6 +447,8 @@
private System.Windows.Forms.ToolStripButton toggleBookmark;
private System.Windows.Forms.ToolStripMenuItem expandAll;
private System.Windows.Forms.ToolStripMenuItem collapseAll;
private System.Windows.Forms.ToolStripButton export;
private System.Windows.Forms.SaveFileDialog exportDialog;
}
}
+71
View File
@@ -86,6 +86,7 @@ namespace renderdocui.Windows
jumpEventButton.Enabled = false;
timeDraws.Enabled = false;
toggleBookmark.Enabled = false;
export.Enabled = false;
}
public class PersistData
@@ -420,6 +421,7 @@ namespace renderdocui.Windows
jumpEventButton.Enabled = false;
timeDraws.Enabled = false;
toggleBookmark.Enabled = false;
export.Enabled = false;
}
public void OnLogfileLoaded()
@@ -428,6 +430,7 @@ namespace renderdocui.Windows
jumpEventButton.Enabled = true;
timeDraws.Enabled = true;
toggleBookmark.Enabled = true;
export.Enabled = true;
ClearBookmarks();
@@ -1158,5 +1161,73 @@ namespace renderdocui.Windows
eventView.Invalidate();
}
private string GetExportDrawcallString(int indent, bool firstchild, FetchDrawcall drawcall)
{
string prefix = new string(' ', indent * 2 - (firstchild ? 1 : 0));
if(firstchild)
prefix += '\\';
return String.Format("{0}- {1}", prefix, drawcall.name);
}
private void GetMaxNameLength(ref int maxNameLength, int indent, bool firstchild, FetchDrawcall drawcall)
{
string nameString = GetExportDrawcallString(indent, firstchild, drawcall);
maxNameLength = Math.Max(maxNameLength, nameString.Length);
for (int i = 0; i < drawcall.children.Length; i++)
GetMaxNameLength(ref maxNameLength, indent + 1, i == 0, drawcall.children[i]);
}
private void ExportDrawcall(StreamWriter sw, int maxNameLength, int indent, bool firstchild, FetchDrawcall drawcall)
{
string eidString = drawcall.children.Length > 0 ? "" : drawcall.eventID.ToString();
string nameString = GetExportDrawcallString(indent, firstchild, drawcall);
sw.WriteLine(String.Format("{0,-5} | {1,-" + maxNameLength + "} | {2,-5}", eidString, nameString, drawcall.drawcallID));
for (int i = 0; i < drawcall.children.Length; i++)
ExportDrawcall(sw, maxNameLength, indent + 1, i == 0, drawcall.children[i]);
}
private void export_Click(object sender, EventArgs e)
{
DialogResult res = exportDialog.ShowDialog();
if (res == DialogResult.OK)
{
try
{
using (Stream s = new FileStream(exportDialog.FileName, FileMode.Create))
{
StreamWriter sw = new StreamWriter(s);
sw.WriteLine(String.Format("{0} - Frame #{1}", m_Core.LogFileName, m_Core.FrameInfo.frameNumber));
sw.WriteLine("");
int maxNameLength = 0;
foreach (FetchDrawcall d in m_Core.GetDrawcalls())
GetMaxNameLength(ref maxNameLength, 0, false, d);
sw.WriteLine(String.Format(" EID | {0,-" + maxNameLength + "} | Draw #", "Event"));
sw.WriteLine(String.Format("--------{0}-----------", new string('-', maxNameLength)));
foreach (FetchDrawcall d in m_Core.GetDrawcalls())
ExportDrawcall(sw, maxNameLength, 0, false, d);
sw.Dispose();
}
}
catch (System.Exception ex)
{
MessageBox.Show("Couldn't save to " + exportDialog.FileName + Environment.NewLine + ex.ToString(), "Cannot save",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
+3
View File
@@ -141,4 +141,7 @@
<metadata name="findHighlight.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>459, 17</value>
</metadata>
<metadata name="exportDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>697, 17</value>
</metadata>
</root>