mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
refactor<*>: rewrite all with AvaloniaUI
This commit is contained in:
parent
0136904612
commit
2a62596999
521 changed files with 19780 additions and 23244 deletions
50
src/ViewModels/Discard.cs
Normal file
50
src/ViewModels/Discard.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels {
|
||||
public class DiscardModeAll { }
|
||||
public class DiscardModeSingle { public string File { get; set; } }
|
||||
public class DiscardModeMulti { public int Count { get; set; } }
|
||||
|
||||
public class Discard : Popup {
|
||||
|
||||
public object Mode {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Discard(Repository repo, List<Models.Change> changes = null) {
|
||||
_repo = repo;
|
||||
_changes = changes;
|
||||
|
||||
if (_changes == null) {
|
||||
Mode = new DiscardModeAll();
|
||||
} else if (_changes.Count == 1) {
|
||||
Mode = new DiscardModeSingle() { File = _changes[0].Path };
|
||||
} else {
|
||||
Mode = new DiscardModeMulti() { Count = _changes.Count };
|
||||
}
|
||||
|
||||
View = new Views.Discard() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure() {
|
||||
_repo.SetWatcherEnabled(false);
|
||||
return Task.Run(() => {
|
||||
if (_changes == null) {
|
||||
SetProgressDescription("Discard all local changes ...");
|
||||
Commands.Discard.All(_repo.FullPath);
|
||||
} else {
|
||||
SetProgressDescription($"Discard total {_changes.Count} changes ...");
|
||||
Commands.Discard.Changes(_repo.FullPath, _changes);
|
||||
}
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private Repository _repo = null;
|
||||
private List<Models.Change> _changes = null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue