_sizes = new();
- private IDrawableContainerList _listOfdrawableContainer;
-
- private void StoreBounds()
- {
- foreach (IDrawableContainer drawableContainer in _listOfdrawableContainer)
- {
- _points.Add(drawableContainer.Location);
- _sizes.Add(drawableContainer.Size);
- }
- }
-
- public DrawableContainerBoundsChangeMemento(IDrawableContainerList listOfdrawableContainer)
- {
- _listOfdrawableContainer = listOfdrawableContainer;
- StoreBounds();
- }
-
- public DrawableContainerBoundsChangeMemento(IDrawableContainer drawableContainer)
- {
- _listOfdrawableContainer = new DrawableContainerList
- {
- drawableContainer
- };
- _listOfdrawableContainer.Parent = drawableContainer.Parent;
- StoreBounds();
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _listOfdrawableContainer?.Dispose();
- }
- _listOfdrawableContainer = null;
- }
-
- public bool Merge(IMemento otherMemento)
- {
- if (otherMemento is not DrawableContainerBoundsChangeMemento other) return false;
-
- if (ObjectExtensions.CompareLists(_listOfdrawableContainer, other._listOfdrawableContainer))
- {
- // Lists are equal, as we have the state already we can ignore the new memento
- return true;
- }
- return false;
- }
-
- public IMemento Restore()
- {
- var oldState = new DrawableContainerBoundsChangeMemento(_listOfdrawableContainer);
- for (int index = 0; index < _listOfdrawableContainer.Count; index++)
- {
- IDrawableContainer drawableContainer = _listOfdrawableContainer[index];
- // Before
- drawableContainer.Invalidate();
- drawableContainer.Left = _points[index].X;
- drawableContainer.Top = _points[index].Y;
- drawableContainer.Width = _sizes[index].Width;
- drawableContainer.Height = _sizes[index].Height;
- // After
- drawableContainer.Invalidate();
- drawableContainer.Parent.Modified = true;
- }
- return oldState;
- }
- }
-}
diff --git a/Greenshot/Memento/SurfaceBackgroundChangeMemento.cs b/Greenshot/Memento/SurfaceBackgroundChangeMemento.cs
deleted file mode 100644
index a20823878..000000000
--- a/Greenshot/Memento/SurfaceBackgroundChangeMemento.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using Greenshot.Drawing;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using GreenshotPlugin.Interfaces.Drawing;
-
-namespace Greenshot.Memento {
- ///
- /// The SurfaceCropMemento makes it possible to undo-redo an surface crop
- ///
- public class SurfaceBackgroundChangeMemento : IMemento {
- private Image _image;
- private Surface _surface;
- private Matrix _matrix;
-
- public SurfaceBackgroundChangeMemento(Surface surface, Matrix matrix) {
- _surface = surface;
- _image = surface.Image;
- _matrix = matrix.Clone();
- // Make sure the reverse is applied
- _matrix.Invert();
- }
-
- public void Dispose() {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposing) return;
-
- if (_matrix != null) {
- _matrix.Dispose();
- _matrix = null;
- }
- if (_image != null) {
- _image.Dispose();
- _image = null;
- }
- _surface = null;
- }
-
- public bool Merge(IMemento otherMemento) {
- return false;
- }
-
- public IMemento Restore() {
- SurfaceBackgroundChangeMemento oldState = new SurfaceBackgroundChangeMemento(_surface, _matrix);
- _surface.UndoBackgroundChange(_image, _matrix);
- _surface.Invalidate();
- return oldState;
- }
- }
-}
diff --git a/Greenshot/Memento/TextChangeMemento.cs b/Greenshot/Memento/TextChangeMemento.cs
deleted file mode 100644
index 4971b8ff0..000000000
--- a/Greenshot/Memento/TextChangeMemento.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using Greenshot.Drawing;
-using GreenshotPlugin.Interfaces.Drawing;
-
-namespace Greenshot.Memento {
- ///
- /// The TextChangeMemento makes it possible to undo-redo an IDrawableContainer move
- ///
- public class TextChangeMemento : IMemento {
- private TextContainer _textContainer;
- private readonly string _oldText;
-
- public TextChangeMemento(TextContainer textContainer) {
- _textContainer = textContainer;
- _oldText = textContainer.Text;
- }
-
- public void Dispose() {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing) {
- if (disposing) {
- _textContainer = null;
- }
- }
-
- public bool Merge(IMemento otherMemento) {
- if (otherMemento is not TextChangeMemento other) return false;
-
- return other._textContainer.Equals(_textContainer);
- }
-
- public IMemento Restore() {
- // Before
- _textContainer.Invalidate();
- TextChangeMemento oldState = new TextChangeMemento(_textContainer);
- _textContainer.ChangeText(_oldText, false);
- // After
- _textContainer.Invalidate();
- return oldState;
- }
- }
-}
diff --git a/Greenshot/web/htdocs/Help/index.de-DE.html b/Greenshot/web/htdocs/Help/index.de-DE.html
deleted file mode 100644
index 9f28a117d..000000000
--- a/Greenshot/web/htdocs/Help/index.de-DE.html
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
- Greenshot Hilfe
-
-
-
-
-
-
-
- Greenshot Hilfe
-
- Modi
-
- Bereichsmodus
-
-
- Aktivieren Sie den Bereichsmodus, indem Sie die Druck-Taste auf
- Ihrer Tastatur betätigen oder Bereich abfotografieren aus dem
- Kontextmenü wählen.
- Drücken und halten Sie die linke Maustaste gedrückt, um einen rechteckigen
- Bereich zu definieren, der abfotografiert werden soll.
- Nach dem Loslassen der Maustaste öffnet sich das Bildbearbeitungsfenster
- zur weiteren Bearbeitung Ihres Screenshots.
- Um den Bereich später noch einmal abzufotografieren, wählen Sie Zuletzt
- gewählten Bereich abfotografieren.
-
-
- Fenstermodus
-
-
- Aktivieren Sie den FensterModus, indem Sie Alt + Druck auf
- Ihrer Tastatur betätigen oder Fenster abfotografieren aus dem
- Kontextmenü wählen.
- Klicken Sie auf das Fenster, dass abfotografiern werden soll.
- Nachdem Sie geklickt haben öffnet sich das Bildbearbeitungsfenster
- zur weiteren Bearbeitung Ihres Screenshots.
-
-
- Bildschirmmodus
-
-
- Wenn Sie den gesamten Bildschirm abfotografieren wollen, drücken Sie einfach
- Ctrl + Print auf Ihrer Tastatur oder wählen Sie Kompletten
- Bildschirm abfotografieren.
- Der komplette Bildschirm wird sofort abfotografiert, das Bildbearbeitungsfenster
- öffnet sich zur weiteren Bearbeitung Ihres Screenshots.
-
-
- Bildbearbeitungsfenster
-
-
- Wenn Sie das Bildbearbeitungsfenster nicht nutzen wollen können Sie im
- Kontextmenü oder im Einstellungsdialog festlegen, dass es nicht angezeigt
- werden soll. In diesem Fall wird der Screenshot sofort in eine Datei
- gespeichert. Speicherort, Dateiname und Bildformat sind dann abhängig von
- den bevorzugten Ausgabedatei-Einstellungen im Einstellungsdialog.
-
-
- Datei-Menü
-
-
- - Speichern: speichert die Grafik unter dem Pfad der beim letzten Speichern unter... Dialog gewählt wurde
- - Speichern unter...: öffnet einen Dialog zur Auswahl des Pfads und Dateinamens unter dem die Grafik gespeichert werden soll
- - Grafik in die Zwischenablage kopieren: kopiert die Grafik in die Zwischenablage, so dass sie in anderer Software verwendet werden kann
-
-
- Bearbeiten-Menü
-
-
- - Gewähltes Element in die Zwischenablage ausschneiden: entfernt das ausgewähltes Element und kopiert es in die Zwischenablage, so dass es in ein anderes Bildbearbeitungsfenster eingefügt werden kann
- - Gewähltes Element in die Zwischenablage kopieren: kopiert das ausgewähltes Element in die Zwischenablage, so dass es in ein anderes Bildbearbeitungsfenster eingefügt werden kann
- - Element aus der Zwischenablage einfügen: fügt ein vorher ausgeschnittenes/kopiertes Element in das Bildbearbeitungsfenster ein
- - Gewähltes Element duplizieren: dupliziert das gewählte Element
-
-
- Objekt-Menü
-
-
- - Rechteck hinzufügen: fügt ein Rechteck zur Grafik hinzu
- - Ellipse hinzufügen: fügt eine Ellipse zur Grafik hinzu
- - Textfeld hinzufügen: fügt ein Textfeld zur Grafik hinzu
- - Gewähltes Element löschen: entfernt das gewählte Element aus der Grafik
-
-
-
- Klicken Sie ein Element an um es auszuwählen. Anschließend können Sie die Größe oder
- Position verändern, oder es kopieren, ausschneiden oder entfernen. Die Größe
- eines Elements kann durch Klicken und Ziehen der Anfasser (kleine schwarze
- Quadrate) an der linken oberen oder der rechten unteren Ecke geändert werden.
-
-
-
-
-
diff --git a/Greenshot/web/htdocs/Help/index.en-US.html b/Greenshot/web/htdocs/Help/index.en-US.html
deleted file mode 100644
index 16bb57bc7..000000000
--- a/Greenshot/web/htdocs/Help/index.en-US.html
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
- Greenshot Help
-
-
-
-
-
-
-
- Greenshot Help
-
- Modes
-
- Region mode
-
-
- Activate region mode by hitting the Print key on your keyboard
- or by choosing Capture region from the context menu.
- Left-click and drag to define a rectangular area you want to be shot.
- After releasing the mouse button, the image editor window will open for
- further editing of your screenshot.
- For shooting the region again later, choose Capture last region from
- the context menu.
-
-
- Window mode
-
-
- Activate window mode by hitting Alt + Print on your keyboard
- or by choosing Capture window from the context menu.
- Click the window you want to be shot.
- After clicking, the image editor window will open for
- further editing of your screenshot.
-
-
- Fullscreen mode
-
-
- If you want to shoot the complete screen, just press Ctrl + Print on
- your keyboard or choose Capture full screen from the context menu.
- The complete screen will be shot instantly, the image editor window will open for
- further editing of your screenshot.
-
-
- Image Editor
-
-
- If you do not want to use the image editor window you can choose to skip
- in in the context menu or in the settings dialog. The screenshot will be
- saved directly to a file then. Storage location, filename and image format
- are defined by your preferred output file settings in the settings dialog.
-
-
- File menu
-
-
- - Save: saves the image to the file specified in the last Save as... dialog
- - Save as...: lets you choose a path and filename to save the image to
- - Copy image to clipboard: copies the image to the clipboard, for pasting it to other software
-
-
- Edit menu
-
-
- - Cut selected element to clipboard: removes the selected element and copies it to the clipboard, so that it can be pasted into another image editor window
- - Copy selected element to clipboard: copies it to the clipboard, so that it can be pasted into another image editor window
- - Paste element from clipboard: pastes a previously cut/copied element into the image editor window
- - Duplicate selected element: duplicates the selected element
-
-
- Object menu
-
-
- - Add rectangle: adds a rectangle to the image
- - Add ellipse: adds an ellipse to the image
- - Add textbox: adds a textbox to the image
- - Delete selected element: removes the selected element from the image
-
-
-
- Click an element to select it for resizing, moving, copying, cutting, or removal. The size of an
- element can be defined by dragging the grippers (small black squares) at the top-left and the
- bottom-right corner of the selected element.
-
-
-
-
-
diff --git a/Greenshot/web/htdocs/favicon.ico b/Greenshot/web/htdocs/favicon.ico
deleted file mode 100644
index 0a2ab97c1..000000000
Binary files a/Greenshot/web/htdocs/favicon.ico and /dev/null differ
diff --git a/Greenshot/web/htdocs/index.html b/Greenshot/web/htdocs/index.html
deleted file mode 100644
index 3ff31a08e..000000000
--- a/Greenshot/web/htdocs/index.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- Greenshot - Screenshot Tool
-
-
-
-
-
-
-
-
- |
-
-
-
-
- |
-
-
-
-
-
-
diff --git a/GreenshotBoxPlugin/BoxConfiguration.cs b/GreenshotBoxPlugin/BoxConfiguration.cs
deleted file mode 100644
index b8e9e0965..000000000
--- a/GreenshotBoxPlugin/BoxConfiguration.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
-using System;
-using GreenshotBoxPlugin.Forms;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotBoxPlugin {
- ///
- /// Description of ImgurConfiguration.
- ///
- [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 { get; set; }
-
- [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
- public int UploadJpegQuality { get; set; }
-
- [IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send Box link to clipboard.", DefaultValue = "true")]
- 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; }
- [IniProperty("FolderId", Description = "Folder ID to upload to, only change if you know what you are doing!", DefaultValue = "0")]
- public string FolderId { get; set; }
-
- [IniProperty("RefreshToken", Description = "Box authorization refresh Token", Encrypted = true)]
- public string RefreshToken { get; set; }
-
- ///
- /// Not stored
- ///
- public string AccessToken {
- get;
- set;
- }
-
- ///
- /// Not stored
- ///
- public DateTimeOffset AccessTokenExpires {
- get;
- set;
- }
-
- ///
- /// A form for token
- ///
- /// bool true if OK was pressed, false if cancel
- public bool ShowConfigDialog() {
- DialogResult result = new SettingsForm().ShowDialog();
- if (result == DialogResult.OK) {
- return true;
- }
- return false;
- }
-
- }
-}
diff --git a/GreenshotBoxPlugin/BoxDestination.cs b/GreenshotBoxPlugin/BoxDestination.cs
deleted file mode 100644
index 4283a178c..000000000
--- a/GreenshotBoxPlugin/BoxDestination.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.ComponentModel;
-using System.Drawing;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Interfaces;
-
-namespace GreenshotBoxPlugin {
- public class BoxDestination : AbstractDestination {
- private readonly BoxPlugin _plugin;
- public BoxDestination(BoxPlugin plugin) {
- _plugin = plugin;
- }
-
- public override string Designation => "Box";
-
- public override string Description => Language.GetString("box", LangKey.upload_menu_item);
-
- public override Image DisplayIcon {
- get {
- ComponentResourceManager resources = new ComponentResourceManager(typeof(BoxPlugin));
- return (Image)resources.GetObject("Box");
- }
- }
-
- public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(Designation, Description);
- string uploadUrl = _plugin.Upload(captureDetails, surface);
- if (uploadUrl != null) {
- exportInformation.ExportMade = true;
- exportInformation.Uri = uploadUrl;
- }
- ProcessExport(exportInformation, surface);
- return exportInformation;
- }
- }
-}
diff --git a/GreenshotBoxPlugin/BoxEntities.cs b/GreenshotBoxPlugin/BoxEntities.cs
deleted file mode 100644
index a1f1a5c61..000000000
--- a/GreenshotBoxPlugin/BoxEntities.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-
-namespace GreenshotBoxPlugin {
- [DataContract]
- public class Authorization {
- [DataMember(Name = "access_token")]
- public string AccessToken { get; set; }
- [DataMember(Name = "expires_in")]
- public int ExpiresIn { get; set; }
- [DataMember(Name = "refresh_token")]
- public string RefreshToken { get; set; }
- [DataMember(Name = "token_type")]
- public string TokenType { get; set; }
- }
- [DataContract]
- public class SharedLink {
- [DataMember(Name = "url")]
- public string Url { get; set; }
- [DataMember(Name = "download_url")]
- public string DownloadUrl { get; set; }
- }
-
- [DataContract]
- public class FileEntry {
- [DataMember(Name = "id")]
- public string Id { get; set; }
- [DataMember(Name = "name")]
- public string Name { get; set; }
- [DataMember(Name = "shared_link")]
- public SharedLink SharedLink { get; set; }
- }
-
- [DataContract]
- public class Upload {
- [DataMember(Name = "entries")]
- public List Entries { get; set; }
- }
-}
diff --git a/GreenshotBoxPlugin/BoxPlugin.cs b/GreenshotBoxPlugin/BoxPlugin.cs
deleted file mode 100644
index b15835063..000000000
--- a/GreenshotBoxPlugin/BoxPlugin.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotBoxPlugin {
- ///
- /// This is the Box base code
- ///
- [Plugin("Box", true)]
- public class BoxPlugin : IGreenshotPlugin {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(BoxPlugin));
- private static BoxConfiguration _config;
- private ComponentResourceManager _resources;
- private ToolStripMenuItem _itemPlugInConfig;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposing)
- {
- if (!disposing) return;
-
- if (_itemPlugInConfig == null) return;
-
- _itemPlugInConfig.Dispose();
- _itemPlugInConfig = null;
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- public bool Initialize() {
-
- // Register configuration (don't need the configuration itself)
- _config = IniConfig.GetIniSection();
- _resources = new ComponentResourceManager(typeof(BoxPlugin));
- SimpleServiceProvider.Current.AddService(new BoxDestination(this));
- _itemPlugInConfig = new ToolStripMenuItem {
- Image = (Image) _resources.GetObject("Box"),
- Text = Language.GetString("box", LangKey.Configure)
- };
- _itemPlugInConfig.Click += ConfigMenuClick;
-
- PluginUtils.AddToContextMenu(_itemPlugInConfig);
- Language.LanguageChanged += OnLanguageChanged;
- return true;
- }
-
- public void OnLanguageChanged(object sender, EventArgs e) {
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Text = Language.GetString("box", LangKey.Configure);
- }
- }
-
- public void Shutdown() {
- LOG.Debug("Box Plugin shutdown.");
- }
-
- ///
- /// Implementation of the IPlugin.Configure
- ///
- public void Configure() {
- _config.ShowConfigDialog();
- }
-
- public void ConfigMenuClick(object sender, EventArgs eventArgs) {
- _config.ShowConfigDialog();
- }
-
- ///
- /// This will be called when the menu item in the Editor is clicked
- ///
- public string Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) {
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
- try {
- string url = null;
- string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
- SurfaceContainer imageToUpload = new SurfaceContainer(surfaceToUpload, outputSettings, filename);
-
- new PleaseWaitForm().ShowAndWait("Box", Language.GetString("box", LangKey.communication_wait),
- delegate {
- url = BoxUtils.UploadToBox(imageToUpload, captureDetails.Title, filename);
- }
- );
-
- if (url != null && _config.AfterUploadLinkToClipBoard) {
- ClipboardHelper.SetClipboardData(url);
- }
-
- return url;
- } catch (Exception ex) {
- LOG.Error("Error uploading.", ex);
- MessageBox.Show(Language.GetString("box", LangKey.upload_failure) + " " + ex.Message);
- return null;
- }
- }
- }
-}
diff --git a/GreenshotBoxPlugin/BoxUtils.cs b/GreenshotBoxPlugin/BoxUtils.cs
deleted file mode 100644
index a20447c86..000000000
--- a/GreenshotBoxPlugin/BoxUtils.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Core;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.Serialization.Json;
-using System.Text;
-using GreenshotPlugin.Core.OAuth;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotBoxPlugin {
-
- ///
- /// Description of BoxUtils.
- ///
- public static class BoxUtils {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(BoxUtils));
- private static readonly BoxConfiguration Config = IniConfig.GetIniSection();
- private const string UploadFileUri = "https://upload.box.com/api/2.0/files/content";
- private const string FilesUri = "https://www.box.com/api/2.0/files/{0}";
-
- ///
- /// Put string
- ///
- ///
- ///
- /// OAuth2Settings
- /// response
- public static string HttpPut(string url, string content, OAuth2Settings settings) {
- var webRequest= OAuth2Helper.CreateOAuth2WebRequest(HTTPMethod.PUT, url, settings);
-
- byte[] data = Encoding.UTF8.GetBytes(content);
- using (var requestStream = webRequest.GetRequestStream()) {
- requestStream.Write(data, 0, data.Length);
- }
- return NetworkHelper.GetResponseAsString(webRequest);
- }
-
- ///
- /// Do the actual upload to Box
- /// For more details on the available parameters, see: http://developers.box.net/w/page/12923951/ApiFunction_Upload%20and%20Download
- ///
- /// Image for box upload
- /// Title of box upload
- /// Filename of box upload
- /// url to uploaded image
- public static string UploadToBox(SurfaceContainer image, string title, string filename) {
-
- // Fill the OAuth2Settings
- var settings = new OAuth2Settings
- {
- AuthUrlPattern = "https://app.box.com/api/oauth2/authorize?client_id={ClientId}&response_type=code&state={State}&redirect_uri={RedirectUrl}",
- TokenUrl = "https://api.box.com/oauth2/token",
- CloudServiceName = "Box",
- ClientId = BoxCredentials.ClientId,
- ClientSecret = BoxCredentials.ClientSecret,
- RedirectUrl = "https://getgreenshot.org/authorize/box",
- AuthorizeMode = OAuth2AuthorizeMode.JsonReceiver,
- RefreshToken = Config.RefreshToken,
- AccessToken = Config.AccessToken,
- AccessTokenExpires = Config.AccessTokenExpires
- };
-
-
- // Copy the settings from the config, which is kept in memory and on the disk
-
- try {
- var webRequest = OAuth2Helper.CreateOAuth2WebRequest(HTTPMethod.POST, UploadFileUri, settings);
- IDictionary parameters = new Dictionary
- {
- { "file", image },
- { "parent_id", Config.FolderId }
- };
-
- NetworkHelper.WriteMultipartFormData(webRequest, parameters);
-
- var response = NetworkHelper.GetResponseAsString(webRequest);
-
- Log.DebugFormat("Box response: {0}", response);
-
- var upload = JsonSerializer.Deserialize(response);
- if (upload?.Entries == null || upload.Entries.Count == 0) return null;
-
- if (Config.UseSharedLink) {
- string filesResponse = HttpPut(string.Format(FilesUri, upload.Entries[0].Id), "{\"shared_link\": {\"access\": \"open\"}}", settings);
- var file = JsonSerializer.Deserialize(filesResponse);
- return file.SharedLink.Url;
- }
- return $"http://www.box.com/files/0/f/0/1/f_{upload.Entries[0].Id}";
- } finally {
- // Copy the settings back to the config, so they are stored.
- Config.RefreshToken = settings.RefreshToken;
- Config.AccessToken = settings.AccessToken;
- Config.AccessTokenExpires = settings.AccessTokenExpires;
- Config.IsDirty = true;
- IniConfig.Save();
- }
- }
- }
- ///
- /// A simple helper class for the DataContractJsonSerializer
- ///
- internal static class JsonSerializer {
- ///
- /// Helper method to parse JSON to object
- ///
- ///
- ///
- ///
- public static T Deserialize(string jsonString) {
- var deserializer = new DataContractJsonSerializer(typeof(T));
- using var stream = new MemoryStream();
- byte[] content = Encoding.UTF8.GetBytes(jsonString);
- stream.Write(content, 0, content.Length);
- stream.Seek(0, SeekOrigin.Begin);
- return (T)deserializer.ReadObject(stream);
- }
- }
-}
diff --git a/GreenshotBoxPlugin/Forms/SettingsForm.cs b/GreenshotBoxPlugin/Forms/SettingsForm.cs
deleted file mode 100644
index 49e62fd17..000000000
--- a/GreenshotBoxPlugin/Forms/SettingsForm.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-namespace GreenshotBoxPlugin.Forms {
- ///
- /// Description of PasswordRequestForm.
- ///
- public partial class SettingsForm : BoxForm {
- public SettingsForm() {
- //
- // The InitializeComponent() call is required for Windows Forms designer support.
- //
- InitializeComponent();
- AcceptButton = buttonOK;
- CancelButton = buttonCancel;
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/Confluence.cs b/GreenshotConfluencePlugin/Confluence.cs
deleted file mode 100644
index bb803602c..000000000
--- a/GreenshotConfluencePlugin/Confluence.cs
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.Windows.Forms;
-using GreenshotConfluencePlugin.confluence;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotConfluencePlugin {
- public class Page {
- public Page(RemotePage page) {
- Id = page.id;
- Title = page.title;
- SpaceKey = page.space;
- Url = page.url;
- Content = page.content;
- }
- public Page(RemoteSearchResult searchResult, string space) {
- Id = searchResult.id;
- Title = searchResult.title;
- SpaceKey = space;
- Url = searchResult.url;
- Content = searchResult.excerpt;
- }
-
- public Page(RemotePageSummary pageSummary) {
- Id = pageSummary.id;
- Title = pageSummary.title;
- SpaceKey = pageSummary.space;
- Url =pageSummary.url;
- }
- public long Id {
- get;
- set;
- }
- public string Title {
- get;
- set;
- }
- public string Url {
- get;
- set;
- }
- public string Content {
- get;
- set;
- }
- public string SpaceKey {
- get;
- set;
- }
- }
- public class Space {
- public Space(RemoteSpaceSummary space) {
- Key = space.key;
- Name = space.name;
- }
- public string Key {
- get;
- set;
- }
- public string Name {
- get;
- set;
- }
- }
-
- ///
- /// For details see the Confluence API site
- /// See: http://confluence.atlassian.com/display/CONFDEV/Remote+API+Specification
- ///
- public class ConfluenceConnector : IDisposable {
- 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();
- private string _credentials;
- private DateTime _loggedInTime = DateTime.Now;
- private bool _loggedIn;
- private ConfluenceSoapServiceService _confluence;
- private readonly int _timeout;
- private string _url;
- private readonly Cache _pageCache = new Cache(60 * Config.Timeout);
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposing) {
- if (_confluence != null) {
- Logout();
- }
- if (disposing) {
- if (_confluence != null) {
- _confluence.Dispose();
- _confluence = null;
- }
- }
- }
-
- public ConfluenceConnector(string url, int timeout) {
- _timeout = timeout;
- Init(url);
- }
-
- private void Init(string url) {
- _url = url;
- _confluence = new ConfluenceSoapServiceService
- {
- Url = url,
- Proxy = NetworkHelper.CreateProxy(new Uri(url))
- };
- }
-
- ~ConfluenceConnector() {
- Dispose(false);
- }
-
- ///
- /// Internal login which catches the exceptions
- ///
- /// true if login was done sucessfully
- private bool DoLogin(string user, string password) {
- try {
- _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(V2Failed) && _url.Contains("v2")) {
- Init(_url.Replace("v2", "v1"));
- return DoLogin(user, password);
- }
- // check if auth failed
- if (e.Message.Contains(AuthFailedExceptionName)) {
- return false;
- }
- // Not an authentication issue
- _loggedIn = false;
- _credentials = null;
- e.Data.Add("user", user);
- e.Data.Add("url", _url);
- throw;
- }
- return true;
- }
-
- 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 = 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 (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;
- }
- }
- } catch (ApplicationException e) {
- // exception handling ...
- Log.Error("Problem using the credentials dialog", e);
- }
- }
-
- 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();
- }
- } else {
- Login();
- }
- }
-
- public bool IsLoggedIn => _loggedIn;
-
- public void AddAttachment(long pageId, string mime, string comment, string filename, IBinaryContainer image) {
- CheckCredentials();
- // Comment is ignored, see: http://jira.atlassian.com/browse/CONF-9395
- var attachment = new RemoteAttachment
- {
- comment = comment,
- fileName = filename,
- contentType = mime
- };
- _confluence.addAttachment(_credentials, pageId, attachment, image.ToByteArray());
- }
-
- public Page GetPage(string spaceKey, string pageTitle) {
- RemotePage page = null;
- string cacheKey = spaceKey + pageTitle;
- if (_pageCache.Contains(cacheKey)) {
- page = _pageCache[cacheKey];
- }
- if (page == null) {
- CheckCredentials();
- page = _confluence.getPage(_credentials, spaceKey, pageTitle);
- _pageCache.Add(cacheKey, page);
- }
- return new Page(page);
- }
-
- public Page GetPage(long pageId) {
- RemotePage page = null;
- string cacheKey = pageId.ToString();
-
- if (_pageCache.Contains(cacheKey)) {
- page = _pageCache[cacheKey];
- }
- if (page == null) {
- 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);
- return new Page(page);
- }
-
- public IEnumerable GetSpaceSummaries() {
- CheckCredentials();
- RemoteSpaceSummary [] spaces = _confluence.getSpaces(_credentials);
- foreach(RemoteSpaceSummary space in spaces) {
- yield return new Space(space);
- }
- }
-
- public IEnumerable GetPageChildren(Page parentPage) {
- CheckCredentials();
- RemotePageSummary[] pages = _confluence.getChildren(_credentials, parentPage.Id);
- foreach(RemotePageSummary page in pages) {
- yield return new Page(page);
- }
- }
-
- public IEnumerable GetPageSummaries(Space space) {
- CheckCredentials();
- RemotePageSummary[] pages = _confluence.getPages(_credentials, space.Key);
- foreach(RemotePageSummary page in pages) {
- yield return new Page(page);
- }
- }
-
- public IEnumerable SearchPages(string query, string space) {
- CheckCredentials();
- foreach(var searchResult in _confluence.search(_credentials, query, 20)) {
- Log.DebugFormat("Got result of type {0}", searchResult.type);
- if ("page".Equals(searchResult.type))
- {
- yield return new Page(searchResult, space);
- }
- }
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/ConfluenceConfiguration.cs b/GreenshotConfluencePlugin/ConfluenceConfiguration.cs
deleted file mode 100644
index 5a3e7019c..000000000
--- a/GreenshotConfluencePlugin/ConfluenceConfiguration.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotConfluencePlugin {
- ///
- /// Description of ConfluenceConfiguration.
- ///
- [Serializable]
- [IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
- public class ConfluenceConfiguration : IniSection {
- public const string DEFAULT_POSTFIX1 = "/rpc/soap-axis/confluenceservice-v1?wsdl";
- public const string DEFAULT_POSTFIX2 = "/rpc/soap-axis/confluenceservice-v2?wsdl";
- public const string DEFAULT_PREFIX = "http://";
- private const string DEFAULT_URL = DEFAULT_PREFIX + "confluence";
-
- [IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue=DEFAULT_URL)]
- public string Url {
- get;
- set;
- }
- [IniProperty("Timeout", Description="Session timeout in minutes", DefaultValue="30")]
- public int Timeout {
- get;
- set;
- }
-
- [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
- public OutputFormat UploadFormat {
- get;
- set;
- }
- [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
- public int UploadJpegQuality {
- get;
- set;
- }
- [IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
- public bool UploadReduceColors {
- get;
- set;
- }
- [IniProperty("OpenPageAfterUpload", Description="Open the page where the picture is uploaded after upload", DefaultValue="True")]
- public bool OpenPageAfterUpload {
- get;
- set;
- }
- [IniProperty("CopyWikiMarkupForImageToClipboard", Description="Copy the Wikimarkup for the recently uploaded image to the Clipboard", DefaultValue="True")]
- public bool CopyWikiMarkupForImageToClipboard {
- get;
- set;
- }
- [IniProperty("SearchSpaceKey", Description="Key of last space that was searched for")]
- public string SearchSpaceKey {
- get;
- set;
- }
- [IniProperty("IncludePersonSpaces", Description = "Include personal spaces in the search & browse spaces list", DefaultValue = "False")]
- public bool IncludePersonSpaces {
- get;
- set;
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/ConfluenceDestination.cs b/GreenshotConfluencePlugin/ConfluenceDestination.cs
deleted file mode 100644
index d7794989a..000000000
--- a/GreenshotConfluencePlugin/ConfluenceDestination.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Threading;
-using System.Windows;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotConfluencePlugin {
- ///
- /// Description of ConfluenceDestination.
- ///
- public class ConfluenceDestination : AbstractDestination {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ConfluenceDestination));
- private static readonly ConfluenceConfiguration ConfluenceConfig = IniConfig.GetIniSection();
- private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection();
- private static readonly Image ConfluenceIcon;
- private readonly Page _page;
-
- static ConfluenceDestination() {
- IsInitialized = false;
- try {
- Uri confluenceIconUri = new Uri("/GreenshotConfluencePlugin;component/Images/Confluence.ico", UriKind.Relative);
- using (Stream iconStream = Application.GetResourceStream(confluenceIconUri)?.Stream)
- {
- // TODO: Check what to do with the IImage
- ConfluenceIcon = ImageHelper.FromStream(iconStream);
- }
- IsInitialized = true;
- } catch (Exception ex) {
- Log.ErrorFormat("Problem in the confluence static initializer: {0}", ex.Message);
- }
- }
-
- public static bool IsInitialized
- {
- get;
- private set;
- }
-
- public ConfluenceDestination() {
- }
-
- public ConfluenceDestination(Page page) {
- _page = page;
- }
-
- public override string Designation {
- get {
- return "Confluence";
- }
- }
-
- public override string Description {
- get {
- if (_page == null) {
- return Language.GetString("confluence", LangKey.upload_menu_item);
- } else {
- return Language.GetString("confluence", LangKey.upload_menu_item) + ": \"" + _page.Title + "\"";
- }
- }
- }
-
- public override bool IsDynamic {
- get {
- return true;
- }
- }
-
- public override bool IsActive {
- get {
- return base.IsActive && !string.IsNullOrEmpty(ConfluenceConfig.Url);
- }
- }
-
- public override Image DisplayIcon {
- get {
- return ConfluenceIcon;
- }
- }
-
- public override IEnumerable DynamicDestinations() {
- if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.IsLoggedIn) {
- yield break;
- }
- List currentPages = ConfluenceUtils.GetCurrentPages();
- if (currentPages == null || currentPages.Count == 0) {
- yield break;
- }
- foreach(Page currentPage in currentPages) {
- yield return new ConfluenceDestination(currentPage);
- }
- }
-
- 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) {
- return exportInformation;
- }
-
- Page selectedPage = _page;
- bool openPage = (_page == null) && ConfluenceConfig.OpenPageAfterUpload;
- string filename = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfig.OutputFileFilenamePattern, captureDetails);
- if (selectedPage == null) {
- Forms.ConfluenceUpload confluenceUpload = new Forms.ConfluenceUpload(filename);
- bool? dialogResult = confluenceUpload.ShowDialog();
- if (dialogResult.HasValue && dialogResult.Value) {
- selectedPage = confluenceUpload.SelectedPage;
- if (confluenceUpload.IsOpenPageSelected) {
- openPage = false;
- }
- filename = confluenceUpload.Filename;
- }
- }
- string extension = "." + ConfluenceConfig.UploadFormat;
- if (!filename.ToLower().EndsWith(extension)) {
- filename += extension;
- }
- if (selectedPage != null) {
- bool uploaded = Upload(surface, selectedPage, filename, out var errorMessage);
- if (uploaded) {
- if (openPage) {
- try
- {
- Process.Start(selectedPage.Url);
- }
- catch
- {
- // Ignore
- }
- }
- exportInformation.ExportMade = true;
- exportInformation.Uri = selectedPage.Url;
- } else {
- exportInformation.ErrorMessage = errorMessage;
- }
- }
- ProcessExport(exportInformation, surface);
- return exportInformation;
- }
-
- private bool Upload(ISurface surfaceToUpload, Page page, string filename, out string errorMessage) {
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(ConfluenceConfig.UploadFormat, ConfluenceConfig.UploadJpegQuality, ConfluenceConfig.UploadReduceColors);
- errorMessage = null;
- try {
- new PleaseWaitForm().ShowAndWait(Description, Language.GetString("confluence", LangKey.communication_wait),
- delegate {
- ConfluencePlugin.ConfluenceConnector.AddAttachment(page.Id, "image/" + ConfluenceConfig.UploadFormat.ToString().ToLower(), null, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
- }
- );
- Log.Debug("Uploaded to Confluence.");
- if (!ConfluenceConfig.CopyWikiMarkupForImageToClipboard)
- {
- return true;
- }
- int retryCount = 2;
- while (retryCount >= 0) {
- try {
- Clipboard.SetText("!" + filename + "!");
- break;
- } catch (Exception ee) {
- if (retryCount == 0) {
- Log.Error(ee);
- } else {
- Thread.Sleep(100);
- }
- } finally {
- --retryCount;
- }
- }
- return true;
- } catch(Exception e) {
- errorMessage = e.Message;
- }
- return false;
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/ConfluencePlugin.cs b/GreenshotConfluencePlugin/ConfluencePlugin.cs
deleted file mode 100644
index f0014f221..000000000
--- a/GreenshotConfluencePlugin/ConfluencePlugin.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Core;
-using System;
-using System.Windows;
-using GreenshotConfluencePlugin.Forms;
-using GreenshotConfluencePlugin.Support;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotConfluencePlugin {
- ///
- /// This is the ConfluencePlugin base code
- ///
- [Plugin("Confluence", true)]
- public class ConfluencePlugin : IGreenshotPlugin {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluencePlugin));
- private static ConfluenceConnector _confluenceConnector;
- private static ConfluenceConfiguration _config;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposing) {
- //if (disposing) {}
- }
-
- private static void CreateConfluenceConnector() {
- if (_confluenceConnector == null) {
- if (_config.Url.Contains("soap-axis")) {
- _confluenceConnector = new ConfluenceConnector(_config.Url, _config.Timeout);
- } else {
- _confluenceConnector = new ConfluenceConnector(_config.Url + ConfluenceConfiguration.DEFAULT_POSTFIX2, _config.Timeout);
- }
- }
- }
-
- public static ConfluenceConnector ConfluenceConnectorNoLogin {
- get {
- return _confluenceConnector;
- }
- }
-
- public static ConfluenceConnector ConfluenceConnector {
- get {
- if (_confluenceConnector == null) {
- CreateConfluenceConnector();
- }
- try {
- if (_confluenceConnector != null && !_confluenceConnector.IsLoggedIn) {
- _confluenceConnector.Login();
- }
- } catch (Exception e) {
- MessageBox.Show(Language.GetFormattedString("confluence", LangKey.login_error, e.Message));
- }
- return _confluenceConnector;
- }
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- public bool Initialize() {
- // Register configuration (don't need the configuration itself)
- _config = IniConfig.GetIniSection();
- if(_config.IsDirty) {
- IniConfig.Save();
- }
- try {
- TranslationManager.Instance.TranslationProvider = new LanguageXMLTranslationProvider();
- //resources = new ComponentResourceManager(typeof(ConfluencePlugin));
- } catch (Exception ex) {
- LOG.ErrorFormat("Problem in ConfluencePlugin.Initialize: {0}", ex.Message);
- return false;
- }
- if (ConfluenceDestination.IsInitialized)
- {
- SimpleServiceProvider.Current.AddService(new ConfluenceDestination());
- }
- return true;
- }
-
- public void Shutdown() {
- LOG.Debug("Confluence Plugin shutdown.");
- if (_confluenceConnector != null) {
- _confluenceConnector.Logout();
- _confluenceConnector = null;
- }
- }
-
- ///
- /// Implementation of the IPlugin.Configure
- ///
- public void Configure() {
- ConfluenceConfiguration clonedConfig = _config.Clone();
- ConfluenceConfigurationForm configForm = new ConfluenceConfigurationForm(clonedConfig);
- string url = _config.Url;
- bool? dialogResult = configForm.ShowDialog();
- if (dialogResult.HasValue && dialogResult.Value) {
- // copy the new object to the old...
- clonedConfig.CloneTo(_config);
- IniConfig.Save();
- if (_confluenceConnector != null) {
- if (!url.Equals(_config.Url)) {
- if (_confluenceConnector.IsLoggedIn) {
- _confluenceConnector.Logout();
- }
- _confluenceConnector = null;
- }
- }
- }
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/ConfluenceUtils.cs b/GreenshotConfluencePlugin/ConfluenceUtils.cs
deleted file mode 100644
index ccb808a0f..000000000
--- a/GreenshotConfluencePlugin/ConfluenceUtils.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Windows.Automation;
-
-using GreenshotPlugin.Core;
-
-namespace GreenshotConfluencePlugin {
- ///
- /// Description of ConfluenceUtils.
- ///
- public class ConfluenceUtils {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceUtils));
-
- public static List GetCurrentPages() {
- List pages = new List();
- Regex pageIdRegex = new Regex(@"pageId=(\d+)");
- Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
- foreach(string browserurl in GetBrowserUrls()) {
- string url;
- try {
- url = Uri.UnescapeDataString(browserurl).Replace("+", " ");
- } catch {
- LOG.WarnFormat("Error processing URL: {0}", browserurl);
- continue;
- }
- MatchCollection pageIdMatch = pageIdRegex.Matches(url);
- if (pageIdMatch != null && pageIdMatch.Count > 0) {
- long pageId = long.Parse(pageIdMatch[0].Groups[1].Value);
- try {
- bool pageDouble = false;
- foreach(Page page in pages) {
- if (page.Id == pageId) {
- pageDouble = true;
- LOG.DebugFormat("Skipping double page with ID {0}", pageId);
- break;
- }
- }
- if (!pageDouble) {
- Page page = ConfluencePlugin.ConfluenceConnector.GetPage(pageId);
- LOG.DebugFormat("Adding page {0}", page.Title);
- pages.Add(page);
- }
- continue;
- } catch (Exception ex) {
- // Preventing security problems
- LOG.DebugFormat("Couldn't get page details for PageID {0}", pageId);
- LOG.Warn(ex);
- }
- }
- MatchCollection spacePageMatch = spacePageRegex.Matches(url);
- if (spacePageMatch != null && spacePageMatch.Count > 0) {
- if (spacePageMatch[0].Groups.Count >= 2) {
- string space = spacePageMatch[0].Groups[1].Value;
- string title = spacePageMatch[0].Groups[2].Value;
- if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(space)) {
- continue;
- }
- if (title.EndsWith("#")) {
- title = title.Substring(0, title.Length-1);
- }
- try {
- bool pageDouble = false;
- foreach(Page page in pages) {
- if (page.Title.Equals(title)) {
- LOG.DebugFormat("Skipping double page with title {0}", title);
- pageDouble = true;
- break;
- }
- }
- if (!pageDouble) {
- Page page = ConfluencePlugin.ConfluenceConnector.GetPage(space, title);
- LOG.DebugFormat("Adding page {0}", page.Title);
- pages.Add(page);
-
- }
- } catch (Exception ex) {
- // Preventing security problems
- LOG.DebugFormat("Couldn't get page details for space {0} / title {1}", space, title);
- LOG.Warn(ex);
- }
- }
- }
- }
- return pages;
- }
-
- private static IEnumerable GetBrowserUrls() {
- HashSet urls = new HashSet();
-
- // FireFox
- foreach (WindowDetails window in WindowDetails.GetAllWindows("MozillaWindowClass")) {
- if (window.Text.Length == 0) {
- continue;
- }
- AutomationElement currentElement = AutomationElement.FromHandle(window.Handle);
- Condition conditionCustom = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
- for (int i = 5; i > 0 && currentElement != null; i--) {
- currentElement = currentElement.FindFirst(TreeScope.Children, conditionCustom);
- }
- if (currentElement == null) {
- continue;
- }
-
- Condition conditionDocument = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
- AutomationElement docElement = currentElement.FindFirst(TreeScope.Children, conditionDocument);
- if (docElement == null) {
- continue;
- }
- foreach (AutomationPattern pattern in docElement.GetSupportedPatterns()) {
- if (pattern.ProgrammaticName != "ValuePatternIdentifiers.Pattern") {
- continue;
- }
- string url = (docElement.GetCurrentPattern(pattern) as ValuePattern).Current.Value;
- if (!string.IsNullOrEmpty(url)) {
- urls.Add(url);
- break;
- }
- }
- }
-
- foreach(string url in IEHelper.GetIEUrls().Distinct()) {
- urls.Add(url);
- }
-
- return urls;
- }
-
- }
-}
diff --git a/GreenshotConfluencePlugin/EnumDisplayer.cs b/GreenshotConfluencePlugin/EnumDisplayer.cs
deleted file mode 100644
index 5358362ef..000000000
--- a/GreenshotConfluencePlugin/EnumDisplayer.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Globalization;
-using System.Reflection;
-using System.Windows.Data;
-
-using GreenshotPlugin.Core;
-
-namespace GreenshotConfluencePlugin {
- public class EnumDisplayer : IValueConverter {
- private Type _type;
- private IDictionary _displayValues;
- private IDictionary _reverseValues;
-
- public Type Type {
- get { return _type; }
- set {
- if (!value.IsEnum) {
- throw new ArgumentException("parameter is not an Enumerated type", nameof(value));
- }
- _type = value;
- }
- }
-
- public ReadOnlyCollection DisplayNames {
- get {
- var genericTypeDefinition = typeof(Dictionary<,>).GetGenericTypeDefinition();
- if (genericTypeDefinition != null)
- {
- _reverseValues = (IDictionary) Activator.CreateInstance(genericTypeDefinition.MakeGenericType(typeof(string),_type));
- }
-
- var typeDefinition = typeof(Dictionary<,>).GetGenericTypeDefinition();
- if (typeDefinition != null)
- {
- _displayValues = (IDictionary)Activator.CreateInstance(typeDefinition.MakeGenericType(_type, typeof(string)));
- }
-
- var fields = _type.GetFields(BindingFlags.Public | BindingFlags.Static);
- foreach (var field in fields) {
- DisplayKeyAttribute[] a = (DisplayKeyAttribute[])field.GetCustomAttributes(typeof(DisplayKeyAttribute), false);
-
- string displayKey = GetDisplayKeyValue(a);
- object enumValue = field.GetValue(null);
-
- string displayString;
- if (displayKey != null && Language.HasKey(displayKey)) {
- displayString = Language.GetString(displayKey);
- }
- displayString = displayKey ?? enumValue.ToString();
-
- _displayValues.Add(enumValue, displayString);
- _reverseValues.Add(displayString, enumValue);
- }
- return new List((IEnumerable)_displayValues.Values).AsReadOnly();
- }
- }
-
- private static string GetDisplayKeyValue(DisplayKeyAttribute[] a) {
- if (a == null || a.Length == 0) {
- return null;
- }
- DisplayKeyAttribute dka = a[0];
- return dka.Value;
- }
-
- object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) {
- return _displayValues[value];
- }
-
- object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
- return _reverseValues[value];
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs
deleted file mode 100644
index 4f2723c89..000000000
--- a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System.Collections.Generic;
-
-namespace GreenshotConfluencePlugin.Forms {
- ///
- /// Interaction logic for ConfluencePagePicker.xaml
- ///
- public partial class ConfluencePagePicker
- {
- private readonly ConfluenceUpload _confluenceUpload;
-
- public ConfluencePagePicker(ConfluenceUpload confluenceUpload, List pagesToPick) {
- _confluenceUpload = confluenceUpload;
- DataContext = pagesToPick;
- InitializeComponent();
- }
-
- private void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
- SelectionChanged();
- }
-
- private void SelectionChanged() {
- 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;
- } else {
- _confluenceUpload.SelectedPage = null;
- }
- }
-
- private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
- SelectionChanged();
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs
deleted file mode 100644
index 0702ddff7..000000000
--- a/GreenshotConfluencePlugin/Forms/ConfluenceSearch.xaml.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotConfluencePlugin.Forms {
- public partial class ConfluenceSearch
- {
- private static readonly ConfluenceConfiguration ConfluenceConfig = IniConfig.GetIniSection();
- private readonly ConfluenceUpload _confluenceUpload;
-
- public IEnumerable Spaces => _confluenceUpload.Spaces;
-
- public ObservableCollection Pages { get; } = new ObservableCollection();
-
- public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
- _confluenceUpload = confluenceUpload;
- DataContext = this;
- InitializeComponent();
- if (ConfluenceConfig.SearchSpaceKey == null) {
- SpaceComboBox.SelectedItem = Spaces.FirstOrDefault();
- } else {
- foreach(var space in Spaces) {
- if (space.Key.Equals(ConfluenceConfig.SearchSpaceKey)) {
- SpaceComboBox.SelectedItem = space;
- }
- }
- }
- }
-
- private void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
- SelectionChanged();
- }
-
- private void SelectionChanged() {
- if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
- _confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
- } else {
- _confluenceUpload.SelectedPage = null;
- }
- }
-
- private void Search_Click(object sender, RoutedEventArgs e) {
- DoSearch();
- }
-
- private void DoSearch() {
- string spaceKey = (string)SpaceComboBox.SelectedValue;
- ConfluenceConfig.SearchSpaceKey = spaceKey;
- Pages.Clear();
- foreach(var page in ConfluencePlugin.ConfluenceConnector.SearchPages(searchText.Text, spaceKey).OrderBy(p => p.Title)) {
- Pages.Add(page);
- }
- }
-
- private void SearchText_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
- if (e.Key == System.Windows.Input.Key.Return && Search.IsEnabled) {
- DoSearch();
- e.Handled = true;
- }
- }
-
- private void Page_Loaded(object sender, RoutedEventArgs e) {
- SelectionChanged();
- }
-
- private void SearchText_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) {
- Search.IsEnabled = !string.IsNullOrEmpty(searchText.Text);
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs
deleted file mode 100644
index 1897a8f53..000000000
--- a/GreenshotConfluencePlugin/Forms/ConfluenceTreePicker.xaml.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Linq;
-using System.Threading;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Threading;
-
-namespace GreenshotConfluencePlugin.Forms {
- ///
- /// Interaction logic for ConfluenceTreePicker.xaml
- ///
- public partial class ConfluenceTreePicker
- {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
- private readonly ConfluenceConnector _confluenceConnector;
- private readonly ConfluenceUpload _confluenceUpload;
- private bool _isInitDone;
-
- public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
- _confluenceConnector = ConfluencePlugin.ConfluenceConnector;
- _confluenceUpload = confluenceUpload;
- InitializeComponent();
- }
-
- private void PageTreeViewItem_DoubleClick(object sender, MouseButtonEventArgs eventArgs) {
- Log.Debug("spaceTreeViewItem_MouseLeftButtonDown is called!");
- TreeViewItem clickedItem = eventArgs.Source as TreeViewItem;
- if (clickedItem?.Tag is not Page page) {
- return;
- }
- if (clickedItem.HasItems)
- {
- return;
- }
- Log.Debug("Loading pages for page: " + page.Title);
- new Thread(() => {
- Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {ShowBusy.Visibility = Visibility.Visible;}));
- var pages = _confluenceConnector.GetPageChildren(page).OrderBy(p => p.Title);
- Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
- foreach(var childPage in pages) {
- Log.Debug("Adding page: " + childPage.Title);
- var pageTreeViewItem = new TreeViewItem
- {
- Header = childPage.Title,
- Tag = childPage
- };
- clickedItem.Items.Add(pageTreeViewItem);
- pageTreeViewItem.PreviewMouseDoubleClick += PageTreeViewItem_DoubleClick;
- pageTreeViewItem.PreviewMouseLeftButtonDown += PageTreeViewItem_Click;
- }
- ShowBusy.Visibility = Visibility.Collapsed;
- }));
- }) { Name = "Loading childpages for confluence page " + page.Title }.Start();
- }
-
- private void PageTreeViewItem_Click(object sender, MouseButtonEventArgs eventArgs) {
- Log.Debug("pageTreeViewItem_PreviewMouseDoubleClick is called!");
- if (eventArgs.Source is not TreeViewItem clickedItem) {
- return;
- }
- Page page = clickedItem.Tag as Page;
- _confluenceUpload.SelectedPage = page;
- if (page != null) {
- Log.Debug("Page selected: " + page.Title);
- }
- }
-
- private void Page_Loaded(object sender, RoutedEventArgs e) {
- _confluenceUpload.SelectedPage = null;
- if (_isInitDone) {
- return;
- }
- ShowBusy.Visibility = Visibility.Visible;
- new Thread(() => {
- Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
- foreach (Space space in _confluenceUpload.Spaces) {
- TreeViewItem spaceTreeViewItem = new TreeViewItem
- {
- Header = space.Name,
- Tag = space
- };
-
- // Get homepage
- try {
- Page page = _confluenceConnector.GetSpaceHomepage(space);
- TreeViewItem pageTreeViewItem = new TreeViewItem
- {
- Header = page.Title,
- Tag = page
- };
- pageTreeViewItem.PreviewMouseDoubleClick += PageTreeViewItem_DoubleClick;
- pageTreeViewItem.PreviewMouseLeftButtonDown += PageTreeViewItem_Click;
- spaceTreeViewItem.Items.Add(pageTreeViewItem);
- ConfluenceTreeView.Items.Add(spaceTreeViewItem);
- } catch (Exception ex) {
- Log.Error("Can't get homepage for space : " + space.Name + " (" + ex.Message + ")");
- }
- }
- ShowBusy.Visibility = Visibility.Collapsed;
- _isInitDone = true;
- }));
- }) { Name = "Loading spaces for confluence"}.Start();
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs
deleted file mode 100644
index 291581a2b..000000000
--- a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Windows;
-
-namespace GreenshotConfluencePlugin.Forms {
- ///
- /// Interaction logic for ConfluenceUpload.xaml
- ///
- public partial class ConfluenceUpload : Window {
- private System.Windows.Controls.Page _pickerPage;
- public System.Windows.Controls.Page PickerPage {
- get {
- if (_pickerPage == null) {
- List pages = ConfluenceUtils.GetCurrentPages();
- if (pages != null && pages.Count > 0) {
- _pickerPage = new ConfluencePagePicker(this, pages);
- }
- }
- return _pickerPage;
- }
- }
-
- private System.Windows.Controls.Page _searchPage;
- public System.Windows.Controls.Page SearchPage {
- get { return _searchPage ??= new ConfluenceSearch(this); }
- }
-
- private System.Windows.Controls.Page _browsePage;
- public System.Windows.Controls.Page BrowsePage {
- get { return _browsePage ??= new ConfluenceTreePicker(this); }
- }
-
- private Page _selectedPage;
- public Page SelectedPage {
- get => _selectedPage;
- set {
- _selectedPage = value;
- Upload.IsEnabled = _selectedPage != null;
- IsOpenPageSelected = false;
- }
- }
-
- public bool IsOpenPageSelected {
- get;
- set;
- }
- public string Filename {
- get;
- set;
- }
-
- private static DateTime _lastLoad = DateTime.Now;
- private static IList _spaces;
- public IList Spaces {
- get {
- UpdateSpaces();
- while (_spaces == null) {
- Thread.Sleep(300);
- }
- return _spaces;
- }
- }
-
- public ConfluenceUpload(string filename) {
- Filename = filename;
- InitializeComponent();
- DataContext = this;
- UpdateSpaces();
- if (PickerPage == null) {
- PickerTab.Visibility = Visibility.Collapsed;
- SearchTab.IsSelected = true;
- }
- }
-
- private void UpdateSpaces() {
- if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) {
- // Reset
- _spaces = null;
- }
- // Check if load is needed
- if (_spaces == null) {
- (new Thread(() => {
- _spaces = ConfluencePlugin.ConfluenceConnector.GetSpaceSummaries().OrderBy(s => s.Name).ToList();
- _lastLoad = DateTime.Now;
- }) { Name = "Loading spaces for confluence"}).Start();
- }
- }
-
- private void Upload_Click(object sender, RoutedEventArgs e) {
- DialogResult = true;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs b/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs
deleted file mode 100644
index 23dbc4fc1..000000000
--- a/GreenshotConfluencePlugin/Support/LanguageXMLTranslationProvider.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using GreenshotPlugin.Core;
-
-namespace GreenshotConfluencePlugin.Support {
- ///
- ///
- ///
- public class LanguageXMLTranslationProvider : ITranslationProvider {
- ///
- /// See
- ///
- public object Translate(string key) {
- if (Language.HasKey("confluence", key)) {
- return Language.GetString("confluence", key);
- }
- return key;
- }
- }
-}
diff --git a/GreenshotConfluencePlugin/Support/TranslationData.cs b/GreenshotConfluencePlugin/Support/TranslationData.cs
deleted file mode 100644
index 0b6371505..000000000
--- a/GreenshotConfluencePlugin/Support/TranslationData.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Windows;
-
-namespace GreenshotConfluencePlugin.Support {
- public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
- private readonly string _key;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The key.
- public TranslationData( string key) {
- _key = key;
- LanguageChangedEventManager.AddListener(TranslationManager.Instance, this);
- }
-
- ///
- /// Releases unmanaged resources and performs other cleanup operations before the
- /// is reclaimed by garbage collection.
- ///
- ~TranslationData() {
- LanguageChangedEventManager.RemoveListener(TranslationManager.Instance, this);
- }
-
- public object Value => TranslationManager.Instance.Translate(_key);
-
- public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
- {
- if (managerType == typeof(LanguageChangedEventManager))
- {
- OnLanguageChanged(sender, e);
- return true;
- }
- return false;
- }
-
- private void OnLanguageChanged(object sender, EventArgs e)
- {
- PropertyChanged?.Invoke( this, new PropertyChangedEventArgs("Value"));
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
- }
-}
diff --git a/GreenshotConfluencePlugin/Support/TranslationManager.cs b/GreenshotConfluencePlugin/Support/TranslationManager.cs
deleted file mode 100644
index 472f2e27d..000000000
--- a/GreenshotConfluencePlugin/Support/TranslationManager.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-
-namespace GreenshotConfluencePlugin.Support {
- public class TranslationManager {
- private static TranslationManager _translationManager;
-
- public event EventHandler LanguageChanged;
-
- /*public CultureInfo CurrentLanguage {
- get { return Thread.CurrentThread.CurrentUICulture; }
- set {
- if( value != Thread.CurrentThread.CurrentUICulture) {
- Thread.CurrentThread.CurrentUICulture = value;
- OnLanguageChanged();
- }
- }
- }
-
- public IEnumerable Languages {
- get {
- if( TranslationProvider != null) {
- return TranslationProvider.Languages;
- }
- return Enumerable.Empty();
- }
- }*/
-
- public static TranslationManager Instance => _translationManager ??= new TranslationManager();
-
- public ITranslationProvider TranslationProvider { get; set; }
-
- public object Translate(string key) {
- object translatedValue = TranslationProvider?.Translate(key);
- if( translatedValue != null) {
- return translatedValue;
- }
- return $"!{key}!";
- }
- }
-}
diff --git a/GreenshotDropboxPlugin/DropboxDestination.cs b/GreenshotDropboxPlugin/DropboxDestination.cs
deleted file mode 100644
index 9762652c4..000000000
--- a/GreenshotDropboxPlugin/DropboxDestination.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.ComponentModel;
-using System.Drawing;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-
-namespace GreenshotDropboxPlugin {
- internal class DropboxDestination : AbstractDestination {
- private static readonly DropboxPluginConfiguration DropboxConfig = IniConfig.GetIniSection();
-
- private readonly DropboxPlugin _plugin;
- public DropboxDestination(DropboxPlugin plugin) {
- _plugin = plugin;
- }
-
- public override string Designation => "Dropbox";
-
- public override string Description => Language.GetString("dropbox", LangKey.upload_menu_item);
-
- public override Image DisplayIcon {
- get {
- ComponentResourceManager resources = new ComponentResourceManager(typeof(DropboxPlugin));
- return (Image)resources.GetObject("Dropbox");
- }
- }
-
- public override ExportInformation ExportCapture(bool manually, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(Designation, Description);
- bool uploaded = _plugin.Upload(captureDetails, surface, out var uploadUrl);
- if (uploaded) {
- exportInformation.Uri = uploadUrl;
- exportInformation.ExportMade = true;
- if (DropboxConfig.AfterUploadLinkToClipBoard) {
- ClipboardHelper.SetClipboardData(uploadUrl);
- }
- }
- ProcessExport(exportInformation, surface);
- return exportInformation;
- }
- }
-}
diff --git a/GreenshotDropboxPlugin/DropboxPlugin.cs b/GreenshotDropboxPlugin/DropboxPlugin.cs
deleted file mode 100644
index 2977c2d36..000000000
--- a/GreenshotDropboxPlugin/DropboxPlugin.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.Windows.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotDropboxPlugin {
- ///
- /// This is the Dropbox base code
- ///
- [Plugin("Dropbox", true)]
- public class DropboxPlugin : IGreenshotPlugin {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(DropboxPlugin));
- private static DropboxPluginConfiguration _config;
- private ComponentResourceManager _resources;
- private ToolStripMenuItem _itemPlugInConfig;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (!disposing) return;
- if (_itemPlugInConfig == null) return;
- _itemPlugInConfig.Dispose();
- _itemPlugInConfig = null;
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- public bool Initialize() {
-
- // Register configuration (don't need the configuration itself)
- _config = IniConfig.GetIniSection();
- _resources = new ComponentResourceManager(typeof(DropboxPlugin));
- SimpleServiceProvider.Current.AddService(new DropboxDestination(this));
- _itemPlugInConfig = new ToolStripMenuItem
- {
- Text = Language.GetString("dropbox", LangKey.Configure),
- Image = (Image)_resources.GetObject("Dropbox")
- };
- _itemPlugInConfig.Click += ConfigMenuClick;
-
- PluginUtils.AddToContextMenu(_itemPlugInConfig);
- Language.LanguageChanged += OnLanguageChanged;
- return true;
- }
-
- public void OnLanguageChanged(object sender, EventArgs e) {
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
- }
- }
-
- public void Shutdown() {
- Log.Debug("Dropbox Plugin shutdown.");
- }
-
- ///
- /// Implementation of the IPlugin.Configure
- ///
- public void Configure() {
- _config.ShowConfigDialog();
- }
-
- public void ConfigMenuClick(object sender, EventArgs eventArgs) {
- _config.ShowConfigDialog();
- }
-
- ///
- /// This will be called when the menu item in the Editor is clicked
- ///
- public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl) {
- uploadUrl = null;
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
- try
- {
- bool result = false;
- new PleaseWaitForm().ShowAndWait("Dropbox", Language.GetString("dropbox", LangKey.communication_wait),
- delegate
- {
- result = DropboxUtils.UploadToDropbox(surfaceToUpload, outputSettings, captureDetails);
- }
- );
- return result;
- } catch (Exception e) {
- Log.Error(e);
- MessageBox.Show(Language.GetString("dropbox", LangKey.upload_failure) + " " + e.Message);
- return false;
- }
- }
- }
-}
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs
deleted file mode 100644
index f8981b820..000000000
--- a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotExternalCommandPlugin {
- ///
- /// Description of FlickrConfiguration.
- ///
- [IniSection("ExternalCommand", Description="Greenshot ExternalCommand Plugin configuration")]
- public class ExternalCommandConfiguration : IniSection {
- [IniProperty("Commands", Description="The commands that are available.")]
- public List 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 { 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 { 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 { 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 { get; set; }
-
- [IniProperty("OutputToClipboard", Description = "Depends on 'RedirectStandardOutput': Place the standard output on the clipboard.", DefaultValue = "false")]
- 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 { get; set; }
-
- [IniProperty("Commandline", Description="The commandline for the output command.")]
- public Dictionary Commandline { get; set; }
-
- [IniProperty("Argument", Description="The arguments for the output command.")]
- public Dictionary Argument { get; set; }
-
- [IniProperty("RunInbackground", Description = "Should the command be started in the background.")]
- public Dictionary RunInbackground { get; set; }
-
- [IniProperty("DeletedBuildInCommands", Description = "If a build in command was deleted manually, it should not be recreated.")]
- public List DeletedBuildInCommands { get; set; }
-
- private const string MsPaint = "MS Paint";
- private static readonly string PaintPath;
- private static readonly bool HasPaint;
-
- private const string PaintDotNet = "Paint.NET";
- private static readonly string PaintDotNetPath;
- private static readonly bool HasPaintDotNet;
- static ExternalCommandConfiguration() {
- try {
- PaintPath = PluginUtils.GetExePath("pbrush.exe");
- HasPaint = !string.IsNullOrEmpty(PaintPath) && File.Exists(PaintPath);
- } catch {
- // Ignore
- }
- try
- {
- PaintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe");
- HasPaintDotNet = !string.IsNullOrEmpty(PaintDotNetPath) && File.Exists(PaintDotNetPath);
- }
- catch
- {
- // Ignore
- }
- }
-
- ///
- /// Delete the configuration for the specified command
- ///
- /// string with command
- public void Delete(string command)
- {
- if (string.IsNullOrEmpty(command))
- {
- return;
- }
- Commands.Remove(command);
- Commandline.Remove(command);
- Argument.Remove(command);
- RunInbackground.Remove(command);
- if (MsPaint.Equals(command) || PaintDotNet.Equals(command))
- {
- if (!DeletedBuildInCommands.Contains(command))
- {
- DeletedBuildInCommands.Add(command);
- }
- }
- }
-
- public override void AfterLoad()
- {
- base.AfterLoad();
-
- // Check if we need to add MsPaint
- if (HasPaint && !Commands.Contains(MsPaint) && !DeletedBuildInCommands.Contains(MsPaint))
- {
- Commands.Add(MsPaint);
- Commandline.Add(MsPaint, PaintPath);
- Argument.Add(MsPaint, "\"{0}\"");
- RunInbackground.Add(MsPaint, true);
- }
-
- // Check if we need to add Paint.NET
- if (HasPaintDotNet && !Commands.Contains(PaintDotNet) && !DeletedBuildInCommands.Contains(PaintDotNet))
- {
- Commands.Add(PaintDotNet);
- Commandline.Add(PaintDotNet, PaintDotNetPath);
- Argument.Add(PaintDotNet, "\"{0}\"");
- RunInbackground.Add(PaintDotNet, true);
- }
- }
-
- ///
- /// Supply values we can't put as defaults
- ///
- /// The property to return a default for
- /// object with the default value for the supplied property
- public override object GetDefault(string property) =>
- property switch
- {
- nameof(DeletedBuildInCommands) => (object) new List(),
- nameof(Commands) => new List(),
- nameof(Commandline) => new Dictionary(),
- nameof(Argument) => new Dictionary(),
- nameof(RunInbackground) => new Dictionary(),
- _ => null
- };
- }
-}
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs
deleted file mode 100644
index 81575c947..000000000
--- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Drawing;
-using System.Text.RegularExpressions;
-using System.Threading;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotExternalCommandPlugin {
- ///
- /// Description of OCRDestination.
- ///
- public class ExternalCommandDestination : AbstractDestination {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
- private static readonly Regex URI_REGEXP = new Regex(@"((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)");
- private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
- private readonly string _presetCommand;
-
- public ExternalCommandDestination(string commando) {
- _presetCommand = commando;
- }
-
- public override string Designation => "External " + _presetCommand.Replace(',','_');
-
- public override string Description => _presetCommand;
-
- public override IEnumerable DynamicDestinations() {
- yield break;
- }
-
- public override Image DisplayIcon => IconCache.IconForCommand(_presetCommand);
-
- public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(Designation, Description);
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
- outputSettings.PreventGreenshotFormat();
-
- if (_presetCommand != null) {
- if (!config.RunInbackground.ContainsKey(_presetCommand)) {
- config.RunInbackground.Add(_presetCommand, true);
- }
- bool runInBackground = config.RunInbackground[_presetCommand];
- string fullPath = captureDetails.Filename ?? ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
-
- string output;
- string error;
- if (runInBackground) {
- Thread commandThread = new Thread(delegate()
- {
- CallExternalCommand(exportInformation, fullPath, out output, out error);
- ProcessExport(exportInformation, surface);
- })
- {
- Name = "Running " + _presetCommand,
- IsBackground = true
- };
- commandThread.SetApartmentState(ApartmentState.STA);
- commandThread.Start();
- exportInformation.ExportMade = true;
- } else {
- CallExternalCommand(exportInformation, fullPath, out output, out error);
- ProcessExport(exportInformation, surface);
- }
- }
- return exportInformation;
- }
-
- ///
- /// Wrapper method for the background and normal call, this does all the logic:
- /// Call the external command, parse for URI, place to clipboard and set the export information
- ///
- ///
- ///
- ///
- ///
- private void CallExternalCommand(ExportInformation exportInformation, string fullPath, out string output, out string error) {
- output = null;
- error = null;
- try {
- if (CallExternalCommand(_presetCommand, fullPath, out output, out error) == 0) {
- exportInformation.ExportMade = true;
- if (!string.IsNullOrEmpty(output)) {
- MatchCollection uriMatches = URI_REGEXP.Matches(output);
- // Place output on the clipboard before the URI, so if one is found this overwrites
- if (config.OutputToClipboard) {
- ClipboardHelper.SetClipboardData(output);
- }
- if (uriMatches.Count > 0) {
- exportInformation.Uri = uriMatches[0].Groups[1].Value;
- LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
- if (config.UriToClipboard) {
- ClipboardHelper.SetClipboardData(exportInformation.Uri);
- }
- }
- }
- } else {
- LOG.WarnFormat("Error calling external command: {0} ", output);
- exportInformation.ExportMade = false;
- exportInformation.ErrorMessage = error;
- }
- } catch (Exception ex) {
- exportInformation.ExportMade = false;
- exportInformation.ErrorMessage = ex.Message;
- LOG.WarnFormat("Error calling external command: {0} ", exportInformation.ErrorMessage);
- }
- }
-
- ///
- /// Wrapper to retry with a runas
- ///
- ///
- ///
- ///
- ///
- ///
- private int CallExternalCommand(string commando, string fullPath, out string output, out string error) {
- try {
- return CallExternalCommand(commando, fullPath, null, out output, out error);
- } catch (Win32Exception w32Ex) {
- try {
- return CallExternalCommand(commando, fullPath, "runas", out output, out error);
- } catch {
- w32Ex.Data.Add("commandline", config.Commandline[_presetCommand]);
- w32Ex.Data.Add("arguments", config.Argument[_presetCommand]);
- throw;
- }
- } catch (Exception ex) {
- ex.Data.Add("commandline", config.Commandline[_presetCommand]);
- ex.Data.Add("arguments", config.Argument[_presetCommand]);
- throw;
- }
- }
-
- ///
- /// The actual executing code for the external command
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private int CallExternalCommand(string commando, string fullPath, string verb, out string output, out string error) {
- string commandline = config.Commandline[commando];
- string arguments = config.Argument[commando];
- output = null;
- error = null;
- if (!string.IsNullOrEmpty(commandline))
- {
- using Process process = new Process();
- // Fix variables
- commandline = FilenameHelper.FillVariables(commandline, true);
- commandline = FilenameHelper.FillCmdVariables(commandline, true);
-
- arguments = FilenameHelper.FillVariables(arguments, false);
- arguments = FilenameHelper.FillCmdVariables(arguments, false);
-
- process.StartInfo.FileName = FilenameHelper.FillCmdVariables(commandline, true);
- process.StartInfo.Arguments = FormatArguments(arguments, fullPath);
- process.StartInfo.UseShellExecute = false;
- if (config.RedirectStandardOutput) {
- process.StartInfo.RedirectStandardOutput = true;
- }
- if (config.RedirectStandardError) {
- process.StartInfo.RedirectStandardError = true;
- }
- if (verb != null) {
- process.StartInfo.Verb = verb;
- }
- LOG.InfoFormat("Starting : {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
- process.Start();
- process.WaitForExit();
- if (config.RedirectStandardOutput) {
- output = process.StandardOutput.ReadToEnd();
- if (config.ShowStandardOutputInLog && output.Trim().Length > 0) {
- LOG.InfoFormat("Output:\n{0}", output);
- }
- }
- if (config.RedirectStandardError) {
- error = process.StandardError.ReadToEnd();
- if (error.Trim().Length > 0) {
- LOG.WarnFormat("Error:\n{0}", error);
- }
- }
- LOG.InfoFormat("Finished : {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
- return process.ExitCode;
- }
- return -1;
- }
-
- public static string FormatArguments(string arguments, string fullpath)
- {
- return string.Format(arguments, fullpath);
- }
- }
-}
diff --git a/GreenshotExternalCommandPlugin/GreenshotExternalCommandPlugin.csproj b/GreenshotExternalCommandPlugin/GreenshotExternalCommandPlugin.csproj
deleted file mode 100644
index 761d1278f..000000000
--- a/GreenshotExternalCommandPlugin/GreenshotExternalCommandPlugin.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- GreenshotExternalCommandPlugin
- GreenshotExternalCommandPlugin
-
-
-
-
- PreserveNewest
-
-
-
-
-
-
-
diff --git a/GreenshotExternalCommandPlugin/IconCache.cs b/GreenshotExternalCommandPlugin/IconCache.cs
deleted file mode 100644
index bf9094c7e..000000000
--- a/GreenshotExternalCommandPlugin/IconCache.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Drawing;
-using System.IO;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotExternalCommandPlugin {
- public static class IconCache {
- private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection();
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
-
- public static Image IconForCommand(string commandName) {
- Image icon = null;
- if (commandName != null) {
- if (config.Commandline.ContainsKey(commandName) && File.Exists(config.Commandline[commandName])) {
- try {
- icon = PluginUtils.GetCachedExeIcon(config.Commandline[commandName], 0);
- } catch (Exception ex) {
- LOG.Warn("Problem loading icon for " + config.Commandline[commandName], ex);
- }
- }
- }
- return icon;
- }
- }
-}
diff --git a/GreenshotExternalCommandPlugin/SettingsForm.cs b/GreenshotExternalCommandPlugin/SettingsForm.cs
deleted file mode 100644
index 01eea89bf..000000000
--- a/GreenshotExternalCommandPlugin/SettingsForm.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotExternalCommandPlugin {
- ///
- /// Description of SettingsForm.
- ///
- public partial class SettingsForm : ExternalCommandForm {
- private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection();
-
- public SettingsForm() {
- //
- // The InitializeComponent() call is required for Windows Forms designer support.
- //
- InitializeComponent();
- AcceptButton = buttonOk;
- CancelButton = buttonCancel;
- UpdateView();
- }
-
- private void ButtonOkClick(object sender, EventArgs e) {
- IniConfig.Save();
- }
-
- private void ButtonAddClick(object sender, EventArgs e) {
- var form = new SettingsFormDetail(null);
- form.ShowDialog();
-
- UpdateView();
- }
-
- private void ButtonDeleteClick(object sender, EventArgs e) {
- foreach(ListViewItem item in listView1.SelectedItems) {
- string commando = item.Tag as string;
-
- ExternalCommandConfig.Delete(commando);
- }
- UpdateView();
- }
-
- private void UpdateView() {
- listView1.Items.Clear();
- if(ExternalCommandConfig.Commands != null) {
- listView1.ListViewItemSorter = new ListviewComparer();
- ImageList imageList = new ImageList();
- listView1.SmallImageList = imageList;
- int imageNr = 0;
- foreach(string commando in ExternalCommandConfig.Commands) {
- ListViewItem item;
- Image iconForExe = IconCache.IconForCommand(commando);
- if(iconForExe != null) {
- imageList.Images.Add(iconForExe);
- item = new ListViewItem(commando, imageNr++);
- } else {
- item = new ListViewItem(commando);
- }
- item.Tag = commando;
- listView1.Items.Add(item);
- }
- }
- // Fix for bug #1484, getting an ArgumentOutOfRangeException as there is nothing selected but the edit button was still active.
- button_edit.Enabled = listView1.SelectedItems.Count > 0;
- }
-
- private void ListView1ItemSelectionChanged(object sender, EventArgs e) {
- button_edit.Enabled = listView1.SelectedItems.Count > 0;
- }
-
- private void ButtonEditClick(object sender, EventArgs e) {
- ListView1DoubleClick(sender, e);
- }
-
- private void ListView1DoubleClick(object sender, EventArgs e) {
- // Safety check for bug #1484
- bool selectionActive = listView1.SelectedItems.Count > 0;
- if(!selectionActive) {
- button_edit.Enabled = false;
- return;
- }
- string commando = listView1.SelectedItems[0].Tag as string;
-
- var form = new SettingsFormDetail(commando);
- form.ShowDialog();
-
- UpdateView();
- }
- }
-
- public class ListviewComparer : System.Collections.IComparer {
- public int Compare(object x, object y) {
- if(!(x is ListViewItem)) {
- return (0);
- }
- if(!(y is ListViewItem)) {
- return (0);
- }
-
- var l1 = (ListViewItem)x;
- var l2 = (ListViewItem)y;
- return string.Compare(l1.Text, l2.Text, StringComparison.Ordinal);
- }
- }
-}
diff --git a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs b/GreenshotExternalCommandPlugin/SettingsFormDetail.cs
deleted file mode 100644
index 8affd6976..000000000
--- a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotExternalCommandPlugin {
- ///
- /// Description of SettingsFormDetail.
- ///
- public partial class SettingsFormDetail : ExternalCommandForm {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(SettingsFormDetail));
- private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection();
-
- private readonly string _commando;
- private readonly int _commandIndex;
-
- public SettingsFormDetail(string commando) {
- InitializeComponent();
- AcceptButton = buttonOk;
- CancelButton = buttonCancel;
- _commando = commando;
-
- if(commando != null) {
- textBox_name.Text = commando;
- textBox_commandline.Text = ExternalCommandConfig.Commandline[commando];
- textBox_arguments.Text = ExternalCommandConfig.Argument[commando];
- _commandIndex = ExternalCommandConfig.Commands.FindIndex(s => s == commando);
- } else {
- textBox_arguments.Text = "\"{0}\"";
- }
- OkButtonState();
- }
-
- private void ButtonOkClick(object sender, EventArgs e) {
- string commandName = textBox_name.Text;
- string commandLine = textBox_commandline.Text;
- string arguments = textBox_arguments.Text;
- if(_commando != null) {
- ExternalCommandConfig.Commands[_commandIndex] = commandName;
- ExternalCommandConfig.Commandline.Remove(_commando);
- ExternalCommandConfig.Commandline.Add(commandName, commandLine);
- ExternalCommandConfig.Argument.Remove(_commando);
- ExternalCommandConfig.Argument.Add(commandName, arguments);
- } else {
- ExternalCommandConfig.Commands.Add(commandName);
- ExternalCommandConfig.Commandline.Add(commandName, commandLine);
- ExternalCommandConfig.Argument.Add(commandName, arguments);
- }
- }
-
- private void Button3Click(object sender, EventArgs e) {
- var openFileDialog = new OpenFileDialog
- {
- Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*",
- FilterIndex = 1,
- CheckFileExists = true,
- Multiselect = false
- };
- string initialPath = null;
- try
- {
- initialPath = Path.GetDirectoryName(textBox_commandline.Text);
- }
- catch (Exception ex)
- {
- Log.WarnFormat("Can't get the initial path via {0}", textBox_commandline.Text);
- Log.Warn("Exception: ", ex);
- }
- if(initialPath != null && Directory.Exists(initialPath)) {
- openFileDialog.InitialDirectory = initialPath;
- } else {
- initialPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
- openFileDialog.InitialDirectory = initialPath;
- }
- Log.DebugFormat("Starting OpenFileDialog at {0}", initialPath);
- if(openFileDialog.ShowDialog() == DialogResult.OK) {
- textBox_commandline.Text = openFileDialog.FileName;
- }
- }
-
- private void OkButtonState() {
- // Assume OK
- buttonOk.Enabled = true;
- textBox_name.BackColor = Color.White;
- textBox_commandline.BackColor = Color.White;
- textBox_arguments.BackColor = Color.White;
- // Is there a text in the name field
- if(string.IsNullOrEmpty(textBox_name.Text)) {
- buttonOk.Enabled = false;
- }
- // Check if commandname is unique
- if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && ExternalCommandConfig.Commands.Contains(textBox_name.Text)) {
- buttonOk.Enabled = false;
- textBox_name.BackColor = Color.Red;
- }
- // Is there a text in the commandline field
- if(string.IsNullOrEmpty(textBox_commandline.Text)) {
- buttonOk.Enabled = false;
- }
-
- if (!string.IsNullOrEmpty(textBox_commandline.Text))
- {
- // Added this to be more flexible, using the Greenshot var format
- string cmdPath = FilenameHelper.FillVariables(textBox_commandline.Text, true);
- // And also replace the "DOS" Variables
- cmdPath = FilenameHelper.FillCmdVariables(cmdPath, true);
- // Is the command available?
- if (!File.Exists(cmdPath))
- {
- buttonOk.Enabled = false;
- textBox_commandline.BackColor = Color.Red;
- }
- }
- // Are the arguments in a valid format?
- try
- {
- string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false);
- arguments = FilenameHelper.FillCmdVariables(arguments, false);
-
- ExternalCommandDestination.FormatArguments(arguments, string.Empty);
- }
- catch
- {
- buttonOk.Enabled = false;
- textBox_arguments.BackColor = Color.Red;
- }
- }
-
- private void textBox_name_TextChanged(object sender, EventArgs e) {
- OkButtonState();
- }
-
- private void textBox_commandline_TextChanged(object sender, EventArgs e) {
- OkButtonState();
- }
-
- private void textBox_arguments_TextChanged(object sender, EventArgs e)
- {
- OkButtonState();
- }
-
- }
-}
diff --git a/GreenshotFlickrPlugin/FlickrConfiguration.cs b/GreenshotFlickrPlugin/FlickrConfiguration.cs
deleted file mode 100644
index 06f65c9fd..000000000
--- a/GreenshotFlickrPlugin/FlickrConfiguration.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.Windows.Forms;
-using GreenshotFlickrPlugin.Forms;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotFlickrPlugin {
- public enum SafetyLevel {
- Safe = 1,
- Moderate = 2,
- Restricted = 3
- }
- ///
- /// Description of FlickrConfiguration.
- ///
- [IniSection("Flickr", Description = "Greenshot Flickr Plugin configuration")]
- public class FlickrConfiguration : IniSection {
- [IniProperty("flickrIsPublic", Description = "IsPublic.", DefaultValue = "true")]
- public bool IsPublic { get; set; }
-
- [IniProperty("flickrIsFamily", Description = "IsFamily.", DefaultValue = "true")]
- public bool IsFamily { get; set; }
-
- [IniProperty("flickrIsFriend", Description = "IsFriend.", DefaultValue = "true")]
- public bool IsFriend { get; set; }
-
- [IniProperty("SafetyLevel", Description = "Safety level", DefaultValue = "Safe")]
- public SafetyLevel SafetyLevel { get; set; }
-
- [IniProperty("HiddenFromSearch", Description = "Hidden from search", DefaultValue = "false")]
- public bool HiddenFromSearch { get; set; }
-
- [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
- public OutputFormat UploadFormat { get; set; }
-
- [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
- public int UploadJpegQuality { get; set; }
-
- [IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send flickr link to clipboard.", DefaultValue = "true")]
- public bool AfterUploadLinkToClipBoard { get; set; }
-
- [IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
- public bool UsePageLink { get; set; }
-
- [IniProperty("FlickrToken", Description = "The Flickr token", Encrypted = true, ExcludeIfNull = true)]
- public string FlickrToken { get; set; }
- [IniProperty("FlickrTokenSecret", Description = "The Flickr token secret", Encrypted = true, ExcludeIfNull = true)]
- public string FlickrTokenSecret { get; set; }
-
- ///
- /// A form for token
- ///
- /// bool true if OK was pressed, false if cancel
- public bool ShowConfigDialog() {
- DialogResult result = new SettingsForm().ShowDialog();
- if (result == DialogResult.OK) {
- return true;
- }
- return false;
- }
- }
-}
diff --git a/GreenshotFlickrPlugin/FlickrDestination.cs b/GreenshotFlickrPlugin/FlickrDestination.cs
deleted file mode 100644
index ccd9392d2..000000000
--- a/GreenshotFlickrPlugin/FlickrDestination.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.ComponentModel;
-using System.Drawing;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Interfaces;
-
-namespace GreenshotFlickrPlugin {
- public class FlickrDestination : AbstractDestination {
- private readonly FlickrPlugin _plugin;
- public FlickrDestination(FlickrPlugin plugin) {
- _plugin = plugin;
- }
-
- public override string Designation => "Flickr";
-
- public override string Description => Language.GetString("flickr", LangKey.upload_menu_item);
-
- public override Image DisplayIcon {
- get {
- ComponentResourceManager resources = new ComponentResourceManager(typeof(FlickrPlugin));
- return (Image)resources.GetObject("flickr");
- }
- }
-
- public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(Designation, Description);
- bool uploaded = _plugin.Upload(captureDetails, surface, out var uploadUrl);
- if (uploaded) {
- exportInformation.ExportMade = true;
- exportInformation.Uri = uploadUrl;
- }
- ProcessExport(exportInformation, surface);
- return exportInformation;
- }
- }
-}
diff --git a/GreenshotFlickrPlugin/FlickrPlugin.cs b/GreenshotFlickrPlugin/FlickrPlugin.cs
deleted file mode 100644
index abf663625..000000000
--- a/GreenshotFlickrPlugin/FlickrPlugin.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-using log4net;
-
-namespace GreenshotFlickrPlugin
-{
- ///
- /// This is the Flickr base code
- ///
- [Plugin("Flickr", true)]
- public class FlickrPlugin : IGreenshotPlugin {
- private static readonly ILog Log = LogManager.GetLogger(typeof(FlickrPlugin));
- private static FlickrConfiguration _config;
- private ComponentResourceManager _resources;
- private ToolStripMenuItem _itemPlugInConfig;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposing) {
- if (!disposing) {
- return;
- }
- if (_itemPlugInConfig == null) {
- return;
- }
- _itemPlugInConfig.Dispose();
- _itemPlugInConfig = null;
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- public bool Initialize() {
- // Register configuration (don't need the configuration itself)
- _config = IniConfig.GetIniSection();
- _resources = new ComponentResourceManager(typeof(FlickrPlugin));
-
- _itemPlugInConfig = new ToolStripMenuItem
- {
- Text = Language.GetString("flickr", LangKey.Configure),
- Image = (Image) _resources.GetObject("flickr")
- };
- _itemPlugInConfig.Click += ConfigMenuClick;
- SimpleServiceProvider.Current.AddService(new FlickrDestination(this));
- PluginUtils.AddToContextMenu(_itemPlugInConfig);
- Language.LanguageChanged += OnLanguageChanged;
- return true;
- }
-
- public void OnLanguageChanged(object sender, EventArgs e) {
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure);
- }
- }
-
- public void Shutdown() {
- Log.Debug("Flickr Plugin shutdown.");
- }
-
- ///
- /// Implementation of the IPlugin.Configure
- ///
- public void Configure() {
- _config.ShowConfigDialog();
- }
-
- public void ConfigMenuClick(object sender, EventArgs eventArgs) {
- _config.ShowConfigDialog();
- }
-
- public bool Upload(ICaptureDetails captureDetails, ISurface surface, out string uploadUrl) {
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
- uploadUrl = null;
- try {
- string flickrUrl = null;
- new PleaseWaitForm().ShowAndWait("Flickr", Language.GetString("flickr", LangKey.communication_wait),
- delegate {
- string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
- flickrUrl = FlickrUtils.UploadToFlickr(surface, outputSettings, captureDetails.Title, filename);
- }
- );
-
- if (flickrUrl == null) {
- return false;
- }
- uploadUrl = flickrUrl;
-
- if (_config.AfterUploadLinkToClipBoard) {
- ClipboardHelper.SetClipboardData(flickrUrl);
- }
- return true;
- } catch (Exception e) {
- Log.Error("Error uploading.", e);
- MessageBox.Show(Language.GetString("flickr", LangKey.upload_failure) + " " + e.Message);
- }
- return false;
- }
- }
-}
diff --git a/GreenshotFlickrPlugin/FlickrUtils.cs b/GreenshotFlickrPlugin/FlickrUtils.cs
deleted file mode 100644
index 9337c51f6..000000000
--- a/GreenshotFlickrPlugin/FlickrUtils.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Xml;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Core.OAuth;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-using log4net;
-
-namespace GreenshotFlickrPlugin {
- ///
- /// Description of FlickrUtils.
- ///
- public static class FlickrUtils {
- private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrUtils));
- private static readonly FlickrConfiguration config = IniConfig.GetIniSection();
- private const string FLICKR_API_BASE_URL = "https://api.flickr.com/services/";
- private const string FLICKR_UPLOAD_URL = FLICKR_API_BASE_URL + "upload/";
- // OAUTH
- private const string FLICKR_OAUTH_BASE_URL = FLICKR_API_BASE_URL + "oauth/";
- private const string FLICKR_ACCESS_TOKEN_URL = FLICKR_OAUTH_BASE_URL + "access_token";
- private const string FLICKR_AUTHORIZE_URL = FLICKR_OAUTH_BASE_URL + "authorize";
- private const string FLICKR_REQUEST_TOKEN_URL = FLICKR_OAUTH_BASE_URL + "request_token";
- private const string FLICKR_FARM_URL = "https://farm{0}.staticflickr.com/{1}/{2}_{3}_o.{4}";
- // REST
- private const string FLICKR_REST_URL = FLICKR_API_BASE_URL + "rest/";
- private const string FLICKR_GET_INFO_URL = FLICKR_REST_URL + "?method=flickr.photos.getInfo";
-
- ///
- /// Do the actual upload to Flickr
- /// For more details on the available parameters, see: http://flickrnet.codeplex.com
- ///
- ///
- ///
- ///
- ///
- /// url to image
- public static string UploadToFlickr(ISurface surfaceToUpload, SurfaceOutputSettings outputSettings, string title, string filename) {
- var oAuth = new OAuthSession(FlickrCredentials.ConsumerKey, FlickrCredentials.ConsumerSecret)
- {
- BrowserSize = new Size(520, 800),
- CheckVerifier = false,
- AccessTokenUrl = FLICKR_ACCESS_TOKEN_URL,
- AuthorizeUrl = FLICKR_AUTHORIZE_URL,
- RequestTokenUrl = FLICKR_REQUEST_TOKEN_URL,
- LoginTitle = "Flickr authorization",
- Token = config.FlickrToken,
- TokenSecret = config.FlickrTokenSecret
- };
- if (string.IsNullOrEmpty(oAuth.Token)) {
- if (!oAuth.Authorize()) {
- return null;
- }
- if (!string.IsNullOrEmpty(oAuth.Token)) {
- config.FlickrToken = oAuth.Token;
- }
- if (!string.IsNullOrEmpty(oAuth.TokenSecret)) {
- config.FlickrTokenSecret = oAuth.TokenSecret;
- }
- IniConfig.Save();
- }
- try {
- IDictionary signedParameters = new Dictionary
- {
- { "content_type", "2" }, // Screenshot
- { "tags", "Greenshot" },
- { "is_public", config.IsPublic ? "1" : "0" },
- { "is_friend", config.IsFriend ? "1" : "0" },
- { "is_family", config.IsFamily ? "1" : "0" },
- { "safety_level", $"{(int)config.SafetyLevel}" },
- { "hidden", config.HiddenFromSearch ? "1" : "2" }
- };
- IDictionary otherParameters = new Dictionary
- {
- { "photo", new SurfaceContainer(surfaceToUpload, outputSettings, filename) }
- };
- string response = oAuth.MakeOAuthRequest(HTTPMethod.POST, FLICKR_UPLOAD_URL, signedParameters, otherParameters, null);
- string photoId = GetPhotoId(response);
-
- // Get Photo Info
- signedParameters = new Dictionary { { "photo_id", photoId } };
- string photoInfo = oAuth.MakeOAuthRequest(HTTPMethod.POST, FLICKR_GET_INFO_URL, signedParameters, null, null);
- return GetUrl(photoInfo);
- } catch (Exception ex) {
- LOG.Error("Upload error: ", ex);
- throw;
- } finally {
- if (!string.IsNullOrEmpty(oAuth.Token)) {
- config.FlickrToken = oAuth.Token;
- }
- if (!string.IsNullOrEmpty(oAuth.TokenSecret)) {
- config.FlickrTokenSecret = oAuth.TokenSecret;
- }
- }
- }
-
- private static string GetUrl(string response) {
- try {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(response);
- if (config.UsePageLink) {
- XmlNodeList nodes = doc.GetElementsByTagName("url");
- if (nodes.Count > 0) {
- var xmlNode = nodes.Item(0);
- if (xmlNode != null) {
- return xmlNode.InnerText;
- }
- }
- } else {
- XmlNodeList nodes = doc.GetElementsByTagName("photo");
- if (nodes.Count > 0) {
- var item = nodes.Item(0);
- if (item?.Attributes != null) {
- string farmId = item.Attributes["farm"].Value;
- string serverId = item.Attributes["server"].Value;
- string photoId = item.Attributes["id"].Value;
- string originalsecret = item.Attributes["originalsecret"].Value;
- string originalFormat = item.Attributes["originalformat"].Value;
- return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, originalsecret, originalFormat);
- }
- }
- }
- } catch (Exception ex) {
- LOG.Error("Error parsing Flickr Response.", ex);
- }
- return null;
- }
-
- private static string GetPhotoId(string response) {
- try {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(response);
- XmlNodeList nodes = doc.GetElementsByTagName("photoid");
- if (nodes.Count > 0) {
- var xmlNode = nodes.Item(0);
- if (xmlNode != null) {
- return xmlNode.InnerText;
- }
- }
- } catch (Exception ex) {
- LOG.Error("Error parsing Flickr Response.", ex);
- }
- return null;
- }
- }
-}
diff --git a/GreenshotGooglePhotosPlugin/GooglePhotosConfiguration.cs b/GreenshotGooglePhotosPlugin/GooglePhotosConfiguration.cs
deleted file mode 100644
index 7e1b614b2..000000000
--- a/GreenshotGooglePhotosPlugin/GooglePhotosConfiguration.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * A GooglePhotos Plugin for Greenshot
- * Copyright (C) 2011 Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.Windows.Forms;
-using GreenshotPlugin.Core;
-using System;
-using GreenshotGooglePhotosPlugin.Forms;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotGooglePhotosPlugin {
- ///
- /// Description of GooglePhotosConfiguration.
- ///
- [IniSection("GooglePhotos", Description = "Greenshot GooglePhotos Plugin configuration")]
- public class GooglePhotosConfiguration : IniSection {
- [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
- public OutputFormat UploadFormat { get; set; }
-
- [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
- public int UploadJpegQuality { get; set; }
-
- [IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send GooglePhotos link to clipboard.", DefaultValue = "true")]
- public bool AfterUploadLinkToClipBoard { get; set; }
- [IniProperty("AddFilename", Description = "Is the filename passed on to GooglePhotos", DefaultValue = "False")]
- public bool AddFilename {
- get;
- set;
- }
-
- [IniProperty("UploadUser", Description = "The GooglePhotos user to upload to", DefaultValue = "default")]
- public string UploadUser {
- get;
- set;
- }
-
- [IniProperty("UploadAlbum", Description = "The GooglePhotos album to upload to", DefaultValue = "default")]
- public string UploadAlbum {
- get;
- set;
- }
-
- [IniProperty("RefreshToken", Description = "GooglePhotos authorization refresh Token", Encrypted = true)]
- public string RefreshToken {
- get;
- set;
- }
-
- ///
- /// Not stored
- ///
- public string AccessToken {
- get;
- set;
- }
-
- ///
- /// Not stored
- ///
- public DateTimeOffset AccessTokenExpires {
- get;
- set;
- }
-
- ///
- /// A form for token
- ///
- /// bool true if OK was pressed, false if cancel
- public bool ShowConfigDialog() {
- DialogResult result = new SettingsForm().ShowDialog();
- if (result == DialogResult.OK) {
- return true;
- }
- return false;
- }
-
- }
-}
diff --git a/GreenshotGooglePhotosPlugin/GooglePhotosDestination.cs b/GreenshotGooglePhotosPlugin/GooglePhotosDestination.cs
deleted file mode 100644
index 586a6e842..000000000
--- a/GreenshotGooglePhotosPlugin/GooglePhotosDestination.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * A GooglePhotos Plugin for Greenshot
- * Copyright (C) 2011 Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System.ComponentModel;
-using System.Drawing;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Interfaces;
-
-namespace GreenshotGooglePhotosPlugin {
- public class GooglePhotosDestination : AbstractDestination {
- private readonly GooglePhotosPlugin _plugin;
- public GooglePhotosDestination(GooglePhotosPlugin plugin) {
- _plugin = plugin;
- }
-
- public override string Designation => "GooglePhotos";
-
- public override string Description => Language.GetString("googlephotos", LangKey.upload_menu_item);
-
- public override Image DisplayIcon {
- get {
- ComponentResourceManager resources = new ComponentResourceManager(typeof(GooglePhotosPlugin));
- return (Image)resources.GetObject("GooglePhotos");
- }
- }
-
- public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
- ExportInformation exportInformation = new ExportInformation(Designation, Description);
- bool uploaded = _plugin.Upload(captureDetails, surface, out var uploadUrl);
- if (uploaded) {
- exportInformation.ExportMade = true;
- exportInformation.Uri = uploadUrl;
- }
- ProcessExport(exportInformation, surface);
- return exportInformation;
- }
- }
-}
diff --git a/GreenshotGooglePhotosPlugin/GooglePhotosPlugin.cs b/GreenshotGooglePhotosPlugin/GooglePhotosPlugin.cs
deleted file mode 100644
index b5d37f62c..000000000
--- a/GreenshotGooglePhotosPlugin/GooglePhotosPlugin.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * A GooglePhotos Plugin for Greenshot
- * Copyright (C) 2011 Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotGooglePhotosPlugin {
- ///
- /// This is the GooglePhotos base code
- ///
- [Plugin("GooglePhotos", true)]
- public class GooglePhotosPlugin : IGreenshotPlugin {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(GooglePhotosPlugin));
- private static GooglePhotosConfiguration _config;
- private ComponentResourceManager _resources;
- private ToolStripMenuItem _itemPlugInRoot;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (!disposing) return;
- if (_itemPlugInRoot == null) return;
- _itemPlugInRoot.Dispose();
- _itemPlugInRoot = null;
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- public bool Initialize() {
- SimpleServiceProvider.Current.AddService(new GooglePhotosDestination(this));
-
- // Get configuration
- _config = IniConfig.GetIniSection();
- _resources = new ComponentResourceManager(typeof(GooglePhotosPlugin));
-
- _itemPlugInRoot = new ToolStripMenuItem
- {
- Text = Language.GetString("googlephotos", LangKey.Configure),
- Image = (Image) _resources.GetObject("GooglePhotos")
- };
- _itemPlugInRoot.Click += ConfigMenuClick;
- PluginUtils.AddToContextMenu(_itemPlugInRoot);
- Language.LanguageChanged += OnLanguageChanged;
- return true;
- }
-
- public void OnLanguageChanged(object sender, EventArgs e) {
- if (_itemPlugInRoot != null) {
- _itemPlugInRoot.Text = Language.GetString("googlephotos", LangKey.Configure);
- }
- }
-
- public void Shutdown() {
- Log.Debug("GooglePhotos Plugin shutdown.");
- Language.LanguageChanged -= OnLanguageChanged;
- //host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened);
- }
-
- ///
- /// Implementation of the IPlugin.Configure
- ///
- public void Configure() {
- _config.ShowConfigDialog();
- }
-
- public void ConfigMenuClick(object sender, EventArgs eventArgs) {
- Configure();
- }
-
- public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadUrl) {
- SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality);
- try {
- string url = null;
- new PleaseWaitForm().ShowAndWait("GooglePhotos", Language.GetString("googlephotos", LangKey.communication_wait),
- delegate
- {
- string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
- url = GooglePhotosUtils.UploadToGooglePhotos(surfaceToUpload, outputSettings, captureDetails.Title, filename);
- }
- );
- uploadUrl = url;
-
- if (uploadUrl != null && _config.AfterUploadLinkToClipBoard) {
- ClipboardHelper.SetClipboardData(uploadUrl);
- }
- return true;
- } catch (Exception e) {
- Log.Error("Error uploading.", e);
- MessageBox.Show(Language.GetString("googlephotos", LangKey.upload_failure) + " " + e.Message);
- }
- uploadUrl = null;
- return false;
- }
- }
-}
diff --git a/GreenshotGooglePhotosPlugin/GooglePhotosUtils.cs b/GreenshotGooglePhotosPlugin/GooglePhotosUtils.cs
deleted file mode 100644
index 27aa13d8f..000000000
--- a/GreenshotGooglePhotosPlugin/GooglePhotosUtils.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * A GooglePhotos Plugin for Greenshot
- * Copyright (C) 2011 Francis Noel
- *
- * For more information see: http://getgreenshot.org/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Core;
-using System;
-using System.Xml;
-using GreenshotPlugin.Core.OAuth;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotGooglePhotosPlugin {
- ///
- /// Description of GooglePhotosUtils.
- ///
- public static class GooglePhotosUtils {
- private const string GooglePhotosScope = "https://picasaweb.google.com/data/";
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(GooglePhotosUtils));
- private static readonly GooglePhotosConfiguration Config = IniConfig.GetIniSection();
- private const string AuthUrl = "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={ClientId}&redirect_uri={RedirectUrl}&state={State}&scope=" + GooglePhotosScope;
- private const string TokenUrl = "https://www.googleapis.com/oauth2/v3/token";
- private const string UploadUrl = "https://picasaweb.google.com/data/feed/api/user/{0}/albumid/{1}";
-
- ///
- /// Do the actual upload to GooglePhotos
- ///
- /// Image to upload
- /// SurfaceOutputSettings
- /// string
- /// string
- /// GooglePhotosResponse
- public static string UploadToGooglePhotos(ISurface surfaceToUpload, SurfaceOutputSettings outputSettings, string title, string filename) {
- // Fill the OAuth2Settings
- var settings = new OAuth2Settings
- {
- AuthUrlPattern = AuthUrl,
- TokenUrl = TokenUrl,
- CloudServiceName = "GooglePhotos",
- ClientId = GooglePhotosCredentials.ClientId,
- ClientSecret = GooglePhotosCredentials.ClientSecret,
- AuthorizeMode = OAuth2AuthorizeMode.JsonReceiver,
- RefreshToken = Config.RefreshToken,
- AccessToken = Config.AccessToken,
- AccessTokenExpires = Config.AccessTokenExpires
- };
-
- // Copy the settings from the config, which is kept in memory and on the disk
-
- try {
- var webRequest = OAuth2Helper.CreateOAuth2WebRequest(HTTPMethod.POST, string.Format(UploadUrl, Config.UploadUser, Config.UploadAlbum), settings);
- if (Config.AddFilename) {
- webRequest.Headers.Add("Slug", NetworkHelper.EscapeDataString(filename));
- }
- SurfaceContainer container = new SurfaceContainer(surfaceToUpload, outputSettings, filename);
- container.Upload(webRequest);
-
- string response = NetworkHelper.GetResponseAsString(webRequest);
-
- return ParseResponse(response);
- } finally {
- // Copy the settings back to the config, so they are stored.
- Config.RefreshToken = settings.RefreshToken;
- Config.AccessToken = settings.AccessToken;
- Config.AccessTokenExpires = settings.AccessTokenExpires;
- Config.IsDirty = true;
- IniConfig.Save();
- }
- }
-
- ///
- /// Parse the upload URL from the response
- ///
- ///
- ///
- public static string ParseResponse(string response) {
- if (response == null) {
- return null;
- }
- try {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(response);
- XmlNodeList nodes = doc.GetElementsByTagName("link", "*");
- if(nodes.Count > 0) {
- string url = null;
- foreach(XmlNode node in nodes) {
- if (node.Attributes != null) {
- url = node.Attributes["href"].Value;
- string rel = node.Attributes["rel"].Value;
- // Pictures with rel="http://schemas.google.com/photos/2007#canonical" are the direct link
- if (rel != null && rel.EndsWith("canonical")) {
- break;
- }
- }
- }
- return url;
- }
- } catch(Exception e) {
- Log.ErrorFormat("Could not parse GooglePhotos response due to error {0}, response was: {1}", e.Message, response);
- }
- return null;
- }
- }
-}
diff --git a/GreenshotImgurPlugin/Forms/ImgurHistory.cs b/GreenshotImgurPlugin/Forms/ImgurHistory.cs
deleted file mode 100644
index 359130a90..000000000
--- a/GreenshotImgurPlugin/Forms/ImgurHistory.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Globalization;
-using System.Text;
-using System.Windows.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotImgurPlugin.Forms {
- ///
- /// Imgur history form
- ///
- public sealed partial class ImgurHistory : ImgurForm {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurHistory));
- private readonly GreenshotColumnSorter _columnSorter;
- private static readonly object Lock = new object();
- private static readonly ImgurConfiguration Config = IniConfig.GetIniSection();
- private static ImgurHistory _instance;
-
- public static void ShowHistory() {
- lock (Lock)
- {
- if (ImgurUtils.IsHistoryLoadingNeeded())
- {
- // Run upload in the background
- new PleaseWaitForm().ShowAndWait("Imgur " + Language.GetString("imgur", LangKey.history), Language.GetString("imgur", LangKey.communication_wait),
- ImgurUtils.LoadHistory
- );
- }
-
- // Make sure the history is loaded, will be done only once
- if (_instance == null)
- {
- _instance = new ImgurHistory();
- }
- if (!_instance.Visible)
- {
- _instance.Show();
- }
- _instance.Redraw();
- }
- }
-
- private ImgurHistory() {
- ManualLanguageApply = true;
- //
- // The InitializeComponent() call is required for Windows Forms designer support.
- //
- InitializeComponent();
- AcceptButton = finishedButton;
- CancelButton = finishedButton;
- // Init sorting
- _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)";
- }
- }
-
- private void Redraw() {
- // Should fix Bug #3378699
- pictureBox1.Image = pictureBox1.ErrorImage;
- listview_imgur_uploads.BeginUpdate();
- listview_imgur_uploads.Items.Clear();
- listview_imgur_uploads.Columns.Clear();
- string[] columns = { "hash", "title", "deleteHash", "Date"};
- foreach (string column in columns) {
- listview_imgur_uploads.Columns.Add(column);
- }
- foreach (ImgurInfo imgurInfo in Config.runtimeImgurHistory.Values) {
- var item = new ListViewItem(imgurInfo.Hash)
- {
- Tag = imgurInfo
- };
- item.SubItems.Add(imgurInfo.Title);
- item.SubItems.Add(imgurInfo.DeleteHash);
- item.SubItems.Add(imgurInfo.Timestamp.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo));
- listview_imgur_uploads.Items.Add(item);
- }
- for (int i = 0; i < columns.Length; i++) {
- listview_imgur_uploads.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
- }
-
- listview_imgur_uploads.EndUpdate();
- listview_imgur_uploads.Refresh();
- deleteButton.Enabled = false;
- openButton.Enabled = false;
- clipboardButton.Enabled = false;
- }
-
- private void Listview_imgur_uploadsSelectedIndexChanged(object sender, EventArgs e) {
- pictureBox1.Image = pictureBox1.ErrorImage;
- if (listview_imgur_uploads.SelectedItems.Count > 0) {
- deleteButton.Enabled = true;
- openButton.Enabled = true;
- clipboardButton.Enabled = true;
- if (listview_imgur_uploads.SelectedItems.Count == 1) {
- ImgurInfo imgurInfo = (ImgurInfo)listview_imgur_uploads.SelectedItems[0].Tag;
- pictureBox1.Image = imgurInfo.Image;
- }
- } else {
- pictureBox1.Image = pictureBox1.ErrorImage;
- deleteButton.Enabled = false;
- openButton.Enabled = false;
- clipboardButton.Enabled = false;
- }
- }
-
- private void DeleteButtonClick(object sender, EventArgs e) {
- if (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;
- DialogResult result = MessageBox.Show(Language.GetFormattedString("imgur", LangKey.delete_question, imgurInfo.Title), Language.GetFormattedString("imgur", LangKey.delete_title, imgurInfo.Hash), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (result != DialogResult.Yes)
- {
- continue;
- }
- // Should fix Bug #3378699
- pictureBox1.Image = pictureBox1.ErrorImage;
- try {
- new PleaseWaitForm().ShowAndWait("Imgur", Language.GetString("imgur", LangKey.communication_wait),
- delegate {
- ImgurUtils.DeleteImgurImage(imgurInfo);
- }
- );
- } catch (Exception ex) {
- Log.Warn("Problem communicating with Imgur: ", ex);
- }
-
- imgurInfo.Dispose();
- }
- }
- Redraw();
- }
-
- private void ClipboardButtonClick(object sender, EventArgs e) {
- StringBuilder links = new StringBuilder();
- if (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;
- links.AppendLine(Config.UsePageLink ? imgurInfo.Page : imgurInfo.Original);
- }
- }
- ClipboardHelper.SetClipboardData(links.ToString());
- }
-
- 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();
- IniConfig.Save();
- Redraw();
- }
- }
-
- private void FinishedButtonClick(object sender, EventArgs e)
- {
- Hide();
- }
-
- private void OpenButtonClick(object sender, EventArgs e) {
- if (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;
- System.Diagnostics.Process.Start(imgurInfo.Page);
- }
- }
- }
-
- 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) {
- // Reverse the current sort direction for this column.
- _columnSorter.Order = _columnSorter.Order == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
- } else {
- // Set the column number that is to be sorted; default to ascending.
- _columnSorter.SortColumn = e.Column;
- _columnSorter.Order = SortOrder.Ascending;
- }
-
- // Perform the sort with these new sort options.
- listview_imgur_uploads.Sort();
- }
-
-
- private void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e)
- {
- _instance = null;
- }
- }
-}
diff --git a/GreenshotImgurPlugin/Forms/SettingsForm.cs b/GreenshotImgurPlugin/Forms/SettingsForm.cs
deleted file mode 100644
index 2ce863660..000000000
--- a/GreenshotImgurPlugin/Forms/SettingsForm.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-
-namespace GreenshotImgurPlugin.Forms {
- ///
- /// Description of PasswordRequestForm.
- ///
- public partial class SettingsForm : ImgurForm {
- public SettingsForm()
- {
- //
- // The InitializeComponent() call is required for Windows Forms designer support.
- //
- InitializeComponent();
- CancelButton = buttonCancel;
- AcceptButton = buttonOK;
-
- historyButton.Enabled = ImgurUtils.IsHistoryLoadingNeeded();
- }
-
- private void ButtonHistoryClick(object sender, EventArgs e) {
- ImgurHistory.ShowHistory();
- }
- }
-}
diff --git a/GreenshotImgurPlugin/ImgurConfiguration.cs b/GreenshotImgurPlugin/ImgurConfiguration.cs
deleted file mode 100644
index d487c2387..000000000
--- a/GreenshotImgurPlugin/ImgurConfiguration.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Collections.Generic;
-using System.Windows.Forms;
-using GreenshotImgurPlugin.Forms;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-
-namespace GreenshotImgurPlugin {
- ///
- /// Description of ImgurConfiguration.
- ///
- [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 { get; set; }
-
- [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
- public OutputFormat UploadFormat { get; set; }
- [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
- public int UploadJpegQuality { get; set; }
- [IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
- 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 { get; set; }
- [IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
- public bool UsePageLink { get; set; }
- [IniProperty("AnonymousAccess", Description = "Use anonymous access to Imgur", DefaultValue="true")]
- public bool AnonymousAccess { get; set; }
-
- [IniProperty("RefreshToken", Description = "Imgur refresh Token", Encrypted = true, ExcludeIfNull = true)]
- public string RefreshToken { get; set; }
-
- ///
- /// AccessToken, not stored
- ///
- public string AccessToken { get; set; }
-
- ///
- /// AccessTokenExpires, not stored
- ///
- public DateTimeOffset AccessTokenExpires { get; set; }
-
- [IniProperty("AddTitle", Description = "Is the title passed on to Imgur", DefaultValue = "False")]
- public bool AddTitle { get; set; }
- [IniProperty("AddFilename", Description = "Is the filename passed on to Imgur", DefaultValue = "False")]
- public bool AddFilename { get; set; }
- [IniProperty("FilenamePattern", Description = "Filename for the Imgur upload", DefaultValue = "${capturetime:d\"yyyyMMdd-HHmm\"}")]
- public string FilenamePattern { get; set; }
-
- [IniProperty("ImgurUploadHistory", Description="Imgur upload history (ImgurUploadHistory.hash=deleteHash)")]
- public Dictionary ImgurUploadHistory { get; set; }
-
- // Not stored, only run-time!
- public Dictionary runtimeImgurHistory = new Dictionary();
- public int Credits {
- get;
- set;
- }
-
- ///
- /// Supply values we can't put as defaults
- ///
- /// The property to return a default for
- /// object with the default value for the supplied property
- public override object GetDefault(string property) =>
- property switch
- {
- "ImgurUploadHistory" => new Dictionary(),
- _ => null
- };
-
- ///
- /// A form for username/password
- ///
- /// bool true if OK was pressed, false if cancel
- public bool ShowConfigDialog() {
- SettingsForm settingsForm = new SettingsForm();
- DialogResult result = settingsForm.ShowDialog();
- return result == DialogResult.OK;
- }
- }
-}
diff --git a/GreenshotImgurPlugin/ImgurInfo.cs b/GreenshotImgurPlugin/ImgurInfo.cs
deleted file mode 100644
index 85ec5b39e..000000000
--- a/GreenshotImgurPlugin/ImgurInfo.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.Drawing;
-using System.Xml;
-
-namespace GreenshotImgurPlugin
-{
- ///
- /// Description of ImgurInfo.
- ///
- public class ImgurInfo : IDisposable
- {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurInfo));
-
- public string Hash
- {
- get;
- set;
- }
-
- private string _deleteHash;
- public string DeleteHash
- {
- get { return _deleteHash; }
- set
- {
- _deleteHash = value;
- DeletePage = "https://imgur.com/delete/" + value;
- }
- }
-
- public string Title
- {
- get;
- set;
- }
-
- public string ImageType
- {
- get;
- set;
- }
-
- public DateTime Timestamp
- {
- get;
- set;
- }
-
- public string Original
- {
- get;
- set;
- }
-
- public string Page
- {
- get;
- set;
- }
-
- public string SmallSquare
- {
- get;
- set;
- }
-
- public string LargeThumbnail
- {
- get;
- set;
- }
-
- public string DeletePage
- {
- get;
- set;
- }
-
- private Image _image;
- public Image Image
- {
- get { return _image; }
- set
- {
- _image?.Dispose();
- _image = value;
- }
- }
-
- ///
- /// The public accessible Dispose
- /// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// This Dispose is called from the Dispose and the Destructor.
- /// When disposing==true all non-managed resources should be freed too!
- ///
- ///
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _image?.Dispose();
- }
- _image = null;
- }
- public static ImgurInfo ParseResponse(string response)
- {
- Log.Debug(response);
- // This is actually a hack for BUG-1695
- // The problem is the (C) sign, we send it HTML encoded "®" to Imgur and get it HTML encoded in the XML back
- // Added all the encodings I found quickly, I guess these are not all... but it should fix the issue for now.
- response = response.Replace("¢", "¢");
- response = response.Replace("£", "£");
- response = response.Replace("¥", "¥");
- response = response.Replace("€", "€");
- response = response.Replace("©", "©");
- response = response.Replace("®", "®");
-
- ImgurInfo imgurInfo = new ImgurInfo();
- try
- {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(response);
- XmlNodeList nodes = doc.GetElementsByTagName("id");
- if (nodes.Count > 0)
- {
- imgurInfo.Hash = nodes.Item(0)?.InnerText;
- }
- nodes = doc.GetElementsByTagName("hash");
- if (nodes.Count > 0)
- {
- imgurInfo.Hash = nodes.Item(0)?.InnerText;
- }
- nodes = doc.GetElementsByTagName("deletehash");
- if (nodes.Count > 0)
- {
- imgurInfo.DeleteHash = nodes.Item(0)?.InnerText;
- }
- nodes = doc.GetElementsByTagName("type");
- if (nodes.Count > 0)
- {
- imgurInfo.ImageType = nodes.Item(0)?.InnerText;
- }
- nodes = doc.GetElementsByTagName("title");
- if (nodes.Count > 0)
- {
- imgurInfo.Title = nodes.Item(0)?.InnerText;
- }
- nodes = doc.GetElementsByTagName("datetime");
- if (nodes.Count > 0)
- {
- // Version 3 has seconds since Epoch
- if (double.TryParse(nodes.Item(0)?.InnerText, out var secondsSince))
- {
- var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
- imgurInfo.Timestamp = epoch.AddSeconds(secondsSince).DateTime;
- }
- }
- nodes = doc.GetElementsByTagName("original");
- if (nodes.Count > 0)
- {
- imgurInfo.Original = nodes.Item(0)?.InnerText.Replace("http:", "https:");
- }
- // Version 3 API only has Link
- nodes = doc.GetElementsByTagName("link");
- if (nodes.Count > 0)
- {
- imgurInfo.Original = nodes.Item(0)?.InnerText.Replace("http:", "https:");
- }
- nodes = doc.GetElementsByTagName("imgur_page");
- if (nodes.Count > 0)
- {
- imgurInfo.Page = nodes.Item(0)?.InnerText.Replace("http:", "https:");
- }
- else
- {
- // Version 3 doesn't have a page link in the response
- imgurInfo.Page = $"https://imgur.com/{imgurInfo.Hash}";
- }
- nodes = doc.GetElementsByTagName("small_square");
- imgurInfo.SmallSquare = nodes.Count > 0 ? nodes.Item(0)?.InnerText : $"http://i.imgur.com/{imgurInfo.Hash}s.png";
- }
- catch (Exception e)
- {
- Log.ErrorFormat("Could not parse Imgur response due to error {0}, response was: {1}", e.Message, response);
- }
- return imgurInfo;
- }
- }
-}
diff --git a/GreenshotImgurPlugin/ImgurPlugin.cs b/GreenshotImgurPlugin/ImgurPlugin.cs
deleted file mode 100644
index d87c91f8e..000000000
--- a/GreenshotImgurPlugin/ImgurPlugin.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
-using GreenshotImgurPlugin.Forms;
-using GreenshotPlugin.Controls;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interfaces;
-using GreenshotPlugin.Interfaces.Plugin;
-
-namespace GreenshotImgurPlugin {
- ///
- /// This is the ImgurPlugin code
- ///
- [Plugin("Imgur", true)]
- public class ImgurPlugin : IGreenshotPlugin {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurPlugin));
- private static ImgurConfiguration _config;
- private ComponentResourceManager _resources;
- private ToolStripMenuItem _historyMenuItem;
- private ToolStripMenuItem _itemPlugInConfig;
-
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing) {
- if (disposing) {
- if (_historyMenuItem != null) {
- _historyMenuItem.Dispose();
- _historyMenuItem = null;
- }
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Dispose();
- _itemPlugInConfig = null;
- }
- }
- }
-
- private IEnumerable Destinations() {
- yield return new ImgurDestination(this);
- }
-
- ///
- /// Implementation of the IGreenshotPlugin.Initialize
- ///
- /// true if plugin is initialized, false if not (doesn't show)
- public bool Initialize() {
- // Get configuration
- _config = IniConfig.GetIniSection();
- _resources = new ComponentResourceManager(typeof(ImgurPlugin));
-
- ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur")
- {
- Image = (Image) _resources.GetObject("Imgur")
- };
-
- // Provide the IDestination
- SimpleServiceProvider.Current.AddService(Destinations());
- _historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history));
- _historyMenuItem.Click += delegate {
- ImgurHistory.ShowHistory();
- };
- itemPlugInRoot.DropDownItems.Add(_historyMenuItem);
-
- _itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure));
- _itemPlugInConfig.Click += delegate {
- _config.ShowConfigDialog();
- };
- itemPlugInRoot.DropDownItems.Add(_itemPlugInConfig);
-
- PluginUtils.AddToContextMenu(itemPlugInRoot);
- Language.LanguageChanged += OnLanguageChanged;
-
- // Enable history if there are items available
- UpdateHistoryMenuItem();
- return true;
- }
-
- public void OnLanguageChanged(object sender, EventArgs e) {
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Text = Language.GetString("imgur", LangKey.configure);
- }
- if (_historyMenuItem != null) {
- _historyMenuItem.Text = Language.GetString("imgur", LangKey.history);
- }
- }
-
- private void UpdateHistoryMenuItem() {
- if (_historyMenuItem == null)
- {
- return;
- }
- try
- {
- var form = SimpleServiceProvider.Current.GetInstance