Files
deskhubsharprevised/DeskHubSharpRevised/DetailWindow.axaml.cs

85 lines
2.2 KiB
C#
Raw Normal View History

2022-06-29 13:02:15 -04:00
using System.Diagnostics;
using Avalonia;
2022-06-29 12:59:53 -04:00
using Avalonia.Controls;
2022-06-29 13:02:15 -04:00
using Avalonia.Interactivity;
2022-06-29 12:59:53 -04:00
using Avalonia.Markup.Xaml;
2022-06-29 13:02:15 -04:00
using DeskHubSharpRevised.BLL;
using DeskHubSharpRevised.Models;
2022-06-29 12:59:53 -04:00
2022-06-29 13:02:15 -04:00
namespace DeskHubSharpRevised;
public partial class DetailWindow : Window
2022-06-29 12:59:53 -04:00
{
2022-06-29 13:02:15 -04:00
public DetailWindow()
2022-06-29 12:59:53 -04:00
{
2022-06-29 13:02:15 -04:00
InitializeComponent();
2022-06-29 12:59:53 -04:00
#if DEBUG
2022-06-29 13:02:15 -04:00
this.AttachDevTools();
2022-06-29 12:59:53 -04:00
#endif
2022-06-29 13:02:15 -04:00
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private RepoDetail _repoDetail;
private Request _request;
private Owner _owner;
public DetailWindow(RepoDetail repoDetail)
{
InitializeComponent();
_repoDetail = repoDetail;
_request = new Request(_repoDetail.name);
RepoInfo info = new RepoInfo();
_request.PerformBranchRequest();
var stuff = info.GetBranchNameComboBox();
cmbbox_branches.Items= stuff;
if (_repoDetail.language != null)
{
txtblk_language.Text = $"This repo is mostly {_repoDetail.language} code.";
}
else
{
txtblk_language.Text = "This repo doesn't have any code.";
2022-06-29 12:59:53 -04:00
}
2022-06-29 13:02:15 -04:00
lbl_reponame.Content = _repoDetail.full_name;
txtblk_stargazers.Text = $"This repo has {_repoDetail.stargazers_count} stargazers.";
txtblk_watchers.Text = $"This repo has {_repoDetail.watchers_count} watchers.";
txtblk_forks.Text = $"This repo has {_repoDetail.forks_count} forks.";
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn_clone_Click(object sender, RoutedEventArgs e)
{
if (cmbbox_branches.SelectedItem.ToString() == "")
2022-06-29 12:59:53 -04:00
{
2022-06-29 13:02:15 -04:00
ErrorWindow err = new ErrorWindow();
err.txtblk_error.Text = "Please select a branch to clone.";
err.Show();
2022-06-29 12:59:53 -04:00
}
2022-06-29 13:02:15 -04:00
else
{
_owner = new Owner();
string link = "https://github.com/" + _repoDetail.owner.login + "/" + _repoDetail.name + "/archive/" + cmbbox_branches.SelectedItem + ".zip";
Process.Start(link);
}
}
private void btn_page_Click(object sender, RoutedEventArgs e)
{
Process.Start($"{_repoDetail.html_url}");
2022-06-29 12:59:53 -04:00
}
2022-06-29 13:02:15 -04:00
}