mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 03:30:02 -07:00
Added some support for opening the url when an upload is made from a Destination (currently Jira & Picasa) and the tooltip is clicked.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1797 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
05f9fb930e
commit
9bf5e44c94
12 changed files with 169 additions and 135 deletions
|
@ -138,6 +138,11 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
public string UploadURL {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ICaptureDetails CaptureDetails {
|
||||
get {return captureDetails;}
|
||||
set {captureDetails = value;}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<JiraConfiguration>();
|
||||
|
||||
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;
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// This class is an implementation of the 'IComparer' interface.
|
||||
/// </summary>
|
||||
public class ListViewColumnSorter : IComparer {
|
||||
/// <summary>
|
||||
/// Specifies the column to be sorted
|
||||
/// </summary>
|
||||
private int ColumnToSort;
|
||||
/// <summary>
|
||||
/// Specifies the order in which to sort (i.e. 'Ascending').
|
||||
/// </summary>
|
||||
private SortOrder OrderOfSort;
|
||||
/// <summary>
|
||||
/// Case insensitive comparer object
|
||||
/// </summary>
|
||||
private CaseInsensitiveComparer ObjectCompare;
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor. Initializes various elements
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
|
||||
/// </summary>
|
||||
/// <param name="x">First object to be compared</param>
|
||||
/// <param name="y">Second object to be compared</param>
|
||||
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
|
||||
/// </summary>
|
||||
public int SortColumn {
|
||||
set {
|
||||
ColumnToSort = value;
|
||||
}
|
||||
get {
|
||||
return ColumnToSort;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
|
||||
/// </summary>
|
||||
public SortOrder Order {
|
||||
set {
|
||||
OrderOfSort = value;
|
||||
}
|
||||
get {
|
||||
return OrderOfSort;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,6 @@
|
|||
<Compile Include="Forms\JiraForm.Designer.cs">
|
||||
<DependentUpon>JiraForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ListViewColumnSorter.cs" />
|
||||
<Compile Include="Forms\SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
119
GreenshotPlugin/Controls/GreenshotColumnSorter.cs
Normal file
119
GreenshotPlugin/Controls/GreenshotColumnSorter.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GreenshotPlugin.Controls {
|
||||
/// <summary>
|
||||
/// This class is an implementation of the 'IComparer' interface.
|
||||
/// </summary>
|
||||
public class GreenshotColumnSorter : IComparer {
|
||||
/// <summary>
|
||||
/// Specifies the column to be sorted
|
||||
/// </summary>
|
||||
private int ColumnToSort;
|
||||
/// <summary>
|
||||
/// Specifies the order in which to sort (i.e. 'Ascending').
|
||||
/// </summary>
|
||||
private SortOrder OrderOfSort;
|
||||
/// <summary>
|
||||
/// Case insensitive comparer object
|
||||
/// </summary>
|
||||
private CaseInsensitiveComparer ObjectCompare;
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor. Initializes various elements
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
|
||||
/// </summary>
|
||||
/// <param name="x">First object to be compared</param>
|
||||
/// <param name="y">Second object to be compared</param>
|
||||
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
|
||||
/// </summary>
|
||||
public int SortColumn {
|
||||
set {
|
||||
ColumnToSort = value;
|
||||
}
|
||||
get {
|
||||
return ColumnToSort;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
|
||||
/// </summary>
|
||||
public SortOrder Order {
|
||||
set {
|
||||
OrderOfSort = value;
|
||||
}
|
||||
get {
|
||||
return OrderOfSort;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{5B924697-4DCD-4F98-85F1-105CB84B7341}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -177,6 +177,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Controls\GreenshotButton.cs" />
|
||||
<Compile Include="Controls\GreenshotCheckBox.cs" />
|
||||
<Compile Include="Controls\GreenshotColumnSorter.cs" />
|
||||
<Compile Include="Controls\GreenshotComboBox.cs" />
|
||||
<Compile Include="Controls\GreenshotForm.cs" />
|
||||
<Compile Include="Controls\GreenshotGroupBox.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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue