Switch-Toolbox/Toolbox/GUI/GithubIssueDialog.cs

62 lines
1.7 KiB
C#
Raw Normal View History

2019-05-01 19:38:14 +00: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 Toolbox.Library.Forms;
2019-05-01 19:38:14 +00:00
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 00:40:37 +00:00
if (titleTB.Text.Length < 5)
2019-05-01 19:38:14 +00:00
{
MessageBox.Show("Title too short! Atleast have 5 or more characters!", "Issue Dialog", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
2019-05-05 00:40:37 +00:00
var client = new GitHubClient(new ProductHeaderValue("Switch-Toolbox"));
2019-05-01 19:38:14 +00: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 00:40:37 +00:00
private void titleTB_TextChanged(object sender, EventArgs e)
{
}
2019-05-01 19:38:14 +00:00
}
}