mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
v1.0
This commit is contained in:
commit
38227b1d57
138 changed files with 17935 additions and 0 deletions
45
Converters/FileStatusToIcon.cs
Normal file
45
Converters/FileStatusToIcon.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
|
||||
/// <summary>
|
||||
/// Convert file status to icon.
|
||||
/// </summary>
|
||||
public class FileStatusToIcon : IValueConverter {
|
||||
|
||||
/// <summary>
|
||||
/// Is only test local changes.
|
||||
/// </summary>
|
||||
public bool OnlyWorkTree { get; set; } = false;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
var change = value as Git.Change;
|
||||
if (change == null) return "";
|
||||
|
||||
var status = Git.Change.Status.None;
|
||||
if (OnlyWorkTree) {
|
||||
if (change.IsConflit) return "X";
|
||||
status = change.WorkTree;
|
||||
} else {
|
||||
status = change.Index;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case Git.Change.Status.Modified: return "M";
|
||||
case Git.Change.Status.Added: return "A";
|
||||
case Git.Change.Status.Deleted: return "D";
|
||||
case Git.Change.Status.Renamed: return "R";
|
||||
case Git.Change.Status.Copied: return "C";
|
||||
case Git.Change.Status.Unmerged: return "U";
|
||||
case Git.Change.Status.Untracked: return "?";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue