diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 1ce2e8b00..67f783c0e 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -138,6 +138,11 @@ namespace Greenshot.Drawing { } } + public string UploadURL { + get; + set; + } + public ICaptureDetails CaptureDetails { get {return captureDetails;} set {captureDetails = value;} diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index 04cbcefe3..10c897ec0 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -252,7 +252,9 @@ namespace Greenshot { private void SurfaceMessageReceived(object sender, SurfaceMessageEventArgs eventArgs) { string dateTime = DateTime.Now.ToLongTimeString(); - if (eventArgs.MessageType == SurfaceMessageTyp.FileSaved) { + // TODO: Fix that we only open files, like in the tooltip + //if (eventArgs.MessageType == SurfaceMessageTyp.FileSaved || eventArgs.MessageType == SurfaceMessageTyp.UploadedUrl) { + if (eventArgs.MessageType == SurfaceMessageTyp.FileSaved || eventArgs.MessageType == SurfaceMessageTyp.UploadedUrl) { updateStatusLabel(dateTime + " - " + eventArgs.Message, fileSavedStatusContextMenu); } else { updateStatusLabel(dateTime + " - " + eventArgs.Message); diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index f102e4643..68743cd71 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -438,6 +438,7 @@ namespace Greenshot.Helpers { MainForm.instance.notifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info); break; case SurfaceMessageTyp.FileSaved: + case SurfaceMessageTyp.UploadedUrl: EventHandler balloonTipClickedHandler = null; EventHandler balloonTipClosedHandler = null; balloonTipClosedHandler = delegate(object sender, EventArgs e) { @@ -447,13 +448,19 @@ namespace Greenshot.Helpers { }; balloonTipClickedHandler = delegate(object sender, EventArgs e) { - if (surface.LastSaveFullPath != null) { - ProcessStartInfo psi = new ProcessStartInfo("explorer"); - psi.Arguments = Path.GetDirectoryName(eventArgs.Surface.LastSaveFullPath); - psi.UseShellExecute = false; - Process p = new Process(); - p.StartInfo = psi; - p.Start(); + if (eventArgs.MessageType == SurfaceMessageTyp.FileSaved) { + if (!string.IsNullOrEmpty(surface.LastSaveFullPath)) { + ProcessStartInfo psi = new ProcessStartInfo("explorer"); + psi.Arguments = Path.GetDirectoryName(surface.LastSaveFullPath); + psi.UseShellExecute = false; + Process p = new Process(); + p.StartInfo = psi; + p.Start(); + } + } else { + if (!string.IsNullOrEmpty(surface.UploadURL)) { + System.Diagnostics.Process.Start(surface.UploadURL); + } } LOG.DebugFormat("Deregistering the BalloonTipClicked"); MainForm.instance.notifyIcon.BalloonTipClicked -= balloonTipClickedHandler; diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs index 3365f7cd4..5a0c0c5dc 100644 --- a/GreenshotJiraPlugin/Forms/JiraForm.cs +++ b/GreenshotJiraPlugin/Forms/JiraForm.cs @@ -31,7 +31,7 @@ namespace GreenshotJiraPlugin { public partial class JiraForm : Form { private JiraConnector jiraConnector; private JiraIssue selectedIssue; - private ListViewColumnSorter columnSorter; + private GreenshotColumnSorter columnSorter; private JiraConfiguration config = IniConfig.GetIniSection(); public JiraForm(JiraConnector jiraConnector) { @@ -39,7 +39,7 @@ namespace GreenshotJiraPlugin { this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); initializeComponentText(); - this.columnSorter = new ListViewColumnSorter(); + this.columnSorter = new GreenshotColumnSorter(); this.jiraListView.ListViewItemSorter = columnSorter; this.jiraConnector = jiraConnector; diff --git a/GreenshotJiraPlugin/Forms/ListViewColumnSorter.cs b/GreenshotJiraPlugin/Forms/ListViewColumnSorter.cs deleted file mode 100644 index 08832ede0..000000000 --- a/GreenshotJiraPlugin/Forms/ListViewColumnSorter.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Greenshot - a free and open source screenshot tool - * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom - * - * For more information see: http://getgreenshot.org/ - * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ - * - * 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 1 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, see . - */ -using System.Collections; -using System.Windows.Forms; - -/// -/// This class is an implementation of the 'IComparer' interface. -/// -public class ListViewColumnSorter : IComparer { - /// - /// Specifies the column to be sorted - /// - private int ColumnToSort; - /// - /// Specifies the order in which to sort (i.e. 'Ascending'). - /// - private SortOrder OrderOfSort; - /// - /// Case insensitive comparer object - /// - private CaseInsensitiveComparer ObjectCompare; - - /// - /// Class constructor. Initializes various elements - /// - public ListViewColumnSorter() { - // Initialize the column to '0' - ColumnToSort = 0; - - // Initialize the sort order to 'none' - OrderOfSort = SortOrder.None; - - // Initialize the CaseInsensitiveComparer object - ObjectCompare = new CaseInsensitiveComparer(); - } - - /// - /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. - /// - /// First object to be compared - /// Second object to be compared - /// The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y' - public int Compare(object x, object y) { - int compareResult; - ListViewItem listviewX, listviewY; - - if (x == null && y == null) { - return 0; - } else if (x == null && y != null) { - return -1; - } else if (x != null && y == null) { - return 1; - } - // Cast the objects to be compared to ListViewItem objects - listviewX = (ListViewItem)x; - listviewY = (ListViewItem)y; - - // Compare the two items - compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); - - // Calculate correct return value based on object comparison - if (OrderOfSort == SortOrder.Ascending) { - // Ascending sort is selected, return normal result of compare operation - return compareResult; - } else if (OrderOfSort == SortOrder.Descending) { - // Descending sort is selected, return negative result of compare operation - return (-compareResult); - } else { - // Return '0' to indicate they are equal - return 0; - } - } - - /// - /// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0'). - /// - public int SortColumn { - set { - ColumnToSort = value; - } - get { - return ColumnToSort; - } - } - - /// - /// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending'). - /// - public SortOrder Order { - set { - OrderOfSort = value; - } - get { - return OrderOfSort; - } - } -} diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index ac9e88eb6..710ec2872 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -59,7 +59,6 @@ JiraForm.cs - Form diff --git a/GreenshotJiraPlugin/Jira.cs b/GreenshotJiraPlugin/Jira.cs index 0de589518..ac536442a 100644 --- a/GreenshotJiraPlugin/Jira.cs +++ b/GreenshotJiraPlugin/Jira.cs @@ -285,6 +285,10 @@ namespace Jira { return issuesToReturn.ToArray(); ; } + public string getURL(string issueKey) { + return url.Replace(DEFAULT_POSTFIX,"") + "/browse/" + issueKey; + } + public void addAttachment(string issueKey, string filename, byte [] buffer) { checkCredentials(); try { diff --git a/GreenshotJiraPlugin/JiraDestination.cs b/GreenshotJiraPlugin/JiraDestination.cs index 2b0300aac..3d4bc44a1 100644 --- a/GreenshotJiraPlugin/JiraDestination.cs +++ b/GreenshotJiraPlugin/JiraDestination.cs @@ -57,12 +57,16 @@ namespace GreenshotJiraPlugin { } } + private string FormatUpload(JiraIssue jira) { + return Designation + " - " + jira.Key + ": " + jira.Summary.Substring(0, Math.Min(20, jira.Summary.Length)); + } + public override string Description { get { if (jira == null) { return Language.GetString("jira", LangKey.upload_menu_item); } else { - return Language.GetString("jira", LangKey.upload_menu_item) + " - " + jira.Key + ": " + jira.Summary.Substring(0, Math.Min(20, jira.Summary.Length)); + return FormatUpload(jira); } } } @@ -113,8 +117,8 @@ namespace GreenshotJiraPlugin { jiraPlugin.JiraConnector.addAttachment(jira.Key, filename, buffer); LOG.Debug("Uploaded to Jira."); backgroundForm.CloseDialog(); - MessageBox.Show(Language.GetString("jira", LangKey.upload_success)); - surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString("exported_to", Description)); + surface.UploadURL = jiraPlugin.JiraConnector.getURL(jira.Key); + surface.SendMessageEvent(this, SurfaceMessageTyp.UploadedUrl, Language.GetFormattedString("exported_to", FormatUpload(jira))); surface.Modified = false; return true; } catch (Exception e) { @@ -140,8 +144,8 @@ namespace GreenshotJiraPlugin { jiraForm.upload(buffer); LOG.Debug("Uploaded to Jira."); backgroundForm.CloseDialog(); - MessageBox.Show(Language.GetString("jira", LangKey.upload_success)); - surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to Jira " + jiraForm.getJiraIssue().Key); + surface.UploadURL = jiraPlugin.JiraConnector.getURL(jiraForm.getJiraIssue().Key); + surface.SendMessageEvent(this, SurfaceMessageTyp.UploadedUrl, Language.GetFormattedString("exported_to", FormatUpload(jiraForm.getJiraIssue()))); surface.Modified = false; return true; } catch(Exception e) { diff --git a/GreenshotJiraPlugin/JiraUtils.cs b/GreenshotJiraPlugin/JiraUtils.cs index db52c2bb8..437782a85 100644 --- a/GreenshotJiraPlugin/JiraUtils.cs +++ b/GreenshotJiraPlugin/JiraUtils.cs @@ -49,7 +49,8 @@ namespace GreenshotJiraPlugin { } MatchCollection jiraKeyMatch = JIRA_KEY_REGEX.Matches(url); if (jiraKeyMatch != null && jiraKeyMatch.Count > 0) { - jirakeys.Add(jiraKeyMatch[0].Groups[1].Value); + string jiraKey = jiraKeyMatch[0].Groups[1].Value; + jirakeys.Add(jiraKey); } } if (!string.IsNullOrEmpty(config.LastUsedJira) && !jirakeys.Contains(config.LastUsedJira)) { @@ -60,7 +61,9 @@ namespace GreenshotJiraPlugin { foreach(string jiraKey in jirakeys) { try { JiraIssue issue = JiraPlugin.Instance.JiraConnector.getIssue(jiraKey); - jiraIssues.Add(issue); + if (issue != null) { + jiraIssues.Add(issue); + } } catch {} } if (jiraIssues.Count > 0) { diff --git a/GreenshotPlugin/Controls/GreenshotColumnSorter.cs b/GreenshotPlugin/Controls/GreenshotColumnSorter.cs new file mode 100644 index 000000000..7e5340462 --- /dev/null +++ b/GreenshotPlugin/Controls/GreenshotColumnSorter.cs @@ -0,0 +1,119 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * 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 1 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, see . + */ +using System.Collections; +using System.Windows.Forms; + +namespace GreenshotPlugin.Controls { + /// + /// This class is an implementation of the 'IComparer' interface. + /// + public class GreenshotColumnSorter : IComparer { + /// + /// Specifies the column to be sorted + /// + private int ColumnToSort; + /// + /// Specifies the order in which to sort (i.e. 'Ascending'). + /// + private SortOrder OrderOfSort; + /// + /// Case insensitive comparer object + /// + private CaseInsensitiveComparer ObjectCompare; + + /// + /// Class constructor. Initializes various elements + /// + public GreenshotColumnSorter() { + // Initialize the column to '0' + ColumnToSort = 0; + + // Initialize the sort order to 'none' + OrderOfSort = SortOrder.None; + + // Initialize the CaseInsensitiveComparer object + ObjectCompare = new CaseInsensitiveComparer(); + } + + /// + /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. + /// + /// First object to be compared + /// Second object to be compared + /// The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y' + public int Compare(object x, object y) { + int compareResult; + ListViewItem listviewX, listviewY; + + if (x == null && y == null) { + return 0; + } else if (x == null && y != null) { + return -1; + } else if (x != null && y == null) { + return 1; + } + // Cast the objects to be compared to ListViewItem objects + listviewX = (ListViewItem)x; + listviewY = (ListViewItem)y; + + // Compare the two items + compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); + + // Calculate correct return value based on object comparison + if (OrderOfSort == SortOrder.Ascending) { + // Ascending sort is selected, return normal result of compare operation + return compareResult; + } else if (OrderOfSort == SortOrder.Descending) { + // Descending sort is selected, return negative result of compare operation + return (-compareResult); + } else { + // Return '0' to indicate they are equal + return 0; + } + } + + /// + /// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0'). + /// + public int SortColumn { + set { + ColumnToSort = value; + } + get { + return ColumnToSort; + } + } + + /// + /// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending'). + /// + public SortOrder Order { + set { + OrderOfSort = value; + } + get { + return OrderOfSort; + } + } + } +} + + diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index c7f5a82bb..f4a1f8829 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -1,5 +1,5 @@  - + {5B924697-4DCD-4F98-85F1-105CB84B7341} Debug @@ -177,6 +177,7 @@ + diff --git a/GreenshotPlugin/Interfaces/Generic.cs b/GreenshotPlugin/Interfaces/Generic.cs index 0519d0d29..ef1229248 100644 --- a/GreenshotPlugin/Interfaces/Generic.cs +++ b/GreenshotPlugin/Interfaces/Generic.cs @@ -36,7 +36,8 @@ namespace Greenshot.Plugin { public enum SurfaceMessageTyp { FileSaved, Error, - Info + Info, + UploadedUrl } public class SurfaceMessageEventArgs : EventArgs { @@ -130,6 +131,10 @@ namespace Greenshot.Plugin { get; set; } + string UploadURL { + get; + set; + } void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable); void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message); void ApplyBitmapEffect(Effects effect);