1
0
mirror of synced 2024-12-04 20:08:00 +01:00
Switch-Toolbox/Toolbox/GUI/GithubIssueDialog.cs

62 lines
1.7 KiB
C#
Raw Normal View History

2019-05-01 21:38:14 +02:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library.Forms;
using Octokit;
namespace Toolbox
{
public partial class GithubIssueDialog : STForm
{
public GithubIssueDialog()
{
InitializeComponent();
typeCB.Items.Add("Bug");
typeCB.Items.Add("Feature");
typeCB.SelectedIndex = 0;
}
public void CreateIssue()
{
if (titleTB.Text == String.Empty) {
MessageBox.Show("Title must not be empty!", "Issue Dialog", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
2019-05-05 02:40:37 +02:00
if (titleTB.Text.Length < 5)
2019-05-01 21:38:14 +02:00
{
MessageBox.Show("Title too short! Atleast have 5 or more characters!", "Issue Dialog", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
2019-05-05 02:40:37 +02:00
var client = new GitHubClient(new ProductHeaderValue("Switch-Toolbox"));
2019-05-01 21:38:14 +02:00
var createIssue = new NewIssue(titleTB.Text);
createIssue.Body = infoTB.Text;
if (typeCB.GetSelectedText() == "Bug")
createIssue.Labels.Add("bug");
else
createIssue.Labels.Add("enhancement");
CreateIssue(client, createIssue).Wait();
}
static async Task CreateIssue(GitHubClient client, NewIssue createIssue)
{
var issue = await client.Issue.Create("fake", "test", createIssue);
}
2019-05-05 02:40:37 +02:00
private void titleTB_TextChanged(object sender, EventArgs e)
{
}
2019-05-01 21:38:14 +02:00
}
}