mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Code quality changes
This commit is contained in:
parent
f07ed83722
commit
610f45d082
189 changed files with 4609 additions and 5203 deletions
|
@ -70,7 +70,7 @@ namespace GreenshotFlickrPlugin {
|
|||
/// </summary>
|
||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||
public bool ShowConfigDialog() {
|
||||
DialogResult result = new SettingsForm(this).ShowDialog();
|
||||
DialogResult result = new SettingsForm().ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,27 +22,17 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using log4net;
|
||||
|
||||
namespace GreenshotFlickrPlugin {
|
||||
public class FlickrDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(FlickrDestination));
|
||||
private readonly FlickrPlugin plugin;
|
||||
private readonly FlickrPlugin _plugin;
|
||||
public FlickrDestination(FlickrPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "Flickr";
|
||||
}
|
||||
}
|
||||
public override string Designation => "Flickr";
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Language.GetString("flickr", LangKey.upload_menu_item);
|
||||
}
|
||||
}
|
||||
public override string Description => Language.GetString("flickr", LangKey.upload_menu_item);
|
||||
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
|
@ -53,11 +43,11 @@ namespace GreenshotFlickrPlugin {
|
|||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
string uploadURL;
|
||||
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
|
||||
string uploadUrl;
|
||||
bool uploaded = _plugin.Upload(captureDetails, surface, out uploadUrl);
|
||||
if (uploaded) {
|
||||
exportInformation.ExportMade = true;
|
||||
exportInformation.Uri = uploadURL;
|
||||
exportInformation.Uri = uploadUrl;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace GreenshotFlickrPlugin
|
|||
/// This is the Flickr base code
|
||||
/// </summary>
|
||||
public class FlickrPlugin : IGreenshotPlugin {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrPlugin));
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(FlickrPlugin));
|
||||
private static FlickrConfiguration _config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost _host;
|
||||
|
@ -83,10 +83,12 @@ namespace GreenshotFlickrPlugin
|
|||
_config = IniConfig.GetIniSection<FlickrConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(FlickrPlugin));
|
||||
|
||||
_itemPlugInConfig = new ToolStripMenuItem();
|
||||
_itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure);
|
||||
_itemPlugInConfig.Tag = _host;
|
||||
_itemPlugInConfig.Image = (Image)_resources.GetObject("flickr");
|
||||
_itemPlugInConfig = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.GetString("flickr", LangKey.Configure),
|
||||
Tag = _host,
|
||||
Image = (Image) _resources.GetObject("flickr")
|
||||
};
|
||||
_itemPlugInConfig.Click += ConfigMenuClick;
|
||||
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
|
||||
|
@ -101,7 +103,7 @@ namespace GreenshotFlickrPlugin
|
|||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Flickr Plugin shutdown.");
|
||||
Log.Debug("Flickr Plugin shutdown.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -137,7 +139,7 @@ namespace GreenshotFlickrPlugin
|
|||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Error uploading.", e);
|
||||
Log.Error("Error uploading.", e);
|
||||
MessageBox.Show(Language.GetString("flickr", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -57,15 +57,17 @@ namespace GreenshotFlickrPlugin {
|
|||
/// <param name="filename"></param>
|
||||
/// <returns>url to image</returns>
|
||||
public static string UploadToFlickr(ISurface surfaceToUpload, SurfaceOutputSettings outputSettings, string title, string filename) {
|
||||
OAuthSession oAuth = new OAuthSession(FlickrCredentials.ConsumerKey, FlickrCredentials.ConsumerSecret);
|
||||
oAuth.BrowserSize = new Size(520, 800);
|
||||
oAuth.CheckVerifier = false;
|
||||
oAuth.AccessTokenUrl = FLICKR_ACCESS_TOKEN_URL;
|
||||
oAuth.AuthorizeUrl = FLICKR_AUTHORIZE_URL;
|
||||
oAuth.RequestTokenUrl = FLICKR_REQUEST_TOKEN_URL;
|
||||
oAuth.LoginTitle = "Flickr authorization";
|
||||
oAuth.Token = config.FlickrToken;
|
||||
oAuth.TokenSecret = config.FlickrTokenSecret;
|
||||
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;
|
||||
|
@ -85,7 +87,7 @@ namespace GreenshotFlickrPlugin {
|
|||
signedParameters.Add("is_public", config.IsPublic ? "1" : "0");
|
||||
signedParameters.Add("is_friend", config.IsFriend ? "1" : "0");
|
||||
signedParameters.Add("is_family", config.IsFamily ? "1" : "0");
|
||||
signedParameters.Add("safety_level", string.Format("{0}", (int)config.SafetyLevel));
|
||||
signedParameters.Add("safety_level", $"{(int) config.SafetyLevel}");
|
||||
signedParameters.Add("hidden", config.HiddenFromSearch ? "1" : "2");
|
||||
IDictionary<string, object> otherParameters = new Dictionary<string, object>();
|
||||
otherParameters.Add("photo", new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
|
@ -125,16 +127,13 @@ namespace GreenshotFlickrPlugin {
|
|||
XmlNodeList nodes = doc.GetElementsByTagName("photo");
|
||||
if (nodes.Count > 0) {
|
||||
var item = nodes.Item(0);
|
||||
if (item != null) {
|
||||
if (item.Attributes != null) {
|
||||
string farmId = item.Attributes["farm"].Value;
|
||||
string serverId = item.Attributes["server"].Value;
|
||||
string photoId = item.Attributes["id"].Value;
|
||||
string secret = item.Attributes["secret"].Value;
|
||||
return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret);
|
||||
}
|
||||
if (item?.Attributes != null) {
|
||||
string farmId = item.Attributes["farm"].Value;
|
||||
string serverId = item.Attributes["server"].Value;
|
||||
string photoId = item.Attributes["id"].Value;
|
||||
string secret = item.Attributes["secret"].Value;
|
||||
return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -26,9 +26,7 @@ namespace GreenshotFlickrPlugin {
|
|||
/// Description of PasswordRequestForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : FlickrForm {
|
||||
private string flickrFrob = string.Empty;
|
||||
|
||||
public SettingsForm(FlickrConfiguration config) {
|
||||
public SettingsForm() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue