mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
Upgrade project style
This commit is contained in:
parent
afd22ca85d
commit
baa6c1445a
136 changed files with 29 additions and 770 deletions
92
SourceGit/UI/CreateTag.xaml.cs
Normal file
92
SourceGit/UI/CreateTag.xaml.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGit.UI {
|
||||
|
||||
/// <summary>
|
||||
/// Create tag dialog
|
||||
/// </summary>
|
||||
public partial class CreateTag : UserControl {
|
||||
private Git.Repository repo = null;
|
||||
private string based = null;
|
||||
|
||||
/// <summary>
|
||||
/// Tag name
|
||||
/// </summary>
|
||||
public string TagName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
public CreateTag(Git.Repository opened) {
|
||||
InitializeComponent();
|
||||
|
||||
repo = opened;
|
||||
nameValidator.Repo = opened;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create tag using current branch.
|
||||
/// </summary>
|
||||
/// <param name="repo">Opened repository.</param>
|
||||
public static void Show(Git.Repository repo) {
|
||||
Show(repo, repo.Branches().First(b => b.IsCurrent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create tag using branch
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="branch"></param>
|
||||
public static void Show(Git.Repository repo, Git.Branch branch) {
|
||||
if (branch == null) {
|
||||
App.RaiseError("Empty repository!");
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = new CreateTag(repo);
|
||||
dialog.based = branch.Head;
|
||||
dialog.basedOnType.Data = dialog.FindResource("Icon.Branch") as Geometry;
|
||||
dialog.basedOnDesc.Content = branch.Name;
|
||||
PopupManager.Show(dialog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create tag using commit.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="commit"></param>
|
||||
public static void Show(Git.Repository repo, Git.Commit commit) {
|
||||
var dialog = new CreateTag(repo);
|
||||
dialog.based = commit.SHA;
|
||||
dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry;
|
||||
dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}";
|
||||
PopupManager.Show(dialog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start to create tag.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Start(object sender, RoutedEventArgs e) {
|
||||
tagName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(tagName)) return;
|
||||
|
||||
Git.Tag.Add(repo, TagName, based, tagMessage.Text);
|
||||
PopupManager.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Cancel(object sender, RoutedEventArgs e) {
|
||||
PopupManager.Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue