in Tools/MultiplayerSessionHistoryViewer/Form1.cs [360:444]
private async void ListView2_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listView2.SelectedIndices.Count > 2)
{
return;
}
this.rtbSnapshotLeft.Text = string.Empty;
this.rtbSnapshotRight.Text = string.Empty;
this.lblChangeLeft.Text = string.Empty;
this.lblChangeRight.Text = string.Empty;
if (this.listView2.SelectedIndices.Count > 0)
{
int index = 0;
if (this.listView1.SelectedItems.Count > 0)
{
index = this.listView1.SelectedIndices[0];
}
var leftIndex = this.listView2.SelectedIndices[0];
long changeLeft;
string errMsg = null;
string leftSnapshot = string.Empty;
string rightSnapshot = string.Empty;
if (long.TryParse(this.listView2.Items[leftIndex].SubItems[0].Text, out changeLeft))
{
Tuple<string, string> getSnapshotResponse = await this.QueryForDocSessionHistoryChangeAsync(
this.listView1.Items[index].SubItems[0].Text,
this.listView1.Items[index].SubItems[1].Text,
changeLeft).ConfigureAwait(true);
if (getSnapshotResponse.Item1 != null)
{
this.lblChangeLeft.Text = string.Format("Change #{0}", changeLeft);
leftSnapshot = getSnapshotResponse.Item1;
}
else
{
errMsg = getSnapshotResponse.Item2;
}
}
if (errMsg == null && this.listView2.SelectedIndices.Count > 1)
{
long changeRight;
var rightIndex = this.listView2.SelectedIndices[1];
if (long.TryParse(this.listView2.Items[rightIndex].SubItems[0].Text, out changeRight))
{
if (!this.showingOfflineSession)
{
this.lblExplanation.Text = string.Format("Downloading change #{0}", changeRight);
}
Tuple<string, string> getSnapshotResponse = await this.QueryForDocSessionHistoryChangeAsync(
this.listView1.Items[index].SubItems[0].Text,
this.listView1.Items[index].SubItems[1].Text,
changeRight).ConfigureAwait(true);
if (getSnapshotResponse.Item1 != null)
{
rightSnapshot = getSnapshotResponse.Item1;
this.lblChangeRight.Text = string.Format("Change #{0}", changeRight);
}
else
{
errMsg = getSnapshotResponse.Item2;
}
}
}
this.ShowDiffs(leftSnapshot, rightSnapshot);
this.downloadPanel.Hide();
if (errMsg != null)
{
MessageBox.Show(string.Format("{0}\n\nThe server is busy.\nPlease try again.", errMsg), QueryFailure);
}
}
}