forked from haacked/seegit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
57 lines (50 loc) · 2.28 KB
/
MainWindow.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
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.IO;
using System.Windows;
using System.Windows.Input;
using SeeGit.Models;
namespace SeeGit
{
public partial class MainWindow : Window
{
private readonly MainWindowViewModel _viewModel;
public MainWindow()
{
InitializeComponent();
DataContext = _viewModel = new MainWindowViewModel(Dispatcher, path => new RepositoryGraphBuilder(path));
_viewModel.MonitorRepository(Directory.GetCurrentDirectory());
}
/// <summary>
/// A reference to the configuration.
/// </summary>
public static Settings Configuration { get; } = new Settings();
private void OnChooseRepository(object sender, RoutedEventArgs args)
{
_viewModel.MonitorRepository(WindowsExtensions.BrowseForFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
}
private void OnRefresh(object sender, ExecutedRoutedEventArgs e)
{
_viewModel.MonitorRepository(_viewModel.RepositoryPath);
}
private void OnToggleSettings(object sender, RoutedEventArgs args)
{
if (!_viewModel.ToggleSettings())
{
foreach (var vertex in _viewModel.Graph.Vertices)
{
vertex.AdornerMessageVisibilityType = Configuration.GetSetting("AdornerCommitMessageVisibility", "ExpandedHidden");
vertex.AuthorShown = Configuration.GetSetting("AuthorInHeader", false);
vertex.DescriptionShown = Configuration.GetSetting("DescriptionInExpander", false);
vertex.ShaLength = Configuration.GetSetting("SHALength", 8);
}
Configuration.Save();
_viewModel.Refresh();
// Ideally we wouldn't have to call relayout. Refreshing the view model would
// update the Graph which would then cause the RepositoryGraphLayout control to adjust its layout.
// Unfortunately, I am not as familiar with the RepositoryGraphLayout control and when the vertices have their
// width's increased due to displaying the author, the graph needs to have its layout adjusted.
graphLayout.Relayout();
}
}
}
}