2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2017-01-11 21:39:40 +13:00
|
|
|
|
Copyright (c) 2007-2017 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
// gpailler
|
|
|
|
|
|
2016-02-26 09:55:54 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2014-12-11 12:19:28 +13:00
|
|
|
|
using ShareX.UploadersLib.Properties;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System;
|
2016-02-26 09:55:54 +13:00
|
|
|
|
using System.Threading.Tasks;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2016-02-26 09:55:54 +13:00
|
|
|
|
namespace ShareX.UploadersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class JiraUpload : Form
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
public delegate string GetSummaryHandler(string issueId);
|
|
|
|
|
|
|
|
|
|
private readonly string _issuePrefix;
|
|
|
|
|
private readonly GetSummaryHandler _getSummary;
|
|
|
|
|
|
|
|
|
|
public string IssueId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return txtIssueId.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public JiraUpload()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Icon = ShareXResources.Icon;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-07 04:02:48 +12:00
|
|
|
|
public JiraUpload(string issuePrefix, GetSummaryHandler getSummary) : this()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
if (getSummary == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("getSummary");
|
|
|
|
|
}
|
|
|
|
|
_issuePrefix = issuePrefix;
|
|
|
|
|
_getSummary = getSummary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void JiraUpload_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-11-12 19:49:36 +13:00
|
|
|
|
UpdateSummary(null);
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
txtIssueId.Text = _issuePrefix;
|
|
|
|
|
txtIssueId.SelectionStart = txtIssueId.Text.Length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ValidateIssueId(((TextBox)sender).Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSend_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ValidateIssueId(string issueId)
|
|
|
|
|
{
|
2014-11-12 19:49:36 +13:00
|
|
|
|
Task.Factory
|
|
|
|
|
.StartNew(() => _getSummary(issueId))
|
|
|
|
|
.ContinueWith(UpdateSummaryAsync);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSummaryAsync(Task<string> task)
|
|
|
|
|
{
|
2015-08-12 06:58:43 +12:00
|
|
|
|
Invoke((Action)(() => UpdateSummary(task.Result)));
|
2014-11-12 19:49:36 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSummary(string summary)
|
|
|
|
|
{
|
2015-11-29 01:53:16 +13:00
|
|
|
|
btnUpload.Enabled = summary != null;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-11-12 19:49:36 +13:00
|
|
|
|
lblSummary.Text = summary ?? Resources.JiraUpload_ValidateIssueId_Issue_not_found;
|
|
|
|
|
lblSummary.Enabled = summary != null;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|