mirror of
https://github.com/greenshot/greenshot.git
synced 2025-03-12 05:25:25 -07:00
Code quality changes [skip ci]
This commit is contained in:
parent
61cfe004c5
commit
798ca503a5
Greenshot
Configuration
Controls
Destinations
Drawing
Forms
Helpers
Languages
Memento
GreenshotBoxPlugin
GreenshotConfluencePlugin
Confluence.csConfluenceDestination.csConfluencePlugin.csConfluenceUtils.cs
Forms
ConfluencePagePicker.xamlConfluencePagePicker.xaml.csConfluenceSearch.xaml.csConfluenceTreePicker.xaml.csConfluenceUpload.xaml.cs
Support
GreenshotDropboxPlugin
GreenshotExternalCommandPlugin
GreenshotFlickrPlugin
GreenshotImgurPlugin
GreenshotJiraPlugin
Forms
Jira.csJiraConfiguration.csJiraDestination.csJiraPlugin.csJiraUtils.csProperties
Web References/JiraSoap
GreenshotOCRCommand
GreenshotOCRPlugin
GreenshotOfficePlugin
GreenshotPhotobucketPlugin
GreenshotPicasaPlugin
GreenshotPlugin
@ -35,35 +35,35 @@ namespace Greenshot.Configuration {
|
||||
[IniSection("Editor", Description="Greenshot editor configuration")]
|
||||
public class EditorConfiguration : IniSection {
|
||||
[IniProperty("RecentColors", Separator="|", Description="Last used colors")]
|
||||
public List<Color> RecentColors;
|
||||
public List<Color> RecentColors { get; set; }
|
||||
|
||||
[IniProperty("LastFieldValue", Separator="|", Description="Field values, make sure the last used settings are re-used")]
|
||||
public Dictionary<string, object> LastUsedFieldValues;
|
||||
public Dictionary<string, object> LastUsedFieldValues { get; set; }
|
||||
|
||||
[IniProperty("MatchSizeToCapture", Description="Match the editor window size to the capture", DefaultValue="True")]
|
||||
public bool MatchSizeToCapture;
|
||||
public bool MatchSizeToCapture { get; set; }
|
||||
[IniProperty("WindowPlacementFlags", Description="Placement flags", DefaultValue="0")]
|
||||
public WindowPlacementFlags WindowPlacementFlags;
|
||||
public WindowPlacementFlags WindowPlacementFlags { get; set; }
|
||||
[IniProperty("WindowShowCommand", Description="Show command", DefaultValue="Normal")]
|
||||
public ShowWindowCommand ShowWindowCommand;
|
||||
public ShowWindowCommand ShowWindowCommand { get; set; }
|
||||
[IniProperty("WindowMinPosition", Description="Position of minimized window", DefaultValue="-1,-1")]
|
||||
public Point WindowMinPosition;
|
||||
public Point WindowMinPosition { get; set; }
|
||||
[IniProperty("WindowMaxPosition", Description="Position of maximized window", DefaultValue="-1,-1")]
|
||||
public Point WindowMaxPosition;
|
||||
public Point WindowMaxPosition { get; set; }
|
||||
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
|
||||
public Rectangle WindowNormalPosition;
|
||||
public Rectangle WindowNormalPosition { get; set; }
|
||||
[IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")]
|
||||
public bool ReuseEditor;
|
||||
public bool ReuseEditor { get; set; }
|
||||
[IniProperty("FreehandSensitivity", Description = "The smaller this number, the less smoothing is used. Decrease for detailed drawing, e.g. when using a pen. Increase for smoother lines. e.g. when you want to draw a smooth line.", DefaultValue = "3")]
|
||||
public int FreehandSensitivity;
|
||||
public int FreehandSensitivity { get; set; }
|
||||
[IniProperty("SuppressSaveDialogAtClose", Description="Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue="False")]
|
||||
public bool SuppressSaveDialogAtClose;
|
||||
public bool SuppressSaveDialogAtClose { get; set; }
|
||||
|
||||
[IniProperty("DropShadowEffectSettings", Description = "Settings for the drop shadow effect.")]
|
||||
public DropShadowEffect DropShadowEffectSettings;
|
||||
public DropShadowEffect DropShadowEffectSettings { get; set; }
|
||||
|
||||
[IniProperty("TornEdgeEffectSettings", Description = "Settings for the torn edge effect.")]
|
||||
public TornEdgeEffect TornEdgeEffectSettings;
|
||||
public TornEdgeEffect TornEdgeEffectSettings { get; set; }
|
||||
|
||||
public override void AfterLoad() {
|
||||
base.AfterLoad();
|
||||
|
@ -19,7 +19,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Greenshot.Configuration {
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum LangKey {
|
||||
none,
|
||||
about_bugs,
|
||||
|
@ -31,7 +31,7 @@ namespace Greenshot.Controls {
|
||||
/// </summary>
|
||||
public class ColorButton : Button, IGreenshotLanguageBindable {
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private Color selectedColor = Color.White;
|
||||
private Color _selectedColor = Color.White;
|
||||
|
||||
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
|
||||
public string LanguageKey {
|
||||
@ -44,9 +44,9 @@ namespace Greenshot.Controls {
|
||||
}
|
||||
|
||||
public Color SelectedColor {
|
||||
get {return selectedColor;}
|
||||
get {return _selectedColor;}
|
||||
set {
|
||||
selectedColor = value;
|
||||
_selectedColor = value;
|
||||
|
||||
Brush brush;
|
||||
if(value != Color.Transparent) {
|
||||
|
@ -30,22 +30,22 @@ namespace Greenshot.Controls {
|
||||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||
/// Needed some modifications to be stable.
|
||||
/// </summary>
|
||||
public class Pipette : Label, IMessageFilter, IDisposable {
|
||||
private MovableShowColorForm movableShowColorForm;
|
||||
private bool dragging;
|
||||
public sealed class Pipette : Label, IMessageFilter, IDisposable {
|
||||
private MovableShowColorForm _movableShowColorForm;
|
||||
private bool _dragging;
|
||||
private Cursor _cursor;
|
||||
private readonly Bitmap _image;
|
||||
private const int VK_ESC = 27;
|
||||
private const int VkEsc = 27;
|
||||
|
||||
public event EventHandler<PipetteUsedArgs> PipetteUsed;
|
||||
|
||||
public Pipette() {
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
dragging = false;
|
||||
_dragging = false;
|
||||
_image = (Bitmap)new ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
|
||||
Image = _image;
|
||||
_cursor = CreateCursor((Bitmap)_image, 1, 14);
|
||||
movableShowColorForm = new MovableShowColorForm();
|
||||
_cursor = CreateCursor(_image, 1, 14);
|
||||
_movableShowColorForm = new MovableShowColorForm();
|
||||
Application.AddMessageFilter(this);
|
||||
}
|
||||
|
||||
@ -58,13 +58,12 @@ namespace Greenshot.Controls {
|
||||
/// <returns>Cursor</returns>
|
||||
private static Cursor CreateCursor(Bitmap bitmap, int hotspotX, int hotspotY) {
|
||||
using (SafeIconHandle iconHandle = new SafeIconHandle( bitmap.GetHicon())) {
|
||||
IntPtr icon;
|
||||
IconInfo iconInfo = new IconInfo();
|
||||
IconInfo iconInfo;
|
||||
User32.GetIconInfo(iconHandle, out iconInfo);
|
||||
iconInfo.xHotspot = hotspotX;
|
||||
iconInfo.yHotspot = hotspotY;
|
||||
iconInfo.fIcon = false;
|
||||
icon = User32.CreateIconIndirect(ref iconInfo);
|
||||
var icon = User32.CreateIconIndirect(ref iconInfo);
|
||||
return new Cursor(icon);
|
||||
}
|
||||
}
|
||||
@ -85,11 +84,11 @@ namespace Greenshot.Controls {
|
||||
if (_cursor != null) {
|
||||
_cursor.Dispose();
|
||||
}
|
||||
if (movableShowColorForm != null) {
|
||||
movableShowColorForm.Dispose();
|
||||
if (_movableShowColorForm != null) {
|
||||
_movableShowColorForm.Dispose();
|
||||
}
|
||||
}
|
||||
movableShowColorForm = null;
|
||||
_movableShowColorForm = null;
|
||||
_cursor = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
@ -101,7 +100,7 @@ namespace Greenshot.Controls {
|
||||
protected override void OnMouseDown(MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
User32.SetCapture(Handle);
|
||||
movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
|
||||
_movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
|
||||
}
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
@ -117,7 +116,7 @@ namespace Greenshot.Controls {
|
||||
User32.ReleaseCapture();
|
||||
if (PipetteUsed != null)
|
||||
{
|
||||
PipetteUsed(this, new PipetteUsedArgs(movableShowColorForm.color));
|
||||
PipetteUsed(this, new PipetteUsedArgs(_movableShowColorForm.color));
|
||||
}
|
||||
}
|
||||
base.OnMouseUp(e);
|
||||
@ -128,10 +127,10 @@ namespace Greenshot.Controls {
|
||||
/// </summary>
|
||||
/// <param name="e">MouseEventArgs</param>
|
||||
protected override void OnMouseMove(MouseEventArgs e) {
|
||||
if (dragging) {
|
||||
if (_dragging) {
|
||||
//display the form on the right side of the cursor by default;
|
||||
Point zp = PointToScreen(new Point(e.X, e.Y));
|
||||
movableShowColorForm.MoveTo(zp);
|
||||
_movableShowColorForm.MoveTo(zp);
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
@ -142,16 +141,16 @@ namespace Greenshot.Controls {
|
||||
/// <param name="e"></param>
|
||||
protected override void OnMouseCaptureChanged(EventArgs e) {
|
||||
if (Capture) {
|
||||
dragging = true;
|
||||
_dragging = true;
|
||||
Image = null;
|
||||
Cursor c = _cursor;
|
||||
Cursor = c;
|
||||
movableShowColorForm.Visible = true;
|
||||
_movableShowColorForm.Visible = true;
|
||||
} else {
|
||||
dragging = false;
|
||||
_dragging = false;
|
||||
Image = _image;
|
||||
Cursor = Cursors.Arrow;
|
||||
movableShowColorForm.Visible = false;
|
||||
_movableShowColorForm.Visible = false;
|
||||
}
|
||||
Update();
|
||||
base.OnMouseCaptureChanged(e);
|
||||
@ -160,9 +159,9 @@ namespace Greenshot.Controls {
|
||||
#region IMessageFilter Members
|
||||
|
||||
public bool PreFilterMessage(ref Message m) {
|
||||
if (dragging) {
|
||||
if (_dragging) {
|
||||
if (m.Msg == (int)WindowsMessages.WM_CHAR) {
|
||||
if ((int)m.WParam == VK_ESC) {
|
||||
if ((int)m.WParam == VkEsc) {
|
||||
User32.ReleaseCapture();
|
||||
}
|
||||
}
|
||||
@ -174,10 +173,10 @@ namespace Greenshot.Controls {
|
||||
}
|
||||
|
||||
public class PipetteUsedArgs : EventArgs {
|
||||
public Color color;
|
||||
public Color Color;
|
||||
|
||||
public PipetteUsedArgs(Color c) {
|
||||
color = c;
|
||||
Color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ namespace Greenshot.Controls {
|
||||
set;
|
||||
}
|
||||
|
||||
private Color selectedColor = Color.Transparent;
|
||||
private Color _selectedColor = Color.Transparent;
|
||||
|
||||
public ToolStripColorButton() {
|
||||
Click+= ColorButtonClick;
|
||||
}
|
||||
|
||||
public Color SelectedColor {
|
||||
get {return selectedColor;}
|
||||
get {return _selectedColor;}
|
||||
set {
|
||||
selectedColor = value;
|
||||
_selectedColor = value;
|
||||
|
||||
Brush brush;
|
||||
if(value != Color.Transparent) {
|
||||
|
@ -114,7 +114,7 @@ namespace Greenshot.Destinations {
|
||||
}
|
||||
// Don't overwrite filename if no output is made
|
||||
if (outputMade) {
|
||||
exportInformation.ExportMade = outputMade;
|
||||
exportInformation.ExportMade = true;
|
||||
exportInformation.Filepath = fullPath;
|
||||
if (captureDetails != null)
|
||||
{
|
||||
|
@ -26,14 +26,12 @@ using Greenshot.Configuration;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Description of FileWithDialog.
|
||||
/// </summary>
|
||||
public class FileWithDialogDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(FileWithDialogDestination));
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
public const string DESIGNATION = "FileDialog";
|
||||
|
||||
@ -69,9 +67,8 @@ namespace Greenshot.Destinations {
|
||||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
string savedTo = null;
|
||||
// Bug #2918756 don't overwrite path if SaveWithDialog returns null!
|
||||
savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
|
||||
var savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
|
||||
if (savedTo != null) {
|
||||
exportInformation.ExportMade = true;
|
||||
exportInformation.Filepath = savedTo;
|
||||
|
@ -35,7 +35,7 @@ namespace Greenshot.Destinations {
|
||||
/// </summary>
|
||||
public class PrinterDestination : AbstractDestination {
|
||||
public const string DESIGNATION = "Printer";
|
||||
public string printerName;
|
||||
public readonly string printerName;
|
||||
|
||||
public PrinterDestination() {
|
||||
}
|
||||
@ -85,7 +85,7 @@ namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Create destinations for all the installed printers
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable<IDestination></returns>
|
||||
/// <returns>IEnumerable of IDestination</returns>
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
PrinterSettings settings = new PrinterSettings();
|
||||
string defaultPrinter = settings.PrinterName;
|
||||
@ -117,7 +117,7 @@ namespace Greenshot.Destinations {
|
||||
/// <returns>ExportInformation</returns>
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
PrinterSettings printerSettings = null;
|
||||
PrinterSettings printerSettings;
|
||||
if (!string.IsNullOrEmpty(printerName)) {
|
||||
using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
|
||||
printerSettings = printHelper.PrintTo(printerName);
|
||||
|
@ -24,7 +24,6 @@ using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using System;
|
||||
|
||||
namespace Greenshot.Drawing.Adorners
|
||||
{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Memento;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
@ -28,7 +28,7 @@ namespace Greenshot.Drawing.Fields
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic IFieldHolderWithChildren implementation. Similar to IFieldHolder,
|
||||
/// but has a List<IFieldHolder> of children.
|
||||
/// but has a List of IFieldHolder for children.
|
||||
/// Field values are passed to and from children as well.
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
|
@ -22,7 +22,7 @@ using System;
|
||||
|
||||
namespace Greenshot.Drawing.Fields.Binding {
|
||||
/// <summary>
|
||||
/// Converts decimal to double (%) and vice versa, e.g. 95f <---> 0.95d
|
||||
/// Converts decimal to double (%) and vice versa, e.g. 95f to 0.95d
|
||||
/// </summary>
|
||||
public class DecimalDoublePercentageConverter : AbstractBindingConverter<double, decimal>
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ using Greenshot.Configuration;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
using log4net;
|
||||
using System.Collections.Generic;
|
||||
|
@ -25,12 +25,12 @@ using System.Drawing;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Graphical filter which can be added to DrawableContainer.
|
||||
/// Subclasses should fulfill INotifyPropertyChanged contract, i.e. call
|
||||
/// OnPropertyChanged whenever a public property has been changed.
|
||||
/// </summary>
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
/// <summary>
|
||||
/// Graphical filter which can be added to DrawableContainer.
|
||||
/// Subclasses should fulfill INotifyPropertyChanged contract, i.e. call
|
||||
/// OnPropertyChanged whenever a public property has been changed.
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public abstract class AbstractFilter : AbstractFieldHolder, IFilter {
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace Greenshot.Drawing {
|
||||
/// To make sure that deleting recalculates, we check the location before every draw.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class StepLabelContainer : DrawableContainer {
|
||||
public sealed class StepLabelContainer : DrawableContainer {
|
||||
[NonSerialized]
|
||||
private StringFormat _stringFormat = new StringFormat();
|
||||
|
||||
@ -103,7 +103,7 @@ namespace Greenshot.Drawing {
|
||||
}
|
||||
base.SwitchParent(newParent);
|
||||
if (newParent != null) {
|
||||
((Surface)Parent).AddStepLabel(this);
|
||||
((Surface)Parent)?.AddStepLabel(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +207,8 @@ namespace Greenshot.Drawing {
|
||||
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
||||
}
|
||||
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
|
||||
using (Font _font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) {
|
||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, _font);
|
||||
using (Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) {
|
||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace Greenshot.Drawing
|
||||
/// <summary>
|
||||
/// Description of Surface.
|
||||
/// </summary>
|
||||
public class Surface : Control, ISurface
|
||||
public sealed class Surface : Control, ISurface
|
||||
{
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(Surface));
|
||||
public static int Count = 0;
|
||||
@ -1609,6 +1609,7 @@ namespace Greenshot.Drawing
|
||||
/// <param name="elementToRemove">Element to remove</param>
|
||||
/// <param name="makeUndoable">flag specifying if the remove needs to be undoable</param>
|
||||
/// <param name="invalidate">flag specifying if an surface invalidate needs to be called</param>
|
||||
/// <param name="generateEvents">false to skip event generation</param>
|
||||
public void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable = true, bool invalidate = true, bool generateEvents = true)
|
||||
{
|
||||
DeselectElement(elementToRemove, generateEvents);
|
||||
@ -1639,7 +1640,6 @@ namespace Greenshot.Drawing
|
||||
/// </summary>
|
||||
/// <param name="elementsToAdd">DrawableContainerList</param>
|
||||
/// <param name="makeUndoable">true if the adding should be undoable</param>
|
||||
/// <param name="invalidate">true if invalidate needs to be called</param>
|
||||
public void AddElements(IDrawableContainerList elementsToAdd, bool makeUndoable = true)
|
||||
{
|
||||
// fix potential issues with iterating a changing list
|
||||
@ -1901,7 +1901,8 @@ namespace Greenshot.Drawing
|
||||
/// <summary>
|
||||
/// Deselect the specified element
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="container">IDrawableContainerList</param>
|
||||
/// <param name="generateEvents">false to skip event generation</param>
|
||||
public void DeselectElement(IDrawableContainer container, bool generateEvents = true)
|
||||
{
|
||||
container.Selected = false;
|
||||
@ -1909,8 +1910,7 @@ namespace Greenshot.Drawing
|
||||
FieldAggregator.UnbindElement(container);
|
||||
if (generateEvents && _movingElementChanged != null)
|
||||
{
|
||||
SurfaceElementEventArgs eventArgs = new SurfaceElementEventArgs();
|
||||
eventArgs.Elements = selectedElements;
|
||||
SurfaceElementEventArgs eventArgs = new SurfaceElementEventArgs {Elements = selectedElements};
|
||||
_movingElementChanged(this, eventArgs);
|
||||
}
|
||||
}
|
||||
@ -1918,7 +1918,7 @@ namespace Greenshot.Drawing
|
||||
/// <summary>
|
||||
/// Deselect the specified elements
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="elements">IDrawableContainerList</param>
|
||||
public void DeselectElements(IDrawableContainerList elements)
|
||||
{
|
||||
if (elements.Count == 0)
|
||||
@ -1951,6 +1951,8 @@ namespace Greenshot.Drawing
|
||||
/// Select the supplied element
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="invalidate">false to skip invalidation</param>
|
||||
/// <param name="generateEvents">false to skip event generation</param>
|
||||
public void SelectElement(IDrawableContainer container, bool invalidate = true, bool generateEvents = true)
|
||||
{
|
||||
if (!selectedElements.Contains(container))
|
||||
|
@ -235,7 +235,7 @@ namespace Greenshot {
|
||||
#endregion
|
||||
|
||||
private void PipetteUsed(object sender, PipetteUsedArgs e) {
|
||||
Color = e.color;
|
||||
Color = e.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ namespace Greenshot {
|
||||
/// with the items from the enumeration
|
||||
/// </summary>
|
||||
/// <param name="comboBox">ComboBox to populate</param>
|
||||
/// <param name="enumeration">Enum to populate with</param>
|
||||
/// <param name="availableValues"></param>
|
||||
/// <param name="selectedValue"></param>
|
||||
private void PopulateComboBox<ET>(ComboBox comboBox, ET[] availableValues, ET selectedValue) where ET : struct {
|
||||
comboBox.Items.Clear();
|
||||
foreach(ET enumValue in availableValues) {
|
||||
|
@ -200,12 +200,11 @@ namespace Greenshot.Forms {
|
||||
}
|
||||
|
||||
|
||||
// <summary>
|
||||
/// <summary>
|
||||
/// adds an item to the select list
|
||||
/// </summary>
|
||||
/// <param name="label">the label to be displayed</param>
|
||||
/// <param name="image">the icon to be displayed</param>
|
||||
/// <param name="selected">whether the item is initially selected</param>
|
||||
/// <param name="isChecked">whether the item is initially checked</param>
|
||||
public void AddItem(string label, Image image, bool isChecked) {
|
||||
AddItem(label, image, null, isChecked);
|
||||
|
@ -209,7 +209,7 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Make Capture for region
|
||||
/// </summary>
|
||||
/// <param name="filename">filename</param>
|
||||
/// <param name="region">Rectangle</param>
|
||||
private void MakeCapture(Rectangle region) {
|
||||
_captureRect = region;
|
||||
MakeCapture();
|
||||
|
@ -75,7 +75,7 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Method to get all the destinations from the plugins
|
||||
/// </summary>
|
||||
/// <returns>List<IDestination></returns>
|
||||
/// <returns>List of IDestination</returns>
|
||||
private static List<IDestination> GetPluginDestinations() {
|
||||
List<IDestination> destinations = new List<IDestination>();
|
||||
foreach (PluginAttribute pluginAttribute in PluginHelper.Instance.Plugins.Keys) {
|
||||
@ -130,6 +130,7 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// A simple helper method which will call ExportCapture for the destination with the specified designation
|
||||
/// </summary>
|
||||
/// <param name="manuallyInitiated"></param>
|
||||
/// <param name="designation"></param>
|
||||
/// <param name="surface"></param>
|
||||
/// <param name="captureDetails"></param>
|
||||
|
@ -125,7 +125,7 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Gets a list of all IE Windows & tabs with the captions of the instances
|
||||
/// </summary>
|
||||
/// <returns>List<KeyValuePair<WindowDetails, string>></returns>
|
||||
/// <returns>List with KeyValuePair of WindowDetails and string</returns>
|
||||
public static List<KeyValuePair<WindowDetails, string>> GetBrowserTabs() {
|
||||
List<IntPtr> ieHandleList = new List<IntPtr>();
|
||||
Dictionary<WindowDetails, List<string>> browserWindows = new Dictionary<WindowDetails, List<string>>();
|
||||
@ -217,7 +217,6 @@ namespace Greenshot.Helpers {
|
||||
/// or return the first if none is supplied.
|
||||
/// </summary>
|
||||
/// <param name="browserWindow">The WindowDetails to get the IHTMLDocument2 for</param>
|
||||
/// <param name="document2">Ref to the IHTMLDocument2 to return</param>
|
||||
/// <returns>The WindowDetails to which the IHTMLDocument2 belongs</returns>
|
||||
private static DocumentContainer CreateDocumentContainer(WindowDetails browserWindow) {
|
||||
DocumentContainer returnDocumentContainer = null;
|
||||
@ -587,8 +586,9 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// This method takes the actual capture of the document (frame)
|
||||
/// </summary>
|
||||
/// <param name="documentContainer"></param>
|
||||
/// <param name="documentContainer">DocumentContainer</param>
|
||||
/// <param name="contentWindowDetails">Needed for referencing the location of the frame</param>
|
||||
/// <param name="graphicsTarget">Graphics</param>
|
||||
/// <returns>Bitmap with the capture</returns>
|
||||
private static void DrawDocument(DocumentContainer documentContainer, WindowDetails contentWindowDetails, Graphics graphicsTarget) {
|
||||
documentContainer.SetAttribute("scroll", 1);
|
||||
|
@ -35,7 +35,7 @@ namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Author: Andrew Baker
|
||||
/// Datum: 10.03.2006
|
||||
/// Available from: http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=71&PostID=1
|
||||
/// Available from <a href="http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=71&PostID=1">here</a>
|
||||
/// </summary>
|
||||
#region Public MapiMailMessage Class
|
||||
|
||||
|
@ -27,15 +27,13 @@ using GreenshotPlugin.UnmanagedHelpers;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using System.IO;
|
||||
/// <summary>
|
||||
/// Create to fix the sometimes wrongly played sample, especially after first start from IDE
|
||||
/// See: http://www.codeproject.com/KB/audio-video/soundplayerbug.aspx?msg=2487569
|
||||
/// </summary>
|
||||
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Description of SoundHelper.
|
||||
/// Create to fix the sometimes wrongly played sample, especially after first start from IDE
|
||||
/// See: http://www.codeproject.com/KB/audio-video/soundplayerbug.aspx?msg=2487569
|
||||
/// </summary>
|
||||
public static class SoundHelper {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(SoundHelper));
|
||||
|
@ -84,7 +84,7 @@
|
||||
</p>
|
||||
<p class="hint">
|
||||
Mit Hilfe der <kbd>Leertaste</kbd> können Sie vom Bereichsmodus in den
|
||||
<a href"#capture-window">Fenstermodus</a> wechseln (und umgekehrt).
|
||||
<a href="#capture-window">Fenstermodus</a> wechseln (und umgekehrt).
|
||||
</p>
|
||||
<p class="hint">
|
||||
Wenn Sie einen exakten Bereich abfotografieren, ist es eventuell einfacher, zuerst
|
||||
|
@ -168,7 +168,7 @@
|
||||
|
||||
<p>
|
||||
Usted puede mover o redimensionar formas existentes después de elegir la
|
||||
<em><b>Herramienta de Selección</b></em> <kbd>ESC</kbd> desde la barra de herramientas.<br
|
||||
<em><b>Herramienta de Selección</b></em> <kbd>ESC</kbd> desde la barra de herramientas.<br />
|
||||
Para cada tipo de elemento hay un conjunto específico de opciones disponibles
|
||||
para cambiar la apariencia del elemento (por ej. grosor de la línea, color
|
||||
de la línea, color de relleno). Usted puede cambiar las opciones para un
|
||||
|
@ -335,7 +335,6 @@
|
||||
<li><em>Stampa con colori inverititi (negativo)</em>: Trasformerà l'immagine in negativo prima di stamparla, utile per esempio quando si stampa un'immagine con testo bianco su sfondo nero (per risparmiare toner o inchiostro).</li>
|
||||
<li><em>Visualizza scelta opzioni di stampa ogni volta che si stampa un'immagine</em>: Permette di scegliere se visualizzare o meno la finestra di scelta opzioni per le stampe successive alla prima.</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<a name="settings-plugins"></a>
|
||||
<h3>Impostazioni Componenti Aggiuntivi</h3>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<!--
|
||||
Note to translator: uncomment entry below to have your effort honored
|
||||
-->
|
||||
<small>Version 0.8<!-- - Русский перевод справки: Андрей Кравцов, www.sapfir.ucoz.ru, 19/03/2012></small>
|
||||
<small>Version 0.8<!-- - Русский перевод справки: Андрей Кравцов, www.sapfir.ucoz.ru, 19/03/2012--></small>
|
||||
|
||||
<h2>Содержание</h2>
|
||||
<ol>
|
||||
|
@ -316,7 +316,7 @@
|
||||
Som standard låter Greenshot dig välja en destination dynamiskt efter en skärmdump, genom att visa en liten meny med olika destinationer att välja mellan. Om du inte vill eller behöver välja mellan destinationer direkt kanske du föredrar att konfigurera Greenshot till att exportera till en eller fler destinationer direkt, utan att visa destinationsväljaren.
|
||||
</p>
|
||||
<p class="hint">
|
||||
Liksom <a href="#editor-export">exportering från redigerarfönstret</a> kommer de visade destinationerna variera baserat på de insticksprogram du har installerade med Greenshot.</a>
|
||||
Liksom <a href="#editor-export">exportering från redigerarfönstret</a> kommer de visade destinationerna variera baserat på de insticksprogram du har installerade med Greenshot.
|
||||
</p>
|
||||
|
||||
<a name="settings-printer"></a>
|
||||
|
@ -19,7 +19,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
||||
|
@ -19,9 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
|
@ -18,9 +18,8 @@
|
||||
* 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;
|
||||
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Configuration;
|
||||
|
||||
namespace Greenshot.Memento {
|
||||
/// <summary>
|
||||
|
@ -31,30 +31,21 @@ namespace GreenshotBoxPlugin {
|
||||
[IniSection("Box", Description = "Greenshot Box Plugin configuration")]
|
||||
public class BoxConfiguration : IniSection {
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
|
||||
[IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send Box link to clipboard.", DefaultValue = "true")]
|
||||
public bool AfterUploadLinkToClipBoard;
|
||||
public bool AfterUploadLinkToClipBoard { get; set; }
|
||||
|
||||
[IniProperty("UseSharedLink", Description = "Use the shared link, instead of the private, on the clipboard", DefaultValue = "True")]
|
||||
public bool UseSharedLink {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool UseSharedLink { get; set; }
|
||||
[IniProperty("FolderId", Description = "Folder ID to upload to, only change if you know what you are doing!", DefaultValue = "0")]
|
||||
public string FolderId {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string FolderId { get; set; }
|
||||
|
||||
[IniProperty("RefreshToken", Description = "Box authorization refresh Token", Encrypted = true)]
|
||||
public string RefreshToken {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Not stored
|
||||
|
@ -105,16 +105,6 @@ namespace GreenshotBoxPlugin {
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Box Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
public void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
@ -26,22 +26,18 @@ using GreenshotConfluencePlugin;
|
||||
using GreenshotConfluencePlugin.confluence;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
/// <summary>
|
||||
/// For details see the Confluence API site
|
||||
/// See: http://confluence.atlassian.com/display/CONFDEV/Remote+API+Specification
|
||||
/// </summary>
|
||||
namespace Confluence {
|
||||
#region transport classes
|
||||
public class Page {
|
||||
public Page(RemotePage page) {
|
||||
id = page.id;
|
||||
Id = page.id;
|
||||
Title = page.title;
|
||||
SpaceKey = page.space;
|
||||
Url = page.url;
|
||||
Content = page.content;
|
||||
}
|
||||
public Page(RemoteSearchResult searchResult, string space) {
|
||||
id = searchResult.id;
|
||||
Id = searchResult.id;
|
||||
Title = searchResult.title;
|
||||
SpaceKey = space;
|
||||
Url = searchResult.url;
|
||||
@ -49,12 +45,12 @@ namespace Confluence {
|
||||
}
|
||||
|
||||
public Page(RemotePageSummary pageSummary) {
|
||||
id = pageSummary.id;
|
||||
Id = pageSummary.id;
|
||||
Title = pageSummary.title;
|
||||
SpaceKey = pageSummary.space;
|
||||
Url =pageSummary.url;
|
||||
}
|
||||
public long id {
|
||||
public long Id {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
@ -91,46 +87,52 @@ namespace Confluence {
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// For details see the Confluence API site
|
||||
/// See: http://confluence.atlassian.com/display/CONFDEV/Remote+API+Specification
|
||||
/// </summary>
|
||||
public class ConfluenceConnector : IDisposable {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||
private const string V2_FAILED = "AXIS";
|
||||
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||
private string credentials = null;
|
||||
private DateTime loggedInTime = DateTime.Now;
|
||||
private bool loggedIn = false;
|
||||
private ConfluenceSoapServiceService confluence;
|
||||
private readonly int timeout;
|
||||
private string url;
|
||||
private readonly Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||
private const string AuthFailedExceptionName = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||
private const string V2Failed = "AXIS";
|
||||
private static readonly ConfluenceConfiguration Config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||
private string _credentials;
|
||||
private DateTime _loggedInTime = DateTime.Now;
|
||||
private bool _loggedIn;
|
||||
private ConfluenceSoapServiceService _confluence;
|
||||
private readonly int _timeout;
|
||||
private string _url;
|
||||
private readonly Cache<string, RemotePage> _pageCache = new Cache<string, RemotePage>(60 * Config.Timeout);
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (confluence != null) {
|
||||
logout();
|
||||
protected void Dispose(bool disposing) {
|
||||
if (_confluence != null) {
|
||||
Logout();
|
||||
}
|
||||
if (disposing) {
|
||||
if (confluence != null) {
|
||||
confluence.Dispose();
|
||||
confluence = null;
|
||||
if (_confluence != null) {
|
||||
_confluence.Dispose();
|
||||
_confluence = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConfluenceConnector(string url, int timeout) {
|
||||
this.timeout = timeout;
|
||||
init(url);
|
||||
_timeout = timeout;
|
||||
Init(url);
|
||||
}
|
||||
|
||||
private void init(string url) {
|
||||
this.url = url;
|
||||
confluence = new ConfluenceSoapServiceService();
|
||||
confluence.Url = url;
|
||||
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||
private void Init(string url) {
|
||||
_url = url;
|
||||
_confluence = new ConfluenceSoapServiceService
|
||||
{
|
||||
Url = url,
|
||||
Proxy = NetworkHelper.CreateProxy(new Uri(url))
|
||||
};
|
||||
}
|
||||
|
||||
~ConfluenceConnector() {
|
||||
@ -141,41 +143,43 @@ namespace Confluence {
|
||||
/// Internal login which catches the exceptions
|
||||
/// </summary>
|
||||
/// <returns>true if login was done sucessfully</returns>
|
||||
private bool doLogin(string user, string password) {
|
||||
private bool DoLogin(string user, string password) {
|
||||
try {
|
||||
credentials = confluence.login(user, password);
|
||||
loggedInTime = DateTime.Now;
|
||||
loggedIn = true;
|
||||
_credentials = _confluence.login(user, password);
|
||||
_loggedInTime = DateTime.Now;
|
||||
_loggedIn = true;
|
||||
} catch (Exception e) {
|
||||
// Check if confluence-v2 caused an error, use v1 instead
|
||||
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
|
||||
init(url.Replace("v2", "v1"));
|
||||
return doLogin(user, password);
|
||||
if (e.Message.Contains(V2Failed) && _url.Contains("v2")) {
|
||||
Init(_url.Replace("v2", "v1"));
|
||||
return DoLogin(user, password);
|
||||
}
|
||||
// check if auth failed
|
||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||
if (e.Message.Contains(AuthFailedExceptionName)) {
|
||||
return false;
|
||||
}
|
||||
// Not an authentication issue
|
||||
loggedIn = false;
|
||||
credentials = null;
|
||||
_loggedIn = false;
|
||||
_credentials = null;
|
||||
e.Data.Add("user", user);
|
||||
e.Data.Add("url", url);
|
||||
e.Data.Add("url", _url);
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
logout();
|
||||
public void Login() {
|
||||
Logout();
|
||||
try {
|
||||
// Get the system name, so the user knows where to login to
|
||||
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||
systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||
dialog.Name = null;
|
||||
string systemName = _url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||
systemName = systemName.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName)
|
||||
{
|
||||
Name = null
|
||||
};
|
||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
if (doLogin(dialog.Name, dialog.Password)) {
|
||||
if (DoLogin(dialog.Name, dialog.Password)) {
|
||||
if (dialog.SaveChecked) {
|
||||
dialog.Confirm(true);
|
||||
}
|
||||
@ -185,7 +189,7 @@ namespace Confluence {
|
||||
dialog.Confirm(false);
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
// For every windows version after XP show an incorrect password baloon
|
||||
dialog.IncorrectPassword = true;
|
||||
@ -195,119 +199,119 @@ namespace Confluence {
|
||||
}
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (credentials != null) {
|
||||
confluence.logout(credentials);
|
||||
credentials = null;
|
||||
loggedIn = false;
|
||||
public void Logout() {
|
||||
if (_credentials != null) {
|
||||
_confluence.logout(_credentials);
|
||||
_credentials = null;
|
||||
_loggedIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCredentials() {
|
||||
if (loggedIn) {
|
||||
if (loggedInTime.AddMinutes(timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
logout();
|
||||
login();
|
||||
private void CheckCredentials() {
|
||||
if (_loggedIn) {
|
||||
if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
Logout();
|
||||
Login();
|
||||
}
|
||||
} else {
|
||||
login();
|
||||
Login();
|
||||
}
|
||||
}
|
||||
|
||||
public bool isLoggedIn {
|
||||
public bool IsLoggedIn {
|
||||
get {
|
||||
return loggedIn;
|
||||
return _loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAttachment(long pageId, string mime, string comment, string filename, IBinaryContainer image) {
|
||||
checkCredentials();
|
||||
public void AddAttachment(long pageId, string mime, string comment, string filename, IBinaryContainer image) {
|
||||
CheckCredentials();
|
||||
RemoteAttachment attachment = new RemoteAttachment();
|
||||
// Comment is ignored, see: http://jira.atlassian.com/browse/CONF-9395
|
||||
attachment.comment = comment;
|
||||
attachment.fileName = filename;
|
||||
attachment.contentType = mime;
|
||||
confluence.addAttachment(credentials, pageId, attachment, image.ToByteArray());
|
||||
_confluence.addAttachment(_credentials, pageId, attachment, image.ToByteArray());
|
||||
}
|
||||
|
||||
public Page getPage(string spaceKey, string pageTitle) {
|
||||
public Page GetPage(string spaceKey, string pageTitle) {
|
||||
RemotePage page = null;
|
||||
string cacheKey = spaceKey + pageTitle;
|
||||
if (pageCache.Contains(cacheKey)) {
|
||||
page = pageCache[cacheKey];
|
||||
if (_pageCache.Contains(cacheKey)) {
|
||||
page = _pageCache[cacheKey];
|
||||
}
|
||||
if (page == null) {
|
||||
checkCredentials();
|
||||
page = confluence.getPage(credentials, spaceKey, pageTitle);
|
||||
pageCache.Add(cacheKey, page);
|
||||
CheckCredentials();
|
||||
page = _confluence.getPage(_credentials, spaceKey, pageTitle);
|
||||
_pageCache.Add(cacheKey, page);
|
||||
}
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public Page getPage(long pageId) {
|
||||
public Page GetPage(long pageId) {
|
||||
RemotePage page = null;
|
||||
string cacheKey = "" + pageId;
|
||||
|
||||
if (pageCache.Contains(cacheKey)) {
|
||||
page = pageCache[cacheKey];
|
||||
if (_pageCache.Contains(cacheKey)) {
|
||||
page = _pageCache[cacheKey];
|
||||
}
|
||||
if (page == null) {
|
||||
checkCredentials();
|
||||
page = confluence.getPage(credentials, pageId);
|
||||
pageCache.Add(cacheKey, page);
|
||||
CheckCredentials();
|
||||
page = _confluence.getPage(_credentials, pageId);
|
||||
_pageCache.Add(cacheKey, page);
|
||||
}
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public Page getSpaceHomepage(Space spaceSummary) {
|
||||
checkCredentials();
|
||||
RemoteSpace spaceDetail = confluence.getSpace(credentials, spaceSummary.Key);
|
||||
RemotePage page = confluence.getPage(credentials, spaceDetail.homePage);
|
||||
public Page GetSpaceHomepage(Space spaceSummary) {
|
||||
CheckCredentials();
|
||||
RemoteSpace spaceDetail = _confluence.getSpace(_credentials, spaceSummary.Key);
|
||||
RemotePage page = _confluence.getPage(_credentials, spaceDetail.homePage);
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public List<Space> getSpaceSummaries() {
|
||||
checkCredentials();
|
||||
RemoteSpaceSummary [] spaces = confluence.getSpaces(credentials);
|
||||
public List<Space> GetSpaceSummaries() {
|
||||
CheckCredentials();
|
||||
RemoteSpaceSummary [] spaces = _confluence.getSpaces(_credentials);
|
||||
List<Space> returnSpaces = new List<Space>();
|
||||
foreach(RemoteSpaceSummary space in spaces) {
|
||||
returnSpaces.Add(new Space(space));
|
||||
}
|
||||
returnSpaces.Sort((x, y) => string.Compare(x.Name, y.Name));
|
||||
returnSpaces.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name));
|
||||
return returnSpaces;
|
||||
}
|
||||
|
||||
public List<Page> getPageChildren(Page parentPage) {
|
||||
checkCredentials();
|
||||
public List<Page> GetPageChildren(Page parentPage) {
|
||||
CheckCredentials();
|
||||
List<Page> returnPages = new List<Page>();
|
||||
RemotePageSummary[] pages = confluence.getChildren(credentials, parentPage.id);
|
||||
RemotePageSummary[] pages = _confluence.getChildren(_credentials, parentPage.Id);
|
||||
foreach(RemotePageSummary page in pages) {
|
||||
returnPages.Add(new Page(page));
|
||||
}
|
||||
returnPages.Sort((x, y) => string.Compare(x.Title, y.Title));
|
||||
returnPages.Sort((x, y) => string.CompareOrdinal(x.Title, y.Title));
|
||||
return returnPages;
|
||||
}
|
||||
|
||||
public List<Page> getPageSummaries(Space space) {
|
||||
checkCredentials();
|
||||
public List<Page> GetPageSummaries(Space space) {
|
||||
CheckCredentials();
|
||||
List<Page> returnPages = new List<Page>();
|
||||
RemotePageSummary[] pages = confluence.getPages(credentials, space.Key);
|
||||
RemotePageSummary[] pages = _confluence.getPages(_credentials, space.Key);
|
||||
foreach(RemotePageSummary page in pages) {
|
||||
returnPages.Add(new Page(page));
|
||||
}
|
||||
returnPages.Sort((x, y) => string.Compare(x.Title, y.Title));
|
||||
returnPages.Sort((x, y) => string.CompareOrdinal(x.Title, y.Title));
|
||||
return returnPages;
|
||||
}
|
||||
|
||||
public List<Page> searchPages(string query, string space) {
|
||||
checkCredentials();
|
||||
public List<Page> SearchPages(string query, string space) {
|
||||
CheckCredentials();
|
||||
List<Page> results = new List<Page>();
|
||||
foreach(RemoteSearchResult searchResult in confluence.search(credentials, query, 20)) {
|
||||
LOG.DebugFormat("Got result of type {0}", searchResult.type);
|
||||
foreach(RemoteSearchResult searchResult in _confluence.search(_credentials, query, 20)) {
|
||||
Log.DebugFormat("Got result of type {0}", searchResult.type);
|
||||
if ("page".Equals(searchResult.type)) {
|
||||
results.Add(new Page(searchResult, space));
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ namespace GreenshotConfluencePlugin {
|
||||
}
|
||||
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
|
||||
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.IsLoggedIn) {
|
||||
yield break;
|
||||
}
|
||||
List<Page> currentPages = ConfluenceUtils.GetCurrentPages();
|
||||
@ -117,7 +117,7 @@ namespace GreenshotConfluencePlugin {
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
// force password check to take place before the pages load
|
||||
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
|
||||
if (!ConfluencePlugin.ConfluenceConnector.IsLoggedIn) {
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ namespace GreenshotConfluencePlugin {
|
||||
Nullable<bool> dialogResult = confluenceUpload.ShowDialog();
|
||||
if (dialogResult.HasValue && dialogResult.Value) {
|
||||
selectedPage = confluenceUpload.SelectedPage;
|
||||
if (confluenceUpload.isOpenPageSelected) {
|
||||
if (confluenceUpload.IsOpenPageSelected) {
|
||||
openPage = false;
|
||||
}
|
||||
filename = confluenceUpload.Filename;
|
||||
@ -164,7 +164,7 @@ namespace GreenshotConfluencePlugin {
|
||||
try {
|
||||
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("confluence", LangKey.communication_wait),
|
||||
delegate() {
|
||||
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
ConfluencePlugin.ConfluenceConnector.AddAttachment(page.Id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
}
|
||||
);
|
||||
LOG.Debug("Uploaded to Confluence.");
|
||||
|
@ -68,8 +68,8 @@ namespace GreenshotConfluencePlugin {
|
||||
CreateConfluenceConntector();
|
||||
}
|
||||
try {
|
||||
if (_confluenceConnector != null && !_confluenceConnector.isLoggedIn) {
|
||||
_confluenceConnector.login();
|
||||
if (_confluenceConnector != null && !_confluenceConnector.IsLoggedIn) {
|
||||
_confluenceConnector.Login();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(Language.GetFormattedString("confluence", LangKey.login_error, e.Message));
|
||||
@ -112,7 +112,7 @@ namespace GreenshotConfluencePlugin {
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Confluence Plugin shutdown.");
|
||||
if (_confluenceConnector != null) {
|
||||
_confluenceConnector.logout();
|
||||
_confluenceConnector.Logout();
|
||||
_confluenceConnector = null;
|
||||
}
|
||||
}
|
||||
@ -131,8 +131,8 @@ namespace GreenshotConfluencePlugin {
|
||||
IniConfig.Save();
|
||||
if (_confluenceConnector != null) {
|
||||
if (!url.Equals(_config.Url)) {
|
||||
if (_confluenceConnector.isLoggedIn) {
|
||||
_confluenceConnector.logout();
|
||||
if (_confluenceConnector.IsLoggedIn) {
|
||||
_confluenceConnector.Logout();
|
||||
}
|
||||
_confluenceConnector = null;
|
||||
}
|
||||
|
@ -50,14 +50,14 @@ namespace GreenshotConfluencePlugin {
|
||||
try {
|
||||
bool pageDouble = false;
|
||||
foreach(Confluence.Page page in pages) {
|
||||
if (page.id == pageId) {
|
||||
if (page.Id == pageId) {
|
||||
pageDouble = true;
|
||||
LOG.DebugFormat("Skipping double page with ID {0}", pageId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pageDouble) {
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.getPage(pageId);
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(pageId);
|
||||
LOG.DebugFormat("Adding page {0}", page.Title);
|
||||
pages.Add(page);
|
||||
}
|
||||
@ -89,7 +89,7 @@ namespace GreenshotConfluencePlugin {
|
||||
}
|
||||
}
|
||||
if (!pageDouble) {
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.getPage(space, title);
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(space, title);
|
||||
LOG.DebugFormat("Adding page {0}", page.Title);
|
||||
pages.Add(page);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Page x:Class="GreenshotConfluencePlugin.ConfluencePagePicker"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:l="clr-namespace:TranslationByMarkupExtension" Loaded="Page_Loaded">
|
||||
Loaded="Page_Loaded">
|
||||
<ListView Name="PageListView" SelectionMode="Single" ItemsSource="{Binding}" SelectionChanged="PageListView_SelectionChanged" Width="480" Height="500">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
@ -44,7 +44,7 @@ namespace GreenshotConfluencePlugin {
|
||||
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
|
||||
confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
|
||||
// Make sure the uploader knows we selected an already opened page
|
||||
confluenceUpload.isOpenPageSelected = true;
|
||||
confluenceUpload.IsOpenPageSelected = true;
|
||||
} else {
|
||||
confluenceUpload.SelectedPage = null;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace GreenshotConfluencePlugin {
|
||||
void doSearch() {
|
||||
string spaceKey = (string)SpaceComboBox.SelectedValue;
|
||||
config.SearchSpaceKey = spaceKey;
|
||||
List<Confluence.Page> searchResult = ConfluencePlugin.ConfluenceConnector.searchPages(searchText.Text, spaceKey);
|
||||
List<Confluence.Page> searchResult = ConfluencePlugin.ConfluenceConnector.SearchPages(searchText.Text, spaceKey);
|
||||
pages.Clear();
|
||||
foreach(Confluence.Page page in searchResult) {
|
||||
pages.Add(page);
|
||||
|
@ -58,7 +58,7 @@ namespace GreenshotConfluencePlugin {
|
||||
LOG.Debug("Loading pages for page: " + page.Title);
|
||||
(new Thread(() => {
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {ShowBusy.Visibility = Visibility.Visible;}));
|
||||
List<Confluence.Page> pages = confluenceConnector.getPageChildren(page);
|
||||
List<Confluence.Page> pages = confluenceConnector.GetPageChildren(page);
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
|
||||
foreach(Confluence.Page childPage in pages) {
|
||||
LOG.Debug("Adding page: " + childPage.Title);
|
||||
@ -105,7 +105,7 @@ namespace GreenshotConfluencePlugin {
|
||||
|
||||
// Get homepage
|
||||
try {
|
||||
Confluence.Page page = confluenceConnector.getSpaceHomepage(space);
|
||||
Confluence.Page page = confluenceConnector.GetSpaceHomepage(space);
|
||||
TreeViewItem pageTreeViewItem = new TreeViewItem();
|
||||
pageTreeViewItem.Header = page.Title;
|
||||
pageTreeViewItem.Tag = page;
|
||||
|
@ -29,56 +29,56 @@ namespace GreenshotConfluencePlugin {
|
||||
/// Interaction logic for ConfluenceUpload.xaml
|
||||
/// </summary>
|
||||
public partial class ConfluenceUpload : Window {
|
||||
private Page pickerPage = null;
|
||||
private Page _pickerPage;
|
||||
public Page PickerPage {
|
||||
get {
|
||||
if (pickerPage == null) {
|
||||
if (_pickerPage == null) {
|
||||
List<Confluence.Page> pages = ConfluenceUtils.GetCurrentPages();
|
||||
if (pages != null && pages.Count > 0) {
|
||||
pickerPage = new ConfluencePagePicker(this, pages);
|
||||
_pickerPage = new ConfluencePagePicker(this, pages);
|
||||
}
|
||||
}
|
||||
return pickerPage;
|
||||
return _pickerPage;
|
||||
}
|
||||
}
|
||||
|
||||
private Page searchPage = null;
|
||||
private Page _searchPage;
|
||||
public Page SearchPage {
|
||||
get {
|
||||
if (searchPage == null) {
|
||||
searchPage = new ConfluenceSearch(this);
|
||||
if (_searchPage == null) {
|
||||
_searchPage = new ConfluenceSearch(this);
|
||||
}
|
||||
return searchPage;
|
||||
return _searchPage;
|
||||
}
|
||||
}
|
||||
|
||||
private Page browsePage = null;
|
||||
private Page _browsePage;
|
||||
public Page BrowsePage {
|
||||
get {
|
||||
if (browsePage == null) {
|
||||
browsePage = new ConfluenceTreePicker(this);
|
||||
if (_browsePage == null) {
|
||||
_browsePage = new ConfluenceTreePicker(this);
|
||||
}
|
||||
return browsePage;
|
||||
return _browsePage;
|
||||
}
|
||||
}
|
||||
|
||||
private Confluence.Page selectedPage = null;
|
||||
private Confluence.Page _selectedPage;
|
||||
public Confluence.Page SelectedPage {
|
||||
get {
|
||||
return selectedPage;
|
||||
return _selectedPage;
|
||||
}
|
||||
set {
|
||||
selectedPage = value;
|
||||
if (selectedPage != null) {
|
||||
_selectedPage = value;
|
||||
if (_selectedPage != null) {
|
||||
Upload.IsEnabled = true;
|
||||
} else {
|
||||
Upload.IsEnabled = false;
|
||||
}
|
||||
isOpenPageSelected = false;
|
||||
IsOpenPageSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isOpenPageSelected {
|
||||
public bool IsOpenPageSelected {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
@ -87,39 +87,39 @@ namespace GreenshotConfluencePlugin {
|
||||
set;
|
||||
}
|
||||
|
||||
private static DateTime lastLoad = DateTime.Now;
|
||||
private static List<Confluence.Space> spaces;
|
||||
private static DateTime _lastLoad = DateTime.Now;
|
||||
private static List<Confluence.Space> _spaces;
|
||||
public List<Confluence.Space> Spaces {
|
||||
get {
|
||||
updateSpaces();
|
||||
while (spaces == null) {
|
||||
UpdateSpaces();
|
||||
while (_spaces == null) {
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
return spaces;
|
||||
return _spaces;
|
||||
}
|
||||
}
|
||||
|
||||
public ConfluenceUpload(string filename) {
|
||||
Filename = filename;
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
updateSpaces();
|
||||
DataContext = this;
|
||||
UpdateSpaces();
|
||||
if (PickerPage == null) {
|
||||
PickerTab.Visibility = Visibility.Collapsed;
|
||||
SearchTab.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSpaces() {
|
||||
if (spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(lastLoad) > 0) {
|
||||
void UpdateSpaces() {
|
||||
if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) {
|
||||
// Reset
|
||||
spaces = null;
|
||||
_spaces = null;
|
||||
}
|
||||
// Check if load is needed
|
||||
if (spaces == null) {
|
||||
if (_spaces == null) {
|
||||
(new Thread(() => {
|
||||
spaces = ConfluencePlugin.ConfluenceConnector.getSpaceSummaries();
|
||||
lastLoad = DateTime.Now;
|
||||
_spaces = ConfluencePlugin.ConfluenceConnector.GetSpaceSummaries();
|
||||
_lastLoad = DateTime.Now;
|
||||
}) { Name = "Loading spaces for confluence"}).Start();
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,5 @@
|
||||
/// <param name="key">The key.</param>
|
||||
/// <returns></returns>
|
||||
object Translate(string key);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available languages.
|
||||
/// </summary>
|
||||
/// <value>The available languages.</value>
|
||||
//IEnumerable<CultureInfo> Languages { get; }
|
||||
}
|
||||
}
|
||||
|
@ -34,20 +34,5 @@ namespace TranslationByMarkupExtension {
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITranslationProvider Members
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="ITranslationProvider.AvailableLanguages" />
|
||||
/// </summary>
|
||||
/*public IEnumerable<CultureInfo> Languages {
|
||||
get {
|
||||
foreach (LanguageFile supportedLanguage in Language.SupportedLanguages) {
|
||||
yield return new CultureInfo(supportedLanguage.Ietf);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ namespace GreenshotDropboxPlugin {
|
||||
/// This is the Dropbox base code
|
||||
/// </summary>
|
||||
public class DropboxPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxPlugin));
|
||||
private static DropboxPluginConfiguration config;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(DropboxPlugin));
|
||||
private static DropboxPluginConfiguration _config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost host;
|
||||
private ComponentResourceManager resources;
|
||||
private ToolStripMenuItem itemPlugInConfig;
|
||||
private IGreenshotHost _host;
|
||||
private ComponentResourceManager _resources;
|
||||
private ToolStripMenuItem _itemPlugInConfig;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
@ -48,9 +48,9 @@ namespace GreenshotDropboxPlugin {
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Dispose();
|
||||
itemPlugInConfig = null;
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Dispose();
|
||||
_itemPlugInConfig = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,56 +70,48 @@ namespace GreenshotDropboxPlugin {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
host = (IGreenshotHost)pluginHost;
|
||||
_host = pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
// Register configuration (don't need the configuration itself)
|
||||
config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(DropboxPlugin));
|
||||
_config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(DropboxPlugin));
|
||||
|
||||
itemPlugInConfig = new ToolStripMenuItem();
|
||||
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
|
||||
itemPlugInConfig.Tag = host;
|
||||
itemPlugInConfig.Click += new EventHandler(ConfigMenuClick);
|
||||
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
|
||||
_itemPlugInConfig = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.GetString("dropbox", LangKey.Configure),
|
||||
Tag = _host,
|
||||
Image = (Image)_resources.GetObject("Dropbox")
|
||||
};
|
||||
_itemPlugInConfig.Click += ConfigMenuClick;
|
||||
|
||||
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
|
||||
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnLanguageChanged(object sender, EventArgs e) {
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Dropbox Plugin shutdown.");
|
||||
Log.Debug("Dropbox Plugin shutdown.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Dropbox Plugin!");
|
||||
Shutdown();
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
public void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
||||
config.ShowConfigDialog();
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -127,12 +119,12 @@ namespace GreenshotDropboxPlugin {
|
||||
/// </summary>
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl) {
|
||||
uploadUrl = null;
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, false);
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
|
||||
try {
|
||||
string dropboxUrl = null;
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("dropbox", LangKey.communication_wait),
|
||||
delegate() {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
|
||||
dropboxUrl = DropboxUtils.UploadToDropbox(surfaceToUpload, outputSettings, filename);
|
||||
}
|
||||
);
|
||||
@ -142,7 +134,7 @@ namespace GreenshotDropboxPlugin {
|
||||
uploadUrl = dropboxUrl;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
Log.Error(e);
|
||||
MessageBox.Show(Language.GetString("dropbox", LangKey.upload_failure) + " " + e.Message);
|
||||
return false;
|
||||
}
|
||||
|
@ -30,19 +30,19 @@ namespace GreenshotDropboxPlugin {
|
||||
[IniSection("Dropbox", Description = "Greenshot Dropbox Plugin configuration")]
|
||||
public class DropboxPluginConfiguration : IniSection {
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
|
||||
[IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send Dropbox link to clipboard.", DefaultValue = "true")]
|
||||
public bool AfterUploadLinkToClipBoard;
|
||||
public bool AfterUploadLinkToClipBoard { get; set; }
|
||||
|
||||
[IniProperty("DropboxToken", Description = "The Dropbox token", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string DropboxToken;
|
||||
public string DropboxToken { get; set; }
|
||||
[IniProperty("DropboxTokenSecret", Description = "The Dropbox token secret", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string DropboxTokenSecret;
|
||||
|
||||
public string DropboxTokenSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A form for token
|
||||
/// </summary>
|
||||
|
@ -31,34 +31,34 @@ namespace ExternalCommand {
|
||||
[IniSection("ExternalCommand", Description="Greenshot ExternalCommand Plugin configuration")]
|
||||
public class ExternalCommandConfiguration : IniSection {
|
||||
[IniProperty("Commands", Description="The commands that are available.")]
|
||||
public List<string> commands;
|
||||
public List<string> Commands { get; set; }
|
||||
|
||||
[IniProperty("RedirectStandardError", Description = "Redirect the standard error of all external commands, used to output as warning to the greenshot.log.", DefaultValue = "true")]
|
||||
public bool RedirectStandardError;
|
||||
public bool RedirectStandardError { get; set; }
|
||||
|
||||
[IniProperty("RedirectStandardOutput", Description = "Redirect the standard output of all external commands, used for different other functions (more below).", DefaultValue = "true")]
|
||||
public bool RedirectStandardOutput;
|
||||
public bool RedirectStandardOutput { get; set; }
|
||||
|
||||
[IniProperty("ShowStandardOutputInLog", Description = "Depends on 'RedirectStandardOutput': Show standard output of all external commands to the Greenshot log, this can be usefull for debugging.", DefaultValue = "false")]
|
||||
public bool ShowStandardOutputInLog;
|
||||
public bool ShowStandardOutputInLog { get; set; }
|
||||
|
||||
[IniProperty("ParseForUri", Description = "Depends on 'RedirectStandardOutput': Parse the output and take the first found URI, if a URI is found than clicking on the notify bubble goes there.", DefaultValue = "true")]
|
||||
public bool ParseOutputForUri;
|
||||
public bool ParseOutputForUri { get; set; }
|
||||
|
||||
[IniProperty("OutputToClipboard", Description = "Depends on 'RedirectStandardOutput': Place the standard output on the clipboard.", DefaultValue = "false")]
|
||||
public bool OutputToClipboard;
|
||||
public bool OutputToClipboard { get; set; }
|
||||
|
||||
[IniProperty("UriToClipboard", Description = "Depends on 'RedirectStandardOutput' & 'ParseForUri': If an URI is found in the standard input, place it on the clipboard. (This overwrites the output from OutputToClipboard setting.)", DefaultValue = "true")]
|
||||
public bool UriToClipboard;
|
||||
public bool UriToClipboard { get; set; }
|
||||
|
||||
[IniProperty("Commandline", Description="The commandline for the output command.")]
|
||||
public Dictionary<string, string> commandlines;
|
||||
public Dictionary<string, string> commandlines { get; set; }
|
||||
|
||||
[IniProperty("Argument", Description="The arguments for the output command.")]
|
||||
public Dictionary<string, string> arguments;
|
||||
public Dictionary<string, string> arguments { get; set; }
|
||||
|
||||
[IniProperty("RunInbackground", Description = "Should the command be started in the background.")]
|
||||
public Dictionary<string, bool> runInbackground;
|
||||
public Dictionary<string, bool> runInbackground { get; set; }
|
||||
|
||||
private const string MSPAINT = "MS Paint";
|
||||
private static readonly string paintPath;
|
||||
|
@ -55,7 +55,7 @@ namespace ExternalCommand {
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
foreach(string command in config.commands) {
|
||||
foreach(string command in config.Commands) {
|
||||
yield return new ExternalCommandDestination(command);
|
||||
}
|
||||
}
|
||||
@ -96,15 +96,14 @@ namespace ExternalCommand {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
LOG.DebugFormat("Initialize called of {0}", myAttributes.Name);
|
||||
|
||||
List<string> commandsToDelete = new List<string>();
|
||||
// Check configuration
|
||||
foreach(string command in config.commands) {
|
||||
foreach(string command in config.Commands) {
|
||||
if (!isCommandValid(command)) {
|
||||
commandsToDelete.Add(command);
|
||||
}
|
||||
@ -115,18 +114,17 @@ namespace ExternalCommand {
|
||||
config.runInbackground.Remove(command);
|
||||
config.commandlines.Remove(command);
|
||||
config.arguments.Remove(command);
|
||||
config.commands.Remove(command);
|
||||
config.Commands.Remove(command);
|
||||
}
|
||||
|
||||
_host = pluginHost;
|
||||
_myAttributes = myAttributes;
|
||||
|
||||
|
||||
_itemPlugInRoot = new ToolStripMenuItem();
|
||||
_itemPlugInRoot.Tag = _host;
|
||||
_itemPlugInRoot = new ToolStripMenuItem {Tag = _host};
|
||||
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
|
||||
OnLanguageChanged(this, null);
|
||||
_itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
|
||||
_itemPlugInRoot.Click += ConfigMenuClick;
|
||||
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
|
@ -56,7 +56,7 @@ namespace ExternalCommand {
|
||||
void ButtonDeleteClick(object sender, EventArgs e) {
|
||||
foreach(ListViewItem item in listView1.SelectedItems) {
|
||||
string commando = item.Tag as string;
|
||||
config.commands.Remove(commando);
|
||||
config.Commands.Remove(commando);
|
||||
config.commandlines.Remove(commando);
|
||||
config.arguments.Remove(commando);
|
||||
}
|
||||
@ -65,12 +65,12 @@ namespace ExternalCommand {
|
||||
|
||||
void UpdateView() {
|
||||
listView1.Items.Clear();
|
||||
if(config.commands != null) {
|
||||
if(config.Commands != null) {
|
||||
listView1.ListViewItemSorter = new ListviewComparer();
|
||||
ImageList imageList = new ImageList();
|
||||
listView1.SmallImageList = imageList;
|
||||
int imageNr = 0;
|
||||
foreach(string commando in config.commands) {
|
||||
foreach(string commando in config.Commands) {
|
||||
ListViewItem item = null;
|
||||
Image iconForExe = IconCache.IconForCommand(commando);
|
||||
if(iconForExe != null) {
|
||||
|
@ -47,7 +47,7 @@ namespace ExternalCommand {
|
||||
textBox_name.Text = commando;
|
||||
textBox_commandline.Text = config.commandlines[commando];
|
||||
textBox_arguments.Text = config.arguments[commando];
|
||||
_commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
|
||||
_commandIndex = config.Commands.FindIndex(delegate(string s) { return s == commando; });
|
||||
} else {
|
||||
textBox_arguments.Text = "\"{0}\"";
|
||||
}
|
||||
@ -59,13 +59,13 @@ namespace ExternalCommand {
|
||||
string commandLine = textBox_commandline.Text;
|
||||
string arguments = textBox_arguments.Text;
|
||||
if(_commando != null) {
|
||||
config.commands[_commandIndex] = commandName;
|
||||
config.Commands[_commandIndex] = commandName;
|
||||
config.commandlines.Remove(_commando);
|
||||
config.commandlines.Add(commandName, commandLine);
|
||||
config.arguments.Remove(_commando);
|
||||
config.arguments.Add(commandName, arguments);
|
||||
} else {
|
||||
config.commands.Add(commandName);
|
||||
config.Commands.Add(commandName);
|
||||
config.commandlines.Add(commandName, commandLine);
|
||||
config.arguments.Add(commandName, arguments);
|
||||
}
|
||||
@ -112,7 +112,7 @@ namespace ExternalCommand {
|
||||
buttonOk.Enabled = false;
|
||||
}
|
||||
// Check if commandname is unique
|
||||
if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
|
||||
if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.Commands.Contains(textBox_name.Text)) {
|
||||
buttonOk.Enabled = false;
|
||||
textBox_name.BackColor = Color.Red;
|
||||
}
|
||||
|
@ -34,36 +34,36 @@ namespace GreenshotFlickrPlugin {
|
||||
[IniSection("Flickr", Description = "Greenshot Flickr Plugin configuration")]
|
||||
public class FlickrConfiguration : IniSection {
|
||||
[IniProperty("flickrIsPublic", Description = "IsPublic.", DefaultValue = "true")]
|
||||
public bool IsPublic;
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
[IniProperty("flickrIsFamily", Description = "IsFamily.", DefaultValue = "true")]
|
||||
public bool IsFamily;
|
||||
public bool IsFamily { get; set; }
|
||||
|
||||
[IniProperty("flickrIsFriend", Description = "IsFriend.", DefaultValue = "true")]
|
||||
public bool IsFriend;
|
||||
public bool IsFriend { get; set; }
|
||||
|
||||
[IniProperty("SafetyLevel", Description = "Safety level", DefaultValue = "Safe")]
|
||||
public SafetyLevel SafetyLevel;
|
||||
public SafetyLevel SafetyLevel { get; set; }
|
||||
|
||||
[IniProperty("HiddenFromSearch", Description = "Hidden from search", DefaultValue = "false")]
|
||||
public bool HiddenFromSearch;
|
||||
|
||||
public bool HiddenFromSearch { get; set; }
|
||||
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
|
||||
[IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send flickr link to clipboard.", DefaultValue = "true")]
|
||||
public bool AfterUploadLinkToClipBoard;
|
||||
public bool AfterUploadLinkToClipBoard { get; set; }
|
||||
|
||||
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
|
||||
public bool UsePageLink;
|
||||
|
||||
public bool UsePageLink { get; set; }
|
||||
|
||||
[IniProperty("FlickrToken", Description = "The Flickr token", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string FlickrToken;
|
||||
public string FlickrToken { get; set; }
|
||||
[IniProperty("FlickrTokenSecret", Description = "The Flickr token secret", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string FlickrTokenSecret;
|
||||
public string FlickrTokenSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A form for token
|
||||
|
@ -111,16 +111,6 @@ namespace GreenshotFlickrPlugin
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Flickr Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
public void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
@ -31,20 +31,20 @@ namespace GreenshotImgurPlugin {
|
||||
/// <summary>
|
||||
/// Description of ImgurHistory.
|
||||
/// </summary>
|
||||
public partial class ImgurHistory : ImgurForm {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
|
||||
private readonly GreenshotColumnSorter columnSorter;
|
||||
private static readonly ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||
private static ImgurHistory instance;
|
||||
public sealed partial class ImgurHistory : ImgurForm {
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurHistory));
|
||||
private readonly GreenshotColumnSorter _columnSorter;
|
||||
private static readonly ImgurConfiguration Config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||
private static ImgurHistory _instance;
|
||||
|
||||
public static void ShowHistory() {
|
||||
// Make sure the history is loaded, will be done only once
|
||||
ImgurUtils.LoadHistory();
|
||||
if (instance == null) {
|
||||
instance = new ImgurHistory();
|
||||
if (_instance == null) {
|
||||
_instance = new ImgurHistory();
|
||||
}
|
||||
instance.Show();
|
||||
instance.redraw();
|
||||
_instance.Show();
|
||||
_instance.Redraw();
|
||||
}
|
||||
|
||||
private ImgurHistory() {
|
||||
@ -56,21 +56,21 @@ namespace GreenshotImgurPlugin {
|
||||
AcceptButton = finishedButton;
|
||||
CancelButton = finishedButton;
|
||||
// Init sorting
|
||||
columnSorter = new GreenshotColumnSorter();
|
||||
listview_imgur_uploads.ListViewItemSorter = columnSorter;
|
||||
columnSorter.SortColumn = 3;
|
||||
columnSorter.Order = SortOrder.Descending;
|
||||
redraw();
|
||||
_columnSorter = new GreenshotColumnSorter();
|
||||
listview_imgur_uploads.ListViewItemSorter = _columnSorter;
|
||||
_columnSorter.SortColumn = 3;
|
||||
_columnSorter.Order = SortOrder.Descending;
|
||||
Redraw();
|
||||
if (listview_imgur_uploads.Items.Count > 0) {
|
||||
listview_imgur_uploads.Items[0].Selected = true;
|
||||
}
|
||||
ApplyLanguage();
|
||||
if (config.Credits > 0) {
|
||||
Text = Text + " (" + config.Credits + " credits)";
|
||||
if (Config.Credits > 0) {
|
||||
Text = Text + " (" + Config.Credits + " credits)";
|
||||
}
|
||||
}
|
||||
|
||||
private void redraw() {
|
||||
private void Redraw() {
|
||||
// Should fix Bug #3378699
|
||||
pictureBox1.Image = pictureBox1.ErrorImage;
|
||||
listview_imgur_uploads.BeginUpdate();
|
||||
@ -80,7 +80,7 @@ namespace GreenshotImgurPlugin {
|
||||
foreach (string column in columns) {
|
||||
listview_imgur_uploads.Columns.Add(column);
|
||||
}
|
||||
foreach (ImgurInfo imgurInfo in config.runtimeImgurHistory.Values) {
|
||||
foreach (ImgurInfo imgurInfo in Config.runtimeImgurHistory.Values) {
|
||||
ListViewItem item = new ListViewItem(imgurInfo.Hash);
|
||||
item.Tag = imgurInfo;
|
||||
item.SubItems.Add(imgurInfo.Title);
|
||||
@ -132,14 +132,14 @@ namespace GreenshotImgurPlugin {
|
||||
}
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
LOG.Warn("Problem communicating with Imgur: ", ex);
|
||||
Log.Warn("Problem communicating with Imgur: ", ex);
|
||||
}
|
||||
|
||||
imgurInfo.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
private void ClipboardButtonClick(object sender, EventArgs e) {
|
||||
@ -147,7 +147,7 @@ namespace GreenshotImgurPlugin {
|
||||
if (listview_imgur_uploads.SelectedItems != null && listview_imgur_uploads.SelectedItems.Count > 0) {
|
||||
for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) {
|
||||
ImgurInfo imgurInfo = (ImgurInfo)listview_imgur_uploads.SelectedItems[i].Tag;
|
||||
if (config.UsePageLink) {
|
||||
if (Config.UsePageLink) {
|
||||
links.AppendLine(imgurInfo.Page);
|
||||
} else {
|
||||
links.AppendLine(imgurInfo.Original);
|
||||
@ -160,10 +160,10 @@ namespace GreenshotImgurPlugin {
|
||||
private void ClearHistoryButtonClick(object sender, EventArgs e) {
|
||||
DialogResult result = MessageBox.Show(Language.GetString("imgur", LangKey.clear_question), "Imgur", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes) {
|
||||
config.runtimeImgurHistory.Clear();
|
||||
config.ImgurUploadHistory.Clear();
|
||||
Config.runtimeImgurHistory.Clear();
|
||||
Config.ImgurUploadHistory.Clear();
|
||||
IniConfig.Save();
|
||||
redraw();
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,17 +183,17 @@ namespace GreenshotImgurPlugin {
|
||||
|
||||
private void listview_imgur_uploads_ColumnClick(object sender, ColumnClickEventArgs e) {
|
||||
// Determine if clicked column is already the column that is being sorted.
|
||||
if (e.Column == columnSorter.SortColumn) {
|
||||
if (e.Column == _columnSorter.SortColumn) {
|
||||
// Reverse the current sort direction for this column.
|
||||
if (columnSorter.Order == SortOrder.Ascending) {
|
||||
columnSorter.Order = SortOrder.Descending;
|
||||
if (_columnSorter.Order == SortOrder.Ascending) {
|
||||
_columnSorter.Order = SortOrder.Descending;
|
||||
} else {
|
||||
columnSorter.Order = SortOrder.Ascending;
|
||||
_columnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
} else {
|
||||
// Set the column number that is to be sorted; default to ascending.
|
||||
columnSorter.SortColumn = e.Column;
|
||||
columnSorter.Order = SortOrder.Ascending;
|
||||
_columnSorter.SortColumn = e.Column;
|
||||
_columnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
// Perform the sort with these new sort options.
|
||||
@ -203,7 +203,7 @@ namespace GreenshotImgurPlugin {
|
||||
|
||||
void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
instance = null;
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,44 +33,44 @@ namespace GreenshotImgurPlugin {
|
||||
[IniSection("Imgur", Description="Greenshot Imgur Plugin configuration")]
|
||||
public class ImgurConfiguration : IniSection {
|
||||
[IniProperty("ImgurApi3Url", Description = "Url to Imgur system.", DefaultValue = "https://api.imgur.com/3")]
|
||||
public string ImgurApi3Url;
|
||||
public string ImgurApi3Url { get; set; }
|
||||
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
|
||||
public bool UploadReduceColors;
|
||||
public bool UploadReduceColors { get; set; }
|
||||
[IniProperty("CopyLinkToClipboard", Description = "Copy the link, which one is controlled by the UsePageLink, on the clipboard", DefaultValue = "True")]
|
||||
public bool CopyLinkToClipboard;
|
||||
public bool CopyLinkToClipboard { get; set; }
|
||||
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
|
||||
public bool UsePageLink;
|
||||
public bool UsePageLink { get; set; }
|
||||
[IniProperty("AnonymousAccess", Description = "Use anonymous access to Imgur", DefaultValue="true")]
|
||||
public bool AnonymousAccess;
|
||||
public bool AnonymousAccess { get; set; }
|
||||
|
||||
[IniProperty("RefreshToken", Description = "Imgur refresh Token", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string RefreshToken;
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// AccessToken, not stored
|
||||
/// </summary>
|
||||
public string AccessToken;
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// AccessTokenExpires, not stored
|
||||
/// </summary>
|
||||
public DateTimeOffset AccessTokenExpires;
|
||||
public DateTimeOffset AccessTokenExpires { get; set; }
|
||||
|
||||
[IniProperty("AddTitle", Description = "Is the title passed on to Imgur", DefaultValue = "False")]
|
||||
public bool AddTitle;
|
||||
public bool AddTitle { get; set; }
|
||||
[IniProperty("AddFilename", Description = "Is the filename passed on to Imgur", DefaultValue = "False")]
|
||||
public bool AddFilename;
|
||||
public bool AddFilename { get; set; }
|
||||
[IniProperty("FilenamePattern", Description = "Filename for the Imgur upload", DefaultValue = "${capturetime:d\"yyyyMMdd-HHmm\"}")]
|
||||
public string FilenamePattern;
|
||||
public string FilenamePattern { get; set; }
|
||||
|
||||
[IniProperty("ImgurUploadHistory", Description="Imgur upload history (ImgurUploadHistory.hash=deleteHash)")]
|
||||
public Dictionary<string, string> ImgurUploadHistory;
|
||||
|
||||
public Dictionary<string, string> ImgurUploadHistory { get; set; }
|
||||
|
||||
// Not stored, only run-time!
|
||||
public Dictionary<string, ImgurInfo> runtimeImgurHistory = new Dictionary<string, ImgurInfo>();
|
||||
public int Credits {
|
||||
|
@ -35,13 +35,13 @@ namespace GreenshotImgurPlugin {
|
||||
/// This is the ImgurPlugin code
|
||||
/// </summary>
|
||||
public class ImgurPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurPlugin));
|
||||
private static ImgurConfiguration config;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurPlugin));
|
||||
private static ImgurConfiguration _config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost host;
|
||||
private ComponentResourceManager resources;
|
||||
private ToolStripMenuItem historyMenuItem = null;
|
||||
private ToolStripMenuItem itemPlugInConfig;
|
||||
private IGreenshotHost _host;
|
||||
private ComponentResourceManager _resources;
|
||||
private ToolStripMenuItem _historyMenuItem;
|
||||
private ToolStripMenuItem _itemPlugInConfig;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
@ -50,13 +50,13 @@ namespace GreenshotImgurPlugin {
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (historyMenuItem != null) {
|
||||
historyMenuItem.Dispose();
|
||||
historyMenuItem = null;
|
||||
if (_historyMenuItem != null) {
|
||||
_historyMenuItem.Dispose();
|
||||
_historyMenuItem = null;
|
||||
}
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Dispose();
|
||||
itemPlugInConfig = null;
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Dispose();
|
||||
_itemPlugInConfig = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,114 +75,112 @@ namespace GreenshotImgurPlugin {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
host = (IGreenshotHost)pluginHost;
|
||||
_host = pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
// Get configuration
|
||||
config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(ImgurPlugin));
|
||||
|
||||
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur");
|
||||
itemPlugInRoot.Image = (Image)resources.GetObject("Imgur");
|
||||
_config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(ImgurPlugin));
|
||||
|
||||
historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history));
|
||||
historyMenuItem.Tag = host;
|
||||
historyMenuItem.Click += delegate {
|
||||
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur")
|
||||
{
|
||||
Image = (Image) _resources.GetObject("Imgur")
|
||||
};
|
||||
|
||||
_historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history))
|
||||
{
|
||||
Tag = _host
|
||||
};
|
||||
_historyMenuItem.Click += delegate {
|
||||
ImgurHistory.ShowHistory();
|
||||
};
|
||||
itemPlugInRoot.DropDownItems.Add(historyMenuItem);
|
||||
itemPlugInRoot.DropDownItems.Add(_historyMenuItem);
|
||||
|
||||
itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure));
|
||||
itemPlugInConfig.Tag = host;
|
||||
itemPlugInConfig.Click += delegate {
|
||||
config.ShowConfigDialog();
|
||||
_itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure))
|
||||
{
|
||||
Tag = _host
|
||||
};
|
||||
itemPlugInRoot.DropDownItems.Add(itemPlugInConfig);
|
||||
_itemPlugInConfig.Click += delegate {
|
||||
_config.ShowConfigDialog();
|
||||
};
|
||||
itemPlugInRoot.DropDownItems.Add(_itemPlugInConfig);
|
||||
|
||||
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
|
||||
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
||||
PluginUtils.AddToContextMenu(_host, itemPlugInRoot);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
|
||||
// retrieve history in the background
|
||||
Thread backgroundTask = new Thread (new ThreadStart(CheckHistory));
|
||||
backgroundTask.Name = "Imgur History";
|
||||
backgroundTask.IsBackground = true;
|
||||
Thread backgroundTask = new Thread(CheckHistory)
|
||||
{
|
||||
Name = "Imgur History",
|
||||
IsBackground = true
|
||||
};
|
||||
backgroundTask.SetApartmentState(ApartmentState.STA);
|
||||
backgroundTask.Start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnLanguageChanged(object sender, EventArgs e) {
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Text = Language.GetString("imgur", LangKey.configure);
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Text = Language.GetString("imgur", LangKey.configure);
|
||||
}
|
||||
if (historyMenuItem != null) {
|
||||
historyMenuItem.Text = Language.GetString("imgur", LangKey.history);
|
||||
if (_historyMenuItem != null) {
|
||||
_historyMenuItem.Text = Language.GetString("imgur", LangKey.history);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckHistory() {
|
||||
try {
|
||||
ImgurUtils.LoadHistory();
|
||||
host.GreenshotForm.BeginInvoke((MethodInvoker)delegate {
|
||||
if (config.ImgurUploadHistory.Count > 0) {
|
||||
historyMenuItem.Enabled = true;
|
||||
_host.GreenshotForm.BeginInvoke((MethodInvoker)delegate {
|
||||
if (_config.ImgurUploadHistory.Count > 0) {
|
||||
_historyMenuItem.Enabled = true;
|
||||
} else {
|
||||
historyMenuItem.Enabled = false;
|
||||
_historyMenuItem.Enabled = false;
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Error loading history", ex);
|
||||
};
|
||||
Log.Error("Error loading history", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Imgur Plugin shutdown.");
|
||||
Language.LanguageChanged -= new LanguageChangedHandler(OnLanguageChanged);
|
||||
Log.Debug("Imgur Plugin shutdown.");
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Imgur Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload the capture to imgur
|
||||
/// </summary>
|
||||
/// <param name="captureDetails"></param>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="uploadURL">out string for the url</param>
|
||||
/// <param name="captureDetails">ICaptureDetails</param>
|
||||
/// <param name="surfaceToUpload">ISurface</param>
|
||||
/// <param name="uploadUrl">out string for the url</param>
|
||||
/// <returns>true if the upload succeeded</returns>
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadURL) {
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl) {
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors);
|
||||
try {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(config.FilenamePattern, config.UploadFormat, captureDetails));
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_config.FilenamePattern, _config.UploadFormat, captureDetails));
|
||||
ImgurInfo imgurInfo = null;
|
||||
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait("Imgur plug-in", Language.GetString("imgur", LangKey.communication_wait),
|
||||
delegate() {
|
||||
delegate
|
||||
{
|
||||
imgurInfo = ImgurUtils.UploadToImgur(surfaceToUpload, outputSettings, captureDetails.Title, filename);
|
||||
if (imgurInfo != null && config.AnonymousAccess) {
|
||||
LOG.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
|
||||
config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
|
||||
config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
|
||||
if (imgurInfo != null && _config.AnonymousAccess) {
|
||||
Log.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
|
||||
_config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
|
||||
_config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
|
||||
CheckHistory();
|
||||
}
|
||||
}
|
||||
@ -195,34 +193,34 @@ namespace GreenshotImgurPlugin {
|
||||
}
|
||||
IniConfig.Save();
|
||||
|
||||
if (config.UsePageLink)
|
||||
if (_config.UsePageLink)
|
||||
{
|
||||
uploadURL = imgurInfo.Page;
|
||||
uploadUrl = imgurInfo.Page;
|
||||
}
|
||||
else
|
||||
{
|
||||
uploadURL = imgurInfo.Original;
|
||||
uploadUrl = imgurInfo.Original;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(uploadURL) && config.CopyLinkToClipboard)
|
||||
if (!string.IsNullOrEmpty(uploadUrl) && _config.CopyLinkToClipboard)
|
||||
{
|
||||
try
|
||||
{
|
||||
ClipboardHelper.SetClipboardData(uploadURL);
|
||||
ClipboardHelper.SetClipboardData(uploadUrl);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error("Can't write to clipboard: ", ex);
|
||||
uploadURL = null;
|
||||
Log.Error("Can't write to clipboard: ", ex);
|
||||
uploadUrl = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Error uploading.", e);
|
||||
Log.Error("Error uploading.", e);
|
||||
MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
uploadURL = null;
|
||||
uploadUrl = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
2
GreenshotJiraPlugin/Forms/JiraForm.Designer.cs
generated
2
GreenshotJiraPlugin/Forms/JiraForm.Designer.cs
generated
@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
namespace GreenshotJiraPlugin {
|
||||
namespace GreenshotJiraPlugin.Forms {
|
||||
partial class JiraForm {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@ -18,21 +18,20 @@
|
||||
* 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;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using Jira;
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
namespace GreenshotJiraPlugin.Forms {
|
||||
public partial class JiraForm : Form {
|
||||
private readonly JiraConnector jiraConnector;
|
||||
private JiraIssue selectedIssue;
|
||||
private readonly GreenshotColumnSorter columnSorter;
|
||||
private readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
private readonly JiraConnector _jiraConnector;
|
||||
private JiraIssue _selectedIssue;
|
||||
private readonly GreenshotColumnSorter _columnSorter;
|
||||
private readonly JiraConfiguration _config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
|
||||
public JiraForm(JiraConnector jiraConnector) {
|
||||
InitializeComponent();
|
||||
@ -40,90 +39,90 @@ namespace GreenshotJiraPlugin {
|
||||
AcceptButton = uploadButton;
|
||||
CancelButton = cancelButton;
|
||||
|
||||
initializeComponentText();
|
||||
InitializeComponentText();
|
||||
|
||||
columnSorter = new GreenshotColumnSorter();
|
||||
jiraListView.ListViewItemSorter = columnSorter;
|
||||
_columnSorter = new GreenshotColumnSorter();
|
||||
jiraListView.ListViewItemSorter = _columnSorter;
|
||||
|
||||
this.jiraConnector = jiraConnector;
|
||||
_jiraConnector = jiraConnector;
|
||||
|
||||
changeModus(false);
|
||||
ChangeModus(false);
|
||||
try {
|
||||
if (!jiraConnector.isLoggedIn) {
|
||||
jiraConnector.login();
|
||||
if (!jiraConnector.IsLoggedIn) {
|
||||
jiraConnector.Login();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(Language.GetFormattedString("jira", LangKey.login_error, e.Message));
|
||||
}
|
||||
uploadButton.Enabled = false;
|
||||
updateForm();
|
||||
UpdateForm();
|
||||
}
|
||||
|
||||
private void initializeComponentText() {
|
||||
private void InitializeComponentText() {
|
||||
label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
|
||||
label_comment.Text = Language.GetString("jira", LangKey.label_comment);
|
||||
label_filename.Text = Language.GetString("jira", LangKey.label_filename);
|
||||
}
|
||||
|
||||
private void updateForm() {
|
||||
if (jiraConnector.isLoggedIn) {
|
||||
JiraFilter[] filters = jiraConnector.getFilters();
|
||||
private void UpdateForm() {
|
||||
if (_jiraConnector.IsLoggedIn) {
|
||||
JiraFilter[] filters = _jiraConnector.GetFilters();
|
||||
if (filters.Length > 0) {
|
||||
foreach (JiraFilter filter in filters) {
|
||||
jiraFilterBox.Items.Add(filter);
|
||||
}
|
||||
jiraFilterBox.SelectedIndex = 0;
|
||||
}
|
||||
changeModus(true);
|
||||
if (config.LastUsedJira != null) {
|
||||
selectedIssue = jiraConnector.getIssue(config.LastUsedJira);
|
||||
if (selectedIssue != null) {
|
||||
jiraKey.Text = config.LastUsedJira;
|
||||
ChangeModus(true);
|
||||
if (_config.LastUsedJira != null) {
|
||||
_selectedIssue = _jiraConnector.GetIssue(_config.LastUsedJira);
|
||||
if (_selectedIssue != null) {
|
||||
jiraKey.Text = _config.LastUsedJira;
|
||||
uploadButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void changeModus(bool enabled) {
|
||||
private void ChangeModus(bool enabled) {
|
||||
jiraFilterBox.Enabled = enabled;
|
||||
jiraListView.Enabled = enabled;
|
||||
jiraFilenameBox.Enabled = enabled;
|
||||
jiraCommentBox.Enabled = enabled;
|
||||
}
|
||||
|
||||
public void setFilename(string filename) {
|
||||
public void SetFilename(string filename) {
|
||||
jiraFilenameBox.Text = filename;
|
||||
}
|
||||
|
||||
public void setComment(string comment) {
|
||||
public void SetComment(string comment) {
|
||||
jiraCommentBox.Text = comment;
|
||||
}
|
||||
|
||||
public JiraIssue getJiraIssue() {
|
||||
return selectedIssue;
|
||||
public JiraIssue GetJiraIssue() {
|
||||
return _selectedIssue;
|
||||
}
|
||||
|
||||
public void upload(IBinaryContainer attachment) {
|
||||
config.LastUsedJira = selectedIssue.Key;
|
||||
jiraConnector.addAttachment(selectedIssue.Key, jiraFilenameBox.Text, attachment);
|
||||
if (jiraCommentBox.Text != null && jiraCommentBox.Text.Length > 0) {
|
||||
jiraConnector.addComment(selectedIssue.Key, jiraCommentBox.Text);
|
||||
public void Upload(IBinaryContainer attachment) {
|
||||
_config.LastUsedJira = _selectedIssue.Key;
|
||||
_jiraConnector.AddAttachment(_selectedIssue.Key, jiraFilenameBox.Text, attachment);
|
||||
if (!string.IsNullOrEmpty(jiraCommentBox.Text)) {
|
||||
_jiraConnector.AddComment(_selectedIssue.Key, jiraCommentBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
jiraConnector.logout();
|
||||
public void Logout() {
|
||||
_jiraConnector.Logout();
|
||||
}
|
||||
|
||||
private void selectJiraToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
|
||||
selectedIssue = (JiraIssue)clickedItem.Tag;
|
||||
jiraKey.Text = selectedIssue.Key;
|
||||
_selectedIssue = (JiraIssue)clickedItem.Tag;
|
||||
jiraKey.Text = _selectedIssue.Key;
|
||||
}
|
||||
|
||||
private void jiraFilterBox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if (jiraConnector.isLoggedIn) {
|
||||
if (_jiraConnector.IsLoggedIn) {
|
||||
JiraIssue[] issues = null;
|
||||
uploadButton.Enabled = false;
|
||||
JiraFilter filter = (JiraFilter)jiraFilterBox.SelectedItem;
|
||||
@ -133,7 +132,7 @@ namespace GreenshotJiraPlugin {
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(JiraPlugin.Instance.JiraPluginAttributes.Name, Language.GetString("jira", LangKey.communication_wait),
|
||||
delegate() {
|
||||
issues = jiraConnector.getIssuesForFilter(filter.Id);
|
||||
issues = _jiraConnector.GetIssuesForFilter(filter.Id);
|
||||
}
|
||||
);
|
||||
jiraListView.BeginUpdate();
|
||||
@ -145,8 +144,10 @@ namespace GreenshotJiraPlugin {
|
||||
jiraListView.Columns.Add(Language.GetString("jira", column));
|
||||
}
|
||||
foreach (JiraIssue issue in issues) {
|
||||
ListViewItem item = new ListViewItem(issue.Key);
|
||||
item.Tag = issue;
|
||||
ListViewItem item = new ListViewItem(issue.Key)
|
||||
{
|
||||
Tag = issue
|
||||
};
|
||||
item.SubItems.Add(issue.Created.Value.ToString("d", DateTimeFormatInfo.InvariantInfo));
|
||||
item.SubItems.Add(issue.Assignee);
|
||||
item.SubItems.Add(issue.Reporter);
|
||||
@ -164,8 +165,8 @@ namespace GreenshotJiraPlugin {
|
||||
|
||||
private void jiraListView_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if (jiraListView.SelectedItems != null && jiraListView.SelectedItems.Count > 0) {
|
||||
selectedIssue = (JiraIssue)jiraListView.SelectedItems[0].Tag;
|
||||
jiraKey.Text = selectedIssue.Key;
|
||||
_selectedIssue = (JiraIssue)jiraListView.SelectedItems[0].Tag;
|
||||
jiraKey.Text = _selectedIssue.Key;
|
||||
uploadButton.Enabled = true;
|
||||
} else {
|
||||
uploadButton.Enabled = false;
|
||||
@ -174,17 +175,17 @@ namespace GreenshotJiraPlugin {
|
||||
|
||||
private void jiraListView_ColumnClick(object sender, ColumnClickEventArgs e) {
|
||||
// Determine if clicked column is already the column that is being sorted.
|
||||
if (e.Column == columnSorter.SortColumn) {
|
||||
if (e.Column == _columnSorter.SortColumn) {
|
||||
// Reverse the current sort direction for this column.
|
||||
if (columnSorter.Order == SortOrder.Ascending) {
|
||||
columnSorter.Order = SortOrder.Descending;
|
||||
if (_columnSorter.Order == SortOrder.Ascending) {
|
||||
_columnSorter.Order = SortOrder.Descending;
|
||||
} else {
|
||||
columnSorter.Order = SortOrder.Ascending;
|
||||
_columnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
} else {
|
||||
// Set the column number that is to be sorted; default to ascending.
|
||||
columnSorter.SortColumn = e.Column;
|
||||
columnSorter.Order = SortOrder.Ascending;
|
||||
_columnSorter.SortColumn = e.Column;
|
||||
_columnSorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
// Perform the sort with these new sort options.
|
||||
@ -196,8 +197,8 @@ namespace GreenshotJiraPlugin {
|
||||
uploadButton.Enabled = false;
|
||||
int dashIndex = jiranumber.IndexOf('-');
|
||||
if (dashIndex > 0 && jiranumber.Length > dashIndex+1) {
|
||||
selectedIssue = jiraConnector.getIssue(jiraKey.Text);
|
||||
if (selectedIssue != null) {
|
||||
_selectedIssue = _jiraConnector.GetIssue(jiraKey.Text);
|
||||
if (_selectedIssue != null) {
|
||||
uploadButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
using GreenshotPlugin.Controls;
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
namespace GreenshotJiraPlugin.Forms {
|
||||
public class JiraFormBase : GreenshotForm {
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
namespace GreenshotJiraPlugin {
|
||||
namespace GreenshotJiraPlugin.Forms {
|
||||
partial class SettingsForm {
|
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
|
@ -19,12 +19,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
namespace GreenshotJiraPlugin.Forms {
|
||||
/// <summary>
|
||||
/// Description of PasswordRequestForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : JiraFormBase {
|
||||
public SettingsForm(JiraConfiguration config) :base () {
|
||||
public SettingsForm()
|
||||
{
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -20,16 +20,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotJiraPlugin;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotJiraPlugin.Web_References.JiraSoap;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace Jira {
|
||||
namespace GreenshotJiraPlugin {
|
||||
#region transport classes
|
||||
public class JiraFilter {
|
||||
public JiraFilter(string name, string id) {
|
||||
@ -98,34 +98,34 @@ namespace Jira {
|
||||
#endregion
|
||||
|
||||
public class JiraConnector : IDisposable {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraConnector));
|
||||
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
|
||||
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||
private string credentials;
|
||||
private DateTime loggedInTime = DateTime.Now;
|
||||
private bool loggedIn;
|
||||
private JiraSoapServiceService jira;
|
||||
private readonly int timeout;
|
||||
private string url;
|
||||
private readonly Cache<string, JiraIssue> jiraCache = new Cache<string, JiraIssue>(60 * config.Timeout);
|
||||
private readonly Cache<string, RemoteUser> userCache = new Cache<string, RemoteUser>(60 * config.Timeout);
|
||||
private readonly bool suppressBackgroundForm = false;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraConnector));
|
||||
private const string AuthFailedExceptionName = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
|
||||
private static readonly JiraConfiguration Config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
public const string DefaultPostfix = "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||
private string _credentials;
|
||||
private DateTime _loggedInTime = DateTime.Now;
|
||||
private bool _loggedIn;
|
||||
private JiraSoapServiceService _jira;
|
||||
private readonly int _timeout;
|
||||
private string _url;
|
||||
private readonly Cache<string, JiraIssue> _jiraCache = new Cache<string, JiraIssue>(60 * Config.Timeout);
|
||||
private readonly Cache<string, RemoteUser> _userCache = new Cache<string, RemoteUser>(60 * Config.Timeout);
|
||||
private readonly bool _suppressBackgroundForm;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (jira != null) {
|
||||
logout();
|
||||
protected void Dispose(bool disposing) {
|
||||
if (_jira != null) {
|
||||
Logout();
|
||||
}
|
||||
|
||||
if (disposing) {
|
||||
if (jira != null) {
|
||||
jira.Dispose();
|
||||
jira = null;
|
||||
if (_jira != null) {
|
||||
_jira.Dispose();
|
||||
_jira = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,27 +134,27 @@ namespace Jira {
|
||||
}
|
||||
|
||||
public JiraConnector(bool suppressBackgroundForm) {
|
||||
url = config.Url;
|
||||
timeout = config.Timeout;
|
||||
this.suppressBackgroundForm = suppressBackgroundForm;
|
||||
createService();
|
||||
_url = Config.Url;
|
||||
_timeout = Config.Timeout;
|
||||
_suppressBackgroundForm = suppressBackgroundForm;
|
||||
CreateService();
|
||||
}
|
||||
|
||||
private void createService() {
|
||||
if (!suppressBackgroundForm) {
|
||||
private void CreateService() {
|
||||
if (!_suppressBackgroundForm) {
|
||||
new PleaseWaitForm().ShowAndWait(JiraPlugin.Instance.JiraPluginAttributes.Name, Language.GetString("jira", LangKey.communication_wait),
|
||||
delegate() {
|
||||
jira = new JiraSoapServiceService();
|
||||
delegate {
|
||||
_jira = new JiraSoapServiceService();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
jira = new JiraSoapServiceService();
|
||||
_jira = new JiraSoapServiceService();
|
||||
}
|
||||
jira.Url = url;
|
||||
jira.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||
_jira.Url = _url;
|
||||
_jira.Proxy = NetworkHelper.CreateProxy(new Uri(_url));
|
||||
// Do not use:
|
||||
//jira.AllowAutoRedirect = true;
|
||||
jira.UserAgent = "Greenshot";
|
||||
_jira.UserAgent = "Greenshot";
|
||||
}
|
||||
|
||||
~JiraConnector() {
|
||||
@ -165,30 +165,30 @@ namespace Jira {
|
||||
/// Internal login which catches the exceptions
|
||||
/// </summary>
|
||||
/// <returns>true if login was done sucessfully</returns>
|
||||
private bool doLogin(string user, string password, bool suppressBackgroundForm) {
|
||||
private bool DoLogin(string user, string password, bool suppressBackgroundForm) {
|
||||
|
||||
// This is what needs to be done
|
||||
ThreadStart jiraLogin = delegate {
|
||||
LOG.DebugFormat("Loggin in");
|
||||
Log.DebugFormat("Loggin in");
|
||||
try {
|
||||
credentials = jira.login(user, password);
|
||||
_credentials = _jira.login(user, password);
|
||||
} catch (Exception) {
|
||||
if (!url.EndsWith("wsdl")) {
|
||||
url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||
if (!_url.EndsWith("wsdl")) {
|
||||
_url = _url + "/rpc/soap/jirasoapservice-v2?wsdl";
|
||||
// recreate the service with the new url
|
||||
createService();
|
||||
credentials = jira.login(user, password);
|
||||
CreateService();
|
||||
_credentials = _jira.login(user, password);
|
||||
// Worked, store the url in the configuration
|
||||
config.Url = url;
|
||||
Config.Url = _url;
|
||||
IniConfig.Save();
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.DebugFormat("Logged in");
|
||||
loggedInTime = DateTime.Now;
|
||||
loggedIn = true;
|
||||
Log.DebugFormat("Logged in");
|
||||
_loggedInTime = DateTime.Now;
|
||||
_loggedIn = true;
|
||||
|
||||
};
|
||||
// Here we do it
|
||||
@ -200,125 +200,126 @@ namespace Jira {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// check if auth failed
|
||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||
if (e.Message.Contains(AuthFailedExceptionName)) {
|
||||
return false;
|
||||
}
|
||||
// Not an authentication issue
|
||||
loggedIn = false;
|
||||
credentials = null;
|
||||
_loggedIn = false;
|
||||
_credentials = null;
|
||||
e.Data.Add("user", user);
|
||||
e.Data.Add("url", url);
|
||||
e.Data.Add("url", _url);
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
login(false);
|
||||
public void Login() {
|
||||
Login(false);
|
||||
}
|
||||
public void login(bool suppressBackgroundForm) {
|
||||
logout();
|
||||
public void Login(bool suppressBackgroundForm) {
|
||||
Logout();
|
||||
try {
|
||||
// Get the system name, so the user knows where to login to
|
||||
string systemName = url.Replace(DEFAULT_POSTFIX,"");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||
dialog.Name = null;
|
||||
string systemName = _url.Replace(DefaultPostfix,"");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName)
|
||||
{
|
||||
Name = null
|
||||
};
|
||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
if (doLogin(dialog.Name, dialog.Password, suppressBackgroundForm)) {
|
||||
if (DoLogin(dialog.Name, dialog.Password, suppressBackgroundForm)) {
|
||||
if (dialog.SaveChecked) {
|
||||
dialog.Confirm(true);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
dialog.Confirm(false);
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
// For every windows version after XP show an incorrect password baloon
|
||||
dialog.IncorrectPassword = true;
|
||||
// Make sure the dialog is display, the password was false!
|
||||
dialog.AlwaysDisplay = true;
|
||||
}
|
||||
try {
|
||||
dialog.Confirm(false);
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
// For every windows version after XP show an incorrect password baloon
|
||||
dialog.IncorrectPassword = true;
|
||||
// Make sure the dialog is display, the password was false!
|
||||
dialog.AlwaysDisplay = true;
|
||||
}
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (credentials != null) {
|
||||
jira.logout(credentials);
|
||||
credentials = null;
|
||||
loggedIn = false;
|
||||
public void Logout() {
|
||||
if (_credentials != null) {
|
||||
_jira.logout(_credentials);
|
||||
_credentials = null;
|
||||
_loggedIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCredentials() {
|
||||
if (loggedIn) {
|
||||
if (loggedInTime.AddMinutes(timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
logout();
|
||||
login();
|
||||
private void CheckCredentials() {
|
||||
if (_loggedIn) {
|
||||
if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
Logout();
|
||||
Login();
|
||||
}
|
||||
} else {
|
||||
login();
|
||||
Login();
|
||||
}
|
||||
}
|
||||
|
||||
public bool isLoggedIn {
|
||||
public bool IsLoggedIn {
|
||||
get {
|
||||
return loggedIn;
|
||||
return _loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
public JiraFilter[] getFilters() {
|
||||
public JiraFilter[] GetFilters() {
|
||||
List<JiraFilter> filters = new List<JiraFilter>();
|
||||
checkCredentials();
|
||||
RemoteFilter[] remoteFilters = jira.getSavedFilters(credentials);
|
||||
CheckCredentials();
|
||||
RemoteFilter[] remoteFilters = _jira.getSavedFilters(_credentials);
|
||||
foreach (RemoteFilter remoteFilter in remoteFilters) {
|
||||
filters.Add(new JiraFilter(remoteFilter.name, remoteFilter.id));
|
||||
}
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
private JiraIssue createDummyErrorIssue(Exception e) {
|
||||
private JiraIssue CreateDummyErrorIssue(Exception e) {
|
||||
// Creating bogus jira to indicate a problem
|
||||
return new JiraIssue("error", DateTime.Now, "error", "error", "error", e.Message, "error", "error", null);
|
||||
}
|
||||
|
||||
public JiraIssue getIssue(string key) {
|
||||
public JiraIssue GetIssue(string key) {
|
||||
JiraIssue jiraIssue = null;
|
||||
if (jiraCache.Contains(key)) {
|
||||
jiraIssue = jiraCache[key];
|
||||
if (_jiraCache.Contains(key)) {
|
||||
jiraIssue = _jiraCache[key];
|
||||
}
|
||||
if (jiraIssue == null) {
|
||||
checkCredentials();
|
||||
CheckCredentials();
|
||||
try {
|
||||
RemoteIssue issue = jira.getIssue(credentials, key);
|
||||
jiraIssue = new JiraIssue(issue.key, issue.created, getUserFullName(issue.reporter), getUserFullName(issue.assignee), issue.project, issue.summary, issue.description, issue.environment, issue.attachmentNames);
|
||||
jiraCache.Add(key, jiraIssue);
|
||||
RemoteIssue issue = _jira.getIssue(_credentials, key);
|
||||
jiraIssue = new JiraIssue(issue.key, issue.created, GetUserFullName(issue.reporter), GetUserFullName(issue.assignee), issue.project, issue.summary, issue.description, issue.environment, issue.attachmentNames);
|
||||
_jiraCache.Add(key, jiraIssue);
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Problem retrieving Jira: " + key, e);
|
||||
Log.Error("Problem retrieving Jira: " + key, e);
|
||||
}
|
||||
}
|
||||
return jiraIssue;
|
||||
}
|
||||
|
||||
public JiraIssue[] getIssuesForFilter(string filterId) {
|
||||
public JiraIssue[] GetIssuesForFilter(string filterId) {
|
||||
List<JiraIssue> issuesToReturn = new List<JiraIssue>();
|
||||
checkCredentials();
|
||||
CheckCredentials();
|
||||
try {
|
||||
RemoteIssue[] issues = jira.getIssuesFromFilter(credentials, filterId);
|
||||
RemoteIssue[] issues = _jira.getIssuesFromFilter(_credentials, filterId);
|
||||
|
||||
#region Username cache update
|
||||
List<string> users = new List<string>();
|
||||
foreach (RemoteIssue issue in issues) {
|
||||
if (issue.reporter != null && !hasUser(issue.reporter) && !users.Contains(issue.reporter)) {
|
||||
if (issue.reporter != null && !HasUser(issue.reporter) && !users.Contains(issue.reporter)) {
|
||||
users.Add(issue.reporter);
|
||||
}
|
||||
if (issue.assignee != null && !hasUser(issue.assignee) && !users.Contains(issue.assignee)) {
|
||||
if (issue.assignee != null && !HasUser(issue.assignee) && !users.Contains(issue.assignee)) {
|
||||
users.Add(issue.assignee);
|
||||
}
|
||||
}
|
||||
@ -327,8 +328,8 @@ namespace Jira {
|
||||
ManualResetEvent doneEvent = new ManualResetEvent(false);
|
||||
for (int i = 0; i < users.Count; i++) {
|
||||
ThreadPool.QueueUserWorkItem(delegate(object name) {
|
||||
LOG.InfoFormat("Retrieving {0}", name);
|
||||
getUserFullName((string)name);
|
||||
Log.InfoFormat("Retrieving {0}", name);
|
||||
GetUserFullName((string)name);
|
||||
if (Interlocked.Decrement(ref taskCount) == 0) {
|
||||
doneEvent.Set();
|
||||
}
|
||||
@ -340,65 +341,67 @@ namespace Jira {
|
||||
|
||||
foreach (RemoteIssue issue in issues) {
|
||||
try {
|
||||
JiraIssue jiraIssue = new JiraIssue(issue.key, issue.created, getUserFullName(issue.reporter), getUserFullName(issue.assignee), issue.project, issue.summary, issue.description, "", issue.attachmentNames);
|
||||
JiraIssue jiraIssue = new JiraIssue(issue.key, issue.created, GetUserFullName(issue.reporter), GetUserFullName(issue.assignee), issue.project, issue.summary, issue.description, "", issue.attachmentNames);
|
||||
issuesToReturn.Add(jiraIssue);
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Problem retrieving Jira: " + issue.key, e);
|
||||
JiraIssue jiraIssue = createDummyErrorIssue(e);
|
||||
Log.Error("Problem retrieving Jira: " + issue.key, e);
|
||||
JiraIssue jiraIssue = CreateDummyErrorIssue(e);
|
||||
jiraIssue.Key = issue.key;
|
||||
issuesToReturn.Add(jiraIssue);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Problem retrieving Jiras for Filter: " + filterId, e);
|
||||
issuesToReturn.Add(createDummyErrorIssue(e));
|
||||
Log.Error("Problem retrieving Jiras for Filter: " + filterId, e);
|
||||
issuesToReturn.Add(CreateDummyErrorIssue(e));
|
||||
}
|
||||
return issuesToReturn.ToArray(); ;
|
||||
}
|
||||
|
||||
public string getURL(string issueKey) {
|
||||
return url.Replace(DEFAULT_POSTFIX,"") + "/browse/" + issueKey;
|
||||
public string GetUrl(string issueKey) {
|
||||
return _url.Replace(DefaultPostfix,"") + "/browse/" + issueKey;
|
||||
}
|
||||
|
||||
public void addAttachment(string issueKey, string filename, IBinaryContainer attachment) {
|
||||
checkCredentials();
|
||||
public void AddAttachment(string issueKey, string filename, IBinaryContainer attachment) {
|
||||
CheckCredentials();
|
||||
try {
|
||||
jira.addBase64EncodedAttachmentsToIssue(credentials, issueKey, new string[] { filename }, new string[] { attachment.ToBase64String(Base64FormattingOptions.InsertLineBreaks) });
|
||||
_jira.addBase64EncodedAttachmentsToIssue(_credentials, issueKey, new[] { filename }, new[] { attachment.ToBase64String(Base64FormattingOptions.InsertLineBreaks) });
|
||||
} catch (Exception ex1) {
|
||||
LOG.WarnFormat("Failed to upload by using method addBase64EncodedAttachmentsToIssue, error was {0}", ex1.Message);
|
||||
Log.WarnFormat("Failed to upload by using method addBase64EncodedAttachmentsToIssue, error was {0}", ex1.Message);
|
||||
try {
|
||||
LOG.Warn("Trying addAttachmentsToIssue instead");
|
||||
jira.addAttachmentsToIssue(credentials, issueKey, new string[] { filename }, (sbyte[])(Array)attachment.ToByteArray());
|
||||
Log.Warn("Trying addAttachmentsToIssue instead");
|
||||
_jira.addAttachmentsToIssue(_credentials, issueKey, new[] { filename }, (sbyte[])(Array)attachment.ToByteArray());
|
||||
} catch (Exception ex2) {
|
||||
LOG.WarnFormat("Failed to use alternative method, error was: {0}", ex2.Message);
|
||||
Log.WarnFormat("Failed to use alternative method, error was: {0}", ex2.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addComment(string issueKey, string commentString) {
|
||||
RemoteComment comment = new RemoteComment();
|
||||
comment.body = commentString;
|
||||
checkCredentials();
|
||||
jira.addComment(credentials, issueKey, comment);
|
||||
public void AddComment(string issueKey, string commentString) {
|
||||
RemoteComment comment = new RemoteComment
|
||||
{
|
||||
body = commentString
|
||||
};
|
||||
CheckCredentials();
|
||||
_jira.addComment(_credentials, issueKey, comment);
|
||||
}
|
||||
|
||||
private bool hasUser(string user) {
|
||||
private bool HasUser(string user) {
|
||||
if (user != null) {
|
||||
return userCache.Contains(user);
|
||||
return _userCache.Contains(user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private string getUserFullName(string user) {
|
||||
string fullname = null;
|
||||
private string GetUserFullName(string user) {
|
||||
string fullname;
|
||||
if (user != null) {
|
||||
if (userCache.Contains(user)) {
|
||||
fullname = userCache[user].fullname;
|
||||
if (_userCache.Contains(user)) {
|
||||
fullname = _userCache[user].fullname;
|
||||
} else {
|
||||
checkCredentials();
|
||||
RemoteUser remoteUser = jira.getUser(credentials, user);
|
||||
userCache.Add(user, remoteUser);
|
||||
CheckCredentials();
|
||||
RemoteUser remoteUser = _jira.getUser(_credentials, user);
|
||||
_userCache.Add(user, remoteUser);
|
||||
fullname = remoteUser.fullname;
|
||||
}
|
||||
} else {
|
||||
|
@ -18,7 +18,7 @@
|
||||
* 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.Windows.Forms;
|
||||
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
@ -28,35 +28,22 @@ namespace GreenshotJiraPlugin {
|
||||
/// </summary>
|
||||
[IniSection("Jira", Description="Greenshot Jira Plugin configuration")]
|
||||
public class JiraConfiguration : IniSection {
|
||||
public const string DEFAULT_PREFIX = "http://";
|
||||
private const string DEFAULT_URL = DEFAULT_PREFIX + "jira" + Jira.JiraConnector.DEFAULT_POSTFIX;
|
||||
public const string DefaultPrefix = "http://";
|
||||
private const string DefaultUrl = DefaultPrefix + "jira" + JiraConnector.DefaultPostfix;
|
||||
|
||||
[IniProperty("Url", Description="Url to Jira system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
||||
public string Url;
|
||||
[IniProperty("Url", Description="Url to Jira system, including wsdl.", DefaultValue=DefaultUrl)]
|
||||
public string Url { get; set; }
|
||||
[IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
|
||||
public int Timeout;
|
||||
|
||||
public int Timeout { get; set; }
|
||||
|
||||
[IniProperty("LastUsedJira", Description="Last used Jira")]
|
||||
public string LastUsedJira;
|
||||
public string LastUsedJira { get; set; }
|
||||
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
|
||||
public bool UploadReduceColors;
|
||||
|
||||
/// <summary>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||
public bool ShowConfigDialog() {
|
||||
SettingsForm settingsForm = new SettingsForm(this);
|
||||
DialogResult result = settingsForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool UploadReduceColors { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -26,27 +27,27 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotJiraPlugin.Forms;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Jira;
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
/// <summary>
|
||||
/// Description of JiraDestination.
|
||||
/// </summary>
|
||||
public class JiraDestination : AbstractDestination {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
|
||||
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
private readonly JiraPlugin jiraPlugin = null;
|
||||
private readonly JiraIssue jira = null;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraDestination));
|
||||
private static readonly JiraConfiguration Config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
private readonly JiraPlugin _jiraPlugin;
|
||||
private readonly JiraIssue _jira;
|
||||
|
||||
public JiraDestination(JiraPlugin jiraPlugin) {
|
||||
this.jiraPlugin = jiraPlugin;
|
||||
_jiraPlugin = jiraPlugin;
|
||||
}
|
||||
|
||||
public JiraDestination(JiraPlugin jiraPlugin, JiraIssue jira) {
|
||||
this.jiraPlugin = jiraPlugin;
|
||||
this.jira = jira;
|
||||
_jiraPlugin = jiraPlugin;
|
||||
_jira = jira;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
@ -60,18 +61,18 @@ namespace GreenshotJiraPlugin {
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
if (jira == null) {
|
||||
get
|
||||
{
|
||||
if (_jira == null) {
|
||||
return Language.GetString("jira", LangKey.upload_menu_item);
|
||||
} else {
|
||||
return FormatUpload(jira);
|
||||
}
|
||||
return FormatUpload(_jira);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isActive {
|
||||
get {
|
||||
return base.isActive && !string.IsNullOrEmpty(config.Url);
|
||||
return base.isActive && !string.IsNullOrEmpty(Config.Url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,36 +83,36 @@ namespace GreenshotJiraPlugin {
|
||||
}
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
ComponentResourceManager resources = new ComponentResourceManager(typeof(JiraPlugin));
|
||||
var resources = new ComponentResourceManager(typeof(JiraPlugin));
|
||||
return (Image)resources.GetObject("Jira");
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
if (JiraPlugin.Instance.CurrentJiraConnector == null || !JiraPlugin.Instance.CurrentJiraConnector.isLoggedIn) {
|
||||
if (JiraPlugin.Instance.CurrentJiraConnector == null || !JiraPlugin.Instance.CurrentJiraConnector.IsLoggedIn) {
|
||||
yield break;
|
||||
}
|
||||
List<JiraIssue> issues = JiraUtils.GetCurrentJiras();
|
||||
if (issues != null) {
|
||||
foreach(JiraIssue jiraIssue in issues) {
|
||||
yield return new JiraDestination(jiraPlugin, jiraIssue);
|
||||
foreach(var jiraIssue in issues) {
|
||||
yield return new JiraDestination(_jiraPlugin, jiraIssue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||
if (jira != null) {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(Config.UploadFormat, captureDetails));
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(Config.UploadFormat, Config.UploadJpegQuality, Config.UploadReduceColors);
|
||||
if (_jira != null) {
|
||||
try {
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
|
||||
delegate() {
|
||||
jiraPlugin.JiraConnector.addAttachment(jira.Key, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
delegate {
|
||||
_jiraPlugin.JiraConnector.AddAttachment(_jira.Key, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
}
|
||||
);
|
||||
LOG.Debug("Uploaded to Jira.");
|
||||
Log.Debug("Uploaded to Jira.");
|
||||
exportInformation.ExportMade = true;
|
||||
// TODO: This can't work:
|
||||
exportInformation.Uri = surfaceToUpload.UploadURL;
|
||||
@ -119,19 +120,19 @@ namespace GreenshotJiraPlugin {
|
||||
MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
} else {
|
||||
JiraForm jiraForm = new JiraForm(jiraPlugin.JiraConnector);
|
||||
if (jiraPlugin.JiraConnector.isLoggedIn) {
|
||||
jiraForm.setFilename(filename);
|
||||
JiraForm jiraForm = new JiraForm(_jiraPlugin.JiraConnector);
|
||||
if (_jiraPlugin.JiraConnector.IsLoggedIn) {
|
||||
jiraForm.SetFilename(filename);
|
||||
DialogResult result = jiraForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
try {
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
|
||||
delegate() {
|
||||
jiraForm.upload(new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
delegate {
|
||||
jiraForm.Upload(new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
}
|
||||
);
|
||||
LOG.Debug("Uploaded to Jira.");
|
||||
Log.Debug("Uploaded to Jira.");
|
||||
exportInformation.ExportMade = true;
|
||||
// TODO: This can't work:
|
||||
exportInformation.Uri = surfaceToUpload.UploadURL;
|
||||
|
@ -23,21 +23,19 @@ using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using Jira;
|
||||
using System;
|
||||
using GreenshotJiraPlugin.Forms;
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
/// <summary>
|
||||
/// This is the JiraPlugin base code
|
||||
/// </summary>
|
||||
public class JiraPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraPlugin));
|
||||
private PluginAttribute jiraPluginAttributes;
|
||||
private IGreenshotHost host;
|
||||
private JiraConnector jiraConnector = null;
|
||||
private JiraConfiguration config = null;
|
||||
private ComponentResourceManager resources;
|
||||
private static JiraPlugin instance = null;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraPlugin));
|
||||
private PluginAttribute _jiraPluginAttributes;
|
||||
private JiraConnector _jiraConnector;
|
||||
private JiraConfiguration _config;
|
||||
private static JiraPlugin _instance;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
@ -46,26 +44,26 @@ namespace GreenshotJiraPlugin {
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (jiraConnector != null) {
|
||||
jiraConnector.Dispose();
|
||||
jiraConnector = null;
|
||||
if (_jiraConnector != null) {
|
||||
_jiraConnector.Dispose();
|
||||
_jiraConnector = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static JiraPlugin Instance {
|
||||
get {
|
||||
return instance;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public JiraPlugin() {
|
||||
instance = this;
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
public PluginAttribute JiraPluginAttributes {
|
||||
get {
|
||||
return jiraPluginAttributes;
|
||||
return _jiraPluginAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,40 +78,38 @@ namespace GreenshotJiraPlugin {
|
||||
//Needed for a fail-fast
|
||||
public JiraConnector CurrentJiraConnector {
|
||||
get {
|
||||
return jiraConnector;
|
||||
return _jiraConnector;
|
||||
}
|
||||
}
|
||||
|
||||
public JiraConnector JiraConnector {
|
||||
get {
|
||||
if (jiraConnector == null) {
|
||||
jiraConnector = new JiraConnector(true);
|
||||
if (_jiraConnector == null) {
|
||||
_jiraConnector = new JiraConnector(true);
|
||||
}
|
||||
return jiraConnector;
|
||||
return _jiraConnector;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
host = (IGreenshotHost)pluginHost;
|
||||
jiraPluginAttributes = myAttributes;
|
||||
_jiraPluginAttributes = myAttributes;
|
||||
|
||||
// Register configuration (don't need the configuration itself)
|
||||
config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(JiraPlugin));
|
||||
_config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
new ComponentResourceManager(typeof(JiraPlugin));
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Jira Plugin shutdown.");
|
||||
if (jiraConnector != null) {
|
||||
jiraConnector.logout();
|
||||
Log.Debug("Jira Plugin shutdown.");
|
||||
if (_jiraConnector != null) {
|
||||
_jiraConnector.Logout();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,25 +117,40 @@ namespace GreenshotJiraPlugin {
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
string url = config.Url;
|
||||
if (config.ShowConfigDialog()) {
|
||||
string url = _config.Url;
|
||||
if (ShowConfigDialog()) {
|
||||
// check for re-login
|
||||
if (jiraConnector != null && jiraConnector.isLoggedIn && !string.IsNullOrEmpty(url)) {
|
||||
if (!url.Equals(config.Url)) {
|
||||
jiraConnector.logout();
|
||||
jiraConnector.login();
|
||||
if (_jiraConnector != null && _jiraConnector.IsLoggedIn && !string.IsNullOrEmpty(url)) {
|
||||
if (!url.Equals(_config.Url)) {
|
||||
_jiraConnector.Logout();
|
||||
_jiraConnector.Login();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||
private bool ShowConfigDialog()
|
||||
{
|
||||
var settingsForm = new SettingsForm();
|
||||
var result = settingsForm.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, calling logout of jira!");
|
||||
Log.Debug("Application closing, calling logout of jira!");
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,14 @@ using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Core;
|
||||
using Jira;
|
||||
|
||||
namespace GreenshotJiraPlugin {
|
||||
/// <summary>
|
||||
/// Description of JiraUtils.
|
||||
/// </summary>
|
||||
public class JiraUtils {
|
||||
private static readonly Regex JIRA_KEY_REGEX = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
|
||||
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
public static class JiraUtils {
|
||||
private static readonly Regex JiraKeyRegex = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
|
||||
private static readonly JiraConfiguration Config = IniConfig.GetIniSection<JiraConfiguration>();
|
||||
|
||||
public static List<JiraIssue> GetCurrentJiras() {
|
||||
// Make sure we suppress the login
|
||||
@ -39,24 +38,30 @@ namespace GreenshotJiraPlugin {
|
||||
if (url == null) {
|
||||
continue;
|
||||
}
|
||||
MatchCollection jiraKeyMatch = JIRA_KEY_REGEX.Matches(url);
|
||||
if (jiraKeyMatch != null && jiraKeyMatch.Count > 0) {
|
||||
MatchCollection jiraKeyMatch = JiraKeyRegex.Matches(url);
|
||||
if (jiraKeyMatch.Count > 0) {
|
||||
string jiraKey = jiraKeyMatch[0].Groups[1].Value;
|
||||
jirakeys.Add(jiraKey);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(config.LastUsedJira) && !jirakeys.Contains(config.LastUsedJira)) {
|
||||
jirakeys.Add(config.LastUsedJira);
|
||||
if (!string.IsNullOrEmpty(Config.LastUsedJira) && !jirakeys.Contains(Config.LastUsedJira)) {
|
||||
jirakeys.Add(Config.LastUsedJira);
|
||||
}
|
||||
if (jirakeys.Count > 0) {
|
||||
List<JiraIssue> jiraIssues = new List<JiraIssue>();
|
||||
foreach(string jiraKey in jirakeys) {
|
||||
try {
|
||||
JiraIssue issue = JiraPlugin.Instance.JiraConnector.getIssue(jiraKey);
|
||||
if (issue != null) {
|
||||
try
|
||||
{
|
||||
JiraIssue issue = JiraPlugin.Instance.JiraConnector.GetIssue(jiraKey);
|
||||
if (issue != null)
|
||||
{
|
||||
jiraIssues.Add(issue);
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
if (jiraIssues.Count > 0) {
|
||||
return jiraIssues;
|
||||
|
@ -35,7 +35,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// The PluginAttribute describes the "entryType" and if the plugin is configurable
|
||||
[assembly: PluginAttribute("GreenshotJiraPlugin.JiraPlugin", true)]
|
||||
[assembly: Plugin("GreenshotJiraPlugin.JiraPlugin", true)]
|
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,55 +38,42 @@ namespace Greenshot.Interop {
|
||||
/// <summary>
|
||||
/// Holds reference to the actual COM object which is wrapped by this proxy
|
||||
/// </summary>
|
||||
private object _COMObject;
|
||||
private readonly object _comObject;
|
||||
|
||||
/// <summary>
|
||||
/// Type of the COM object, set on constructor after getting the COM reference
|
||||
/// </summary>
|
||||
private readonly Type _COMType;
|
||||
private readonly Type _comType;
|
||||
|
||||
/// <summary>
|
||||
/// The type of which method calls are intercepted and executed on the COM object.
|
||||
/// </summary>
|
||||
private readonly Type _InterceptType;
|
||||
private readonly Type _interceptType;
|
||||
|
||||
#endregion
|
||||
[DllImport("ole32.dll")]
|
||||
static extern int ProgIDFromCLSID([In] ref Guid clsid, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgID);
|
||||
|
||||
#region Construction
|
||||
|
||||
/// <summary>
|
||||
/// Gets a COM object and returns the transparent proxy which intercepts all calls to the object
|
||||
/// </summary>
|
||||
/// <param name="type">Interface which defines the method and properties to intercept</param>
|
||||
/// <typeparam name="T">Interface which defines the method and properties to intercept</typeparam>
|
||||
/// <returns>Transparent proxy to the real proxy for the object</returns>
|
||||
/// <remarks>The <paramref name="type"/> must be an interface decorated with the <see cref="ComProgIdAttribute"/>attribute.</remarks>
|
||||
/// <remarks>T must be an interface decorated with the <see cref="ComProgIdAttribute"/>attribute.</remarks>
|
||||
public static T GetInstance<T>() {
|
||||
Type type = typeof(T);
|
||||
if (null == type) {
|
||||
throw new ArgumentNullException("type");
|
||||
throw new ArgumentNullException(nameof(T));
|
||||
}
|
||||
if (!type.IsInterface) {
|
||||
throw new ArgumentException("The specified type must be an interface.", "type");
|
||||
throw new ArgumentException("The specified type must be an interface.", nameof(T));
|
||||
}
|
||||
|
||||
ComProgIdAttribute progIDAttribute = ComProgIdAttribute.GetAttribute(type);
|
||||
if (null == progIDAttribute || null == progIDAttribute.Value || 0 == progIDAttribute.Value.Length) {
|
||||
throw new ArgumentException("The specified type must define a ComProgId attribute.", "type");
|
||||
}
|
||||
string progId = progIDAttribute.Value;
|
||||
|
||||
// Convert from clsid to Prog ID, if needed
|
||||
if (progId.StartsWith("clsid:")) {
|
||||
Guid guid = new Guid(progId.Substring(6));
|
||||
int result = ProgIDFromCLSID(ref guid, out progId);
|
||||
if (result != 0) {
|
||||
//LOG.WarnFormat("Error {0} getting progId {1}", result, progIDAttribute.Value);
|
||||
} else {
|
||||
//LOG.InfoFormat("Mapped {0} to progId {1}", progIDAttribute.Value, progId);
|
||||
}
|
||||
ComProgIdAttribute progIdAttribute = ComProgIdAttribute.GetAttribute(type);
|
||||
if (string.IsNullOrEmpty(progIdAttribute?.Value)) {
|
||||
throw new ArgumentException("The specified type must define a ComProgId attribute.", nameof(T));
|
||||
}
|
||||
string progId = progIdAttribute.Value;
|
||||
|
||||
object comObject = null;
|
||||
try {
|
||||
@ -96,8 +83,6 @@ namespace Greenshot.Interop {
|
||||
//LOG.DebugFormat("No current instance of {0} object available.", progId);
|
||||
} else if (comE.ErrorCode == CO_E_CLASSSTRING) {
|
||||
//LOG.WarnFormat("Unknown progId {0}", progId);
|
||||
} else {
|
||||
//LOG.Warn("Error getting active object for " + progId, comE);
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.Warn("Error getting active object for " + progId, e);
|
||||
@ -114,37 +99,26 @@ namespace Greenshot.Interop {
|
||||
/// Gets or creates a COM object and returns the transparent proxy which intercepts all calls to the object
|
||||
/// The ComProgId can be a normal ComProgId or a GUID prefixed with "clsid:"
|
||||
/// </summary>
|
||||
/// <param name="type">Interface which defines the method and properties to intercept</param>
|
||||
/// <typeparam name="T">Interface which defines the method and properties to intercept</typeparam>
|
||||
/// <returns>Transparent proxy to the real proxy for the object</returns>
|
||||
/// <remarks>The <paramref name="type"/> must be an interface decorated with the <see cref="ComProgIdAttribute"/>attribute.</remarks>
|
||||
/// <remarks>The type must be an interface decorated with the <see cref="ComProgIdAttribute"/>attribute.</remarks>
|
||||
public static T GetOrCreateInstance<T>() {
|
||||
Type type = typeof(T);
|
||||
if (null == type) {
|
||||
throw new ArgumentNullException("type");
|
||||
throw new ArgumentNullException(nameof(T));
|
||||
}
|
||||
if (!type.IsInterface) {
|
||||
throw new ArgumentException("The specified type must be an interface.", "type");
|
||||
throw new ArgumentException("The specified type must be an interface.", nameof(T));
|
||||
}
|
||||
|
||||
ComProgIdAttribute progIDAttribute = ComProgIdAttribute.GetAttribute(type);
|
||||
if (null == progIDAttribute || null == progIDAttribute.Value || 0 == progIDAttribute.Value.Length) {
|
||||
throw new ArgumentException("The specified type must define a ComProgId attribute.", "type");
|
||||
ComProgIdAttribute progIdAttribute = ComProgIdAttribute.GetAttribute(type);
|
||||
if (string.IsNullOrEmpty(progIdAttribute?.Value)) {
|
||||
throw new ArgumentException("The specified type must define a ComProgId attribute.", nameof(T));
|
||||
}
|
||||
|
||||
object comObject = null;
|
||||
Type comType = null;
|
||||
string progId = progIDAttribute.Value;
|
||||
|
||||
// Convert from clsid to Prog ID, if needed
|
||||
if (progId.StartsWith("clsid:")) {
|
||||
Guid guid = new Guid(progId.Substring(6));
|
||||
int result = ProgIDFromCLSID(ref guid, out progId);
|
||||
if (result != 0) {
|
||||
//LOG.WarnFormat("Error {0} getting progId {1}", result, progIDAttribute.Value);
|
||||
} else {
|
||||
//LOG.InfoFormat("Mapped {0} to progId {1}", progIDAttribute.Value, progId);
|
||||
}
|
||||
}
|
||||
string progId = progIdAttribute.Value;
|
||||
|
||||
try {
|
||||
comObject = Marshal.GetActiveObject(progId);
|
||||
@ -154,8 +128,6 @@ namespace Greenshot.Interop {
|
||||
} else if (comE.ErrorCode == CO_E_CLASSSTRING) {
|
||||
//LOG.WarnFormat("Unknown progId {0} (application not installed)", progId);
|
||||
return default(T);
|
||||
} else {
|
||||
//LOG.Warn("Error getting active object for " + progId, comE);
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.Warn("Error getting active object for " + progId, e);
|
||||
@ -193,10 +165,10 @@ namespace Greenshot.Interop {
|
||||
/// <returns>Transparent proxy to the real proxy for the object</returns>
|
||||
private static object Wrap(object comObject, Type type) {
|
||||
if (null == comObject) {
|
||||
throw new ArgumentNullException("comObject");
|
||||
throw new ArgumentNullException(nameof(comObject));
|
||||
}
|
||||
if (null == type) {
|
||||
throw new ArgumentNullException("type");
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
COMWrapper wrapper = new COMWrapper(comObject, type);
|
||||
@ -214,9 +186,9 @@ namespace Greenshot.Interop {
|
||||
/// </param>
|
||||
private COMWrapper(object comObject, Type type)
|
||||
: base(type) {
|
||||
_COMObject = comObject;
|
||||
_COMType = comObject.GetType();
|
||||
_InterceptType = type;
|
||||
_comObject = comObject;
|
||||
_comType = comObject.GetType();
|
||||
_interceptType = type;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -247,17 +219,17 @@ namespace Greenshot.Interop {
|
||||
/// <see cref="IDisposable"/> interface.
|
||||
/// </param>
|
||||
private void Dispose(bool disposing) {
|
||||
if (disposing && null != _COMObject) {
|
||||
if (Marshal.IsComObject(_COMObject)) {
|
||||
if (disposing && null != _comObject) {
|
||||
if (Marshal.IsComObject(_comObject)) {
|
||||
try {
|
||||
while (Marshal.ReleaseComObject(_COMObject) > 0);
|
||||
while (Marshal.ReleaseComObject(_comObject) > 0)
|
||||
{
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.WarnFormat("Problem releasing {0}", _COMType);
|
||||
//LOG.Warn("Error: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
_COMObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +244,7 @@ namespace Greenshot.Interop {
|
||||
/// The full name of the intercepted type.
|
||||
/// </returns>
|
||||
public override string ToString() {
|
||||
return _InterceptType.FullName;
|
||||
return _interceptType.FullName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -282,7 +254,7 @@ namespace Greenshot.Interop {
|
||||
/// The hash code of the wrapped object.
|
||||
/// </returns>
|
||||
public override int GetHashCode() {
|
||||
return _COMObject.GetHashCode();
|
||||
return _comObject.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -298,7 +270,7 @@ namespace Greenshot.Interop {
|
||||
if (null != value && RemotingServices.IsTransparentProxy(value)) {
|
||||
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
|
||||
if (null != wrapper) {
|
||||
return _COMObject == wrapper._COMObject;
|
||||
return _comObject == wrapper._comObject;
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +291,7 @@ namespace Greenshot.Interop {
|
||||
/// </exception>
|
||||
private static Type GetByValType(Type byRefType) {
|
||||
if (null == byRefType) {
|
||||
throw new ArgumentNullException("byRefType");
|
||||
throw new ArgumentNullException(nameof(byRefType));
|
||||
}
|
||||
|
||||
if (byRefType.IsByRef) {
|
||||
@ -333,97 +305,6 @@ namespace Greenshot.Interop {
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Use this static method to cast a wrapped proxy to a new wrapper proxy of the supplied type.
|
||||
/// In English, use this to cast you base "COM" interface to a specialized interface.
|
||||
/// E.G. Outlook Item -> MailItem
|
||||
/// </summary>
|
||||
/// <typeparam name="T">the type you want to cast to</typeparam>
|
||||
/// <param name="wrapperProxy">The wrapper interface, e.g. something you got back from calling GetItem</param>
|
||||
/// <returns>A new wrapper proxy for the specified type</returns>
|
||||
public static T Cast<T>(object wrapperProxy) {
|
||||
if (wrapperProxy == null) {
|
||||
return default(T);
|
||||
}
|
||||
|
||||
Type newType = typeof(T);
|
||||
COMWrapper oldWrapper = RemotingServices.GetRealProxy(wrapperProxy) as COMWrapper;
|
||||
if (oldWrapper == null) {
|
||||
throw new ArgumentException("wrapper proxy was no COMWrapper");
|
||||
}
|
||||
if (oldWrapper._InterceptType.IsAssignableFrom(newType)) {
|
||||
COMWrapper newWrapper = new COMWrapper(oldWrapper._COMObject, newType);
|
||||
return (T)newWrapper.GetTransparentProxy();
|
||||
}
|
||||
throw new InvalidCastException(string.Format("{0} is not assignable from {1}", oldWrapper._InterceptType, newType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the "com" type of the wrapperproxy, making it possible to perform reflection on it.
|
||||
/// </summary>
|
||||
/// <param name="wrapperProxy">wrapperProxy to get the type from</param>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetUnderlyingTypeForWrapper(object wrapperProxy) {
|
||||
Type returnType = null;
|
||||
COMWrapper wrapper = RemotingServices.GetRealProxy(wrapperProxy) as COMWrapper;
|
||||
if (wrapper != null) {
|
||||
IDispatch dispatch = wrapper._COMObject as IDispatch;
|
||||
if (dispatch != null) {
|
||||
int result = dispatch.GetTypeInfo(0, 0, out returnType);
|
||||
if (result != 0) {
|
||||
//LOG.DebugFormat("GetTypeInfo : 0x{0} ({1})", result.ToString("X"), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the Type of a IDispatch
|
||||
/// </summary>
|
||||
/// <param name="dispatch">IDispatch to get the type object for</param>
|
||||
/// <returns>Type of the IDispatch</returns>
|
||||
public static Type GetUnderlyingType(IDispatch dispatch) {
|
||||
Type returnType = null;
|
||||
if (dispatch != null) {
|
||||
int result = dispatch.GetTypeInfo(0, 0, out returnType);
|
||||
if (result != 0) {
|
||||
//LOG.DebugFormat("GetTypeInfo : 0x{0} ({1})", result.ToString("X"), result);
|
||||
}
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump the Type-Information for the Type to the log, this uses reflection
|
||||
/// </summary>
|
||||
/// <param name="type">Type to inspect</param>
|
||||
public static void DumpTypeInfo(Type type) {
|
||||
//LOG.InfoFormat("Type information for Type with name: {0}", type.Name);
|
||||
try {
|
||||
foreach (MemberInfo memberInfo in type.GetMembers()) {
|
||||
//LOG.InfoFormat("Member: {0};", memberInfo.ToString());
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.Error(memberException);
|
||||
}
|
||||
try {
|
||||
foreach (PropertyInfo propertyInfo in type.GetProperties()) {
|
||||
//LOG.InfoFormat("Property: {0};", propertyInfo.ToString());
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.Error(propertyException);
|
||||
}
|
||||
try {
|
||||
foreach (FieldInfo fieldInfo in type.GetFields()) {
|
||||
//LOG.InfoFormat("Field: {0};", fieldInfo.ToString());
|
||||
}
|
||||
} catch (Exception) {
|
||||
//LOG.Error(fieldException);
|
||||
}
|
||||
//LOG.InfoFormat("Type information end.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intercept method calls
|
||||
/// </summary>
|
||||
@ -473,22 +354,19 @@ namespace Greenshot.Interop {
|
||||
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
|
||||
returnValue = ToString();
|
||||
} else if ("GetType" == methodName && 0 == argCount && typeof(Type) == returnType) {
|
||||
returnValue = _InterceptType;
|
||||
returnValue = _interceptType;
|
||||
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
|
||||
returnValue = GetHashCode();
|
||||
} else if ("Equals" == methodName && 1 == argCount && typeof(bool) == returnType) {
|
||||
returnValue = Equals(callMessage.Args[0]);
|
||||
} else if (1 == argCount && typeof(void) == returnType && (methodName.StartsWith("add_") || methodName.StartsWith("remove_"))) {
|
||||
bool removeHandler = methodName.StartsWith("remove_");
|
||||
methodName = methodName.Substring(removeHandler ? 7 : 4);
|
||||
|
||||
Delegate handler = callMessage.InArgs[0] as Delegate;
|
||||
var handler = callMessage.InArgs[0] as Delegate;
|
||||
if (null == handler) {
|
||||
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
|
||||
return new ReturnMessage(new ArgumentNullException(nameof(handler)), callMessage);
|
||||
}
|
||||
} else {
|
||||
invokeObject = _COMObject;
|
||||
invokeType = _COMType;
|
||||
invokeObject = _comObject;
|
||||
invokeType = _comType;
|
||||
|
||||
if (methodName.StartsWith("get_")) {
|
||||
// Property Get
|
||||
@ -532,7 +410,7 @@ namespace Greenshot.Interop {
|
||||
wrapper = RemotingServices.GetRealProxy(args[i]) as COMWrapper;
|
||||
if (null != wrapper) {
|
||||
originalArgs[i] = wrapper;
|
||||
args[i] = wrapper._COMObject;
|
||||
args[i] = wrapper._comObject;
|
||||
}
|
||||
} else if (0 != outArgsCount && argModifiers[0][i]) {
|
||||
byValType = GetByValType(parameters[i].ParameterType);
|
||||
@ -543,7 +421,7 @@ namespace Greenshot.Interop {
|
||||
if (null == args[i]) {
|
||||
args[i] = new DispatchWrapper(null);
|
||||
}
|
||||
} else if (typeof(Decimal) == byValType) {
|
||||
} else if (typeof(decimal) == byValType) {
|
||||
// If we're passing a decimal value by reference,
|
||||
// we need to pass a CurrencyWrapper to avoid a
|
||||
// type mismatch exception.
|
||||
@ -590,7 +468,7 @@ namespace Greenshot.Interop {
|
||||
wrapper = null;
|
||||
|
||||
byValType = GetByValType(parameter.ParameterType);
|
||||
if (typeof(Decimal) == byValType) {
|
||||
if (typeof(decimal) == byValType) {
|
||||
if (arg is CurrencyWrapper) {
|
||||
arg = ((CurrencyWrapper)arg).WrappedObject;
|
||||
}
|
||||
@ -599,7 +477,7 @@ namespace Greenshot.Interop {
|
||||
} else if (byValType.IsInterface) {
|
||||
if (Marshal.IsComObject(arg)) {
|
||||
wrapper = originalArgs[i];
|
||||
if (null != wrapper && wrapper._COMObject != arg) {
|
||||
if (null != wrapper && wrapper._comObject != arg) {
|
||||
wrapper.Dispose();
|
||||
wrapper = null;
|
||||
}
|
||||
@ -626,7 +504,7 @@ namespace Greenshot.Interop {
|
||||
/// <param name="o">object to cast</param>
|
||||
/// <returns></returns>
|
||||
public bool CanCastTo(Type toType, object o) {
|
||||
bool returnValue = _InterceptType.IsAssignableFrom(toType);
|
||||
bool returnValue = _interceptType.IsAssignableFrom(toType);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace GreenshotOCR {
|
||||
[IniSection("OCR", Description="Greenshot OCR Plugin configuration")]
|
||||
public class OCRConfiguration : IniSection {
|
||||
[IniProperty("Language", Description="Language for OCR", DefaultValue="miLANG_ENGLISH")]
|
||||
public string Language;
|
||||
public string Language { get; set; }
|
||||
[IniProperty("orientimage", Description="Orient image?", DefaultValue="true")]
|
||||
public bool Orientimage;
|
||||
public bool Orientimage { get; set; }
|
||||
[IniProperty("straightenImage", Description="Straighten image?", DefaultValue="true")]
|
||||
public bool StraightenImage;
|
||||
public bool StraightenImage { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -94,9 +94,8 @@ namespace GreenshotOCR {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="greenshotHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost greenshotHost, PluginAttribute myAttributes) {
|
||||
LOG.Debug("Initialize called of " + myAttributes.Name);
|
||||
|
@ -28,24 +28,25 @@ namespace GreenshotOfficePlugin {
|
||||
/// </summary>
|
||||
[IniSection("Office", Description="Greenshot Office configuration")]
|
||||
public class OfficeConfiguration : IniSection {
|
||||
[IniProperty("OutlookEmailFormat", Description = "Default type for emails. (Text, HTML)", DefaultValue="HTML")]
|
||||
public EmailFormat OutlookEmailFormat;
|
||||
[IniProperty("OutlookEmailFormat", Description = "Default type for emails. (Text, HTML)", DefaultValue = "HTML")]
|
||||
public EmailFormat OutlookEmailFormat { get; set; }
|
||||
|
||||
[IniProperty("EmailSubjectPattern", Description = "Email subject pattern, works like the OutputFileFilenamePattern", DefaultValue = "${title}")]
|
||||
public string EmailSubjectPattern;
|
||||
public string EmailSubjectPattern { get; set; }
|
||||
[IniProperty("EmailTo", Description = "Default value for the to in emails that are created", DefaultValue = "")]
|
||||
public string EmailTo;
|
||||
public string EmailTo { get; set; }
|
||||
[IniProperty("EmailCC", Description = "Default value for the CC in emails that are created", DefaultValue = "")]
|
||||
public string EmailCC;
|
||||
public string EmailCC { get; set; }
|
||||
[IniProperty("EmailBCC", Description = "Default value for the BCC in emails that are created", DefaultValue = "")]
|
||||
public string EmailBCC;
|
||||
public string EmailBCC { get; set; }
|
||||
[IniProperty("OutlookAllowExportInMeetings", Description = "For Outlook: Allow export in meeting items", DefaultValue = "False")]
|
||||
public bool OutlookAllowExportInMeetings;
|
||||
public bool OutlookAllowExportInMeetings { get; set; }
|
||||
[IniProperty("WordLockAspectRatio", Description = "For Word: Lock the aspect ratio of the image", DefaultValue = "True")]
|
||||
public bool WordLockAspectRatio;
|
||||
public bool WordLockAspectRatio { get; set; }
|
||||
[IniProperty("PowerpointLockAspectRatio", Description = "For Powerpoint: Lock the aspect ratio of the image", DefaultValue = "True")]
|
||||
public bool PowerpointLockAspectRatio;
|
||||
public bool PowerpointLockAspectRatio { get; set; }
|
||||
[IniProperty("PowerpointSlideLayout", Description = "For Powerpoint: Slide layout, changing this to a wrong value will fallback on ppLayoutBlank!!", DefaultValue = "ppLayoutPictureWithCaption")]
|
||||
public PPSlideLayout PowerpointSlideLayout;
|
||||
public PPSlideLayout PowerpointSlideLayout { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace Greenshot.Interop.Office {
|
||||
/// <summary>
|
||||
/// Get all currently opened workbooks
|
||||
/// </summary>
|
||||
/// <returns>List<string> with names of the workbooks</returns>
|
||||
/// <returns>List of string with names of the workbooks</returns>
|
||||
public static List<string> GetWorkbooks() {
|
||||
List<string> currentWorkbooks = new List<string>();
|
||||
using (IExcelApplication excelApplication = GetExcelApplication()) {
|
||||
|
@ -49,7 +49,7 @@ namespace Greenshot.Interop.Office {
|
||||
/// <summary>
|
||||
/// A method to retrieve all inspectors which can act as an export target
|
||||
/// </summary>
|
||||
/// <returns>List<string> with inspector captions (window title)</returns>
|
||||
/// <returns>List of strings with inspector captions (window title)</returns>
|
||||
public static IDictionary<string, OlObjectClass> RetrievePossibleTargets() {
|
||||
IDictionary<string, OlObjectClass> inspectorCaptions = new SortedDictionary<string, OlObjectClass>();
|
||||
try {
|
||||
@ -76,7 +76,6 @@ namespace Greenshot.Interop.Office {
|
||||
if (inspectors != null && inspectors.Count > 0) {
|
||||
for (int i = 1; i <= inspectors.Count; i++) {
|
||||
using (IInspector inspector = outlookApplication.Inspectors[i]) {
|
||||
string inspectorCaption = inspector.Caption;
|
||||
using (IItem currentItem = inspector.CurrentItem) {
|
||||
if (canExportToInspector(currentItem)) {
|
||||
OlObjectClass currentItemClass = currentItem.Class;
|
||||
@ -328,13 +327,20 @@ namespace Greenshot.Interop.Office {
|
||||
LOG.Debug("Finished!");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export image to a new email
|
||||
/// </summary>
|
||||
/// <param name="outlookApplication"></param>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="captureDetails"></param>
|
||||
private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) {
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="attachmentName"></param>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="cc"></param>
|
||||
/// <param name="bcc"></param>
|
||||
/// <param name="url"></param>
|
||||
private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url) {
|
||||
using (IItem newItem = outlookApplication.CreateItem(OlItemType.olMailItem)) {
|
||||
if (newItem == null) {
|
||||
return;
|
||||
@ -345,11 +351,11 @@ namespace Greenshot.Interop.Office {
|
||||
if (!string.IsNullOrEmpty(to)) {
|
||||
newMail.To = to;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(CC)) {
|
||||
newMail.CC = CC;
|
||||
if (!string.IsNullOrEmpty(cc)) {
|
||||
newMail.CC = cc;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(BCC)) {
|
||||
newMail.BCC = BCC;
|
||||
if (!string.IsNullOrEmpty(bcc)) {
|
||||
newMail.BCC = bcc;
|
||||
}
|
||||
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
|
||||
string bodyString = null;
|
||||
@ -362,7 +368,8 @@ namespace Greenshot.Interop.Office {
|
||||
switch (format) {
|
||||
case EmailFormat.Text:
|
||||
// Create the attachment (and dispose the COM object after using)
|
||||
using (IAttachment attachment = newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 1, attachmentName)) {
|
||||
using (newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 1, attachmentName))
|
||||
{
|
||||
newMail.BodyFormat = OlBodyFormat.olFormatPlain;
|
||||
if (bodyString == null) {
|
||||
bodyString = "";
|
||||
@ -433,14 +440,21 @@ namespace Greenshot.Interop.Office {
|
||||
/// <summary>
|
||||
/// Helper method to create an outlook mail item with attachment
|
||||
/// </summary>
|
||||
/// <param name="tmpfile">The file to send, do not delete the file right away!</param>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="tmpFile">The file to send, do not delete the file right away!</param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="attachmentName"></param>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="cc"></param>
|
||||
/// <param name="bcc"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns>true if it worked, false if not</returns>
|
||||
public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) {
|
||||
public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url) {
|
||||
bool exported = false;
|
||||
try {
|
||||
using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
|
||||
if (outlookApplication != null) {
|
||||
ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, CC, BCC, url);
|
||||
ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, cc, bcc, url);
|
||||
exported = true;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace Greenshot.Interop.Office {
|
||||
/// <param name="wordApplication"></param>
|
||||
/// <param name="wordDocument"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="adress">link for the image</param>
|
||||
/// <param name="address">link for the image</param>
|
||||
/// <param name="tooltip">tooltip of the image</param>
|
||||
/// <returns></returns>
|
||||
internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile, string address, string tooltip) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
|
||||
namespace GreenshotOfficePlugin {
|
||||
@ -30,15 +28,14 @@ namespace GreenshotOfficePlugin {
|
||||
/// </summary>
|
||||
public class OfficePlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OfficePlugin));
|
||||
public static PluginAttribute Attributes;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
//if (disposing) {}
|
||||
protected void Dispose(bool disposing) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
@ -100,7 +97,6 @@ namespace GreenshotOfficePlugin {
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
Attributes = myAttributes;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -113,15 +109,5 @@ namespace GreenshotOfficePlugin {
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Office Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,22 +30,22 @@ namespace GreenshotPhotobucketPlugin {
|
||||
[IniSection("Photobucket", Description="Greenshot Photobucket Plugin configuration")]
|
||||
public class PhotobucketConfiguration : IniSection {
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
|
||||
public bool UploadReduceColors;
|
||||
public bool UploadReduceColors { get; set; }
|
||||
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
|
||||
public bool UsePageLink;
|
||||
public bool UsePageLink { get; set; }
|
||||
[IniProperty("Token", Description = "The Photobucket token", Encrypted=true, ExcludeIfNull=true)]
|
||||
public string Token;
|
||||
public string Token { get; set; }
|
||||
[IniProperty("TokenSecret", Description = "The Photobucket token secret", Encrypted=true, ExcludeIfNull=true)]
|
||||
public string TokenSecret;
|
||||
public string TokenSecret { get; set; }
|
||||
[IniProperty("SubDomain", Description = "The Photobucket api subdomain", Encrypted = true, ExcludeIfNull = true)]
|
||||
public string SubDomain;
|
||||
public string SubDomain { get; set; }
|
||||
[IniProperty("Username", Description = "The Photobucket api username", ExcludeIfNull = true)]
|
||||
public string Username;
|
||||
|
||||
public string Username { get; set; }
|
||||
|
||||
public int Credits {
|
||||
get;
|
||||
set;
|
||||
|
@ -34,12 +34,12 @@ namespace GreenshotPhotobucketPlugin {
|
||||
/// This is the GreenshotPhotobucketPlugin base code
|
||||
/// </summary>
|
||||
public class PhotobucketPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketPlugin));
|
||||
private static PhotobucketConfiguration config;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(PhotobucketPlugin));
|
||||
private static PhotobucketConfiguration _config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost host;
|
||||
private ComponentResourceManager resources;
|
||||
private ToolStripMenuItem itemPlugInConfig;
|
||||
private IGreenshotHost _host;
|
||||
private ComponentResourceManager _resources;
|
||||
private ToolStripMenuItem _itemPlugInConfig;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
@ -48,9 +48,9 @@ namespace GreenshotPhotobucketPlugin {
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Dispose();
|
||||
itemPlugInConfig = null;
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Dispose();
|
||||
_itemPlugInConfig = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,97 +69,89 @@ namespace GreenshotPhotobucketPlugin {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
host = (IGreenshotHost)pluginHost;
|
||||
_host = pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
// Get configuration
|
||||
config = IniConfig.GetIniSection<PhotobucketConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(PhotobucketPlugin));
|
||||
|
||||
itemPlugInConfig = new ToolStripMenuItem(Language.GetString("photobucket", LangKey.configure));
|
||||
itemPlugInConfig.Tag = host;
|
||||
itemPlugInConfig.Click += delegate {
|
||||
config.ShowConfigDialog();
|
||||
};
|
||||
itemPlugInConfig.Image = (Image)resources.GetObject("Photobucket");
|
||||
_config = IniConfig.GetIniSection<PhotobucketConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(PhotobucketPlugin));
|
||||
|
||||
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
|
||||
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
||||
_itemPlugInConfig = new ToolStripMenuItem(Language.GetString("photobucket", LangKey.configure))
|
||||
{
|
||||
Tag = _host,
|
||||
Image = (Image)_resources.GetObject("Photobucket")
|
||||
};
|
||||
_itemPlugInConfig.Click += delegate {
|
||||
_config.ShowConfigDialog();
|
||||
};
|
||||
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnLanguageChanged(object sender, EventArgs e) {
|
||||
if (itemPlugInConfig != null) {
|
||||
itemPlugInConfig.Text = Language.GetString("photobucket", LangKey.configure);
|
||||
if (_itemPlugInConfig != null) {
|
||||
_itemPlugInConfig.Text = Language.GetString("photobucket", LangKey.configure);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Photobucket Plugin shutdown.");
|
||||
Language.LanguageChanged -= new LanguageChangedHandler(OnLanguageChanged);
|
||||
Log.Debug("Photobucket Plugin shutdown.");
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Photobucket Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload the capture to Photobucket
|
||||
/// </summary>
|
||||
/// <param name="captureDetails"></param>
|
||||
/// <param name="surfaceToUpload">ISurface</param>
|
||||
/// <param name="uploadURL">out string for the url</param>
|
||||
/// <param name="albumPath">Path to the album</param>
|
||||
/// <param name="uploadUrl">out string for the url</param>
|
||||
/// <returns>true if the upload succeeded</returns>
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, string albumPath, out string uploadURL) {
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, string albumPath, out string uploadUrl) {
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors);
|
||||
try {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
|
||||
PhotobucketInfo photobucketInfo = null;
|
||||
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait),
|
||||
delegate() {
|
||||
delegate {
|
||||
photobucketInfo = PhotobucketUtils.UploadToPhotobucket(surfaceToUpload, outputSettings, albumPath, captureDetails.Title, filename);
|
||||
}
|
||||
);
|
||||
// This causes an exeption if the upload failed :)
|
||||
LOG.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page);
|
||||
uploadURL = null;
|
||||
Log.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page);
|
||||
uploadUrl = null;
|
||||
try {
|
||||
if (config.UsePageLink) {
|
||||
uploadURL = photobucketInfo.Page;
|
||||
if (_config.UsePageLink) {
|
||||
uploadUrl = photobucketInfo.Page;
|
||||
Clipboard.SetText(photobucketInfo.Page);
|
||||
} else {
|
||||
uploadURL = photobucketInfo.Original;
|
||||
uploadUrl = photobucketInfo.Original;
|
||||
Clipboard.SetText(photobucketInfo.Original);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Can't write to clipboard: ", ex);
|
||||
Log.Error("Can't write to clipboard: ", ex);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
Log.Error(e);
|
||||
MessageBox.Show(Language.GetString("photobucket", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
uploadURL = null;
|
||||
uploadUrl = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ namespace GreenshotPhotobucketPlugin {
|
||||
/// <summary>
|
||||
/// Get list of photobucket albums
|
||||
/// </summary>
|
||||
/// <returns>List<string></returns>
|
||||
/// <returns>List of string</returns>
|
||||
public static List<string> RetrievePhotobucketAlbums() {
|
||||
if (albumsCache != null) {
|
||||
return albumsCache;
|
||||
|
@ -29,14 +29,13 @@ namespace GreenshotPicasaPlugin {
|
||||
[IniSection("Picasa", Description = "Greenshot Picasa Plugin configuration")]
|
||||
public class PicasaConfiguration : IniSection {
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
public OutputFormat UploadFormat { get; set; }
|
||||
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
public int UploadJpegQuality { get; set; }
|
||||
|
||||
[IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send Picasa link to clipboard.", DefaultValue = "true")]
|
||||
public bool AfterUploadLinkToClipBoard;
|
||||
|
||||
public bool AfterUploadLinkToClipBoard { get; set; }
|
||||
[IniProperty("AddFilename", Description = "Is the filename passed on to Picasa", DefaultValue = "False")]
|
||||
public bool AddFilename {
|
||||
get;
|
||||
|
@ -33,12 +33,12 @@ namespace GreenshotPicasaPlugin {
|
||||
/// This is the Picasa base code
|
||||
/// </summary>
|
||||
public class PicasaPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PicasaPlugin));
|
||||
private static PicasaConfiguration config;
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(PicasaPlugin));
|
||||
private static PicasaConfiguration _config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost host;
|
||||
private ComponentResourceManager resources;
|
||||
private ToolStripMenuItem itemPlugInRoot;
|
||||
private IGreenshotHost _host;
|
||||
private ComponentResourceManager _resources;
|
||||
private ToolStripMenuItem _itemPlugInRoot;
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
@ -47,9 +47,9 @@ namespace GreenshotPicasaPlugin {
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (itemPlugInRoot != null) {
|
||||
itemPlugInRoot.Dispose();
|
||||
itemPlugInRoot = null;
|
||||
if (_itemPlugInRoot != null) {
|
||||
_itemPlugInRoot.Dispose();
|
||||
_itemPlugInRoot = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,36 +69,35 @@ namespace GreenshotPicasaPlugin {
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
host = (IGreenshotHost)pluginHost;
|
||||
_host = pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
// Get configuration
|
||||
config = IniConfig.GetIniSection<PicasaConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(PicasaPlugin));
|
||||
_config = IniConfig.GetIniSection<PicasaConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(PicasaPlugin));
|
||||
|
||||
itemPlugInRoot = new ToolStripMenuItem();
|
||||
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
||||
itemPlugInRoot.Tag = host;
|
||||
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
|
||||
itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
|
||||
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
|
||||
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
|
||||
_itemPlugInRoot = new ToolStripMenuItem();
|
||||
_itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
||||
_itemPlugInRoot.Tag = _host;
|
||||
_itemPlugInRoot.Image = (Image)_resources.GetObject("Picasa");
|
||||
_itemPlugInRoot.Click += ConfigMenuClick;
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnLanguageChanged(object sender, EventArgs e) {
|
||||
if (itemPlugInRoot != null) {
|
||||
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
||||
if (_itemPlugInRoot != null) {
|
||||
_itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Picasa Plugin shutdown.");
|
||||
Language.LanguageChanged -= new LanguageChangedHandler(OnLanguageChanged);
|
||||
Log.Debug("Picasa Plugin shutdown.");
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
//host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||
}
|
||||
|
||||
@ -106,17 +105,7 @@ namespace GreenshotPicasaPlugin {
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Picasa Plugin!");
|
||||
Shutdown();
|
||||
_config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
public void ConfigMenuClick(object sender, EventArgs eventArgs) {
|
||||
@ -124,24 +113,24 @@ namespace GreenshotPicasaPlugin {
|
||||
}
|
||||
|
||||
public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl) {
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality);
|
||||
try {
|
||||
string url = null;
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
|
||||
delegate() {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
string contentType = "image/" + config.UploadFormat.ToString();
|
||||
delegate
|
||||
{
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
|
||||
url = PicasaUtils.UploadToPicasa(surfaceToUpload, outputSettings, captureDetails.Title, filename);
|
||||
}
|
||||
);
|
||||
uploadUrl = url;
|
||||
|
||||
if (uploadUrl != null && config.AfterUploadLinkToClipBoard) {
|
||||
if (uploadUrl != null && _config.AfterUploadLinkToClipBoard) {
|
||||
ClipboardHelper.SetClipboardData(uploadUrl);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Error uploading.", e);
|
||||
Log.Error("Error uploading.", e);
|
||||
MessageBox.Show(Language.GetString("picasa", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
uploadUrl = null;
|
||||
|
@ -28,7 +28,7 @@ namespace GreenshotPlugin.Controls {
|
||||
/// <summary>
|
||||
/// Description of PleaseWaitForm.
|
||||
/// </summary>
|
||||
public partial class BackgroundForm : Form {
|
||||
public sealed partial class BackgroundForm : Form {
|
||||
private volatile bool _shouldClose;
|
||||
|
||||
private void BackgroundShowDialog() {
|
||||
|
@ -457,7 +457,6 @@ namespace GreenshotPlugin.Controls {
|
||||
/// <summary>
|
||||
/// Register a hotkey
|
||||
/// </summary>
|
||||
/// <param name="hWnd">The window which will get the event</param>
|
||||
/// <param name="modifierKeyCode">The modifier, e.g.: Modifiers.CTRL, Modifiers.NONE or Modifiers.ALT</param>
|
||||
/// <param name="virtualKeyCode">The virtual key code</param>
|
||||
/// <param name="handler">A HotKeyHandler, this will be called to handle the hotkey press</param>
|
||||
|
@ -299,14 +299,17 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Return a menu item
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="addDynamics"></param>
|
||||
/// <param name="destinationClickHandler"></param>
|
||||
/// <returns>ToolStripMenuItem</returns>
|
||||
public virtual ToolStripMenuItem GetMenuItem(bool addDynamics, ContextMenuStrip menu, EventHandler destinationClickHandler) {
|
||||
ToolStripMenuItem basisMenuItem;
|
||||
basisMenuItem = new ToolStripMenuItem(Description);
|
||||
basisMenuItem.Image = DisplayIcon;
|
||||
basisMenuItem.Tag = this;
|
||||
basisMenuItem.Text = Description;
|
||||
var basisMenuItem = new ToolStripMenuItem(Description)
|
||||
{
|
||||
Image = DisplayIcon,
|
||||
Tag = this,
|
||||
Text = Description
|
||||
};
|
||||
AddTagEvents(basisMenuItem, menu, Description);
|
||||
basisMenuItem.Click -= destinationClickHandler;
|
||||
basisMenuItem.Click += destinationClickHandler;
|
||||
|
@ -50,7 +50,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// Get a struct from a byte array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">typeof struct</typeparam>
|
||||
/// <param name="bytes">byte[]</param>
|
||||
/// <param name="intPtr">Pointer to the structor to return</param>
|
||||
/// <returns>struct</returns>
|
||||
public static T FromIntPtr<T>(IntPtr intPtr) where T : struct {
|
||||
object obj = Marshal.PtrToStructure(intPtr, typeof(T));
|
||||
|
@ -304,7 +304,7 @@ EndSelection:<<<<<<<4
|
||||
/// Returned images must be disposed by the calling code!
|
||||
/// </summary>
|
||||
/// <param name="dataObject"></param>
|
||||
/// <returns>IEnumerable<Image></returns>
|
||||
/// <returns>IEnumerable of Image</returns>
|
||||
public static IEnumerable<Image> GetImages(IDataObject dataObject) {
|
||||
// Get single image, this takes the "best" match
|
||||
Image singleImage = GetImage(dataObject);
|
||||
@ -708,7 +708,7 @@ EndSelection:<<<<<<<4
|
||||
/// <summary>
|
||||
/// Retrieve a list of all formats currently on the clipboard
|
||||
/// </summary>
|
||||
/// <returns>List<string> with the current formats</returns>
|
||||
/// <returns>List of strings with the current formats</returns>
|
||||
public static List<string> GetFormats() {
|
||||
return GetFormats(GetDataObject());
|
||||
}
|
||||
@ -716,7 +716,7 @@ EndSelection:<<<<<<<4
|
||||
/// <summary>
|
||||
/// Retrieve a list of all formats currently in the IDataObject
|
||||
/// </summary>
|
||||
/// <returns>List<string> with the current formats</returns>
|
||||
/// <returns>List of string with the current formats</returns>
|
||||
public static List<string> GetFormats(IDataObject dataObj) {
|
||||
string[] formats = null;
|
||||
|
||||
@ -733,7 +733,6 @@ EndSelection:<<<<<<<4
|
||||
/// <summary>
|
||||
/// Check if there is currently something in the dataObject which has the supplied format
|
||||
/// </summary>
|
||||
/// <param name="dataObject">IDataObject</param>
|
||||
/// <param name="format">string with format</param>
|
||||
/// <returns>true if one the format is found</returns>
|
||||
public static bool ContainsFormat(string format) {
|
||||
@ -743,6 +742,7 @@ EndSelection:<<<<<<<4
|
||||
/// <summary>
|
||||
/// Check if there is currently something on the clipboard which has the supplied format
|
||||
/// </summary>
|
||||
/// <param name="dataObject">IDataObject</param>
|
||||
/// <param name="format">string with format</param>
|
||||
/// <returns>true if one the format is found</returns>
|
||||
public static bool ContainsFormat(IDataObject dataObject, string format) {
|
||||
|
@ -62,206 +62,206 @@ namespace GreenshotPlugin.Core {
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[IniProperty("Language", Description = "The language in IETF format (e.g. en-US)")]
|
||||
public string Language;
|
||||
public string Language { get; set; }
|
||||
|
||||
[IniProperty("RegionHotkey", Description="Hotkey for starting the region capture", DefaultValue="PrintScreen")]
|
||||
public string RegionHotkey;
|
||||
public string RegionHotkey { get; set; }
|
||||
[IniProperty("WindowHotkey", Description="Hotkey for starting the window capture", DefaultValue="Alt + PrintScreen")]
|
||||
public string WindowHotkey;
|
||||
public string WindowHotkey { get; set; }
|
||||
[IniProperty("FullscreenHotkey", Description="Hotkey for starting the fullscreen capture", DefaultValue="Ctrl + PrintScreen")]
|
||||
public string FullscreenHotkey;
|
||||
public string FullscreenHotkey { get; set; }
|
||||
[IniProperty("LastregionHotkey", Description="Hotkey for starting the last region capture", DefaultValue="Shift + PrintScreen")]
|
||||
public string LastregionHotkey;
|
||||
public string LastregionHotkey { get; set; }
|
||||
[IniProperty("IEHotkey", Description="Hotkey for starting the IE capture", DefaultValue="Shift + Ctrl + PrintScreen")]
|
||||
public string IEHotkey;
|
||||
public string IEHotkey { get; set; }
|
||||
|
||||
[IniProperty("IsFirstLaunch", Description="Is this the first time launch?", DefaultValue="true")]
|
||||
public bool IsFirstLaunch;
|
||||
public bool IsFirstLaunch { get; set; }
|
||||
[IniProperty("Destinations", Separator=",", Description="Which destinations? Possible options (more might be added by plugins) are: Editor, FileDefault, FileWithDialog, Clipboard, Printer, EMail, Picker", DefaultValue="Picker")]
|
||||
public List<string> OutputDestinations = new List<string>();
|
||||
public List<string> OutputDestinations { get; set; } = new List<string>();
|
||||
[IniProperty("ClipboardFormats", Separator=",", Description="Specify which formats we copy on the clipboard? Options are: PNG, HTML, HTMLDATAURL and DIB", DefaultValue="PNG,DIB")]
|
||||
public List<ClipboardFormat> ClipboardFormats = new List<ClipboardFormat>();
|
||||
public List<ClipboardFormat> ClipboardFormats { get; set; } = new List<ClipboardFormat>();
|
||||
|
||||
[IniProperty("CaptureMousepointer", Description="Should the mouse be captured?", DefaultValue="true")]
|
||||
public bool CaptureMousepointer;
|
||||
public bool CaptureMousepointer { get; set; }
|
||||
[IniProperty("CaptureWindowsInteractive", Description="Use interactive window selection to capture? (false=Capture active window)", DefaultValue="false")]
|
||||
public bool CaptureWindowsInteractive;
|
||||
public bool CaptureWindowsInteractive { get; set; }
|
||||
[IniProperty("CaptureDelay", Description="Capture delay in millseconds.", DefaultValue="100")]
|
||||
public int CaptureDelay;
|
||||
public int CaptureDelay { get; set; }
|
||||
[IniProperty("ScreenCaptureMode", Description = "The capture mode used to capture a screen. (Auto, FullScreen, Fixed)", DefaultValue = "Auto")]
|
||||
public ScreenCaptureMode ScreenCaptureMode;
|
||||
public ScreenCaptureMode ScreenCaptureMode { get; set; }
|
||||
[IniProperty("ScreenToCapture", Description = "The screen number to capture when using ScreenCaptureMode Fixed.", DefaultValue = "1")]
|
||||
public int ScreenToCapture;
|
||||
public int ScreenToCapture { get; set; }
|
||||
[IniProperty("WindowCaptureMode", Description = "The capture mode used to capture a Window (Screen, GDI, Aero, AeroTransparent, Auto).", DefaultValue = "Auto")]
|
||||
public WindowCaptureMode WindowCaptureMode;
|
||||
public WindowCaptureMode WindowCaptureMode { get; set; }
|
||||
[IniProperty("WindowCaptureAllChildLocations", Description="Enable/disable capture all children, very slow but will make it possible to use this information in the editor.", DefaultValue="False")]
|
||||
public bool WindowCaptureAllChildLocations;
|
||||
public bool WindowCaptureAllChildLocations { get; set; }
|
||||
|
||||
[IniProperty("DWMBackgroundColor", Description="The background color for a DWM window capture.")]
|
||||
public Color DWMBackgroundColor;
|
||||
public Color DWMBackgroundColor { get; set; }
|
||||
|
||||
[IniProperty("PlayCameraSound", LanguageKey="settings_playsound",Description="Play a camera sound after taking a capture.", DefaultValue="false")]
|
||||
public bool PlayCameraSound = false;
|
||||
public bool PlayCameraSound { get; set; } = false;
|
||||
[IniProperty("ShowTrayNotification", LanguageKey="settings_shownotify",Description="Show a notification from the systray when a capture is taken.", DefaultValue="true")]
|
||||
public bool ShowTrayNotification = true;
|
||||
public bool ShowTrayNotification { get; set; } = true;
|
||||
|
||||
[IniProperty("OutputFilePath", Description="Output file path.")]
|
||||
public string OutputFilePath;
|
||||
public string OutputFilePath { get; set; }
|
||||
[IniProperty("OutputFileAllowOverwrite", Description = "If the target file already exists True will make Greenshot always overwrite and False will display a 'Save-As' dialog.", DefaultValue = "true")]
|
||||
public bool OutputFileAllowOverwrite;
|
||||
public bool OutputFileAllowOverwrite { get; set; }
|
||||
[IniProperty("OutputFileFilenamePattern", Description = "Filename pattern for screenshot.", DefaultValue = "${capturetime:d\"yyyy-MM-dd HH_mm_ss\"}-${title}")]
|
||||
public string OutputFileFilenamePattern;
|
||||
public string OutputFileFilenamePattern { get; set; }
|
||||
[IniProperty("OutputFileFormat", Description="Default file type for writing screenshots. (bmp, gif, jpg, png, tiff)", DefaultValue="png")]
|
||||
public OutputFormat OutputFileFormat = OutputFormat.png;
|
||||
public OutputFormat OutputFileFormat { get; set; } = OutputFormat.png;
|
||||
[IniProperty("OutputFileReduceColors", Description="If set to true, than the colors of the output file are reduced to 256 (8-bit) colors", DefaultValue="false")]
|
||||
public bool OutputFileReduceColors;
|
||||
public bool OutputFileReduceColors { get; set; }
|
||||
[IniProperty("OutputFileAutoReduceColors", Description = "If set to true the amount of colors is counted and if smaller than 256 the color reduction is automatically used.", DefaultValue = "false")]
|
||||
public bool OutputFileAutoReduceColors;
|
||||
public bool OutputFileAutoReduceColors { get; set; }
|
||||
[IniProperty("OutputFileReduceColorsTo", Description = "Amount of colors to reduce to, when reducing", DefaultValue = "256")]
|
||||
public int OutputFileReduceColorsTo;
|
||||
public int OutputFileReduceColorsTo { get; set; }
|
||||
|
||||
[IniProperty("OutputFileCopyPathToClipboard", Description="When saving a screenshot, copy the path to the clipboard?", DefaultValue="true")]
|
||||
public bool OutputFileCopyPathToClipboard;
|
||||
public bool OutputFileCopyPathToClipboard { get; set; }
|
||||
[IniProperty("OutputFileAsFullpath", Description="SaveAs Full path?")]
|
||||
public string OutputFileAsFullpath;
|
||||
|
||||
public string OutputFileAsFullpath { get; set; }
|
||||
|
||||
[IniProperty("OutputFileJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int OutputFileJpegQuality;
|
||||
public int OutputFileJpegQuality { get; set; }
|
||||
[IniProperty("OutputFilePromptQuality", Description="Ask for the quality before saving?", DefaultValue="false")]
|
||||
public bool OutputFilePromptQuality;
|
||||
public bool OutputFilePromptQuality { get; set; }
|
||||
[IniProperty("OutputFileIncrementingNumber", Description="The number for the ${NUM} in the filename pattern, is increased automatically after each save.", DefaultValue="1")]
|
||||
public uint OutputFileIncrementingNumber;
|
||||
|
||||
public uint OutputFileIncrementingNumber { get; set; }
|
||||
|
||||
[IniProperty("OutputPrintPromptOptions", LanguageKey="settings_alwaysshowprintoptionsdialog", Description="Ask for print options when printing?", DefaultValue="true")]
|
||||
public bool OutputPrintPromptOptions;
|
||||
public bool OutputPrintPromptOptions { get; set; }
|
||||
[IniProperty("OutputPrintAllowRotate", LanguageKey="printoptions_allowrotate", Description="Allow rotating the picture for fitting on paper?", DefaultValue="false")]
|
||||
public bool OutputPrintAllowRotate;
|
||||
public bool OutputPrintAllowRotate { get; set; }
|
||||
[IniProperty("OutputPrintAllowEnlarge", LanguageKey="printoptions_allowenlarge", Description="Allow growing the picture for fitting on paper?", DefaultValue="false")]
|
||||
public bool OutputPrintAllowEnlarge;
|
||||
public bool OutputPrintAllowEnlarge { get; set; }
|
||||
[IniProperty("OutputPrintAllowShrink", LanguageKey="printoptions_allowshrink", Description="Allow shrinking the picture for fitting on paper?", DefaultValue="true")]
|
||||
public bool OutputPrintAllowShrink;
|
||||
public bool OutputPrintAllowShrink { get; set; }
|
||||
[IniProperty("OutputPrintCenter", LanguageKey="printoptions_allowcenter", Description="Center image when printing?", DefaultValue="true")]
|
||||
public bool OutputPrintCenter;
|
||||
public bool OutputPrintCenter { get; set; }
|
||||
[IniProperty("OutputPrintInverted", LanguageKey="printoptions_inverted", Description="Print image inverted (use e.g. for console captures)", DefaultValue="false")]
|
||||
public bool OutputPrintInverted;
|
||||
public bool OutputPrintInverted { get; set; }
|
||||
[IniProperty("OutputPrintGrayscale", LanguageKey = "printoptions_printgrayscale", Description = "Force grayscale printing", DefaultValue = "false")]
|
||||
public bool OutputPrintGrayscale;
|
||||
public bool OutputPrintGrayscale { get; set; }
|
||||
[IniProperty("OutputPrintMonochrome", LanguageKey = "printoptions_printmonochrome", Description = "Force monorchrome printing", DefaultValue = "false")]
|
||||
public bool OutputPrintMonochrome;
|
||||
public bool OutputPrintMonochrome { get; set; }
|
||||
[IniProperty("OutputPrintMonochromeThreshold", Description = "Threshold for monochrome filter (0 - 255), lower value means less black", DefaultValue = "127")]
|
||||
public byte OutputPrintMonochromeThreshold;
|
||||
public byte OutputPrintMonochromeThreshold { get; set; }
|
||||
[IniProperty("OutputPrintFooter", LanguageKey = "printoptions_timestamp", Description = "Print footer on print?", DefaultValue = "true")]
|
||||
public bool OutputPrintFooter;
|
||||
public bool OutputPrintFooter { get; set; }
|
||||
[IniProperty("OutputPrintFooterPattern", Description = "Footer pattern", DefaultValue = "${capturetime:d\"D\"} ${capturetime:d\"T\"} - ${title}")]
|
||||
public string OutputPrintFooterPattern;
|
||||
public string OutputPrintFooterPattern { get; set; }
|
||||
[IniProperty("NotificationSound", Description = "The wav-file to play when a capture is taken, loaded only once at the Greenshot startup", DefaultValue="default")]
|
||||
public string NotificationSound;
|
||||
public string NotificationSound { get; set; }
|
||||
[IniProperty("UseProxy", Description="Use your global proxy?", DefaultValue="True")]
|
||||
public bool UseProxy;
|
||||
public bool UseProxy { get; set; }
|
||||
[IniProperty("IECapture", Description="Enable/disable IE capture", DefaultValue="True")]
|
||||
public bool IECapture;
|
||||
public bool IECapture { get; set; }
|
||||
[IniProperty("IEFieldCapture", Description="Enable/disable IE field capture, very slow but will make it possible to annotate the fields of a capture in the editor.", DefaultValue="False")]
|
||||
public bool IEFieldCapture;
|
||||
public bool IEFieldCapture { get; set; }
|
||||
[IniProperty("WindowClassesToCheckForIE", Description = "Comma separated list of Window-Classes which need to be checked for a IE instance!", DefaultValue = "AfxFrameOrView70,IMWindowClass")]
|
||||
public List<string> WindowClassesToCheckForIE;
|
||||
public List<string> WindowClassesToCheckForIE { get; set; }
|
||||
[IniProperty("AutoCropDifference", Description="Sets how to compare the colors for the autocrop detection, the higher the more is 'selected'. Possible values are from 0 to 255, where everything above ~150 doesn't make much sense!", DefaultValue="10")]
|
||||
public int AutoCropDifference;
|
||||
public int AutoCropDifference { get; set; }
|
||||
|
||||
[IniProperty("IncludePlugins", Description="Comma separated list of Plugins which are allowed. If something in the list, than every plugin not in the list will not be loaded!")]
|
||||
public List<string> IncludePlugins;
|
||||
public List<string> IncludePlugins { get; set; }
|
||||
[IniProperty("ExcludePlugins", Description="Comma separated list of Plugins which are NOT allowed.")]
|
||||
public List<string> ExcludePlugins;
|
||||
public List<string> ExcludePlugins { get; set; }
|
||||
[IniProperty("ExcludeDestinations", Description = "Comma separated list of destinations which should be disabled.")]
|
||||
public List<string> ExcludeDestinations;
|
||||
public List<string> ExcludeDestinations { get; set; }
|
||||
|
||||
[IniProperty("UpdateCheckInterval", Description="How many days between every update check? (0=no checks)", DefaultValue="1")]
|
||||
public int UpdateCheckInterval;
|
||||
public int UpdateCheckInterval { get; set; }
|
||||
[IniProperty("LastUpdateCheck", Description="Last update check")]
|
||||
public DateTime LastUpdateCheck;
|
||||
public DateTime LastUpdateCheck { get; set; }
|
||||
|
||||
[IniProperty("DisableSettings", Description = "Enable/disable the access to the settings, can only be changed manually in this .ini", DefaultValue = "False")]
|
||||
public bool DisableSettings;
|
||||
public bool DisableSettings { get; set; }
|
||||
[IniProperty("DisableQuickSettings", Description = "Enable/disable the access to the quick settings, can only be changed manually in this .ini", DefaultValue = "False")]
|
||||
public bool DisableQuickSettings;
|
||||
public bool DisableQuickSettings { get; set; }
|
||||
[IniProperty("DisableTrayicon", Description = "Disable the trayicon, can only be changed manually in this .ini", DefaultValue = "False")]
|
||||
public bool HideTrayicon;
|
||||
public bool HideTrayicon { get; set; }
|
||||
[IniProperty("HideExpertSettings", Description = "Hide expert tab in the settings, can only be changed manually in this .ini", DefaultValue = "False")]
|
||||
public bool HideExpertSettings;
|
||||
public bool HideExpertSettings { get; set; }
|
||||
|
||||
[IniProperty("ThumnailPreview", Description="Enable/disable thumbnail previews", DefaultValue="True")]
|
||||
public bool ThumnailPreview;
|
||||
|
||||
public bool ThumnailPreview { get; set; }
|
||||
|
||||
[IniProperty("NoGDICaptureForProduct", Description = "List of productnames for which GDI capturing is skipped (using fallback).", DefaultValue = "IntelliJ IDEA")]
|
||||
public List<string> NoGDICaptureForProduct;
|
||||
public List<string> NoGDICaptureForProduct { get; set; }
|
||||
[IniProperty("NoDWMCaptureForProduct", Description = "List of productnames for which DWM capturing is skipped (using fallback).", DefaultValue = "Citrix ICA Client")]
|
||||
public List<string> NoDWMCaptureForProduct;
|
||||
public List<string> NoDWMCaptureForProduct { get; set; }
|
||||
|
||||
[IniProperty("OptimizeForRDP", Description="Make some optimizations for usage with remote desktop", DefaultValue="False")]
|
||||
public bool OptimizeForRDP;
|
||||
public bool OptimizeForRDP { get; set; }
|
||||
[IniProperty("DisableRDPOptimizing", Description = "Disable all optimizations for usage with remote desktop", DefaultValue = "False")]
|
||||
public bool DisableRDPOptimizing;
|
||||
public bool DisableRDPOptimizing { get; set; }
|
||||
|
||||
[IniProperty("MinimizeWorkingSetSize", Description="Optimize memory footprint, but with a performance penalty!", DefaultValue="False")]
|
||||
public bool MinimizeWorkingSetSize;
|
||||
public bool MinimizeWorkingSetSize { get; set; }
|
||||
|
||||
[IniProperty("WindowCaptureRemoveCorners", Description = "Remove the corners from a window capture", DefaultValue = "True")]
|
||||
public bool WindowCaptureRemoveCorners;
|
||||
public bool WindowCaptureRemoveCorners { get; set; }
|
||||
|
||||
[IniProperty("CheckForUnstable", Description = "Also check for unstable version updates", DefaultValue = "False")]
|
||||
public bool CheckForUnstable;
|
||||
public bool CheckForUnstable { get; set; }
|
||||
|
||||
[IniProperty("ActiveTitleFixes", Description="The fixes that are active.")]
|
||||
public List<string> ActiveTitleFixes;
|
||||
|
||||
public List<string> ActiveTitleFixes { get; set; }
|
||||
|
||||
[IniProperty("TitleFixMatcher", Description="The regular expressions to match the title with.")]
|
||||
public Dictionary<string, string> TitleFixMatcher;
|
||||
public Dictionary<string, string> TitleFixMatcher { get; set; }
|
||||
|
||||
[IniProperty("TitleFixReplacer", Description="The replacements for the matchers.")]
|
||||
public Dictionary<string, string> TitleFixReplacer;
|
||||
public Dictionary<string, string> TitleFixReplacer { get; set; }
|
||||
|
||||
[IniProperty("ExperimentalFeatures", Description="A list of experimental features, this allows us to test certain features before releasing them.", ExcludeIfNull=true)]
|
||||
public List<string> ExperimentalFeatures;
|
||||
public List<string> ExperimentalFeatures { get; set; }
|
||||
|
||||
[IniProperty("EnableSpecialDIBClipboardReader", Description = "Enable a special DIB clipboard reader", DefaultValue="True")]
|
||||
public bool EnableSpecialDIBClipboardReader;
|
||||
public bool EnableSpecialDIBClipboardReader { get; set; }
|
||||
|
||||
[IniProperty("WindowCornerCutShape", Description = "The cutshape which is used to remove the window corners, is mirrorred for all corners", DefaultValue = "5,3,2,1,1")]
|
||||
public List<int> WindowCornerCutShape;
|
||||
public List<int> WindowCornerCutShape { get; set; }
|
||||
|
||||
[IniProperty("LeftClickAction", Description = "Specify what action is made if the tray icon is left clicked, if a double-click action is specified this action is initiated after a delay (configurable via the windows double-click speed)", DefaultValue = "SHOW_CONTEXT_MENU")]
|
||||
public ClickActions LeftClickAction;
|
||||
public ClickActions LeftClickAction { get; set; }
|
||||
|
||||
[IniProperty("DoubleClickAction", Description = "Specify what action is made if the tray icon is double clicked", DefaultValue = "OPEN_LAST_IN_EXPLORER")]
|
||||
public ClickActions DoubleClickAction;
|
||||
public ClickActions DoubleClickAction { get; set; }
|
||||
|
||||
[IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")]
|
||||
public bool ZoomerEnabled;
|
||||
public bool ZoomerEnabled { get; set; }
|
||||
[IniProperty("ZoomerOpacity", Description = "Specify the transparency for the zoomer, from 0-1 (where 1 is no transparency and 0 is complete transparent. An usefull setting would be 0.7)", DefaultValue = "1")]
|
||||
public float ZoomerOpacity;
|
||||
public float ZoomerOpacity { get; set; }
|
||||
|
||||
[IniProperty("MaxMenuItemLength", Description = "Maximum length of submenu items in the context menu, making this longer might cause context menu issues on dual screen systems.", DefaultValue = "25")]
|
||||
public int MaxMenuItemLength;
|
||||
public int MaxMenuItemLength { get; set; }
|
||||
|
||||
[IniProperty("MailApiTo", Description = "The 'to' field for the email destination (settings for Outlook can be found under the Office section)", DefaultValue = "")]
|
||||
public string MailApiTo;
|
||||
public string MailApiTo { get; set; }
|
||||
[IniProperty("MailApiCC", Description = "The 'CC' field for the email destination (settings for Outlook can be found under the Office section)", DefaultValue = "")]
|
||||
public string MailApiCC;
|
||||
public string MailApiCC { get; set; }
|
||||
[IniProperty("MailApiBCC", Description = "The 'BCC' field for the email destination (settings for Outlook can be found under the Office section)", DefaultValue = "")]
|
||||
public string MailApiBCC;
|
||||
public string MailApiBCC { get; set; }
|
||||
|
||||
[IniProperty("OptimizePNGCommand", Description = "Optional command to execute on a temporary PNG file, the command should overwrite the file and Greenshot will read it back. Note: this command is also executed when uploading PNG's!", DefaultValue = "")]
|
||||
public string OptimizePNGCommand;
|
||||
public string OptimizePNGCommand { get; set; }
|
||||
[IniProperty("OptimizePNGCommandArguments", Description = "Arguments for the optional command to execute on a PNG, {0} is replaced by the temp-filename from Greenshot. Note: Temp-file is deleted afterwards by Greenshot.", DefaultValue = "\"{0}\"")]
|
||||
public string OptimizePNGCommandArguments;
|
||||
public string OptimizePNGCommandArguments { get; set; }
|
||||
|
||||
[IniProperty("LastSaveWithVersion", Description = "Version of Greenshot which created this .ini")]
|
||||
public string LastSaveWithVersion;
|
||||
public string LastSaveWithVersion { get; set; }
|
||||
|
||||
[IniProperty("ProcessEXIFOrientation", Description = "When reading images from files or clipboard, use the EXIF information to correct the orientation", DefaultValue = "True")]
|
||||
public bool ProcessEXIFOrientation;
|
||||
public bool ProcessEXIFOrientation { get; set; }
|
||||
|
||||
[IniProperty("LastCapturedRegion", Description = "The last used region, for reuse in the capture last region")]
|
||||
public Rectangle LastCapturedRegion;
|
||||
public Rectangle LastCapturedRegion { get; set; }
|
||||
|
||||
private Size _iconSize;
|
||||
[IniProperty("IconSize", Description = "Defines the size of the icons (e.g. for the buttons in the editor), default value 16,16 anything bigger will cause scaling", DefaultValue = "16,16")]
|
||||
@ -295,9 +295,9 @@ namespace GreenshotPlugin.Core {
|
||||
}
|
||||
|
||||
[IniProperty("WebRequestTimeout", Description = "The connect timeout value for webrequets, these are seconds", DefaultValue = "100")]
|
||||
public int WebRequestTimeout;
|
||||
public int WebRequestTimeout { get; set; }
|
||||
[IniProperty("WebRequestReadWriteTimeout", Description = "The read/write timeout value for webrequets, these are seconds", DefaultValue = "100")]
|
||||
public int WebRequestReadWriteTimeout;
|
||||
public int WebRequestReadWriteTimeout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies what THIS build is
|
||||
|
@ -25,37 +25,37 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// The following code comes from: http://www.developerfusion.com/code/4693/using-the-credential-management-api/
|
||||
/// and is slightly modified so it works for us.
|
||||
/// As the "Stored usernames and passwords" which can be accessed by: Start-> Run and type "Control keymgr.dll"
|
||||
/// doesn't show all credentials use the tool here: http://www.microsoft.com/indonesia/msdn/credmgmt.aspx
|
||||
/// The following code is an example for a login, it will call the Authenticate with user/password
|
||||
/// which should return true if the login worked, false if not.
|
||||
/// private static bool Login(string system, string name) {
|
||||
/// try {
|
||||
/// CredentialsDialog dialog = new CredentialsDialog(system);
|
||||
/// dialog.Name = name;
|
||||
/// while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
/// if (Authenticate(dialog.Name, dialog.Password)) {
|
||||
/// if (dialog.SaveChecked) dialog.Confirm(true);
|
||||
/// return true;
|
||||
/// } else {
|
||||
/// try {
|
||||
/// dialog.Confirm(false);
|
||||
/// } catch (ApplicationException) {
|
||||
/// // exception handling ...
|
||||
/// }
|
||||
/// dialog.IncorrectPassword = true;
|
||||
/// }
|
||||
/// }
|
||||
/// } catch (ApplicationException) {
|
||||
/// // exception handling ...
|
||||
/// }
|
||||
/// return false;
|
||||
/// }
|
||||
/// </summary>
|
||||
namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// The following code comes from: http://www.developerfusion.com/code/4693/using-the-credential-management-api/
|
||||
/// and is slightly modified so it works for us.
|
||||
/// As the "Stored usernames and passwords" which can be accessed by: Start-> Run and type "Control keymgr.dll"
|
||||
/// doesn't show all credentials use the tool here: http://www.microsoft.com/indonesia/msdn/credmgmt.aspx
|
||||
/// The following code is an example for a login, it will call the Authenticate with user/password
|
||||
/// which should return true if the login worked, false if not.
|
||||
/// private static bool Login(string system, string name) {
|
||||
/// try {
|
||||
/// CredentialsDialog dialog = new CredentialsDialog(system);
|
||||
/// dialog.Name = name;
|
||||
/// while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
/// if (Authenticate(dialog.Name, dialog.Password)) {
|
||||
/// if (dialog.SaveChecked) dialog.Confirm(true);
|
||||
/// return true;
|
||||
/// } else {
|
||||
/// try {
|
||||
/// dialog.Confirm(false);
|
||||
/// } catch (ApplicationException) {
|
||||
/// // exception handling ...
|
||||
/// }
|
||||
/// dialog.IncorrectPassword = true;
|
||||
/// }
|
||||
/// }
|
||||
/// } catch (ApplicationException) {
|
||||
/// // exception handling ...
|
||||
/// }
|
||||
/// return false;
|
||||
/// }
|
||||
/// </summary>
|
||||
/// <summary>Encapsulates dialog functionality from the Credential Management API.</summary>
|
||||
public sealed class CredentialsDialog {
|
||||
[DllImport("gdi32.dll", SetLastError=true)]
|
||||
|
@ -52,7 +52,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// The returned byte[] color depends on the underlying pixel format
|
||||
/// </summary>
|
||||
/// <param name="x">int x</param>
|
||||
/// <param name="y">int y</par
|
||||
/// <param name="y">int y</param>
|
||||
/// <param name="color">byte array</param>
|
||||
void GetColorAt(int x, int y, byte[] color);
|
||||
|
||||
/// <summary>
|
||||
@ -139,7 +140,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Returns if this FastBitmap has an alpha channel
|
||||
/// </summary>
|
||||
bool hasAlphaChannel {
|
||||
bool HasAlphaChannel {
|
||||
get;
|
||||
}
|
||||
|
||||
@ -216,7 +217,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// The returned byte[] color depends on the underlying pixel format
|
||||
/// </summary>
|
||||
/// <param name="x">int x</param>
|
||||
/// <param name="y">int y</par
|
||||
/// <param name="y">int y</param>
|
||||
/// <param name="color">byte array</param>
|
||||
new void GetColorAt(int x, int y, byte[] color);
|
||||
|
||||
new int Left {
|
||||
@ -283,20 +285,20 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// The base class for the fast bitmap implementation
|
||||
/// </summary>
|
||||
public unsafe abstract class FastBitmap : IFastBitmap, IFastBitmapWithClip, IFastBitmapWithOffset {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(FastBitmap));
|
||||
public abstract unsafe class FastBitmap : IFastBitmap, IFastBitmapWithClip, IFastBitmapWithOffset {
|
||||
private static ILog _log = LogManager.GetLogger(typeof(FastBitmap));
|
||||
|
||||
protected const int PIXELFORMAT_INDEX_A = 3;
|
||||
protected const int PIXELFORMAT_INDEX_R = 2;
|
||||
protected const int PIXELFORMAT_INDEX_G = 1;
|
||||
protected const int PIXELFORMAT_INDEX_B = 0;
|
||||
protected const int PixelformatIndexA = 3;
|
||||
protected const int PixelformatIndexR = 2;
|
||||
protected const int PixelformatIndexG = 1;
|
||||
protected const int PixelformatIndexB = 0;
|
||||
|
||||
public const int COLOR_INDEX_R = 0;
|
||||
public const int COLOR_INDEX_G = 1;
|
||||
public const int COLOR_INDEX_B = 2;
|
||||
public const int COLOR_INDEX_A = 3;
|
||||
public const int ColorIndexR = 0;
|
||||
public const int ColorIndexG = 1;
|
||||
public const int ColorIndexB = 2;
|
||||
public const int ColorIndexA = 3;
|
||||
|
||||
protected Rectangle area = Rectangle.Empty;
|
||||
protected Rectangle Area = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// If this is set to true, the bitmap will be disposed when disposing the IFastBitmap
|
||||
/// </summary>
|
||||
@ -318,19 +320,19 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// The bitmap for which the FastBitmap is creating access
|
||||
/// </summary>
|
||||
protected Bitmap bitmap;
|
||||
protected Bitmap Bitmap;
|
||||
|
||||
protected BitmapData bmData;
|
||||
protected int stride; /* bytes per pixel row */
|
||||
protected bool bitsLocked;
|
||||
protected byte* pointer;
|
||||
protected BitmapData BmData;
|
||||
protected int Stride; /* bytes per pixel row */
|
||||
protected bool BitsLocked;
|
||||
protected byte* Pointer;
|
||||
|
||||
public static IFastBitmap Create(Bitmap source) {
|
||||
return Create(source, Rectangle.Empty);
|
||||
}
|
||||
|
||||
public void SetResolution(float horizontal, float vertical) {
|
||||
bitmap.SetResolution(horizontal, vertical);
|
||||
Bitmap.SetResolution(horizontal, vertical);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -345,12 +347,12 @@ namespace GreenshotPlugin.Core {
|
||||
case PixelFormat.Format8bppIndexed:
|
||||
return new FastChunkyBitmap(source, area);
|
||||
case PixelFormat.Format24bppRgb:
|
||||
return new Fast24RGBBitmap(source, area);
|
||||
return new Fast24RgbBitmap(source, area);
|
||||
case PixelFormat.Format32bppRgb:
|
||||
return new Fast32RGBBitmap(source, area);
|
||||
return new Fast32RgbBitmap(source, area);
|
||||
case PixelFormat.Format32bppArgb:
|
||||
case PixelFormat.Format32bppPArgb:
|
||||
return new Fast32ARGBBitmap(source, area);
|
||||
return new Fast32ArgbBitmap(source, area);
|
||||
default:
|
||||
throw new NotSupportedException(string.Format("Not supported Pixelformat {0}", source.PixelFormat));
|
||||
}
|
||||
@ -417,21 +419,22 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Constructor which stores the image and locks it when called
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <param name="bitmap">Bitmap</param>
|
||||
/// <param name="area">Rectangle</param>
|
||||
protected FastBitmap(Bitmap bitmap, Rectangle area) {
|
||||
this.bitmap = bitmap;
|
||||
Bitmap = bitmap;
|
||||
Rectangle bitmapArea = new Rectangle(Point.Empty, bitmap.Size);
|
||||
if (area != Rectangle.Empty) {
|
||||
area.Intersect(bitmapArea);
|
||||
this.area = area;
|
||||
Area = area;
|
||||
} else {
|
||||
this.area = bitmapArea;
|
||||
Area = bitmapArea;
|
||||
}
|
||||
// As the lock takes care that only the specified area is made available we need to calculate the offset
|
||||
Left = area.Left;
|
||||
Top = area.Top;
|
||||
// Default cliping is done to the area without invert
|
||||
Clip = this.area;
|
||||
Clip = Area;
|
||||
InvertClip = false;
|
||||
// Always lock, so we don't need to do this ourselves
|
||||
Lock();
|
||||
@ -442,10 +445,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
public Size Size {
|
||||
get {
|
||||
if (area == Rectangle.Empty) {
|
||||
return bitmap.Size;
|
||||
if (Area == Rectangle.Empty) {
|
||||
return Bitmap.Size;
|
||||
}
|
||||
return area.Size;
|
||||
return Area.Size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,10 +457,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
public int Width {
|
||||
get {
|
||||
if (area == Rectangle.Empty) {
|
||||
return bitmap.Width;
|
||||
if (Area == Rectangle.Empty) {
|
||||
return Bitmap.Width;
|
||||
}
|
||||
return area.Width;
|
||||
return Area.Width;
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,14 +469,14 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
public int Height {
|
||||
get {
|
||||
if (area == Rectangle.Empty) {
|
||||
return bitmap.Height;
|
||||
if (Area == Rectangle.Empty) {
|
||||
return Bitmap.Height;
|
||||
}
|
||||
return area.Height;
|
||||
return Area.Height;
|
||||
}
|
||||
}
|
||||
|
||||
private int left;
|
||||
private int _left;
|
||||
/// <summary>
|
||||
/// Return the left of the fastbitmap, this is also used as an offset
|
||||
/// </summary>
|
||||
@ -482,7 +485,7 @@ namespace GreenshotPlugin.Core {
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
left = value;
|
||||
_left = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,14 +494,14 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
int IFastBitmapWithOffset.Left {
|
||||
get {
|
||||
return left;
|
||||
return _left;
|
||||
}
|
||||
set {
|
||||
left = value;
|
||||
_left = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int top;
|
||||
private int _top;
|
||||
/// <summary>
|
||||
/// Return the top of the fastbitmap, this is also used as an offset
|
||||
/// </summary>
|
||||
@ -507,7 +510,7 @@ namespace GreenshotPlugin.Core {
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
top = value;
|
||||
_top = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,10 +519,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
int IFastBitmapWithOffset.Top {
|
||||
get {
|
||||
return top;
|
||||
return _top;
|
||||
}
|
||||
set {
|
||||
top = value;
|
||||
_top = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,14 +548,14 @@ namespace GreenshotPlugin.Core {
|
||||
/// Returns the underlying bitmap, unlocks it and prevents that it will be disposed
|
||||
/// </summary>
|
||||
public Bitmap UnlockAndReturnBitmap() {
|
||||
if (bitsLocked) {
|
||||
if (BitsLocked) {
|
||||
Unlock();
|
||||
}
|
||||
NeedsDispose = false;
|
||||
return bitmap;
|
||||
return Bitmap;
|
||||
}
|
||||
|
||||
public virtual bool hasAlphaChannel {
|
||||
public virtual bool HasAlphaChannel {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
@ -584,26 +587,26 @@ namespace GreenshotPlugin.Core {
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
Unlock();
|
||||
if (disposing) {
|
||||
if (bitmap != null && NeedsDispose) {
|
||||
bitmap.Dispose();
|
||||
if (Bitmap != null && NeedsDispose) {
|
||||
Bitmap.Dispose();
|
||||
}
|
||||
}
|
||||
bitmap = null;
|
||||
bmData = null;
|
||||
pointer = null;
|
||||
Bitmap = null;
|
||||
BmData = null;
|
||||
Pointer = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock the bitmap so we have direct access to the memory
|
||||
/// </summary>
|
||||
public void Lock() {
|
||||
if (Width > 0 && Height > 0 && !bitsLocked) {
|
||||
bmData = bitmap.LockBits(area, ImageLockMode.ReadWrite, bitmap.PixelFormat);
|
||||
bitsLocked = true;
|
||||
if (Width > 0 && Height > 0 && !BitsLocked) {
|
||||
BmData = Bitmap.LockBits(Area, ImageLockMode.ReadWrite, Bitmap.PixelFormat);
|
||||
BitsLocked = true;
|
||||
|
||||
IntPtr Scan0 = bmData.Scan0;
|
||||
pointer = (byte*)(void*)Scan0;
|
||||
stride = bmData.Stride;
|
||||
IntPtr scan0 = BmData.Scan0;
|
||||
Pointer = (byte*)(void*)scan0;
|
||||
Stride = BmData.Stride;
|
||||
}
|
||||
}
|
||||
|
||||
@ -611,9 +614,9 @@ namespace GreenshotPlugin.Core {
|
||||
/// Unlock the System Memory
|
||||
/// </summary>
|
||||
public void Unlock() {
|
||||
if (bitsLocked) {
|
||||
bitmap.UnlockBits(bmData);
|
||||
bitsLocked = false;
|
||||
if (BitsLocked) {
|
||||
Bitmap.UnlockBits(BmData);
|
||||
BitsLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,7 +626,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="destination"></param>
|
||||
public void DrawTo(Graphics graphics, Point destination) {
|
||||
DrawTo(graphics, new Rectangle(destination, area.Size));
|
||||
DrawTo(graphics, new Rectangle(destination, Area.Size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -635,12 +638,12 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="destination"></param>
|
||||
public void DrawTo(Graphics graphics, Rectangle destinationRect) {
|
||||
// Make sure this.bitmap is unlocked, if it was locked
|
||||
bool isLocked = bitsLocked;
|
||||
bool isLocked = BitsLocked;
|
||||
if (isLocked) {
|
||||
Unlock();
|
||||
}
|
||||
|
||||
graphics.DrawImage(bitmap, destinationRect, area, GraphicsUnit.Pixel);
|
||||
graphics.DrawImage(Bitmap, destinationRect, Area, GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -650,7 +653,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <returns>true if x & y are inside the FastBitmap</returns>
|
||||
public bool Contains(int x, int y) {
|
||||
return area.Contains(x - Left, y - Top);
|
||||
return Area.Contains(x - Left, y - Top);
|
||||
}
|
||||
|
||||
public abstract Color GetColorAt(int x, int y);
|
||||
@ -693,29 +696,29 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <returns>true if x & y are inside the FastBitmap</returns>
|
||||
bool IFastBitmapWithOffset.Contains(int x, int y) {
|
||||
return area.Contains(x - Left, y - Top);
|
||||
return Area.Contains(x - Left, y - Top);
|
||||
}
|
||||
|
||||
Color IFastBitmapWithOffset.GetColorAt(int x, int y) {
|
||||
x -= left;
|
||||
y -= top;
|
||||
x -= _left;
|
||||
y -= _top;
|
||||
return GetColorAt(x, y);
|
||||
}
|
||||
void IFastBitmapWithOffset.GetColorAt(int x, int y, byte[] color) {
|
||||
x -= left;
|
||||
y -= top;
|
||||
x -= _left;
|
||||
y -= _top;
|
||||
GetColorAt(x, y, color);
|
||||
}
|
||||
|
||||
void IFastBitmapWithOffset.SetColorAt(int x, int y, byte[] color) {
|
||||
x -= left;
|
||||
y -= top;
|
||||
x -= _left;
|
||||
y -= _top;
|
||||
SetColorAt(x, y, color);
|
||||
}
|
||||
|
||||
void IFastBitmapWithOffset.SetColorAt(int x, int y, Color color) {
|
||||
x -= left;
|
||||
y -= top;
|
||||
x -= _left;
|
||||
y -= _top;
|
||||
SetColorAt(x, y, color);
|
||||
}
|
||||
#endregion
|
||||
@ -726,11 +729,11 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
public unsafe class FastChunkyBitmap : FastBitmap {
|
||||
// Used for indexed images
|
||||
private readonly Color[] colorEntries;
|
||||
private readonly Dictionary<Color, byte> colorCache = new Dictionary<Color, byte>();
|
||||
private readonly Color[] _colorEntries;
|
||||
private readonly Dictionary<Color, byte> _colorCache = new Dictionary<Color, byte>();
|
||||
|
||||
public FastChunkyBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
colorEntries = bitmap.Palette.Entries;
|
||||
_colorEntries = Bitmap.Palette.Entries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -740,9 +743,9 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <returns>Color</returns>
|
||||
public override Color GetColorAt(int x, int y) {
|
||||
int offset = x + (y * stride);
|
||||
byte colorIndex = pointer[offset];
|
||||
return colorEntries[colorIndex];
|
||||
int offset = x + (y * Stride);
|
||||
byte colorIndex = Pointer[offset];
|
||||
return _colorEntries[colorIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -772,8 +775,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <returns>byte with index</returns>
|
||||
public byte GetColorIndexAt(int x, int y) {
|
||||
int offset = x + (y * stride);
|
||||
return pointer[offset];
|
||||
int offset = x + (y * Stride);
|
||||
return Pointer[offset];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -781,10 +784,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color-index"></param>
|
||||
/// <param name="colorIndex"></param>
|
||||
public void SetColorIndexAt(int x, int y, byte colorIndex) {
|
||||
int offset = x + (y * stride);
|
||||
pointer[offset] = colorIndex;
|
||||
int offset = x + (y * Stride);
|
||||
Pointer[offset] = colorIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -795,13 +798,13 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">Color to set</param>
|
||||
public override void SetColorAt(int x, int y, Color color) {
|
||||
int offset = x + (y * stride);
|
||||
int offset = x + (y * Stride);
|
||||
byte colorIndex;
|
||||
if (!colorCache.TryGetValue(color, out colorIndex)) {
|
||||
if (!_colorCache.TryGetValue(color, out colorIndex)) {
|
||||
bool foundColor = false;
|
||||
for (colorIndex = 0; colorIndex < colorEntries.Length; colorIndex++) {
|
||||
if (color == colorEntries[colorIndex]) {
|
||||
colorCache.Add(color, colorIndex);
|
||||
for (colorIndex = 0; colorIndex < _colorEntries.Length; colorIndex++) {
|
||||
if (color == _colorEntries[colorIndex]) {
|
||||
_colorCache.Add(color, colorIndex);
|
||||
foundColor = true;
|
||||
break;
|
||||
}
|
||||
@ -810,16 +813,16 @@ namespace GreenshotPlugin.Core {
|
||||
throw new ArgumentException("No such color!");
|
||||
}
|
||||
}
|
||||
pointer[offset] = colorIndex;
|
||||
Pointer[offset] = colorIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the implementation of the IFastBitmap for 24 bit images (no Alpha)
|
||||
/// </summary>
|
||||
public unsafe class Fast24RGBBitmap : FastBitmap {
|
||||
public unsafe class Fast24RgbBitmap : FastBitmap {
|
||||
|
||||
public Fast24RGBBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
public Fast24RgbBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -830,8 +833,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y">Y Coordinate</param>
|
||||
/// <returns>Color</returns>
|
||||
public override Color GetColorAt(int x, int y) {
|
||||
int offset = (x * 3) + (y * stride);
|
||||
return Color.FromArgb(255, pointer[PIXELFORMAT_INDEX_R + offset], pointer[PIXELFORMAT_INDEX_G + offset], pointer[PIXELFORMAT_INDEX_B + offset]);
|
||||
int offset = (x * 3) + (y * Stride);
|
||||
return Color.FromArgb(255, Pointer[PixelformatIndexR + offset], Pointer[PixelformatIndexG + offset], Pointer[PixelformatIndexB + offset]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -842,10 +845,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public override void SetColorAt(int x, int y, Color color) {
|
||||
int offset = (x * 3) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color.R;
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color.G;
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color.B;
|
||||
int offset = (x * 3) + (y * Stride);
|
||||
Pointer[PixelformatIndexR + offset] = color.R;
|
||||
Pointer[PixelformatIndexG + offset] = color.G;
|
||||
Pointer[PixelformatIndexB + offset] = color.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -855,10 +858,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (r,g,b)</param>
|
||||
public override void GetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 3) + (y * stride);
|
||||
color[PIXELFORMAT_INDEX_R] = pointer[PIXELFORMAT_INDEX_R + offset];
|
||||
color[PIXELFORMAT_INDEX_G] = pointer[PIXELFORMAT_INDEX_G + offset];
|
||||
color[PIXELFORMAT_INDEX_B] = pointer[PIXELFORMAT_INDEX_B + offset];
|
||||
int offset = (x * 3) + (y * Stride);
|
||||
color[PixelformatIndexR] = Pointer[PixelformatIndexR + offset];
|
||||
color[PixelformatIndexG] = Pointer[PixelformatIndexG + offset];
|
||||
color[PixelformatIndexB] = Pointer[PixelformatIndexB + offset];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -868,10 +871,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (r,g,b)</param>
|
||||
public override void SetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 3) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color[PIXELFORMAT_INDEX_R];
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color[PIXELFORMAT_INDEX_G];
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color[PIXELFORMAT_INDEX_B];
|
||||
int offset = (x * 3) + (y * Stride);
|
||||
Pointer[PixelformatIndexR + offset] = color[PixelformatIndexR];
|
||||
Pointer[PixelformatIndexG + offset] = color[PixelformatIndexG];
|
||||
Pointer[PixelformatIndexB + offset] = color[PixelformatIndexB];
|
||||
}
|
||||
|
||||
}
|
||||
@ -879,8 +882,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// This is the implementation of the IFastBitmap for 32 bit images (no Alpha)
|
||||
/// </summary>
|
||||
public unsafe class Fast32RGBBitmap : FastBitmap {
|
||||
public Fast32RGBBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
public unsafe class Fast32RgbBitmap : FastBitmap {
|
||||
public Fast32RgbBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
|
||||
}
|
||||
|
||||
@ -892,8 +895,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y">Y Coordinate</param>
|
||||
/// <returns>Color</returns>
|
||||
public override Color GetColorAt(int x, int y) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
return Color.FromArgb(255, pointer[PIXELFORMAT_INDEX_R + offset], pointer[PIXELFORMAT_INDEX_G + offset], pointer[PIXELFORMAT_INDEX_B + offset]);
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
return Color.FromArgb(255, Pointer[PixelformatIndexR + offset], Pointer[PixelformatIndexG + offset], Pointer[PixelformatIndexB + offset]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -904,10 +907,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public override void SetColorAt(int x, int y, Color color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color.R;
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color.G;
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color.B;
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
Pointer[PixelformatIndexR + offset] = color.R;
|
||||
Pointer[PixelformatIndexG + offset] = color.G;
|
||||
Pointer[PixelformatIndexB + offset] = color.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -917,10 +920,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (a,r,g,b)</param>
|
||||
public override void GetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
color[COLOR_INDEX_R] = pointer[PIXELFORMAT_INDEX_R + offset];
|
||||
color[COLOR_INDEX_G] = pointer[PIXELFORMAT_INDEX_G + offset];
|
||||
color[COLOR_INDEX_B] = pointer[PIXELFORMAT_INDEX_B + offset];
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
color[ColorIndexR] = Pointer[PixelformatIndexR + offset];
|
||||
color[ColorIndexG] = Pointer[PixelformatIndexG + offset];
|
||||
color[ColorIndexB] = Pointer[PixelformatIndexB + offset];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -930,18 +933,18 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (r,g,b)</param>
|
||||
public override void SetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color[COLOR_INDEX_R]; // R
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color[COLOR_INDEX_G];
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color[COLOR_INDEX_B];
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
Pointer[PixelformatIndexR + offset] = color[ColorIndexR]; // R
|
||||
Pointer[PixelformatIndexG + offset] = color[ColorIndexG];
|
||||
Pointer[PixelformatIndexB + offset] = color[ColorIndexB];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the implementation of the IFastBitmap for 32 bit images with Alpha
|
||||
/// </summary>
|
||||
public unsafe class Fast32ARGBBitmap : FastBitmap, IFastBitmapWithBlend {
|
||||
public override bool hasAlphaChannel {
|
||||
public unsafe class Fast32ArgbBitmap : FastBitmap, IFastBitmapWithBlend {
|
||||
public override bool HasAlphaChannel {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
@ -951,7 +954,7 @@ namespace GreenshotPlugin.Core {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Fast32ARGBBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
public Fast32ArgbBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
BackgroundBlendColor = Color.White;
|
||||
}
|
||||
|
||||
@ -962,8 +965,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y">Y Coordinate</param>
|
||||
/// <returns>Color</returns>
|
||||
public override Color GetColorAt(int x, int y) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
return Color.FromArgb(pointer[PIXELFORMAT_INDEX_A + offset], pointer[PIXELFORMAT_INDEX_R + offset], pointer[PIXELFORMAT_INDEX_G + offset], pointer[PIXELFORMAT_INDEX_B + offset]);
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
return Color.FromArgb(Pointer[PixelformatIndexA + offset], Pointer[PixelformatIndexR + offset], Pointer[PixelformatIndexG + offset], Pointer[PixelformatIndexB + offset]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -974,11 +977,11 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color"></param>
|
||||
public override void SetColorAt(int x, int y, Color color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_A + offset] = color.A;
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color.R;
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color.G;
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color.B;
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
Pointer[PixelformatIndexA + offset] = color.A;
|
||||
Pointer[PixelformatIndexR + offset] = color.R;
|
||||
Pointer[PixelformatIndexG + offset] = color.G;
|
||||
Pointer[PixelformatIndexB + offset] = color.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -988,11 +991,11 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (r,g,b,a)</param>
|
||||
public override void GetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
color[COLOR_INDEX_R] = pointer[PIXELFORMAT_INDEX_R + offset];
|
||||
color[COLOR_INDEX_G] = pointer[PIXELFORMAT_INDEX_G + offset];
|
||||
color[COLOR_INDEX_B] = pointer[PIXELFORMAT_INDEX_B + offset];
|
||||
color[COLOR_INDEX_A] = pointer[PIXELFORMAT_INDEX_A + offset];
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
color[ColorIndexR] = Pointer[PixelformatIndexR + offset];
|
||||
color[ColorIndexG] = Pointer[PixelformatIndexG + offset];
|
||||
color[ColorIndexB] = Pointer[PixelformatIndexB + offset];
|
||||
color[ColorIndexA] = Pointer[PixelformatIndexA + offset];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1002,11 +1005,11 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y"></param>
|
||||
/// <param name="color">byte[4] as reference (r,g,b,a)</param>
|
||||
public override void SetColorAt(int x, int y, byte[] color) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
pointer[PIXELFORMAT_INDEX_R + offset] = color[COLOR_INDEX_R]; // R
|
||||
pointer[PIXELFORMAT_INDEX_G + offset] = color[COLOR_INDEX_G];
|
||||
pointer[PIXELFORMAT_INDEX_B + offset] = color[COLOR_INDEX_B];
|
||||
pointer[PIXELFORMAT_INDEX_A + offset] = color[COLOR_INDEX_A];
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
Pointer[PixelformatIndexR + offset] = color[ColorIndexR]; // R
|
||||
Pointer[PixelformatIndexG + offset] = color[ColorIndexG];
|
||||
Pointer[PixelformatIndexB + offset] = color[ColorIndexB];
|
||||
Pointer[PixelformatIndexA + offset] = color[ColorIndexA];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1017,11 +1020,11 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="y">Y Coordinate</param>
|
||||
/// <returns>Color</returns>
|
||||
public Color GetBlendedColorAt(int x, int y) {
|
||||
int offset = (x * 4) + (y * stride);
|
||||
int a = pointer[PIXELFORMAT_INDEX_A + offset];
|
||||
int red = pointer[PIXELFORMAT_INDEX_R + offset];
|
||||
int green = pointer[PIXELFORMAT_INDEX_G + offset];
|
||||
int blue = pointer[PIXELFORMAT_INDEX_B + offset];
|
||||
int offset = (x * 4) + (y * Stride);
|
||||
int a = Pointer[PixelformatIndexA + offset];
|
||||
int red = Pointer[PixelformatIndexR + offset];
|
||||
int green = Pointer[PixelformatIndexG + offset];
|
||||
int blue = Pointer[PixelformatIndexB + offset];
|
||||
|
||||
if (a < 255) {
|
||||
// As the request is to get without alpha, we blend.
|
||||
|
@ -48,7 +48,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Remove invalid characters from the fully qualified filename
|
||||
/// </summary>
|
||||
/// <param name="fullpath">string with the full path to a file</param>
|
||||
/// <param name="fullPath">string with the full path to a file</param>
|
||||
/// <returns>string with the full path to a file, without invalid characters</returns>
|
||||
public static string MakeFQFilenameSafe(string fullPath) {
|
||||
string path = MakePathSafe(Path.GetDirectoryName(fullPath));
|
||||
@ -60,7 +60,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Remove invalid characters from the filename
|
||||
/// </summary>
|
||||
/// <param name="fullpath">string with the full path to a file</param>
|
||||
/// <param name="filename">string with the full path to a file</param>
|
||||
/// <returns>string with the full path to a file, without invalid characters</returns>
|
||||
public static string MakeFilenameSafe(string filename) {
|
||||
// Make the filename save!
|
||||
@ -121,6 +121,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// This method will be called by the regexp.replace as a MatchEvaluator delegate!
|
||||
/// Will delegate this to the MatchVarEvaluatorInternal and catch any exceptions
|
||||
/// </summary>
|
||||
/// <param name="match">What are we matching?</param>
|
||||
/// <param name="captureDetails">The detail, can be null</param>
|
||||
/// <param name="processVars">Variables from the process</param>
|
||||
@ -141,6 +142,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
/// <param name="match">What are we matching?</param>
|
||||
/// <param name="captureDetails">The detail, can be null</param>
|
||||
/// <param name="processVars"></param>
|
||||
/// <param name="userVars"></param>
|
||||
/// <param name="machineVars"></param>
|
||||
/// <param name="filenameSafeMode"></param>
|
||||
/// <returns></returns>
|
||||
private static string MatchVarEvaluatorInternal(Match match, ICaptureDetails captureDetails, IDictionary processVars, IDictionary userVars, IDictionary machineVars, bool filenameSafeMode) {
|
||||
// some defaults
|
||||
|
@ -356,7 +356,6 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to </param>
|
||||
/// <param name="location">The file (EXE or DLL) to get the icon from</param>
|
||||
/// <param name="index">Index of the icon</param>
|
||||
/// <param name="takeLarge">true if the large icon is wanted</param>
|
||||
@ -409,8 +408,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="matrix"></param>
|
||||
/// <returns>Bitmap</returns>
|
||||
public static Image ApplyEffect(Image sourceImage, IEffect effect, Matrix matrix) {
|
||||
List<IEffect> effects = new List<IEffect>();
|
||||
effects.Add(effect);
|
||||
List<IEffect> effects = new List<IEffect> {effect};
|
||||
return ApplyEffects(sourceImage, effects, matrix);
|
||||
}
|
||||
|
||||
@ -418,7 +416,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// Apply the effects in the supplied order to the bitmap
|
||||
/// </summary>
|
||||
/// <param name="sourceImage">Bitmap</param>
|
||||
/// <param name="effects">List<IEffect></param>
|
||||
/// <param name="effects">List of IEffect</param>
|
||||
/// <param name="matrix"></param>
|
||||
/// <returns>Bitmap</returns>
|
||||
public static Image ApplyEffects(Image sourceImage, List<IEffect> effects, Matrix matrix) {
|
||||
@ -577,7 +575,7 @@ namespace GreenshotPlugin.Core {
|
||||
// By the central limit theorem, if applied 3 times on the same image, a box blur approximates the Gaussian kernel to within about 3%, yielding the same result as a quadratic convolution kernel.
|
||||
// This might be true, but the GDI+ BlurEffect doesn't look the same, a 2x blur is more simular and we only make 2x Box-Blur.
|
||||
// (Might also be a mistake in our blur, but for now it looks great)
|
||||
if (fastBitmap.hasAlphaChannel) {
|
||||
if (fastBitmap.HasAlphaChannel) {
|
||||
BoxBlurHorizontalAlpha(fastBitmap, range);
|
||||
BoxBlurVerticalAlpha(fastBitmap, range);
|
||||
BoxBlurHorizontalAlpha(fastBitmap, range);
|
||||
@ -596,7 +594,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="targetFastBitmap">Target BitmapBuffer</param>
|
||||
/// <param name="range">Range must be odd!</param>
|
||||
private static void BoxBlurHorizontal(IFastBitmap targetFastBitmap, int range) {
|
||||
if (targetFastBitmap.hasAlphaChannel) {
|
||||
if (targetFastBitmap.HasAlphaChannel) {
|
||||
throw new NotSupportedException("BoxBlurHorizontal should NOT be called for bitmaps with alpha channel");
|
||||
}
|
||||
int halfRange = range / 2;
|
||||
@ -611,18 +609,18 @@ namespace GreenshotPlugin.Core {
|
||||
int oldPixel = x - halfRange - 1;
|
||||
if (oldPixel >= targetFastBitmap.Left) {
|
||||
targetFastBitmap.GetColorAt(oldPixel, y, tmpColor);
|
||||
r -= tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g -= tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b -= tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
r -= tmpColor[FastBitmap.ColorIndexR];
|
||||
g -= tmpColor[FastBitmap.ColorIndexG];
|
||||
b -= tmpColor[FastBitmap.ColorIndexB];
|
||||
hits--;
|
||||
}
|
||||
|
||||
int newPixel = x + halfRange;
|
||||
if (newPixel < targetFastBitmap.Right) {
|
||||
targetFastBitmap.GetColorAt(newPixel, y, tmpColor);
|
||||
r += tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g += tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b += tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
r += tmpColor[FastBitmap.ColorIndexR];
|
||||
g += tmpColor[FastBitmap.ColorIndexG];
|
||||
b += tmpColor[FastBitmap.ColorIndexB];
|
||||
hits++;
|
||||
}
|
||||
|
||||
@ -641,7 +639,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="targetFastBitmap">Target BitmapBuffer</param>
|
||||
/// <param name="range">Range must be odd!</param>
|
||||
private static void BoxBlurHorizontalAlpha(IFastBitmap targetFastBitmap, int range) {
|
||||
if (!targetFastBitmap.hasAlphaChannel) {
|
||||
if (!targetFastBitmap.HasAlphaChannel) {
|
||||
throw new NotSupportedException("BoxBlurHorizontalAlpha should be called for bitmaps with alpha channel");
|
||||
}
|
||||
int halfRange = range / 2;
|
||||
@ -657,20 +655,20 @@ namespace GreenshotPlugin.Core {
|
||||
int oldPixel = x - halfRange - 1;
|
||||
if (oldPixel >= targetFastBitmap.Left) {
|
||||
targetFastBitmap.GetColorAt(oldPixel, y, tmpColor);
|
||||
a -= tmpColor[FastBitmap.COLOR_INDEX_A];
|
||||
r -= tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g -= tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b -= tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
a -= tmpColor[FastBitmap.ColorIndexA];
|
||||
r -= tmpColor[FastBitmap.ColorIndexR];
|
||||
g -= tmpColor[FastBitmap.ColorIndexG];
|
||||
b -= tmpColor[FastBitmap.ColorIndexB];
|
||||
hits--;
|
||||
}
|
||||
|
||||
int newPixel = x + halfRange;
|
||||
if (newPixel < targetFastBitmap.Right) {
|
||||
targetFastBitmap.GetColorAt(newPixel, y, tmpColor);
|
||||
a += tmpColor[FastBitmap.COLOR_INDEX_A];
|
||||
r += tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g += tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b += tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
a += tmpColor[FastBitmap.ColorIndexA];
|
||||
r += tmpColor[FastBitmap.ColorIndexR];
|
||||
g += tmpColor[FastBitmap.ColorIndexG];
|
||||
b += tmpColor[FastBitmap.ColorIndexB];
|
||||
hits++;
|
||||
}
|
||||
|
||||
@ -690,7 +688,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="targetFastBitmap">BitmapBuffer which previously was created with BoxBlurHorizontal</param>
|
||||
/// <param name="range">Range must be odd!</param>
|
||||
private static void BoxBlurVertical(IFastBitmap targetFastBitmap, int range) {
|
||||
if (targetFastBitmap.hasAlphaChannel) {
|
||||
if (targetFastBitmap.HasAlphaChannel) {
|
||||
throw new NotSupportedException("BoxBlurVertical should NOT be called for bitmaps with alpha channel");
|
||||
}
|
||||
int halfRange = range / 2;
|
||||
@ -705,18 +703,18 @@ namespace GreenshotPlugin.Core {
|
||||
int oldPixel = y - halfRange - 1;
|
||||
if (oldPixel >= targetFastBitmap.Top) {
|
||||
targetFastBitmap.GetColorAt(x, oldPixel, tmpColor);
|
||||
r -= tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g -= tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b -= tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
r -= tmpColor[FastBitmap.ColorIndexR];
|
||||
g -= tmpColor[FastBitmap.ColorIndexG];
|
||||
b -= tmpColor[FastBitmap.ColorIndexB];
|
||||
hits--;
|
||||
}
|
||||
|
||||
int newPixel = y + halfRange;
|
||||
if (newPixel < targetFastBitmap.Bottom) {
|
||||
targetFastBitmap.GetColorAt(x, newPixel, tmpColor);
|
||||
r += tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g += tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b += tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
r += tmpColor[FastBitmap.ColorIndexR];
|
||||
g += tmpColor[FastBitmap.ColorIndexG];
|
||||
b += tmpColor[FastBitmap.ColorIndexB];
|
||||
hits++;
|
||||
}
|
||||
|
||||
@ -737,7 +735,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <param name="targetFastBitmap">BitmapBuffer which previously was created with BoxBlurHorizontal</param>
|
||||
/// <param name="range">Range must be odd!</param>
|
||||
private static void BoxBlurVerticalAlpha(IFastBitmap targetFastBitmap, int range) {
|
||||
if (!targetFastBitmap.hasAlphaChannel) {
|
||||
if (!targetFastBitmap.HasAlphaChannel) {
|
||||
throw new NotSupportedException("BoxBlurVerticalAlpha should be called for bitmaps with alpha channel");
|
||||
}
|
||||
|
||||
@ -754,10 +752,10 @@ namespace GreenshotPlugin.Core {
|
||||
int oldPixel = y - halfRange - 1;
|
||||
if (oldPixel >= targetFastBitmap.Top) {
|
||||
targetFastBitmap.GetColorAt(x, oldPixel, tmpColor);
|
||||
a -= tmpColor[FastBitmap.COLOR_INDEX_A];
|
||||
r -= tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g -= tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b -= tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
a -= tmpColor[FastBitmap.ColorIndexA];
|
||||
r -= tmpColor[FastBitmap.ColorIndexR];
|
||||
g -= tmpColor[FastBitmap.ColorIndexG];
|
||||
b -= tmpColor[FastBitmap.ColorIndexB];
|
||||
hits--;
|
||||
}
|
||||
|
||||
@ -765,10 +763,10 @@ namespace GreenshotPlugin.Core {
|
||||
if (newPixel < targetFastBitmap.Bottom) {
|
||||
//int colorg = pixels[index + newPixelOffset];
|
||||
targetFastBitmap.GetColorAt(x, newPixel, tmpColor);
|
||||
a += tmpColor[FastBitmap.COLOR_INDEX_A];
|
||||
r += tmpColor[FastBitmap.COLOR_INDEX_R];
|
||||
g += tmpColor[FastBitmap.COLOR_INDEX_G];
|
||||
b += tmpColor[FastBitmap.COLOR_INDEX_B];
|
||||
a += tmpColor[FastBitmap.ColorIndexA];
|
||||
r += tmpColor[FastBitmap.ColorIndexR];
|
||||
g += tmpColor[FastBitmap.ColorIndexG];
|
||||
b += tmpColor[FastBitmap.ColorIndexB];
|
||||
hits++;
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ namespace GreenshotPlugin.Core {
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
return hasKey(prefix + "." + key.ToString());
|
||||
return hasKey(prefix + "." + key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -534,7 +534,7 @@ namespace GreenshotPlugin.Core {
|
||||
|
||||
public static string Translate(object key) {
|
||||
string typename = key.GetType().Name;
|
||||
string enumKey = typename + "." + key.ToString();
|
||||
string enumKey = typename + "." + key;
|
||||
if (hasKey(enumKey)) {
|
||||
return GetString(enumKey);
|
||||
}
|
||||
@ -563,7 +563,7 @@ namespace GreenshotPlugin.Core {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
return GetString(prefix + "." + key.ToString());
|
||||
return GetString(prefix + "." + key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -596,6 +596,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// Get the resource for key, format with with string.format an supply the parameters
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns>formatted resource or a "string ###key### not found"</returns>
|
||||
public static string GetFormattedString(Enum key, object param) {
|
||||
return GetFormattedString(key.ToString(), param);
|
||||
@ -604,7 +605,9 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Get the resource for prefix.key, format with with string.format an supply the parameters
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns>formatted resource or a "string ###prefix.key### not found"</returns>
|
||||
public static string GetFormattedString(string prefix, Enum key, object param) {
|
||||
return GetFormattedString(prefix, key.ToString(), param);
|
||||
@ -613,7 +616,9 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Get the resource for prefix.key, format with with string.format an supply the parameters
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns>formatted resource or a "string ###prefix.key### not found"</returns>
|
||||
public static string GetFormattedString(string prefix, string key, object param) {
|
||||
return GetFormattedString(prefix + "." + key, param);
|
||||
@ -623,6 +628,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// Get the resource for key, format with with string.format an supply the parameters
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns>formatted resource or a "string ###key### not found"</returns>
|
||||
public static string GetFormattedString(string key, object param) {
|
||||
string returnValue;
|
||||
|
@ -709,20 +709,20 @@ namespace GreenshotPlugin.Core {
|
||||
/// And additionally a signature is added.
|
||||
/// </summary>
|
||||
/// <param name="method">Method (POST,PUT,GET)</param>
|
||||
/// <param name="requestURL">Url to call</param>
|
||||
/// <param name="parameters">IDictionary<string, string></param>
|
||||
private void Sign(HTTPMethod method, string requestURL, IDictionary<string, object> parameters) {
|
||||
/// <param name="requestUrl">Url to call</param>
|
||||
/// <param name="parameters">IDictionary of string and string</param>
|
||||
private void Sign(HTTPMethod method, string requestUrl, IDictionary<string, object> parameters) {
|
||||
if (parameters == null) {
|
||||
throw new ArgumentNullException("parameters");
|
||||
throw new ArgumentNullException(nameof(parameters));
|
||||
}
|
||||
// Build the signature base
|
||||
StringBuilder signatureBase = new StringBuilder();
|
||||
|
||||
// Add Method to signature base
|
||||
signatureBase.Append(method.ToString()).Append("&");
|
||||
signatureBase.Append(method).Append("&");
|
||||
|
||||
// Add normalized URL
|
||||
Uri url = new Uri(requestURL);
|
||||
Uri url = new Uri(requestUrl);
|
||||
string normalizedUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}", url.Scheme, url.Host);
|
||||
if (!((url.Scheme == "http" && url.Port == 80) || (url.Scheme == "https" && url.Port == 443))) {
|
||||
normalizedUrl += ":" + url.Port;
|
||||
@ -747,7 +747,7 @@ namespace GreenshotPlugin.Core {
|
||||
break;
|
||||
}
|
||||
parameters.Add(OAUTH_CONSUMER_KEY_KEY, _consumerKey);
|
||||
if (CallbackUrl != null && RequestTokenUrl != null && requestURL.StartsWith(RequestTokenUrl)) {
|
||||
if (CallbackUrl != null && RequestTokenUrl != null && requestUrl.StartsWith(RequestTokenUrl)) {
|
||||
parameters.Add(OAUTH_CALLBACK_KEY, CallbackUrl);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Verifier)) {
|
||||
@ -810,7 +810,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <returns>Response from server</returns>
|
||||
private string MakeRequest(HTTPMethod method, string requestURL, IDictionary<string, string> headers, IDictionary<string, object> parameters, IBinaryContainer postData) {
|
||||
if (parameters == null) {
|
||||
throw new ArgumentNullException("parameters");
|
||||
throw new ArgumentNullException(nameof(parameters));
|
||||
}
|
||||
IDictionary<string, object> requestParameters;
|
||||
// Add oAuth values as HTTP headers, if this is allowed
|
||||
@ -1085,7 +1085,6 @@ Greenshot received information from CloudServiceName. You can close this browser
|
||||
/// <summary>
|
||||
/// Generate an OAuth 2 Token by using the supplied code
|
||||
/// </summary>
|
||||
/// <param name="code">Code to get the RefreshToken</param>
|
||||
/// <param name="settings">OAuth2Settings to update with the information that was retrieved</param>
|
||||
public static void GenerateRefreshToken(OAuth2Settings settings) {
|
||||
IDictionary<string, object> data = new Dictionary<string, object>();
|
||||
|
@ -156,6 +156,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Helper method to add a MenuItem to the File MenuItem of an ImageEditor
|
||||
/// </summary>
|
||||
/// <param name="imageEditor"></param>
|
||||
/// <param name="image">Image to display in the menu</param>
|
||||
/// <param name="text">Text to display in the menu</param>
|
||||
/// <param name="tag">The TAG value</param>
|
||||
@ -215,8 +216,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Helper method to add a plugin MenuItem to the Greenshot context menu
|
||||
/// </summary>
|
||||
/// <param name="imageEditor"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="host">IGreenshotHost</param>
|
||||
/// <param name="item">ToolStripMenuItem</param>
|
||||
public static void AddToContextMenu(IGreenshotHost host, ToolStripMenuItem item) {
|
||||
// Here we can hang ourselves to the main context menu!
|
||||
ContextMenuStrip contextMenu = host.MainMenu;
|
||||
|
@ -31,69 +31,69 @@ namespace GreenshotPlugin.Core {
|
||||
/// Gets or sets the red minimum.
|
||||
/// </summary>
|
||||
/// <value>The red minimum.</value>
|
||||
public Int32 RedMinimum { get; set; }
|
||||
public int RedMinimum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the red maximum.
|
||||
/// </summary>
|
||||
/// <value>The red maximum.</value>
|
||||
public Int32 RedMaximum { get; set; }
|
||||
public int RedMaximum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the green minimum.
|
||||
/// </summary>
|
||||
/// <value>The green minimum.</value>
|
||||
public Int32 GreenMinimum { get; set; }
|
||||
public int GreenMinimum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the green maximum.
|
||||
/// </summary>
|
||||
/// <value>The green maximum.</value>
|
||||
public Int32 GreenMaximum { get; set; }
|
||||
public int GreenMaximum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the blue minimum.
|
||||
/// </summary>
|
||||
/// <value>The blue minimum.</value>
|
||||
public Int32 BlueMinimum { get; set; }
|
||||
public int BlueMinimum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the blue maximum.
|
||||
/// </summary>
|
||||
/// <value>The blue maximum.</value>
|
||||
public Int32 BlueMaximum { get; set; }
|
||||
public int BlueMaximum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cube volume.
|
||||
/// </summary>
|
||||
/// <value>The volume.</value>
|
||||
public Int32 Volume { get; set; }
|
||||
public int Volume { get; set; }
|
||||
}
|
||||
|
||||
public class WuQuantizer : IDisposable {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(WuQuantizer));
|
||||
|
||||
private const Int32 MAXCOLOR = 512;
|
||||
private const Int32 RED = 2;
|
||||
private const Int32 GREEN = 1;
|
||||
private const Int32 BLUE = 0;
|
||||
private const Int32 SIDESIZE = 33;
|
||||
private const Int32 MAXSIDEINDEX = 32;
|
||||
private const Int32 MAXVOLUME = SIDESIZE * SIDESIZE * SIDESIZE;
|
||||
private const int MAXCOLOR = 512;
|
||||
private const int RED = 2;
|
||||
private const int GREEN = 1;
|
||||
private const int BLUE = 0;
|
||||
private const int SIDESIZE = 33;
|
||||
private const int MAXSIDEINDEX = 32;
|
||||
private const int MAXVOLUME = SIDESIZE * SIDESIZE * SIDESIZE;
|
||||
|
||||
// To count the colors
|
||||
private readonly int colorCount;
|
||||
|
||||
private Int32[] reds;
|
||||
private Int32[] greens;
|
||||
private Int32[] blues;
|
||||
private Int32[] sums;
|
||||
private int[] reds;
|
||||
private int[] greens;
|
||||
private int[] blues;
|
||||
private int[] sums;
|
||||
|
||||
private readonly Int64[, ,] weights;
|
||||
private readonly Int64[, ,] momentsRed;
|
||||
private readonly Int64[, ,] momentsGreen;
|
||||
private readonly Int64[, ,] momentsBlue;
|
||||
private readonly Single[, ,] moments;
|
||||
private readonly long[,,] weights;
|
||||
private readonly long[,,] momentsRed;
|
||||
private readonly long[,,] momentsGreen;
|
||||
private readonly long[,,] momentsBlue;
|
||||
private readonly float[,,] moments;
|
||||
|
||||
private byte[] tag;
|
||||
|
||||
@ -128,7 +128,7 @@ namespace GreenshotPlugin.Core {
|
||||
cubes = new WuColorCube[MAXCOLOR];
|
||||
|
||||
// initializes all the cubes
|
||||
for (Int32 cubeIndex = 0; cubeIndex < MAXCOLOR; cubeIndex++) {
|
||||
for (int cubeIndex = 0; cubeIndex < MAXCOLOR; cubeIndex++) {
|
||||
cubes[cubeIndex] = new WuColorCube();
|
||||
}
|
||||
|
||||
@ -142,15 +142,15 @@ namespace GreenshotPlugin.Core {
|
||||
cubes[0].GreenMaximum = MAXSIDEINDEX;
|
||||
cubes[0].BlueMaximum = MAXSIDEINDEX;
|
||||
|
||||
weights = new Int64[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsRed = new Int64[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsGreen = new Int64[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsBlue = new Int64[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
moments = new Single[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
weights = new long[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsRed = new long[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsGreen = new long[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
momentsBlue = new long[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
moments = new float[SIDESIZE, SIDESIZE, SIDESIZE];
|
||||
|
||||
Int32[] table = new Int32[256];
|
||||
int[] table = new int[256];
|
||||
|
||||
for (Int32 tableIndex = 0; tableIndex < 256; ++tableIndex) {
|
||||
for (int tableIndex = 0; tableIndex < 256; ++tableIndex) {
|
||||
table[tableIndex] = tableIndex * tableIndex;
|
||||
}
|
||||
|
||||
@ -177,9 +177,9 @@ namespace GreenshotPlugin.Core {
|
||||
bitArray.Set(index, true);
|
||||
}
|
||||
|
||||
Int32 indexRed = (color.R >> 3) + 1;
|
||||
Int32 indexGreen = (color.G >> 3) + 1;
|
||||
Int32 indexBlue = (color.B >> 3) + 1;
|
||||
int indexRed = (color.R >> 3) + 1;
|
||||
int indexGreen = (color.G >> 3) + 1;
|
||||
int indexBlue = (color.B >> 3) + 1;
|
||||
|
||||
weights[indexRed, indexGreen, indexBlue]++;
|
||||
momentsRed[indexRed, indexGreen, indexBlue] += color.R;
|
||||
@ -188,7 +188,7 @@ namespace GreenshotPlugin.Core {
|
||||
moments[indexRed, indexGreen, indexBlue] += table[color.R] + table[color.G] + table[color.B];
|
||||
|
||||
// Store the initial "match"
|
||||
Int32 paletteIndex = (indexRed << 10) + (indexRed << 6) + indexRed + (indexGreen << 5) + indexGreen + indexBlue;
|
||||
int paletteIndex = (indexRed << 10) + (indexRed << 6) + indexRed + (indexGreen << 5) + indexGreen + indexBlue;
|
||||
destinationFastBitmap.SetColorIndexAt(x, y, (byte)(paletteIndex & 0xff));
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// See <see cref="IColorQuantizer.Prepare"/> for more details.
|
||||
/// </summary>
|
||||
public Int32 GetColorCount() {
|
||||
public int GetColorCount() {
|
||||
return colorCount;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ namespace GreenshotPlugin.Core {
|
||||
// generates palette
|
||||
ColorPalette imagePalette = resultBitmap.Palette;
|
||||
Color[] entries = imagePalette.Entries;
|
||||
for (Int32 paletteIndex = 0; paletteIndex < 256; paletteIndex++) {
|
||||
for (int paletteIndex = 0; paletteIndex < 256; paletteIndex++) {
|
||||
if (paletteIndex < colorCount) {
|
||||
entries[paletteIndex] = colors[paletteIndex];
|
||||
} else {
|
||||
@ -262,7 +262,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
public Bitmap GetQuantizedImage(int allowedColorCount) {
|
||||
if (allowedColorCount > 256) {
|
||||
throw new ArgumentOutOfRangeException("Quantizing muss be done to get less than 256 colors");
|
||||
throw new ArgumentOutOfRangeException(nameof(allowedColorCount), "Quantizing muss be done to get less than 256 colors");
|
||||
}
|
||||
if (colorCount < allowedColorCount) {
|
||||
// Simple logic to reduce to 8 bit
|
||||
@ -272,11 +272,11 @@ namespace GreenshotPlugin.Core {
|
||||
// preprocess the colors
|
||||
CalculateMoments();
|
||||
LOG.Info("Calculated the moments...");
|
||||
Int32 next = 0;
|
||||
Single[] volumeVariance = new Single[MAXCOLOR];
|
||||
int next = 0;
|
||||
float[] volumeVariance = new float[MAXCOLOR];
|
||||
|
||||
// processes the cubes
|
||||
for (Int32 cubeIndex = 1; cubeIndex < allowedColorCount; ++cubeIndex) {
|
||||
for (int cubeIndex = 1; cubeIndex < allowedColorCount; ++cubeIndex) {
|
||||
// if cut is possible; make it
|
||||
if (Cut(cubes[next], cubes[cubeIndex])) {
|
||||
volumeVariance[next] = cubes[next].Volume > 1 ? CalculateVariance(cubes[next]) : 0.0f;
|
||||
@ -288,9 +288,9 @@ namespace GreenshotPlugin.Core {
|
||||
}
|
||||
|
||||
next = 0;
|
||||
Single temp = volumeVariance[0];
|
||||
float temp = volumeVariance[0];
|
||||
|
||||
for (Int32 index = 1; index <= cubeIndex; ++index) {
|
||||
for (int index = 1; index <= cubeIndex; ++index) {
|
||||
if (volumeVariance[index] > temp) {
|
||||
temp = volumeVariance[index];
|
||||
next = index;
|
||||
@ -303,9 +303,9 @@ namespace GreenshotPlugin.Core {
|
||||
}
|
||||
}
|
||||
|
||||
Int32[] lookupRed = new Int32[MAXCOLOR];
|
||||
Int32[] lookupGreen = new Int32[MAXCOLOR];
|
||||
Int32[] lookupBlue = new Int32[MAXCOLOR];
|
||||
int[] lookupRed = new int[MAXCOLOR];
|
||||
int[] lookupGreen = new int[MAXCOLOR];
|
||||
int[] lookupBlue = new int[MAXCOLOR];
|
||||
|
||||
tag = new byte[MAXVOLUME];
|
||||
|
||||
@ -326,10 +326,10 @@ namespace GreenshotPlugin.Core {
|
||||
}
|
||||
}
|
||||
|
||||
reds = new Int32[allowedColorCount + 1];
|
||||
greens = new Int32[allowedColorCount + 1];
|
||||
blues = new Int32[allowedColorCount + 1];
|
||||
sums = new Int32[allowedColorCount + 1];
|
||||
reds = new int[allowedColorCount + 1];
|
||||
greens = new int[allowedColorCount + 1];
|
||||
blues = new int[allowedColorCount + 1];
|
||||
sums = new int[allowedColorCount + 1];
|
||||
|
||||
LOG.Info("Starting bitmap reconstruction...");
|
||||
|
||||
@ -356,16 +356,16 @@ namespace GreenshotPlugin.Core {
|
||||
bestMatch = dest.GetColorIndexAt(x, y);
|
||||
bestMatch = tag[bestMatch];
|
||||
|
||||
Int32 bestDistance = 100000000;
|
||||
int bestDistance = 100000000;
|
||||
for (int lookupIndex = 0; lookupIndex < allowedColorCount; lookupIndex++) {
|
||||
Int32 foundRed = lookupRed[lookupIndex];
|
||||
Int32 foundGreen = lookupGreen[lookupIndex];
|
||||
Int32 foundBlue = lookupBlue[lookupIndex];
|
||||
Int32 deltaRed = color.R - foundRed;
|
||||
Int32 deltaGreen = color.G - foundGreen;
|
||||
Int32 deltaBlue = color.B - foundBlue;
|
||||
int foundRed = lookupRed[lookupIndex];
|
||||
int foundGreen = lookupGreen[lookupIndex];
|
||||
int foundBlue = lookupBlue[lookupIndex];
|
||||
int deltaRed = color.R - foundRed;
|
||||
int deltaGreen = color.G - foundGreen;
|
||||
int deltaBlue = color.B - foundBlue;
|
||||
|
||||
Int32 distance = deltaRed * deltaRed + deltaGreen * deltaGreen + deltaBlue * deltaBlue;
|
||||
int distance = deltaRed * deltaRed + deltaGreen * deltaGreen + deltaBlue * deltaBlue;
|
||||
|
||||
if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
@ -393,7 +393,7 @@ namespace GreenshotPlugin.Core {
|
||||
// generates palette
|
||||
ColorPalette imagePalette = resultBitmap.Palette;
|
||||
Color[] entries = imagePalette.Entries;
|
||||
for (Int32 paletteIndex = 0; paletteIndex < allowedColorCount; paletteIndex++) {
|
||||
for (int paletteIndex = 0; paletteIndex < allowedColorCount; paletteIndex++) {
|
||||
if (sums[paletteIndex] > 0) {
|
||||
reds[paletteIndex] /= sums[paletteIndex];
|
||||
greens[paletteIndex] /= sums[paletteIndex];
|
||||
@ -414,14 +414,14 @@ namespace GreenshotPlugin.Core {
|
||||
/// Converts the histogram to a series of moments.
|
||||
/// </summary>
|
||||
private void CalculateMoments() {
|
||||
Int64[] area = new Int64[SIDESIZE];
|
||||
Int64[] areaRed = new Int64[SIDESIZE];
|
||||
Int64[] areaGreen = new Int64[SIDESIZE];
|
||||
Int64[] areaBlue = new Int64[SIDESIZE];
|
||||
Single[] area2 = new Single[SIDESIZE];
|
||||
long[] area = new long[SIDESIZE];
|
||||
long[] areaRed = new long[SIDESIZE];
|
||||
long[] areaGreen = new long[SIDESIZE];
|
||||
long[] areaBlue = new long[SIDESIZE];
|
||||
float[] area2 = new float[SIDESIZE];
|
||||
|
||||
for (Int32 redIndex = 1; redIndex <= MAXSIDEINDEX; ++redIndex) {
|
||||
for (Int32 index = 0; index <= MAXSIDEINDEX; ++index) {
|
||||
for (int redIndex = 1; redIndex <= MAXSIDEINDEX; ++redIndex) {
|
||||
for (int index = 0; index <= MAXSIDEINDEX; ++index) {
|
||||
area[index] = 0;
|
||||
areaRed[index] = 0;
|
||||
areaGreen[index] = 0;
|
||||
@ -429,14 +429,14 @@ namespace GreenshotPlugin.Core {
|
||||
area2[index] = 0;
|
||||
}
|
||||
|
||||
for (Int32 greenIndex = 1; greenIndex <= MAXSIDEINDEX; ++greenIndex) {
|
||||
Int64 line = 0;
|
||||
Int64 lineRed = 0;
|
||||
Int64 lineGreen = 0;
|
||||
Int64 lineBlue = 0;
|
||||
Single line2 = 0.0f;
|
||||
for (int greenIndex = 1; greenIndex <= MAXSIDEINDEX; ++greenIndex) {
|
||||
long line = 0;
|
||||
long lineRed = 0;
|
||||
long lineGreen = 0;
|
||||
long lineBlue = 0;
|
||||
float line2 = 0.0f;
|
||||
|
||||
for (Int32 blueIndex = 1; blueIndex <= MAXSIDEINDEX; ++blueIndex) {
|
||||
for (int blueIndex = 1; blueIndex <= MAXSIDEINDEX; ++blueIndex) {
|
||||
line += weights[redIndex, greenIndex, blueIndex];
|
||||
lineRed += momentsRed[redIndex, greenIndex, blueIndex];
|
||||
lineGreen += momentsGreen[redIndex, greenIndex, blueIndex];
|
||||
@ -462,7 +462,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Computes the volume of the cube in a specific moment.
|
||||
/// </summary>
|
||||
private static Int64 Volume(WuColorCube cube, Int64[, ,] moment) {
|
||||
private static long Volume(WuColorCube cube, long[,,] moment) {
|
||||
return moment[cube.RedMaximum, cube.GreenMaximum, cube.BlueMaximum] -
|
||||
moment[cube.RedMaximum, cube.GreenMaximum, cube.BlueMinimum] -
|
||||
moment[cube.RedMaximum, cube.GreenMinimum, cube.BlueMaximum] +
|
||||
@ -476,7 +476,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Computes the volume of the cube in a specific moment. For the floating-point values.
|
||||
/// </summary>
|
||||
private static Single VolumeFloat(WuColorCube cube, Single[, ,] moment) {
|
||||
private static float VolumeFloat(WuColorCube cube, float[,,] moment) {
|
||||
return moment[cube.RedMaximum, cube.GreenMaximum, cube.BlueMaximum] -
|
||||
moment[cube.RedMaximum, cube.GreenMaximum, cube.BlueMinimum] -
|
||||
moment[cube.RedMaximum, cube.GreenMinimum, cube.BlueMaximum] +
|
||||
@ -490,7 +490,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Splits the cube in given position, and color direction.
|
||||
/// </summary>
|
||||
private static Int64 Top(WuColorCube cube, Int32 direction, Int32 position, Int64[, ,] moment) {
|
||||
private static long Top(WuColorCube cube, int direction, int position, long[,,] moment) {
|
||||
switch (direction) {
|
||||
case RED:
|
||||
return (moment[position, cube.GreenMaximum, cube.BlueMaximum] -
|
||||
@ -518,7 +518,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Splits the cube in a given color direction at its minimum.
|
||||
/// </summary>
|
||||
private static Int64 Bottom(WuColorCube cube, Int32 direction, Int64[, ,] moment) {
|
||||
private static long Bottom(WuColorCube cube, int direction, long[,,] moment) {
|
||||
switch (direction) {
|
||||
case RED:
|
||||
return (-moment[cube.RedMinimum, cube.GreenMaximum, cube.BlueMaximum] +
|
||||
@ -545,14 +545,14 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Calculates statistical variance for a given cube.
|
||||
/// </summary>
|
||||
private Single CalculateVariance(WuColorCube cube) {
|
||||
Single volumeRed = Volume(cube, momentsRed);
|
||||
Single volumeGreen = Volume(cube, momentsGreen);
|
||||
Single volumeBlue = Volume(cube, momentsBlue);
|
||||
Single volumeMoment = VolumeFloat(cube, moments);
|
||||
Single volumeWeight = Volume(cube, weights);
|
||||
private float CalculateVariance(WuColorCube cube) {
|
||||
float volumeRed = Volume(cube, momentsRed);
|
||||
float volumeGreen = Volume(cube, momentsGreen);
|
||||
float volumeBlue = Volume(cube, momentsBlue);
|
||||
float volumeMoment = VolumeFloat(cube, moments);
|
||||
float volumeWeight = Volume(cube, weights);
|
||||
|
||||
Single distance = volumeRed * volumeRed + volumeGreen * volumeGreen + volumeBlue * volumeBlue;
|
||||
float distance = volumeRed * volumeRed + volumeGreen * volumeGreen + volumeBlue * volumeBlue;
|
||||
|
||||
return volumeMoment - (distance / volumeWeight);
|
||||
}
|
||||
@ -560,26 +560,26 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Finds the optimal (maximal) position for the cut.
|
||||
/// </summary>
|
||||
private Single Maximize(WuColorCube cube, Int32 direction, Int32 first, Int32 last, Int32[] cut, Int64 wholeRed, Int64 wholeGreen, Int64 wholeBlue, Int64 wholeWeight) {
|
||||
Int64 bottomRed = Bottom(cube, direction, momentsRed);
|
||||
Int64 bottomGreen = Bottom(cube, direction, momentsGreen);
|
||||
Int64 bottomBlue = Bottom(cube, direction, momentsBlue);
|
||||
Int64 bottomWeight = Bottom(cube, direction, weights);
|
||||
private float Maximize(WuColorCube cube, int direction, int first, int last, int[] cut, long wholeRed, long wholeGreen, long wholeBlue, long wholeWeight) {
|
||||
long bottomRed = Bottom(cube, direction, momentsRed);
|
||||
long bottomGreen = Bottom(cube, direction, momentsGreen);
|
||||
long bottomBlue = Bottom(cube, direction, momentsBlue);
|
||||
long bottomWeight = Bottom(cube, direction, weights);
|
||||
|
||||
Single result = 0.0f;
|
||||
float result = 0.0f;
|
||||
cut[0] = -1;
|
||||
|
||||
for (Int32 position = first; position < last; ++position) {
|
||||
for (int position = first; position < last; ++position) {
|
||||
// determines the cube cut at a certain position
|
||||
Int64 halfRed = bottomRed + Top(cube, direction, position, momentsRed);
|
||||
Int64 halfGreen = bottomGreen + Top(cube, direction, position, momentsGreen);
|
||||
Int64 halfBlue = bottomBlue + Top(cube, direction, position, momentsBlue);
|
||||
Int64 halfWeight = bottomWeight + Top(cube, direction, position, weights);
|
||||
long halfRed = bottomRed + Top(cube, direction, position, momentsRed);
|
||||
long halfGreen = bottomGreen + Top(cube, direction, position, momentsGreen);
|
||||
long halfBlue = bottomBlue + Top(cube, direction, position, momentsBlue);
|
||||
long halfWeight = bottomWeight + Top(cube, direction, position, weights);
|
||||
|
||||
// the cube cannot be cut at bottom (this would lead to empty cube)
|
||||
if (halfWeight != 0) {
|
||||
Single halfDistance = (Single)halfRed * halfRed + (Single)halfGreen * halfGreen + (Single)halfBlue * halfBlue;
|
||||
Single temp = halfDistance / halfWeight;
|
||||
float halfDistance = (float)halfRed * halfRed + (float)halfGreen * halfGreen + (float)halfBlue * halfBlue;
|
||||
float temp = halfDistance / halfWeight;
|
||||
|
||||
halfRed = wholeRed - halfRed;
|
||||
halfGreen = wholeGreen - halfGreen;
|
||||
@ -587,7 +587,7 @@ namespace GreenshotPlugin.Core {
|
||||
halfWeight = wholeWeight - halfWeight;
|
||||
|
||||
if (halfWeight != 0) {
|
||||
halfDistance = (Single)halfRed * halfRed + (Single)halfGreen * halfGreen + (Single)halfBlue * halfBlue;
|
||||
halfDistance = (float)halfRed * halfRed + (float)halfGreen * halfGreen + (float)halfBlue * halfBlue;
|
||||
temp += halfDistance / halfWeight;
|
||||
|
||||
if (temp > result) {
|
||||
@ -604,21 +604,21 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Cuts a cube with another one.
|
||||
/// </summary>
|
||||
private Boolean Cut(WuColorCube first, WuColorCube second) {
|
||||
Int32 direction;
|
||||
private bool Cut(WuColorCube first, WuColorCube second) {
|
||||
int direction;
|
||||
|
||||
Int32[] cutRed = { 0 };
|
||||
Int32[] cutGreen = { 0 };
|
||||
Int32[] cutBlue = { 0 };
|
||||
int[] cutRed = { 0 };
|
||||
int[] cutGreen = { 0 };
|
||||
int[] cutBlue = { 0 };
|
||||
|
||||
Int64 wholeRed = Volume(first, momentsRed);
|
||||
Int64 wholeGreen = Volume(first, momentsGreen);
|
||||
Int64 wholeBlue = Volume(first, momentsBlue);
|
||||
Int64 wholeWeight = Volume(first, weights);
|
||||
long wholeRed = Volume(first, momentsRed);
|
||||
long wholeGreen = Volume(first, momentsGreen);
|
||||
long wholeBlue = Volume(first, momentsBlue);
|
||||
long wholeWeight = Volume(first, weights);
|
||||
|
||||
Single maxRed = Maximize(first, RED, first.RedMinimum + 1, first.RedMaximum, cutRed, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
Single maxGreen = Maximize(first, GREEN, first.GreenMinimum + 1, first.GreenMaximum, cutGreen, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
Single maxBlue = Maximize(first, BLUE, first.BlueMinimum + 1, first.BlueMaximum, cutBlue, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
float maxRed = Maximize(first, RED, first.RedMinimum + 1, first.RedMaximum, cutRed, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
float maxGreen = Maximize(first, GREEN, first.GreenMinimum + 1, first.GreenMaximum, cutGreen, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
float maxBlue = Maximize(first, BLUE, first.BlueMinimum + 1, first.BlueMaximum, cutBlue, wholeRed, wholeGreen, wholeBlue, wholeWeight);
|
||||
|
||||
if ((maxRed >= maxGreen) && (maxRed >= maxBlue)) {
|
||||
direction = RED;
|
||||
@ -669,10 +669,10 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Marks all the tags with a given label.
|
||||
/// </summary>
|
||||
private void Mark(WuColorCube cube, Int32 label, byte[] tag) {
|
||||
for (Int32 redIndex = cube.RedMinimum + 1; redIndex <= cube.RedMaximum; ++redIndex) {
|
||||
for (Int32 greenIndex = cube.GreenMinimum + 1; greenIndex <= cube.GreenMaximum; ++greenIndex) {
|
||||
for (Int32 blueIndex = cube.BlueMinimum + 1; blueIndex <= cube.BlueMaximum; ++blueIndex) {
|
||||
private void Mark(WuColorCube cube, int label, byte[] tag) {
|
||||
for (int redIndex = cube.RedMinimum + 1; redIndex <= cube.RedMaximum; ++redIndex) {
|
||||
for (int greenIndex = cube.GreenMinimum + 1; greenIndex <= cube.GreenMaximum; ++greenIndex) {
|
||||
for (int blueIndex = cube.BlueMinimum + 1; blueIndex <= cube.BlueMaximum; ++blueIndex) {
|
||||
tag[(redIndex << 10) + (redIndex << 6) + redIndex + (greenIndex << 5) + greenIndex + blueIndex] = (byte)label;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ using GreenshotPlugin.UnmanagedHelpers;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@ -154,9 +153,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// Main code is taken from vbAccelerator, location:
|
||||
/// http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows/Enumerating_Windows/article.asp
|
||||
/// but a LOT of changes/enhancements were made to adapt it for Greenshot.
|
||||
/// <summary>
|
||||
/// Provides details about a Window returned by the
|
||||
/// enumeration
|
||||
///
|
||||
/// Provides details about a Window returned by the enumeration
|
||||
/// </summary>
|
||||
public class WindowDetails : IEquatable<WindowDetails>{
|
||||
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow"; // Windows 10 uses ApplicationFrameWindow
|
||||
@ -167,15 +165,21 @@ namespace GreenshotPlugin.Core {
|
||||
private static readonly CoreConfiguration Conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly List<IntPtr> IgnoreHandles = new List<IntPtr>();
|
||||
private static readonly List<string> ExcludeProcessesFromFreeze = new List<string>();
|
||||
private static readonly IAppVisibility appVisibility;
|
||||
private static readonly IAppVisibility AppVisibility;
|
||||
|
||||
static WindowDetails() {
|
||||
try {
|
||||
try
|
||||
{
|
||||
// Only try to instantiate when Windows 8 or later.
|
||||
if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2) {
|
||||
appVisibility = COMWrapper.CreateInstance<IAppVisibility>();
|
||||
if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2)
|
||||
{
|
||||
AppVisibility = COMWrapper.CreateInstance<IAppVisibility>();
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.WarnFormat("Couldn't create instance of IAppVisibility: {0}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddProcessToExcludeFromFreeze(string processname) {
|
||||
@ -529,7 +533,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// This method will find the child window according to a path of classnames.
|
||||
/// Usually used for finding a certain "content" window like for the IE Browser
|
||||
/// </summary>
|
||||
/// <param name="classnames">List<string> with classname "path"</param>
|
||||
/// <param name="classnames">List of string with classname "path"</param>
|
||||
/// <param name="allowSkip">true allows the search to skip a classname of the path</param>
|
||||
/// <returns>WindowDetails if found</returns>
|
||||
public WindowDetails FindPath(List<string> classnames, bool allowSkip) {
|
||||
@ -695,8 +699,8 @@ namespace GreenshotPlugin.Core {
|
||||
RECT rect = new RECT(screen.Bounds);
|
||||
IntPtr monitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONULL);
|
||||
if (monitor != IntPtr.Zero) {
|
||||
if (appVisibility != null) {
|
||||
MONITOR_APP_VISIBILITY monitorAppVisibility = appVisibility.GetAppVisibilityOnMonitor(monitor);
|
||||
if (AppVisibility != null) {
|
||||
MONITOR_APP_VISIBILITY monitorAppVisibility = AppVisibility.GetAppVisibilityOnMonitor(monitor);
|
||||
//LOG.DebugFormat("App {0} visible: {1} on {2}", Text, monitorAppVisibility, screen.Bounds);
|
||||
if (monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE) {
|
||||
return true;
|
||||
@ -1395,7 +1399,7 @@ namespace GreenshotPlugin.Core {
|
||||
Rectangle windowRect = WindowRectangle;
|
||||
// Start the capture
|
||||
Exception exceptionOccured = null;
|
||||
Image returnImage = null;
|
||||
Image returnImage;
|
||||
using (Region region = GetRegion()) {
|
||||
PixelFormat pixelFormat = PixelFormat.Format24bppRgb;
|
||||
// Only use 32 bpp ARGB when the window has a region
|
||||
@ -1446,7 +1450,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// </summary>
|
||||
/// <param name="hWnd">The Window Handle</param>
|
||||
public WindowDetails(IntPtr hWnd) {
|
||||
this._hWnd = hWnd;
|
||||
_hWnd = hWnd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1455,7 +1459,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <returns>WindowDetails of the current window</returns>
|
||||
public static WindowDetails GetActiveWindow() {
|
||||
IntPtr hWnd = User32.GetForegroundWindow();
|
||||
if (hWnd != null && hWnd != IntPtr.Zero) {
|
||||
if (hWnd != IntPtr.Zero) {
|
||||
if (IgnoreHandles.Contains(hWnd)) {
|
||||
return GetDesktopWindow();
|
||||
}
|
||||
@ -1499,7 +1503,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Get all the top level windows
|
||||
/// </summary>
|
||||
/// <returns>List<WindowDetails> with all the top level windows</returns>
|
||||
/// <returns>List of WindowDetails with all the top level windows</returns>
|
||||
public static List<WindowDetails> GetAllWindows() {
|
||||
return GetAllWindows(null);
|
||||
}
|
||||
@ -1582,7 +1586,7 @@ namespace GreenshotPlugin.Core {
|
||||
public static List<WindowDetails> GetMetroApps() {
|
||||
List<WindowDetails> metroApps = new List<WindowDetails>();
|
||||
// if the appVisibility != null we have Windows 8.
|
||||
if (appVisibility == null) {
|
||||
if (AppVisibility == null) {
|
||||
return metroApps;
|
||||
}
|
||||
//string[] wcs = {"ImmersiveGutter", "Snapped Desktop", "ImmersiveBackgroundWindow","ImmersiveLauncher","Windows.UI.Core.CoreWindow","ApplicationManager_ImmersiveShellWindow","SearchPane","MetroGhostWindow","EdgeUiInputWndClass", "NativeHWNDHost", "Shell_CharmWindow"};
|
||||
@ -1712,7 +1716,7 @@ namespace GreenshotPlugin.Core {
|
||||
/// <returns></returns>
|
||||
public static WindowDetails GetAppLauncher() {
|
||||
// Only if Windows 8 (or higher)
|
||||
if (appVisibility == null) {
|
||||
if (AppVisibility == null) {
|
||||
return null;
|
||||
}
|
||||
IntPtr appLauncher = User32.FindWindow(METRO_APPLAUNCHER_CLASS, null);
|
||||
@ -1728,8 +1732,8 @@ namespace GreenshotPlugin.Core {
|
||||
/// <returns></returns>
|
||||
public static bool IsAppLauncherVisible {
|
||||
get {
|
||||
if (appVisibility != null) {
|
||||
return appVisibility.IsLauncherVisible;
|
||||
if (AppVisibility != null) {
|
||||
return AppVisibility.IsLauncherVisible;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ namespace Greenshot.IniFile {
|
||||
/// <summary>
|
||||
/// Initialize the ini config
|
||||
/// </summary>
|
||||
/// <param name="applicationName"></param>
|
||||
/// <param name="appName"></param>
|
||||
/// <param name="configName"></param>
|
||||
public static void Init(string appName, string confName) {
|
||||
public static void Init(string appName, string configName) {
|
||||
applicationName = appName;
|
||||
configName = confName;
|
||||
IniConfig.configName = configName;
|
||||
Reload();
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ namespace Greenshot.IniFile {
|
||||
/// <param name="sectionName"></param>
|
||||
/// <returns></returns>
|
||||
public static IniSection GetIniSection(string sectionName) {
|
||||
IniSection returnValue = null;
|
||||
IniSection returnValue;
|
||||
sectionMap.TryGetValue(sectionName, out returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
@ -369,11 +369,10 @@ namespace Greenshot.IniFile {
|
||||
/// </summary>
|
||||
/// <param name="section"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> PropertiesForSection(IniSection section) {
|
||||
Type iniSectionType = section.GetType();
|
||||
public static IDictionary<string, string> PropertiesForSection(IniSection section) {
|
||||
string sectionName = section.IniSectionAttribute.Name;
|
||||
// Get the properties for the section
|
||||
Dictionary<string, string> properties = null;
|
||||
IDictionary<string, string> properties;
|
||||
if (sections.ContainsKey(sectionName)) {
|
||||
properties = sections[sectionName];
|
||||
} else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user