/
ChangesetHistory.xaml.cs
45 lines (38 loc) · 1.47 KB
/
ChangesetHistory.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using GG.Libraries;
namespace GG.UserControls
{
/// <summary>
/// Interaction logic for ChangesetHistory.xaml
/// </summary>
public partial class ChangesetHistory : UserControl
{
public ChangesetHistory()
{
InitializeComponent();
ChangesetHistoryGrid.Loaded += (sender, args) => RedrawGraph();
}
/// <summary>
/// Recalculates the height for the graph and draws it.
/// </summary>
public void RedrawGraph()
{
// Redraw the graph.
var changesetGraph = new ChangesetGraph((RepositoryViewModel) DataContext, Graph);
changesetGraph.Draw(ChangesetHistoryGrid.Items);
// Update the height for the Graph element.
Graph.Height = changesetGraph.TotalHeight;
// TODO: Set width also, and for the datagrid as well!
}
private void ChangesetHistoryGrid_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
var scrollViewer = UIHelper.FindChild<ScrollViewer>(this, "GraphScrollViewer");
scrollViewer.ScrollToVerticalOffset(Math.Floor(e.VerticalOffset) * 24);
var dataGrid = UIHelper.FindChild<DataGrid>(this, "ChangesetHistoryGrid");
scrollViewer.Height = Math.Abs(dataGrid.ActualHeight - 24);
}
}
}