mirror of
https://github.com/greenshot/greenshot
synced 2025-08-25 07:36:38 -07:00
A lot of cleanup, trying to use IoC everywhere. Also removing forms designer code too.
This commit is contained in:
parent
9fd835293a
commit
dc16b1df74
68 changed files with 473 additions and 3029 deletions
|
@ -103,7 +103,7 @@ namespace Greenshot.Addon.Box
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "box.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "box.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -204,12 +204,11 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -224,11 +224,11 @@
|
|||
<Resource Include="FodyWeavers.xml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\Fody.3.0.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.0.3\build\Fody.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace Greenshot.Addon.Dropbox
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "Dropbox.gif"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "Dropbox.gif"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -220,12 +220,11 @@
|
|||
<Resource Include="Languages\language_dropboxplugin-zh-TW.xml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Addon.ExternalCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is needed for design-time resolving of the language files
|
||||
/// </summary>
|
||||
public class ExternalCommandForm : GreenshotForm
|
||||
{
|
||||
}
|
||||
}
|
|
@ -149,9 +149,6 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="ExternalCommandConfigurationExtensions.cs" />
|
||||
<Compile Include="ExternalCommandDestination.cs" />
|
||||
<Compile Include="ExternalCommandForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExternalCommandDestinationProvider.cs" />
|
||||
<Compile Include="IExternalCommandLanguage.cs" />
|
||||
<Compile Include="IconCache.cs" />
|
||||
|
@ -212,11 +209,11 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
|
|
|
@ -27,7 +27,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Ini;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Gfx;
|
||||
|
||||
#endregion
|
||||
|
@ -37,12 +37,15 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
/// <summary>
|
||||
/// External Command settings form
|
||||
/// </summary>
|
||||
public partial class SettingsForm : ExternalCommandForm
|
||||
public partial class SettingsForm : GreenshotForm
|
||||
{
|
||||
private static readonly IExternalCommandConfiguration ExternalCommandConfig = IniConfig.Current.Get<IExternalCommandConfiguration>();
|
||||
private readonly IExternalCommandLanguage _externalCommandLanguage;
|
||||
private readonly IExternalCommandConfiguration _externalCommandConfiguration;
|
||||
private readonly IList<Image> _images = new List<Image>();
|
||||
public SettingsForm()
|
||||
public SettingsForm(IExternalCommandConfiguration externalCommandConfiguration, IExternalCommandLanguage externalCommandLanguage) : base(externalCommandLanguage)
|
||||
{
|
||||
_externalCommandConfiguration = externalCommandConfiguration;
|
||||
_externalCommandLanguage = externalCommandLanguage;
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -59,7 +62,7 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
|
||||
private void ButtonAddClick(object sender, EventArgs e)
|
||||
{
|
||||
var form = new SettingsFormDetail(null);
|
||||
var form = new SettingsFormDetail(null, _externalCommandLanguage);
|
||||
form.ShowDialog();
|
||||
|
||||
UpdateView();
|
||||
|
@ -71,7 +74,7 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
{
|
||||
var commando = item.Tag as string;
|
||||
|
||||
ExternalCommandConfig.Delete(commando);
|
||||
_externalCommandConfiguration.Delete(commando);
|
||||
}
|
||||
UpdateView();
|
||||
}
|
||||
|
@ -90,13 +93,13 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
{
|
||||
listView.Items.Clear();
|
||||
DisposeImages();
|
||||
if (ExternalCommandConfig.Commands != null)
|
||||
if (_externalCommandConfiguration.Commands != null)
|
||||
{
|
||||
listView.ListViewItemSorter = new ListviewComparer();
|
||||
var imageList = new ImageList();
|
||||
listView.SmallImageList = imageList;
|
||||
var imageNr = 0;
|
||||
foreach (var commando in ExternalCommandConfig.Commands)
|
||||
foreach (var commando in _externalCommandConfiguration.Commands)
|
||||
{
|
||||
ListViewItem item;
|
||||
var iconForExe = IconCache.IconForCommand(commando, DpiHandler.Dpi > 100);
|
||||
|
@ -143,7 +146,7 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
}
|
||||
var commando = listView.SelectedItems[0].Tag as string;
|
||||
|
||||
var form = new SettingsFormDetail(commando);
|
||||
var form = new SettingsFormDetail(commando, _externalCommandLanguage);
|
||||
form.ShowDialog();
|
||||
|
||||
UpdateView();
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.Log;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
|
||||
#endregion
|
||||
|
@ -39,7 +40,7 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
/// <summary>
|
||||
/// Description of SettingsFormDetail.
|
||||
/// </summary>
|
||||
public partial class SettingsFormDetail : ExternalCommandForm
|
||||
public partial class SettingsFormDetail : GreenshotForm
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private static readonly IExternalCommandConfiguration ExternalCommandConfig = IniConfig.Current.Get<IExternalCommandConfiguration>();
|
||||
|
@ -47,7 +48,7 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
|
||||
private readonly string _commando;
|
||||
|
||||
public SettingsFormDetail(string commando)
|
||||
public SettingsFormDetail(string commando, IExternalCommandLanguage externalCommandLanguage): base(externalCommandLanguage)
|
||||
{
|
||||
InitializeComponent();
|
||||
AcceptButton = buttonOk;
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Greenshot.Addon.Flickr
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "flickr.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "flickr.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -209,11 +209,11 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace Greenshot.Addon.GooglePhotos
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "GooglePhotos.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "GooglePhotos.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ namespace Greenshot.Addon.GooglePhotos
|
|||
catch (Exception e)
|
||||
{
|
||||
Log.Error().WriteLine(e, "Error uploading.");
|
||||
MessageBox.Show(_googlePhotosLanguage.UploadFailure + " " + e.Message);
|
||||
MessageBox.Show(_googlePhotosLanguage.UploadFailure + @" " + e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -186,12 +186,11 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -221,11 +221,10 @@
|
|||
<EmbeddedResource Include="Imgur.png" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -80,7 +80,7 @@ namespace Greenshot.Addon.Imgur
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this, by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "Imgur.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "Imgur.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -248,19 +248,13 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
del /q /s "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"\*
|
||||
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
|
||||
if "$(ConfigurationName)" == "Debug" (
|
||||
copy "$(ProjectDir)bin\$(Configuration)\Dapplo.*" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\Svg.dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
)
|
||||
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\Svg.dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace Greenshot.Addon.Jira
|
|||
}
|
||||
if (displayIcon == null)
|
||||
{
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "jira.svgz"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "jira.svgz"))
|
||||
{
|
||||
using (var gzStream = new GZipStream(bitmapStream, CompressionMode.Decompress))
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using ColorDialog = Greenshot.Addons.Controls.ColorDialog;
|
||||
|
||||
|
@ -37,10 +38,12 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
|||
{
|
||||
public class ToolStripColorButton : ToolStripButton, INotifyPropertyChanged, IGreenshotLanguageBindable
|
||||
{
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
private Color _selectedColor = Color.Transparent;
|
||||
|
||||
public ToolStripColorButton()
|
||||
public ToolStripColorButton(IGreenshotLanguage greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
Click += ColorButtonClick;
|
||||
}
|
||||
|
||||
|
@ -86,7 +89,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
|||
|
||||
private void ColorButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
var colorDialog = new ColorDialog
|
||||
var colorDialog = new ColorDialog(_greenshotLanguage)
|
||||
{
|
||||
Color = SelectedColor
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Gfx.Effects;
|
||||
|
||||
|
@ -33,11 +34,11 @@ using Greenshot.Gfx.Effects;
|
|||
|
||||
namespace Greenshot.Addon.LegacyEditor.Forms
|
||||
{
|
||||
public partial class DropShadowSettingsForm : BaseForm
|
||||
public partial class DropShadowSettingsForm : GreenshotForm
|
||||
{
|
||||
private readonly DropShadowEffect _effect;
|
||||
|
||||
public DropShadowSettingsForm(DropShadowEffect effect)
|
||||
public DropShadowSettingsForm(DropShadowEffect effect, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
|
|
|
@ -153,8 +153,8 @@ namespace Greenshot.Addon.LegacyEditor.Forms {
|
|||
this.areaHighlightMenuItem = new GreenshotToolStripMenuItem();
|
||||
this.grayscaleHighlightMenuItem = new GreenshotToolStripMenuItem();
|
||||
this.magnifyMenuItem = new GreenshotToolStripMenuItem();
|
||||
this.btnFillColor = new ToolStripColorButton();
|
||||
this.btnLineColor = new ToolStripColorButton();
|
||||
this.btnFillColor = new ToolStripColorButton(_greenshotLanguage);
|
||||
this.btnLineColor = new ToolStripColorButton(_greenshotLanguage);
|
||||
this.lineThicknessLabel = new GreenshotToolStripLabel();
|
||||
this.lineThicknessUpDown = new ToolStripNumericUpDown();
|
||||
this.counterLabel = new GreenshotToolStripLabel();
|
||||
|
|
|
@ -46,6 +46,7 @@ using Greenshot.Addon.LegacyEditor.Controls;
|
|||
using Greenshot.Addon.LegacyEditor.Drawing;
|
||||
using Greenshot.Addon.LegacyEditor.Drawing.Fields;
|
||||
using Greenshot.Addon.LegacyEditor.Drawing.Fields.Binding;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
|
@ -63,13 +64,15 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
/// <summary>
|
||||
/// Description of ImageEditorForm.
|
||||
/// </summary>
|
||||
public partial class ImageEditorForm : BaseForm, IImageEditor
|
||||
public partial class ImageEditorForm : GreenshotForm, IImageEditor
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private static readonly List<string> IgnoreDestinations = new List<string> { "Picker", "Editor"};
|
||||
private static readonly string[] SupportedClipboardFormats = { typeof(string).FullName, "Text", typeof(IDrawableContainerList).FullName };
|
||||
private readonly IEditorConfiguration _editorConfiguration;
|
||||
private readonly IEditorLanguage _editorLanguage;
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
|
||||
// whether part of the editor controls are disabled depending on selected item(s)
|
||||
private bool _controlsDisabledDueToConfirmable;
|
||||
|
@ -89,15 +92,19 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
public ImageEditorForm(
|
||||
IEditorConfiguration editorConfiguration,
|
||||
IEditorLanguage editorLanguage,
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
EditorFactory editorFactory,
|
||||
DestinationHolder destinationHolder,
|
||||
Func<ResizeEffect, Owned<ResizeSettingsForm>> resizeSettingsFormFactory,
|
||||
Func<TornEdgeEffect, Owned<TornEdgeSettingsForm>> tornEdgeSettingsFormFactory,
|
||||
Func<DropShadowEffect, Owned<DropShadowSettingsForm>> dropShadowSettingsFormFactory
|
||||
)
|
||||
) : base(editorLanguage)
|
||||
{
|
||||
_editorConfiguration = editorConfiguration;
|
||||
_editorLanguage = editorLanguage;
|
||||
_coreConfiguration = coreConfiguration;
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
_editorFactory = editorFactory;
|
||||
_destinationHolder = destinationHolder;
|
||||
_resizeSettingsFormFactory = resizeSettingsFormFactory;
|
||||
|
@ -152,7 +159,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
{
|
||||
case DpiChangeEventTypes.Before:
|
||||
// Change the ImageScalingSize before setting the bitmaps
|
||||
var width = DpiHandler.ScaleWithDpi(coreConfiguration.IconSize.Width, info.NewDpi);
|
||||
var width = DpiHandler.ScaleWithDpi(_coreConfiguration.IconSize.Width, info.NewDpi);
|
||||
var size = new Size(width, width);
|
||||
SuspendLayout();
|
||||
toolsToolStrip.ImageScalingSize = size;
|
||||
|
@ -321,10 +328,10 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
private void UpdateUi()
|
||||
{
|
||||
// Disable access to the settings, for feature #3521446
|
||||
preferencesToolStripMenuItem.Visible = !coreConfiguration.DisableSettings;
|
||||
toolStripSeparator12.Visible = !coreConfiguration.DisableSettings;
|
||||
toolStripSeparator11.Visible = !coreConfiguration.DisableSettings;
|
||||
btnSettings.Visible = !coreConfiguration.DisableSettings;
|
||||
preferencesToolStripMenuItem.Visible = !_coreConfiguration.DisableSettings;
|
||||
toolStripSeparator12.Visible = !_coreConfiguration.DisableSettings;
|
||||
toolStripSeparator11.Visible = !_coreConfiguration.DisableSettings;
|
||||
btnSettings.Visible = !_coreConfiguration.DisableSettings;
|
||||
|
||||
// Make sure Double-buffer is enabled
|
||||
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
|
||||
|
@ -904,7 +911,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
var saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Greenshot templates (*.gst)|*.gst",
|
||||
FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConfiguration.OutputFileFilenamePattern, _surface.CaptureDetails)
|
||||
FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(_coreConfiguration.OutputFileFilenamePattern, _surface.CaptureDetails)
|
||||
};
|
||||
var dialogResult = saveFileDialog.ShowDialog();
|
||||
if (!dialogResult.Equals(DialogResult.OK))
|
||||
|
@ -1064,7 +1071,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
NativeRect cropRectangle;
|
||||
using (var tmpImage = GetImageForExport())
|
||||
{
|
||||
cropRectangle = tmpImage.FindAutoCropRectangle(coreConfiguration.AutoCropDifference);
|
||||
cropRectangle = tmpImage.FindAutoCropRectangle(_coreConfiguration.AutoCropDifference);
|
||||
}
|
||||
if (!_surface.IsCropPossible(ref cropRectangle))
|
||||
{
|
||||
|
@ -1592,7 +1599,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
_surface.Dispose();
|
||||
|
||||
GC.Collect();
|
||||
if (coreConfiguration.MinimizeWorkingSetSize)
|
||||
if (_coreConfiguration.MinimizeWorkingSetSize)
|
||||
{
|
||||
PsApi.EmptyWorkingSet();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Gfx.Effects;
|
||||
|
||||
|
@ -37,13 +38,13 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
/// <summary>
|
||||
/// A form to set the resize settings
|
||||
/// </summary>
|
||||
public partial class ResizeSettingsForm : BaseForm
|
||||
public partial class ResizeSettingsForm : GreenshotForm
|
||||
{
|
||||
private readonly ResizeEffect _effect;
|
||||
private readonly string _valuePercent;
|
||||
private double _newWidth, _newHeight;
|
||||
|
||||
public ResizeSettingsForm(ResizeEffect effect, IEditorLanguage editorLanguage)
|
||||
public ResizeSettingsForm(ResizeEffect effect, IEditorLanguage editorLanguage, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Gfx.Effects;
|
||||
|
||||
|
@ -33,11 +34,11 @@ using Greenshot.Gfx.Effects;
|
|||
|
||||
namespace Greenshot.Addon.LegacyEditor.Forms
|
||||
{
|
||||
public partial class TornEdgeSettingsForm : BaseForm
|
||||
public partial class TornEdgeSettingsForm : GreenshotForm
|
||||
{
|
||||
private readonly TornEdgeEffect _effect;
|
||||
|
||||
public TornEdgeSettingsForm(TornEdgeEffect effect)
|
||||
public TornEdgeSettingsForm(TornEdgeEffect effect, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
|
|
|
@ -279,12 +279,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
del /q /s "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"\*
|
||||
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -233,14 +233,10 @@
|
|||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -66,7 +66,7 @@ namespace Greenshot.Addon.Lutim {
|
|||
public override Bitmap DisplayIcon {
|
||||
get {
|
||||
// TODO: Optimize this by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "Lutim.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "Lutim.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -146,12 +146,10 @@
|
|||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IOcrLanguage.cs" />
|
||||
<Compile Include="ModiLanguage.cs" />
|
||||
<Compile Include="IOCRConfiguration.cs" />
|
||||
<Compile Include="OcrDestination.cs" />
|
||||
<Compile Include="OCRForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="OcrAddonModule.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SettingsForm.cs">
|
||||
|
@ -187,11 +185,11 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
|
|
33
src/Greenshot.Addon.OCR/IOcrLanguage.cs
Normal file
33
src/Greenshot.Addon.OCR/IOcrLanguage.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2017 Thomas Braun, Jens Klingen, Robin Krom
|
||||
//
|
||||
// For more information see: http://getgreenshot.org/
|
||||
// The Greenshot project is hosted on GitHub: https://github.com/greenshot
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.ComponentModel;
|
||||
using Dapplo.Language;
|
||||
|
||||
namespace Greenshot.Addon.OCR
|
||||
{
|
||||
[Language("Ocr")]
|
||||
public interface IOcrLanguage : ILanguage, INotifyPropertyChanged
|
||||
{
|
||||
string Language { get; }
|
||||
string OrientImage { get; }
|
||||
string StraightenImage { get; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Addon.OCR
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is needed for design-time resolving of the language files
|
||||
/// </summary>
|
||||
public class OcrForm : GreenshotForm
|
||||
{
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace Greenshot.Addon.OCR
|
|||
{
|
||||
private bool HasModi()
|
||||
{
|
||||
var ocrCommand = Path.Combine(FileTools.NormalizeDirectory("."), "greenshotocrcommand.exe");
|
||||
var ocrCommand = Path.Combine(FileTools.NormalizeDirectory(Path.GetDirectoryName(GetType().Assembly.Location)), "greenshotocrcommand.exe");
|
||||
try
|
||||
{
|
||||
using (var process = Process.Start(ocrCommand, "-c"))
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#region Usings
|
||||
|
||||
using System;
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -32,11 +33,11 @@ namespace Greenshot.Addon.OCR
|
|||
/// <summary>
|
||||
/// Description of SettingsForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : OcrForm
|
||||
public partial class SettingsForm : GreenshotForm
|
||||
{
|
||||
private readonly IOCRConfiguration config;
|
||||
|
||||
public SettingsForm(string[] languages, IOCRConfiguration config)
|
||||
public SettingsForm(string[] languages, IOcrLanguage ocrLanguage, IOCRConfiguration config) : base(ocrLanguage)
|
||||
{
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
|
|
|
@ -243,12 +243,11 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\Fody.3.0.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.0.3\build\Fody.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
|
|
@ -187,12 +187,10 @@
|
|||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -113,7 +113,7 @@ namespace Greenshot.Addon.OneDrive
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this by caching
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "onedrive.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "onedrive.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -217,11 +217,10 @@
|
|||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -168,7 +168,7 @@ namespace Greenshot.Addon.Photobucket
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "photobucket-logo.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "photobucket-logo.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -190,12 +190,10 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\$(ProjectName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -131,7 +131,7 @@ namespace Greenshot.Addon.Tfs
|
|||
get
|
||||
{
|
||||
// TODO: Optimize this by using a cache
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType(), "vsts.png"))
|
||||
using (var bitmapStream = _resourceProvider.ResourceAsStream(GetType().Assembly, "vsts.png"))
|
||||
{
|
||||
return BitmapHelper.FromStream(bitmapStream);
|
||||
}
|
||||
|
|
|
@ -171,10 +171,9 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -25,6 +25,7 @@ using Autofac;
|
|||
using Dapplo.Addons;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.ViewModels;
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
namespace Greenshot.Addons
|
||||
{
|
||||
|
@ -39,6 +40,9 @@ namespace Greenshot.Addons
|
|||
builder
|
||||
.RegisterType<DestinationHolder>()
|
||||
.AsSelf();
|
||||
builder
|
||||
.RegisterType<ColorDialog>()
|
||||
.AsSelf();
|
||||
|
||||
base.Load(builder);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Language;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Gdi32;
|
||||
using Dapplo.Windows.Gdi32.Enums;
|
||||
using Dapplo.Windows.Gdi32.SafeHandles;
|
||||
using Greenshot.Addons.Core;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -39,6 +41,7 @@ namespace Greenshot.Addons.Controls
|
|||
/// </summary>
|
||||
public class AnimatingForm : GreenshotForm
|
||||
{
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
private const int DefaultVerticalRefresh = 60;
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private Timer _timer;
|
||||
|
@ -47,8 +50,9 @@ namespace Greenshot.Addons.Controls
|
|||
/// <summary>
|
||||
/// Initialize the animation
|
||||
/// </summary>
|
||||
protected AnimatingForm()
|
||||
protected AnimatingForm(ICoreConfiguration coreConfiguration, ILanguage language) : base(language)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
Load += (sender, args) =>
|
||||
{
|
||||
DoubleBuffered = true;
|
||||
|
@ -102,7 +106,7 @@ namespace Greenshot.Addons.Controls
|
|||
/// <summary>
|
||||
/// Check if we are in a Terminal Server session OR need to optimize for RDP / remote desktop connections
|
||||
/// </summary>
|
||||
protected bool IsTerminalServerSession => !coreConfiguration.DisableRDPOptimizing && (coreConfiguration.OptimizeForRDP || SystemInformation.TerminalServerSession);
|
||||
protected bool IsTerminalServerSession => !_coreConfiguration.DisableRDPOptimizing && (_coreConfiguration.OptimizeForRDP || SystemInformation.TerminalServerSession);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the amount of frames that an animation takes
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Addons.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is only here to help in the Designer mode, so it's clear where the language files are
|
||||
/// </summary>
|
||||
public class BaseForm : GreenshotForm
|
||||
{
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using Autofac.Features.OwnedInstances;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -38,10 +39,12 @@ namespace Greenshot.Addons.Controls
|
|||
/// </summary>
|
||||
public class ColorButton : Button, IGreenshotLanguageBindable
|
||||
{
|
||||
private readonly Func<Owned<ColorDialog>> _colorDialogFactory;
|
||||
private Color _selectedColor = Color.White;
|
||||
|
||||
public ColorButton()
|
||||
public ColorButton(Func<Owned<ColorDialog>> colorDialogFactory)
|
||||
{
|
||||
_colorDialogFactory = colorDialogFactory;
|
||||
Click += ColorButtonClick;
|
||||
}
|
||||
|
||||
|
@ -82,10 +85,10 @@ namespace Greenshot.Addons.Controls
|
|||
|
||||
private void ColorButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
var colorDialog = new ColorDialog
|
||||
using (var ownedColorDialog = _colorDialogFactory())
|
||||
{
|
||||
Color = SelectedColor
|
||||
};
|
||||
var colorDialog = ownedColorDialog.Value;
|
||||
colorDialog.Color = SelectedColor;
|
||||
// Using the parent to make sure the dialog doesn't show on another window
|
||||
colorDialog.ShowDialog(Parent.Parent);
|
||||
if (colorDialog.DialogResult == DialogResult.Cancel)
|
||||
|
@ -98,6 +101,7 @@ namespace Greenshot.Addons.Controls
|
|||
}
|
||||
SelectedColor = colorDialog.Color;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ namespace Greenshot.Addons.Controls
|
|||
/// <summary>
|
||||
/// Description of ColorDialog.
|
||||
/// </summary>
|
||||
public partial class ColorDialog : BaseForm
|
||||
public partial class ColorDialog : GreenshotForm
|
||||
{
|
||||
|
||||
private readonly IList<Button> _colorButtons = new List<Button>();
|
||||
|
@ -46,7 +46,7 @@ namespace Greenshot.Addons.Controls
|
|||
private readonly ToolTip _toolTip = new ToolTip();
|
||||
private bool _updateInProgress;
|
||||
|
||||
public ColorDialog()
|
||||
public ColorDialog(IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
SuspendLayout();
|
||||
InitializeComponent();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons.Core;
|
||||
using Dapplo.Language;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -34,11 +34,13 @@ namespace Greenshot.Addons.Controls
|
|||
{
|
||||
public class GreenshotComboBox : ComboBox, IGreenshotConfigBindable
|
||||
{
|
||||
private readonly ILanguage _language;
|
||||
private Type _enumType;
|
||||
private Enum _selectedEnum;
|
||||
|
||||
public GreenshotComboBox()
|
||||
public GreenshotComboBox(ILanguage language)
|
||||
{
|
||||
_language = language;
|
||||
SelectedIndexChanged += (sender, args) => StoreSelectedEnum();
|
||||
}
|
||||
|
||||
|
@ -60,7 +62,16 @@ namespace Greenshot.Addons.Controls
|
|||
}
|
||||
|
||||
_selectedEnum = currentValue;
|
||||
SelectedItem = Language.Translate(currentValue);
|
||||
|
||||
var key = ToKey(currentValue);
|
||||
if (_language.Keys().Contains(key))
|
||||
{
|
||||
SelectedItem = _language[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedItem = currentValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -77,8 +88,22 @@ namespace Greenshot.Addons.Controls
|
|||
Items.Clear();
|
||||
foreach (var enumValue in availableValues)
|
||||
{
|
||||
Items.Add(Language.Translate((Enum) enumValue));
|
||||
var key = ToKey(enumValue);
|
||||
if (_language.Keys().Contains(key))
|
||||
{
|
||||
Items.Add(_language[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Items.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ToKey(object enumValue)
|
||||
{
|
||||
var typename = enumValue.GetType().Name;
|
||||
return typename + "." + enumValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -102,12 +127,14 @@ namespace Greenshot.Addons.Controls
|
|||
|
||||
foreach (Enum enumValue in availableValues)
|
||||
{
|
||||
if (!Language.HasKey(enumTypeName, enumValue))
|
||||
var key = enumValue.ToString();
|
||||
|
||||
if (!_language.Keys().Contains(key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var translation = Language.GetString(enumTypeName,enumValue);
|
||||
var translation = _language[key];
|
||||
if (translation.Equals(selectedValue))
|
||||
{
|
||||
returnValue = enumValue;
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.InterfaceImpl.Extensions;
|
||||
using Dapplo.Language;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Desktop;
|
||||
using Dapplo.Windows.Dpi;
|
||||
|
@ -45,43 +45,24 @@ namespace Greenshot.Addons.Controls
|
|||
/// <summary>
|
||||
/// This form is used for automatically binding the elements of the form to the language
|
||||
/// </summary>
|
||||
public class GreenshotForm : DpiAwareForm, IGreenshotLanguageBindable
|
||||
public abstract class GreenshotForm : DpiAwareForm, IGreenshotLanguageBindable
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
protected static readonly ICoreConfiguration coreConfiguration;
|
||||
private static readonly IDictionary<Type, FieldInfo[]> ReflectionCache = new Dictionary<Type, FieldInfo[]>();
|
||||
private IDictionary<string, Control> _designTimeControls;
|
||||
private IDictionary<string, ToolStripItem> _designTimeToolStripItems;
|
||||
private bool _isDesignModeLanguageSet;
|
||||
private IComponentChangeService _componentChangeService;
|
||||
private readonly ILanguage _language;
|
||||
|
||||
protected readonly BitmapScaleHandler<string> ScaleHandler;
|
||||
|
||||
static GreenshotForm()
|
||||
{
|
||||
if (!IsInDesignMode)
|
||||
{
|
||||
coreConfiguration = IniConfig.Current.Get<ICoreConfiguration>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor, for default functionality like DPI awareness
|
||||
/// </summary>
|
||||
protected GreenshotForm()
|
||||
protected GreenshotForm(ILanguage language)
|
||||
{
|
||||
_language = language;
|
||||
// Add the Dapplo.Windows DPI change handler
|
||||
ScaleHandler = BitmapScaleHandler.WithComponentResourceManager(DpiHandler, GetType(), (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to check the designmode during a constructor
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected static bool IsInDesignMode => Application.ExecutablePath.IndexOf("devenv.exe", StringComparison.OrdinalIgnoreCase) > -1 ||
|
||||
Application.ExecutablePath.IndexOf("sharpdevelop.exe", StringComparison.OrdinalIgnoreCase) > -1 ||
|
||||
Application.ExecutablePath.IndexOf("wdexpress.exe", StringComparison.OrdinalIgnoreCase) > -1;
|
||||
|
||||
protected bool ManualLanguageApply { get; set; }
|
||||
|
||||
protected bool ManualStoreFields { get; set; }
|
||||
|
@ -91,68 +72,16 @@ namespace Greenshot.Addons.Controls
|
|||
/// </summary>
|
||||
protected bool ToFront { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This override allows the control to register event handlers for IComponentChangeService events
|
||||
/// at the time the control is sited, which happens only in design mode.
|
||||
/// </summary>
|
||||
public override ISite Site
|
||||
{
|
||||
get { return base.Site; }
|
||||
set
|
||||
{
|
||||
// Clear any component change event handlers.
|
||||
ClearChangeNotifications();
|
||||
|
||||
// Set the new Site value.
|
||||
base.Site = value;
|
||||
|
||||
_componentChangeService = (IComponentChangeService) GetService(typeof(IComponentChangeService));
|
||||
|
||||
// Register event handlers for component change events.
|
||||
RegisterChangeNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Greenshot")]
|
||||
[DefaultValue(null)]
|
||||
[Description("Specifies key of the language file to use when displaying the text.")]
|
||||
public string LanguageKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Code to initialize the language etc during design time
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// This override is only for the design-time of the form
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (DesignMode)
|
||||
{
|
||||
if (!_isDesignModeLanguageSet)
|
||||
{
|
||||
_isDesignModeLanguageSet = true;
|
||||
try
|
||||
{
|
||||
ApplyLanguage();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
base.OnPaint(e);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
// Every GreenshotForm should have it's default icon
|
||||
// And it might not ne needed for a Tool Window, but still for the task manager / switcher it's important
|
||||
Icon = GreenshotResources.GetGreenshotIcon();
|
||||
if (!DesignMode)
|
||||
{
|
||||
if (!ManualLanguageApply)
|
||||
{
|
||||
ApplyLanguage();
|
||||
|
@ -160,7 +89,6 @@ namespace Greenshot.Addons.Controls
|
|||
FillFields();
|
||||
base.OnLoad(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the form is visible, if this is wanted
|
||||
|
@ -181,7 +109,7 @@ namespace Greenshot.Addons.Controls
|
|||
/// <param name="e"></param>
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (!DesignMode && !ManualStoreFields)
|
||||
if (!ManualStoreFields)
|
||||
{
|
||||
if (DialogResult == DialogResult.OK)
|
||||
{
|
||||
|
@ -192,143 +120,37 @@ namespace Greenshot.Addons.Controls
|
|||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
private void ClearChangeNotifications()
|
||||
{
|
||||
// The m_changeService value is null when not in design mode,
|
||||
// as the IComponentChangeService is only available at design time.
|
||||
_componentChangeService = (IComponentChangeService) GetService(typeof(IComponentChangeService));
|
||||
|
||||
// Clear our the component change events to prepare for re-siting.
|
||||
if (_componentChangeService == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_componentChangeService.ComponentChanged -= OnComponentChanged;
|
||||
_componentChangeService.ComponentAdded -= OnComponentAdded;
|
||||
}
|
||||
|
||||
private void RegisterChangeNotifications()
|
||||
{
|
||||
// Register the event handlers for the IComponentChangeService events
|
||||
if (_componentChangeService == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_componentChangeService.ComponentChanged += OnComponentChanged;
|
||||
_componentChangeService.ComponentAdded += OnComponentAdded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method handles the OnComponentChanged event to display a notification.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="ce"></param>
|
||||
private void OnComponentChanged(object sender, ComponentChangedEventArgs ce)
|
||||
{
|
||||
if (((IComponent) ce.Component)?.Site == null || ce.Member == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!"LanguageKey".Equals(ce.Member.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ce.Component)
|
||||
{
|
||||
case Control control:
|
||||
Log.Info().WriteLine("Changing LanguageKey for {0} to {1}", control.Name, ce.NewValue);
|
||||
ApplyLanguage(control, (string) ce.NewValue);
|
||||
break;
|
||||
case ToolStripItem item:
|
||||
Log.Info().WriteLine("Changing LanguageKey for {0} to {1}", item.Name, ce.NewValue);
|
||||
ApplyLanguage(item, (string) ce.NewValue);
|
||||
break;
|
||||
default:
|
||||
Log.Info().WriteLine("Not possible to changing LanguageKey for {0} to {1}", ce.Component.GetType(), ce.NewValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnComponentAdded(object sender, ComponentEventArgs ce)
|
||||
{
|
||||
if (ce.Component?.Site == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ce.Component)
|
||||
{
|
||||
case Control control:
|
||||
if (!_designTimeControls.ContainsKey(control.Name))
|
||||
{
|
||||
_designTimeControls.Add(control.Name, control);
|
||||
}
|
||||
else
|
||||
{
|
||||
_designTimeControls[control.Name] = control;
|
||||
}
|
||||
|
||||
break;
|
||||
case ToolStripItem stripItem:
|
||||
var item = stripItem;
|
||||
if (!_designTimeControls.ContainsKey(item.Name))
|
||||
{
|
||||
_designTimeToolStripItems.Add(item.Name, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_designTimeToolStripItems[item.Name] = item;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
ClearChangeNotifications();
|
||||
}
|
||||
ScaleHandler.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
protected void ApplyLanguage(ToolStripItem applyTo, string languageKey)
|
||||
private void ApplyLanguage(ToolStripItem applyTo, string languageKey)
|
||||
{
|
||||
string langString;
|
||||
if (!string.IsNullOrEmpty(languageKey))
|
||||
if (_language == null)
|
||||
{
|
||||
if (!Language.TryGetString(languageKey, out langString))
|
||||
{
|
||||
Log.Warn().WriteLine("Unknown language key '{0}' configured for control '{1}', this might be okay.", languageKey, applyTo.Name);
|
||||
return;
|
||||
}
|
||||
applyTo.Text = langString;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to control name!
|
||||
if (Language.TryGetString(applyTo.Name, out langString))
|
||||
{
|
||||
applyTo.Text = langString;
|
||||
return;
|
||||
}
|
||||
if (!DesignMode)
|
||||
{
|
||||
Log.Debug().WriteLine("Greenshot control without language key: {0}", applyTo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ApplyLanguage(ToolStripItem applyTo)
|
||||
if (!string.IsNullOrEmpty(languageKey) && _language.Keys().Contains(languageKey))
|
||||
{
|
||||
applyTo.Text = _language[languageKey];
|
||||
return;
|
||||
}
|
||||
|
||||
if (_language.Keys().Contains(applyTo.Name))
|
||||
{
|
||||
applyTo.Text = _language[applyTo.Name];
|
||||
return;
|
||||
}
|
||||
Log.Warn().WriteLine("Unknown language key '{0}' configured for control '{1}'", languageKey, applyTo.Name);
|
||||
}
|
||||
|
||||
private void ApplyLanguage(ToolStripItem applyTo)
|
||||
{
|
||||
if (applyTo is IGreenshotLanguageBindable languageBindable)
|
||||
{
|
||||
|
@ -336,7 +158,7 @@ namespace Greenshot.Addons.Controls
|
|||
}
|
||||
}
|
||||
|
||||
protected void ApplyLanguage(Control applyTo)
|
||||
private void ApplyLanguage(Control applyTo)
|
||||
{
|
||||
if (!(applyTo is IGreenshotLanguageBindable languageBindable))
|
||||
{
|
||||
|
@ -398,13 +220,17 @@ namespace Greenshot.Addons.Controls
|
|||
/// </summary>
|
||||
protected void ApplyLanguage()
|
||||
{
|
||||
if (_language == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SuspendLayout();
|
||||
try
|
||||
{
|
||||
// Set title of the form
|
||||
if (!string.IsNullOrEmpty(LanguageKey) && Language.TryGetString(LanguageKey, out var langString))
|
||||
if (!string.IsNullOrEmpty(LanguageKey) && _language.Keys().Contains(LanguageKey))
|
||||
{
|
||||
Text = langString;
|
||||
Text = _language[LanguageKey];
|
||||
}
|
||||
|
||||
// Reset the text values for all GreenshotControls
|
||||
|
@ -417,33 +243,19 @@ namespace Greenshot.Addons.Controls
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!(controlObject is Control applyToControl))
|
||||
{
|
||||
if (!(controlObject is ToolStripItem applyToItem))
|
||||
{
|
||||
Log.Debug().WriteLine("No Control or ToolStripItem: {0}", field.Name);
|
||||
continue;
|
||||
}
|
||||
ApplyLanguage(applyToItem);
|
||||
}
|
||||
else
|
||||
if (controlObject is Control applyToControl)
|
||||
{
|
||||
ApplyLanguage(applyToControl);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!DesignMode)
|
||||
if (controlObject is ToolStripItem applyToItem)
|
||||
{
|
||||
return;
|
||||
ApplyLanguage(applyToItem);
|
||||
continue;
|
||||
}
|
||||
Log.Debug().WriteLine("No Control or ToolStripItem: {0}", field.Name);
|
||||
|
||||
foreach (var designControl in _designTimeControls.Values)
|
||||
{
|
||||
ApplyLanguage(designControl);
|
||||
}
|
||||
foreach (var designToolStripItem in _designTimeToolStripItems.Values)
|
||||
{
|
||||
ApplyLanguage(designToolStripItem);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -455,31 +267,25 @@ namespace Greenshot.Addons.Controls
|
|||
/// <summary>
|
||||
/// Apply the language text to supplied control
|
||||
/// </summary>
|
||||
protected void ApplyLanguage(Control applyTo, string languageKey)
|
||||
private void ApplyLanguage(Control applyTo, string languageKey)
|
||||
{
|
||||
string langString;
|
||||
if (!string.IsNullOrEmpty(languageKey))
|
||||
if (_language == null)
|
||||
{
|
||||
if (!Language.TryGetString(languageKey, out langString))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(languageKey) && _language.Keys().Contains(languageKey))
|
||||
{
|
||||
applyTo.Text = _language[languageKey];
|
||||
return;
|
||||
}
|
||||
|
||||
if (_language.Keys().Contains(applyTo.Name))
|
||||
{
|
||||
applyTo.Text = _language[applyTo.Name];
|
||||
return;
|
||||
}
|
||||
Log.Warn().WriteLine("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name);
|
||||
return;
|
||||
}
|
||||
applyTo.Text = langString;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to control name!
|
||||
if (Language.TryGetString(applyTo.Name, out langString))
|
||||
{
|
||||
applyTo.Text = langString;
|
||||
return;
|
||||
}
|
||||
if (!DesignMode)
|
||||
{
|
||||
Log.Debug().WriteLine("Greenshot control without language key: {0}", applyTo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -38,10 +38,14 @@ namespace Greenshot.Addons.Controls
|
|||
/// </summary>
|
||||
public partial class QualityDialog : GreenshotForm
|
||||
{
|
||||
private static readonly ICoreConfiguration conf = IniConfig.Current.Get<ICoreConfiguration>();
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
|
||||
public QualityDialog(SurfaceOutputSettings outputSettings)
|
||||
public QualityDialog(
|
||||
SurfaceOutputSettings outputSettings,
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
Settings = outputSettings;
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
|
@ -67,9 +71,9 @@ namespace Greenshot.Addons.Controls
|
|||
return;
|
||||
}
|
||||
|
||||
conf.OutputFileJpegQuality = Settings.JPGQuality;
|
||||
conf.OutputFilePromptQuality = false;
|
||||
conf.OutputFileReduceColors = Settings.ReduceColors;
|
||||
_coreConfiguration.OutputFileJpegQuality = Settings.JPGQuality;
|
||||
_coreConfiguration.OutputFilePromptQuality = false;
|
||||
_coreConfiguration.OutputFileReduceColors = Settings.ReduceColors;
|
||||
}
|
||||
|
||||
private void TrackBarJpegQualityScroll(object sender, EventArgs e)
|
||||
|
|
|
@ -36,6 +36,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.Language;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Common;
|
||||
using Greenshot.Addons.Controls;
|
||||
|
@ -137,7 +138,8 @@ namespace Greenshot.Addons.Core
|
|||
var outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
|
||||
if (CoreConfig.OutputFilePromptQuality)
|
||||
{
|
||||
var qualityDialog = new QualityDialog(outputSettings);
|
||||
// TODO: Resolve
|
||||
var qualityDialog = new QualityDialog(outputSettings, CoreConfig, LanguageLoader.Current.Get<IGreenshotLanguage>());
|
||||
qualityDialog.ShowDialog();
|
||||
}
|
||||
// TODO: For now we always overwrite, should be changed
|
||||
|
|
|
@ -172,9 +172,6 @@
|
|||
<Compile Include="Controls\AnimatingForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\BaseForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\InvertedBoolenConverter.cs" />
|
||||
<Compile Include="Controls\ColorButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Greenshot.Destinations
|
|||
}
|
||||
if (CoreConfiguration.OutputFilePromptQuality)
|
||||
{
|
||||
var qualityDialog = new QualityDialog(outputSettings);
|
||||
var qualityDialog = new QualityDialog(outputSettings, CoreConfiguration, GreenshotLanguage);
|
||||
qualityDialog.ShowDialog();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,13 +42,16 @@ namespace Greenshot.Destinations
|
|||
|
||||
public class FileWithDialogDestination : AbstractDestination
|
||||
{
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
|
||||
public FileWithDialogDestination(ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
}
|
||||
|
||||
public override string Description => Language.GetString(LangKey.settings_destination_fileas);
|
||||
public override string Description => _greenshotLanguage.SettingsDestinationFileas;
|
||||
|
||||
public override Keys EditorShortcutKeys => Keys.Control | Keys.Shift | Keys.S;
|
||||
|
||||
|
|
|
@ -45,12 +45,14 @@ namespace Greenshot.Destinations
|
|||
[Destination("Printer", DestinationOrder.Printer)]
|
||||
public class PrinterDestination : AbstractDestination
|
||||
{
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
private readonly string _printerName;
|
||||
|
||||
public PrinterDestination(ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage
|
||||
): base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
}
|
||||
|
||||
protected PrinterDestination(
|
||||
|
@ -65,11 +67,12 @@ namespace Greenshot.Destinations
|
|||
{
|
||||
get
|
||||
{
|
||||
var printerDestination = _greenshotLanguage.SettingsDestinationPicker;
|
||||
if (_printerName != null)
|
||||
{
|
||||
return Language.GetString(LangKey.settings_destination_printer) + " - " + _printerName;
|
||||
return printerDestination + " - " + _printerName;
|
||||
}
|
||||
return Language.GetString(LangKey.settings_destination_printer);
|
||||
return printerDestination;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +127,7 @@ namespace Greenshot.Destinations
|
|||
PrinterSettings printerSettings;
|
||||
if (!string.IsNullOrEmpty(_printerName))
|
||||
{
|
||||
using (var printHelper = new PrintHelper(surface, captureDetails))
|
||||
using (var printHelper = new PrintHelper(CoreConfiguration, GreenshotLanguage,surface, captureDetails))
|
||||
{
|
||||
printerSettings = printHelper.PrintTo(_printerName);
|
||||
}
|
||||
|
@ -132,14 +135,14 @@ namespace Greenshot.Destinations
|
|||
else if (!manuallyInitiated)
|
||||
{
|
||||
var settings = new PrinterSettings();
|
||||
using (var printHelper = new PrintHelper(surface, captureDetails))
|
||||
using (var printHelper = new PrintHelper(CoreConfiguration, GreenshotLanguage, surface, captureDetails))
|
||||
{
|
||||
printerSettings = printHelper.PrintTo(settings.PrinterName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var printHelper = new PrintHelper(surface, captureDetails))
|
||||
using (var printHelper = new PrintHelper(CoreConfiguration, GreenshotLanguage, surface, captureDetails))
|
||||
{
|
||||
printerSettings = printHelper.PrintWithDialog();
|
||||
}
|
||||
|
|
2
src/Greenshot/Forms/AboutForm.Designer.cs
generated
2
src/Greenshot/Forms/AboutForm.Designer.cs
generated
|
@ -180,7 +180,7 @@ namespace Greenshot.Forms {
|
|||
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(90, 90);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.TabIndex = 14;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
|
|
|
@ -32,11 +32,13 @@ using System.Drawing.Imaging;
|
|||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Helpers;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Dpi;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Animation;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
using Greenshot.Gfx;
|
||||
|
||||
|
@ -47,8 +49,10 @@ namespace Greenshot.Forms
|
|||
/// <summary>
|
||||
/// The about form
|
||||
/// </summary>
|
||||
public sealed partial class AboutForm : AnimatingBaseForm
|
||||
public sealed partial class AboutForm : AnimatingForm
|
||||
{
|
||||
private readonly IGreenshotLanguage _greenshotlanguage;
|
||||
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
// Variables are used to define the location of the dots
|
||||
private const int w = 13;
|
||||
|
@ -62,6 +66,7 @@ namespace Greenshot.Forms
|
|||
private readonly Color _backColor = Color.FromArgb(61, 61, 61);
|
||||
private readonly ColorAnimator _backgroundAnimation;
|
||||
private readonly IList<Color> _colorFlow = new List<Color>();
|
||||
private readonly IDisposable _dpiSubscription;
|
||||
|
||||
// 0 1 2 3 4
|
||||
// 5 6
|
||||
|
@ -130,8 +135,9 @@ namespace Greenshot.Forms
|
|||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public AboutForm()
|
||||
public AboutForm(ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotlanguage) : base(coreConfiguration, greenshotlanguage)
|
||||
{
|
||||
_greenshotlanguage = greenshotlanguage;
|
||||
// Make sure our resources are removed again.
|
||||
Disposed += Cleanup;
|
||||
FormClosing += Cleanup;
|
||||
|
@ -146,6 +152,13 @@ namespace Greenshot.Forms
|
|||
// Use the self drawn image, first we create the background to be the backcolor (as we animate from this)
|
||||
_bitmap = BitmapFactory.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor);
|
||||
pictureBox1.Image = _bitmap;
|
||||
|
||||
_dpiSubscription = DpiHandler.OnDpiChangeInfo.Subscribe(info =>
|
||||
{
|
||||
pictureBox1.Width = DpiHandler.ScaleWithDpi(90, info.NewDpi);
|
||||
pictureBox1.Height = DpiHandler.ScaleWithDpi(90, info.NewDpi);
|
||||
});
|
||||
|
||||
var v = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")]
|
||||
|
@ -216,6 +229,8 @@ namespace Greenshot.Forms
|
|||
_bitmap.Dispose();
|
||||
_bitmap = null;
|
||||
}
|
||||
_dpiSubscription.Dispose();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -236,7 +251,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, linkLabel.Text), Language.GetString(LangKey.error));
|
||||
MessageBox.Show(string.Format(_greenshotlanguage.ErrorOpenlink, linkLabel.Text), _greenshotlanguage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is only here to help in the Designer mode, so it's clear where the language files are
|
||||
/// </summary>
|
||||
public class AnimatingBaseForm : AnimatingForm
|
||||
{
|
||||
}
|
||||
}
|
|
@ -26,18 +26,23 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
using Greenshot.Configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Forms
|
||||
{
|
||||
public partial class BugReportForm : BaseForm
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class BugReportForm : GreenshotForm
|
||||
{
|
||||
private BugReportForm()
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
|
||||
private BugReportForm(IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -45,7 +50,7 @@ namespace Greenshot.Forms
|
|||
ToFront = true;
|
||||
}
|
||||
|
||||
public BugReportForm(string bugText) : this()
|
||||
public BugReportForm(string bugText, IGreenshotLanguage greenshotLanguage) : this(greenshotLanguage)
|
||||
{
|
||||
textBoxDescription.Text = bugText;
|
||||
}
|
||||
|
@ -64,7 +69,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, link.Text), Language.GetString(LangKey.error));
|
||||
MessageBox.Show(string.Format(_greenshotLanguage.ErrorOpenlink, link.Text), _greenshotLanguage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ using System.Linq;
|
|||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Windows.Desktop;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Common.Extensions;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
|
@ -57,14 +56,14 @@ namespace Greenshot.Forms
|
|||
public sealed partial class CaptureForm : AnimatingForm
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private static readonly ICoreConfiguration Conf = IniConfig.Current.Get<ICoreConfiguration>();
|
||||
private static readonly Brush GreenOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.MediumSeaGreen));
|
||||
private static readonly Brush ScrollingOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.GreenYellow));
|
||||
private static readonly Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||
private static CaptureForm _currentForm;
|
||||
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
private static readonly Brush BackgroundBrush;
|
||||
private readonly ICapture _capture;
|
||||
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
|
||||
private readonly bool _isZoomerTransparent;
|
||||
private readonly IList<IInteropWindow> _windows;
|
||||
private NativeRect _captureRect = NativeRect.Empty;
|
||||
private NativePoint _cursorPos;
|
||||
|
@ -93,25 +92,19 @@ namespace Greenshot.Forms
|
|||
/// <summary>
|
||||
/// This creates the capture form
|
||||
/// </summary>
|
||||
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
||||
/// <param name="capture">ICapture</param>
|
||||
/// <param name="windows">IList of IInteropWindow</param>
|
||||
public CaptureForm(ICapture capture, IList<IInteropWindow> windows)
|
||||
public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList<IInteropWindow> windows) : base(coreConfiguration, null)
|
||||
{
|
||||
if (_currentForm != null)
|
||||
{
|
||||
Log.Warn().WriteLine("Found currentForm, Closing already opened CaptureForm");
|
||||
_currentForm.Close();
|
||||
_currentForm = null;
|
||||
Application.DoEvents();
|
||||
}
|
||||
_currentForm = this;
|
||||
_coreConfiguration = coreConfiguration;
|
||||
_isZoomerTransparent = _coreConfiguration.ZoomerOpacity < 1;
|
||||
ManualLanguageApply = true;
|
||||
ManualStoreFields = true;
|
||||
|
||||
// Enable the AnimatingForm
|
||||
EnableAnimation = true;
|
||||
|
||||
// clean up
|
||||
FormClosed += ClosedHandler;
|
||||
|
||||
_capture = capture;
|
||||
_windows = windows;
|
||||
UsedCaptureMode = capture.CaptureDetails.CaptureMode;
|
||||
|
@ -136,7 +129,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
|
||||
// Set the zoomer animation
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
InitializeZoomer(_coreConfiguration.ZoomerEnabled);
|
||||
|
||||
SuspendLayout();
|
||||
Bounds = capture.ScreenBounds;
|
||||
|
@ -181,12 +174,6 @@ namespace Greenshot.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void ClosedHandler(object sender, EventArgs e)
|
||||
{
|
||||
Log.Debug().WriteLine("Remove CaptureForm from currentForm");
|
||||
_currentForm = null;
|
||||
}
|
||||
|
||||
private void ClosingHandler(object sender, EventArgs e)
|
||||
{
|
||||
Log.Debug().WriteLine("Closing captureform");
|
||||
|
@ -293,8 +280,8 @@ namespace Greenshot.Forms
|
|||
if (UsedCaptureMode == CaptureMode.Region)
|
||||
{
|
||||
// Toggle zoom
|
||||
Conf.ZoomerEnabled = !Conf.ZoomerEnabled;
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
_coreConfiguration.ZoomerEnabled = !_coreConfiguration.ZoomerEnabled;
|
||||
InitializeZoomer(_coreConfiguration.ZoomerEnabled);
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
|
@ -326,7 +313,7 @@ namespace Greenshot.Forms
|
|||
// "Fade out" window
|
||||
_windowAnimator.ChangeDestination(new NativeRect(_cursorPos, NativeSize.Empty), FramesForMillis(700));
|
||||
// Fade in zoom
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
InitializeZoomer(_coreConfiguration.ZoomerEnabled);
|
||||
_captureRect = Rectangle.Empty;
|
||||
Invalidate();
|
||||
break;
|
||||
|
@ -574,7 +561,7 @@ namespace Greenshot.Forms
|
|||
if (UsedCaptureMode == CaptureMode.Window)
|
||||
{
|
||||
// Recreate the WindowScroller, if this is enabled, so we can detect if we can scroll
|
||||
if (Conf.IsScrollingCaptureEnabled)
|
||||
if (_coreConfiguration.IsScrollingCaptureEnabled)
|
||||
{
|
||||
WindowScroller = SelectedCaptureWindow.GetWindowScroller(ScrollBarTypes.Vertical);
|
||||
if (WindowScroller == null)
|
||||
|
@ -702,7 +689,7 @@ namespace Greenshot.Forms
|
|||
invalidateRectangle = _zoomAnimator.Current.Offset(lastPos);
|
||||
Invalidate(invalidateRectangle);
|
||||
// Only verify if we are really showing the zoom, not the outgoing animation
|
||||
if (Conf.ZoomerEnabled && UsedCaptureMode != CaptureMode.Window)
|
||||
if (_coreConfiguration.ZoomerEnabled && UsedCaptureMode != CaptureMode.Window)
|
||||
{
|
||||
VerifyZoomAnimation(_cursorPos, false);
|
||||
}
|
||||
|
@ -799,7 +786,7 @@ namespace Greenshot.Forms
|
|||
//create a color matrix object to change the opacy
|
||||
var opacyMatrix = new ColorMatrix
|
||||
{
|
||||
Matrix33 = Conf.ZoomerOpacity
|
||||
Matrix33 = _coreConfiguration.ZoomerOpacity
|
||||
};
|
||||
attributes = new ImageAttributes();
|
||||
attributes.SetColorMatrix(opacyMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
|
@ -829,7 +816,7 @@ namespace Greenshot.Forms
|
|||
attributes);
|
||||
}
|
||||
}
|
||||
var alpha = (int) (255 * Conf.ZoomerOpacity);
|
||||
var alpha = (int) (255 * _coreConfiguration.ZoomerOpacity);
|
||||
var opacyWhite = Color.FromArgb(alpha, 255, 255, 255);
|
||||
var opacyBlack = Color.FromArgb(alpha, 0, 0, 0);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Language;
|
||||
using Dapplo.Log;
|
||||
using Greenshot.Addons.Core;
|
||||
|
||||
|
@ -64,7 +65,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
}
|
||||
|
||||
protected void FormLoad(object sender, EventArgs e)
|
||||
private void FormLoad(object sender, EventArgs e)
|
||||
{
|
||||
// Initialize the Language ComboBox
|
||||
comboBoxLanguage.DisplayMember = "Description";
|
||||
|
@ -72,12 +73,14 @@ namespace Greenshot.Forms
|
|||
|
||||
// Set datasource last to prevent problems
|
||||
// See: http://www.codeproject.com/KB/database/scomlistcontrolbinding.aspx?fid=111644
|
||||
comboBoxLanguage.DataSource = Language.SupportedLanguages;
|
||||
comboBoxLanguage.DataSource = LanguageLoader.Current.AvailableLanguages;
|
||||
|
||||
if (Language.CurrentLanguage != null)
|
||||
var currentLanguage = LanguageLoader.Current.CurrentLanguage;
|
||||
|
||||
if (currentLanguage != null)
|
||||
{
|
||||
Log.Debug().WriteLine("Selecting {0}", Language.CurrentLanguage);
|
||||
comboBoxLanguage.SelectedValue = Language.CurrentLanguage;
|
||||
Log.Debug().WriteLine("Selecting {0}", currentLanguage);
|
||||
comboBoxLanguage.SelectedValue = currentLanguage;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -86,13 +89,14 @@ namespace Greenshot.Forms
|
|||
|
||||
// Close again when there is only one language, this shows the form briefly!
|
||||
// But the use-case is not so interesting, only happens once, to invest a lot of time here.
|
||||
if (Language.SupportedLanguages.Count != 1)
|
||||
if (LanguageLoader.Current.AvailableLanguages.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
comboBoxLanguage.SelectedValue = Language.SupportedLanguages.Keys.FirstOrDefault();
|
||||
Language.CurrentLanguage = SelectedLanguage;
|
||||
comboBoxLanguage.SelectedValue = LanguageLoader.Current.AvailableLanguages.Keys.FirstOrDefault();
|
||||
// TODO: Check
|
||||
var ignoreTask = LanguageLoader.Current.ChangeLanguageAsync(SelectedLanguage);
|
||||
_properOkPressed = true;
|
||||
Close();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ using Dapplo.Windows.DesktopWindowsManager;
|
|||
using Dapplo.Windows.Dpi.Enums;
|
||||
using Dapplo.Windows.Dpi.Forms;
|
||||
using Dapplo.Windows.Kernel32;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
|
@ -68,7 +69,7 @@ namespace Greenshot.Forms
|
|||
/// <summary>
|
||||
/// Description of MainForm.
|
||||
/// </summary>
|
||||
public partial class MainForm : BaseForm
|
||||
public partial class MainForm : GreenshotForm
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
|
@ -77,8 +78,6 @@ namespace Greenshot.Forms
|
|||
|
||||
// Timer for the double click test
|
||||
private readonly Timer _doubleClickTimer = new Timer();
|
||||
// Make sure we have only one settings form
|
||||
private readonly Func<Owned<SettingsForm>> _settingsFormFactory;
|
||||
private readonly Func<Owned<AboutForm>> _aboutFormFactory;
|
||||
|
||||
private readonly DestinationHolder _destinationHolder;
|
||||
|
@ -89,15 +88,14 @@ namespace Greenshot.Forms
|
|||
|
||||
public MainForm(ICoreConfiguration coreConfiguration,
|
||||
IWindowManager windowManager,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ConfigViewModel configViewModel,
|
||||
Func<Owned<SettingsForm>> settingsFormFactory,
|
||||
Func<Owned<AboutForm>> aboutFormFactory,
|
||||
DestinationHolder destinationHolder)
|
||||
DestinationHolder destinationHolder) : base(greenshotLanguage)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
_windowManager = windowManager;
|
||||
_configViewModel = configViewModel;
|
||||
_settingsFormFactory = settingsFormFactory;
|
||||
_aboutFormFactory = aboutFormFactory;
|
||||
_destinationHolder = destinationHolder;
|
||||
Instance = this;
|
||||
|
@ -394,7 +392,7 @@ namespace Greenshot.Forms
|
|||
{
|
||||
case DpiChangeEventTypes.Before:
|
||||
// Change the ImageScalingSize before setting the bitmaps
|
||||
var width = DpiHandler.ScaleWithDpi(coreConfiguration.IconSize.Width, info.NewDpi);
|
||||
var width = DpiHandler.ScaleWithDpi(_coreConfiguration.IconSize.Width, info.NewDpi);
|
||||
var size = new Size(width, width);
|
||||
contextMenu.SuspendLayout();
|
||||
contextMenu.ImageScalingSize = size;
|
||||
|
@ -489,7 +487,7 @@ namespace Greenshot.Forms
|
|||
private void ContextMenuOpening(object sender, CancelEventArgs e)
|
||||
{
|
||||
contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage();
|
||||
contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != NativeRect.Empty;
|
||||
contextmenu_capturelastregion.Enabled = _coreConfiguration.LastCapturedRegion != NativeRect.Empty;
|
||||
|
||||
// IE context menu code
|
||||
try
|
||||
|
@ -848,16 +846,8 @@ namespace Greenshot.Forms
|
|||
{
|
||||
_windowManager.ShowDialog(_configViewModel);
|
||||
}
|
||||
|
||||
using (var settingsForm = _settingsFormFactory())
|
||||
{
|
||||
settingsForm.Value.Initialize();
|
||||
if (settingsForm.Value.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
InitializeQuickSettingsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "About Greenshot" entry is clicked
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -34,10 +36,16 @@ namespace Greenshot.Forms
|
|||
/// <summary>
|
||||
/// Description of PrintOptionsDialog.
|
||||
/// </summary>
|
||||
public partial class PrintOptionsDialog : BaseForm
|
||||
public partial class PrintOptionsDialog : GreenshotForm
|
||||
{
|
||||
public PrintOptionsDialog()
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
|
||||
public PrintOptionsDialog(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage
|
||||
) : base(greenshotLanguage)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -49,7 +57,7 @@ namespace Greenshot.Forms
|
|||
private void Button_okClick(object sender, EventArgs e)
|
||||
{
|
||||
// update config
|
||||
coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked;
|
||||
_coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
|
|
1376
src/Greenshot/Forms/SettingsForm.Designer.cs
generated
1376
src/Greenshot/Forms/SettingsForm.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -1,764 +0,0 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Common;
|
||||
using Dapplo.Windows.DesktopWindowsManager;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Controls;
|
||||
using Greenshot.Addons.Core;
|
||||
using Greenshot.Addons.Core.Enums;
|
||||
using Greenshot.Addons.Extensions;
|
||||
using Greenshot.Components;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Destinations;
|
||||
using Greenshot.Helpers;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of SettingsForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : BaseForm
|
||||
{
|
||||
private readonly DestinationHolder _destinationHolder;
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly ToolTip _toolTip = new ToolTip();
|
||||
private int _daysbetweencheckPreviousValue;
|
||||
private bool _inHotkey;
|
||||
|
||||
public SettingsForm(DestinationHolder destinationHolder)
|
||||
{
|
||||
_destinationHolder = destinationHolder;
|
||||
// Make sure the store isn't called to early, that's why we do it manually
|
||||
ManualStoreFields = true;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
// Fix for Vista/XP differences
|
||||
trackBarJpegQuality.BackColor = WindowsVersion.IsWindowsVistaOrLater ? SystemColors.Window : SystemColors.Control;
|
||||
|
||||
// This makes it possible to still capture the settings screen
|
||||
fullscreen_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
fullscreen_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
window_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
window_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
region_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
region_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
ie_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
ie_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
lastregion_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
lastregion_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
// Changes for BUG-2077
|
||||
numericUpDown_daysbetweencheck.ValueChanged += NumericUpDownDaysbetweencheckOnValueChanged;
|
||||
|
||||
_daysbetweencheckPreviousValue = (int) numericUpDown_daysbetweencheck.Value;
|
||||
UpdateUi();
|
||||
ExpertSettingsEnableState(false);
|
||||
DisplaySettings();
|
||||
CheckSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This makes sure the check cannot be set to 1-6
|
||||
/// </summary>
|
||||
/// <param name="sender">object</param>
|
||||
/// <param name="eventArgs">EventArgs</param>
|
||||
private void NumericUpDownDaysbetweencheckOnValueChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
var currentValue = (int) numericUpDown_daysbetweencheck.Value;
|
||||
|
||||
// Check if we can into the forbidden range
|
||||
if (currentValue > 0 && currentValue < 7)
|
||||
{
|
||||
if (_daysbetweencheckPreviousValue <= currentValue)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 0;
|
||||
}
|
||||
}
|
||||
if ((int) numericUpDown_daysbetweencheck.Value < 0)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 0;
|
||||
}
|
||||
if ((int) numericUpDown_daysbetweencheck.Value > 365)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 365;
|
||||
}
|
||||
_daysbetweencheckPreviousValue = (int) numericUpDown_daysbetweencheck.Value;
|
||||
}
|
||||
|
||||
private void EnterHotkeyControl(object sender, EventArgs e)
|
||||
{
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
_inHotkey = true;
|
||||
}
|
||||
|
||||
private void LeaveHotkeyControl(object sender, EventArgs e)
|
||||
{
|
||||
HotkeyHandler.RegisterHotkeys();
|
||||
_inHotkey = false;
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
switch (keyData)
|
||||
{
|
||||
case Keys.Escape:
|
||||
if (!_inHotkey)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a method to populate the ComboBox
|
||||
/// with the items from the enumeration
|
||||
/// </summary>
|
||||
/// <param name="comboBox">ComboBox to populate</param>
|
||||
/// <param name="availableValues"></param>
|
||||
/// <param name="selectedValue"></param>
|
||||
private void PopulateComboBox<TEnum>(ComboBox comboBox, TEnum[] availableValues, TEnum selectedValue) where TEnum : struct
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
foreach (var enumValue in availableValues)
|
||||
{
|
||||
comboBox.Items.Add(Language.Translate(enumValue));
|
||||
}
|
||||
comboBox.SelectedItem = Language.Translate(selectedValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the selected enum value from the combobox, uses generics
|
||||
/// </summary>
|
||||
/// <param name="comboBox">Combobox to get the value from</param>
|
||||
/// <returns>The generics value of the combobox</returns>
|
||||
private TEnum GetSelected<TEnum>(ComboBox comboBox)
|
||||
{
|
||||
var enumTypeName = typeof(TEnum).Name;
|
||||
var selectedValue = comboBox.SelectedItem as string;
|
||||
var availableValues = (TEnum[]) Enum.GetValues(typeof(TEnum));
|
||||
var returnValue = availableValues[0];
|
||||
foreach (var enumValue in availableValues)
|
||||
{
|
||||
var translation = Language.GetString(enumTypeName + "." + enumValue);
|
||||
if (translation.Equals(selectedValue))
|
||||
{
|
||||
returnValue = enumValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private void SetWindowCaptureMode(WindowCaptureModes selectedWindowCaptureMode)
|
||||
{
|
||||
WindowCaptureModes[] availableModes;
|
||||
if (!Dwm.IsDwmEnabled)
|
||||
{
|
||||
// Remove DWM from configuration, as DWM is disabled!
|
||||
if (coreConfiguration.WindowCaptureMode == WindowCaptureModes.Aero || coreConfiguration.WindowCaptureMode == WindowCaptureModes.AeroTransparent)
|
||||
{
|
||||
coreConfiguration.WindowCaptureMode = WindowCaptureModes.GDI;
|
||||
}
|
||||
availableModes = new[] {WindowCaptureModes.Auto, WindowCaptureModes.Screen, WindowCaptureModes.GDI};
|
||||
}
|
||||
else
|
||||
{
|
||||
availableModes = new[] {WindowCaptureModes.Auto, WindowCaptureModes.Screen, WindowCaptureModes.GDI, WindowCaptureModes.Aero, WindowCaptureModes.AeroTransparent};
|
||||
}
|
||||
PopulateComboBox(combobox_window_capture_mode, availableModes, selectedWindowCaptureMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add plugins to the Listview
|
||||
/// </summary>
|
||||
/// <param name="plugins"></param>
|
||||
/// <param name="listview"></param>
|
||||
private void FillListview(IEnumerable<Assembly> plugins, ListView listview)
|
||||
{
|
||||
foreach (var pluginAssembly in plugins)
|
||||
{
|
||||
var item = new ListViewItem(pluginAssembly.GetName().Name)
|
||||
{
|
||||
Tag = pluginAssembly
|
||||
};
|
||||
item.SubItems.Add(pluginAssembly.GetName().Version.ToString());
|
||||
item.SubItems.Add(pluginAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false).Cast<AssemblyCompanyAttribute>().FirstOrDefault()?.Company);
|
||||
item.SubItems.Add(pluginAssembly.Location);
|
||||
listview.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the UI to reflect the language and other text settings
|
||||
/// </summary>
|
||||
private void UpdateUi()
|
||||
{
|
||||
if (coreConfiguration.HideExpertSettings)
|
||||
{
|
||||
tabcontrol.Controls.Remove(tab_expert);
|
||||
}
|
||||
_toolTip.SetToolTip(label_language, Language.GetString(LangKey.settings_tooltip_language));
|
||||
_toolTip.SetToolTip(label_storagelocation, Language.GetString(LangKey.settings_tooltip_storagelocation));
|
||||
_toolTip.SetToolTip(label_screenshotname, Language.GetString(LangKey.settings_tooltip_filenamepattern));
|
||||
_toolTip.SetToolTip(label_primaryimageformat, Language.GetString(LangKey.settings_tooltip_primaryimageformat));
|
||||
|
||||
// Removing, otherwise we keep getting the event multiple times!
|
||||
combobox_language.SelectedIndexChanged -= Combobox_languageSelectedIndexChanged;
|
||||
|
||||
// Initialize the Language ComboBox
|
||||
combobox_language.DisplayMember = "Description";
|
||||
combobox_language.ValueMember = "Ietf";
|
||||
// Set datasource last to prevent problems
|
||||
// See: http://www.codeproject.com/KB/database/scomlistcontrolbinding.aspx?fid=111644
|
||||
combobox_language.DataSource = Language.SupportedLanguages;
|
||||
if (Language.CurrentLanguage != null)
|
||||
{
|
||||
combobox_language.SelectedValue = Language.CurrentLanguage;
|
||||
}
|
||||
|
||||
// Delaying the SelectedIndexChanged events untill all is initiated
|
||||
combobox_language.SelectedIndexChanged += Combobox_languageSelectedIndexChanged;
|
||||
UpdateDestinationDescriptions();
|
||||
UpdateClipboardFormatDescriptions();
|
||||
}
|
||||
|
||||
// Check the settings and somehow visibly mark when something is incorrect
|
||||
private bool CheckSettings()
|
||||
{
|
||||
return CheckFilenamePattern() && CheckStorageLocationPath();
|
||||
}
|
||||
|
||||
private bool CheckFilenamePattern()
|
||||
{
|
||||
var filename = FilenameHelper.GetFilenameFromPattern(textbox_screenshotname.Text, coreConfiguration.OutputFileFormat, null);
|
||||
// we allow dynamically created subfolders, need to check for them, too
|
||||
var pathParts = filename.Split(Path.DirectorySeparatorChar);
|
||||
|
||||
var filenamePart = pathParts[pathParts.Length - 1];
|
||||
var settingsOk = FilenameHelper.IsFilenameValid(filenamePart);
|
||||
|
||||
for (var i = 0; settingsOk && i < pathParts.Length - 1; i++)
|
||||
{
|
||||
settingsOk = FilenameHelper.IsDirectoryNameValid(pathParts[i]);
|
||||
}
|
||||
|
||||
DisplayTextBoxValidity(textbox_screenshotname, settingsOk);
|
||||
|
||||
return settingsOk;
|
||||
}
|
||||
|
||||
private bool CheckStorageLocationPath()
|
||||
{
|
||||
var settingsOk = Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false));
|
||||
DisplayTextBoxValidity(textbox_storagelocation, settingsOk);
|
||||
return settingsOk;
|
||||
}
|
||||
|
||||
private void DisplayTextBoxValidity(GreenshotTextBox textbox, bool valid)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
// "Added" feature #3547158
|
||||
textbox.BackColor = WindowsVersion.IsWindowsVistaOrLater ? SystemColors.Window : SystemColors.Control;
|
||||
}
|
||||
else
|
||||
{
|
||||
textbox.BackColor = Color.Red;
|
||||
}
|
||||
}
|
||||
|
||||
private void FilenamePatternChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckFilenamePattern();
|
||||
}
|
||||
|
||||
private void StorageLocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckStorageLocationPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show all destination descriptions in the current language
|
||||
/// </summary>
|
||||
private void UpdateDestinationDescriptions()
|
||||
{
|
||||
foreach (ListViewItem item in listview_destinations.Items)
|
||||
{
|
||||
if (item.Tag is IDestination destinationFromTag)
|
||||
{
|
||||
item.Text = destinationFromTag.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show all clipboard format descriptions in the current language
|
||||
/// </summary>
|
||||
private void UpdateClipboardFormatDescriptions()
|
||||
{
|
||||
foreach (ListViewItem item in listview_clipboardformats.Items)
|
||||
{
|
||||
var cf = (ClipboardFormats) item.Tag;
|
||||
item.Text = Language.Translate(cf);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build the view with all the destinations
|
||||
/// </summary>
|
||||
private void DisplayDestinations()
|
||||
{
|
||||
var destinationsEnabled = !coreConfiguration.IsWriteProtected("Destinations");
|
||||
checkbox_picker.Checked = false;
|
||||
|
||||
listview_destinations.Items.Clear();
|
||||
var imageList = new ImageList();
|
||||
listview_destinations.SmallImageList = imageList;
|
||||
var imageNr = -1;
|
||||
foreach (var currentDestination in _destinationHolder.SortedActiveDestinations)
|
||||
{
|
||||
var destinationImage = currentDestination.GetDisplayIcon(DpiHandler.Dpi);
|
||||
if (destinationImage != null)
|
||||
{
|
||||
imageList.Images.Add(destinationImage);
|
||||
imageNr++;
|
||||
}
|
||||
if (typeof(PickerDestination).GetDesignation().Equals(currentDestination.Designation))
|
||||
{
|
||||
checkbox_picker.Checked = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
||||
checkbox_picker.Text = currentDestination.Description;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListViewItem item;
|
||||
if (destinationImage != null)
|
||||
{
|
||||
item = listview_destinations.Items.Add(currentDestination.Description, imageNr);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = listview_destinations.Items.Add(currentDestination.Description);
|
||||
}
|
||||
item.Tag = currentDestination;
|
||||
item.Checked = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
||||
}
|
||||
}
|
||||
if (checkbox_picker.Checked)
|
||||
{
|
||||
listview_destinations.Enabled = false;
|
||||
foreach (int index in listview_destinations.CheckedIndices)
|
||||
{
|
||||
var item = listview_destinations.Items[index];
|
||||
item.Checked = false;
|
||||
}
|
||||
}
|
||||
checkbox_picker.Enabled = destinationsEnabled;
|
||||
listview_destinations.Enabled = destinationsEnabled;
|
||||
}
|
||||
|
||||
private void DisplaySettings()
|
||||
{
|
||||
colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;
|
||||
|
||||
// Expert mode, the clipboard formats
|
||||
foreach (ClipboardFormats clipboardFormat in Enum.GetValues(typeof(ClipboardFormats)))
|
||||
{
|
||||
var item = listview_clipboardformats.Items.Add(Language.Translate(clipboardFormat));
|
||||
item.Tag = clipboardFormat;
|
||||
item.Checked = coreConfiguration.ClipboardFormats.Contains(clipboardFormat);
|
||||
}
|
||||
|
||||
if (Language.CurrentLanguage != null)
|
||||
{
|
||||
combobox_language.SelectedValue = Language.CurrentLanguage;
|
||||
}
|
||||
// Disable editing when the value is fixed
|
||||
combobox_language.Enabled = !coreConfiguration.IsWriteProtected("Language");
|
||||
|
||||
textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);
|
||||
// Disable editing when the value is fixed
|
||||
textbox_storagelocation.Enabled = !coreConfiguration.IsWriteProtected("OutputFilePath");
|
||||
|
||||
SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);
|
||||
// Disable editing when the value is fixed
|
||||
combobox_window_capture_mode.Enabled = !coreConfiguration.CaptureWindowsInteractive && !coreConfiguration.IsWriteProtected("WindowCaptureMode");
|
||||
radiobuttonWindowCapture.Checked = !coreConfiguration.CaptureWindowsInteractive;
|
||||
|
||||
trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality;
|
||||
trackBarJpegQuality.Enabled = !coreConfiguration.IsWriteProtected("OutputFileJpegQuality");
|
||||
textBoxJpegQuality.Text = $"{coreConfiguration.OutputFileJpegQuality}%";
|
||||
|
||||
DisplayDestinations();
|
||||
|
||||
numericUpDownWaitTime.Value = coreConfiguration.CaptureDelay >= 0 ? coreConfiguration.CaptureDelay : 0;
|
||||
numericUpDownWaitTime.Enabled = !coreConfiguration.IsWriteProtected("CaptureDelay");
|
||||
if (coreConfiguration.IsPortable)
|
||||
{
|
||||
checkbox_autostartshortcut.Visible = false;
|
||||
checkbox_autostartshortcut.Checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Autostart checkbox logic.
|
||||
if (StartupHelper.HasRunAll())
|
||||
{
|
||||
// Remove runUser if we already have a run under all
|
||||
StartupHelper.DeleteRunUser();
|
||||
checkbox_autostartshortcut.Enabled = StartupHelper.CanWriteRunAll();
|
||||
checkbox_autostartshortcut.Checked = true; // We already checked this
|
||||
}
|
||||
else if (StartupHelper.IsInStartupFolder())
|
||||
{
|
||||
checkbox_autostartshortcut.Enabled = false;
|
||||
checkbox_autostartshortcut.Checked = true; // We already checked this
|
||||
}
|
||||
else
|
||||
{
|
||||
// No run for all, enable the checkbox and set it to true if the current user has a key
|
||||
checkbox_autostartshortcut.Enabled = StartupHelper.CanWriteRunUser();
|
||||
checkbox_autostartshortcut.Checked = StartupHelper.HasRunUser();
|
||||
}
|
||||
}
|
||||
|
||||
numericUpDown_daysbetweencheck.Value = coreConfiguration.UpdateCheckInterval;
|
||||
numericUpDown_daysbetweencheck.Enabled = !coreConfiguration.IsWriteProtected("UpdateCheckInterval");
|
||||
numericUpdownIconSize.Value = coreConfiguration.IconSize.Width / 16 * 16;
|
||||
CheckDestinationSettings();
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
if (combobox_language.SelectedItem != null)
|
||||
{
|
||||
var newLang = combobox_language.SelectedValue.ToString();
|
||||
if (!string.IsNullOrEmpty(newLang))
|
||||
{
|
||||
coreConfiguration.Language = combobox_language.SelectedValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve the set clipboard formats
|
||||
var clipboardFormats = new List<ClipboardFormats>();
|
||||
foreach (int index in listview_clipboardformats.CheckedIndices)
|
||||
{
|
||||
var item = listview_clipboardformats.Items[index];
|
||||
if (item.Checked)
|
||||
{
|
||||
clipboardFormats.Add((ClipboardFormats) item.Tag);
|
||||
}
|
||||
}
|
||||
coreConfiguration.ClipboardFormats = clipboardFormats;
|
||||
|
||||
coreConfiguration.WindowCaptureMode = GetSelected<WindowCaptureModes>(combobox_window_capture_mode);
|
||||
if (!FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false).Equals(textbox_storagelocation.Text))
|
||||
{
|
||||
coreConfiguration.OutputFilePath = textbox_storagelocation.Text;
|
||||
}
|
||||
coreConfiguration.OutputFileJpegQuality = trackBarJpegQuality.Value;
|
||||
|
||||
var destinations = new List<string>();
|
||||
if (checkbox_picker.Checked)
|
||||
{
|
||||
destinations.Add(typeof(PickerDestination).GetDesignation());
|
||||
}
|
||||
foreach (int index in listview_destinations.CheckedIndices)
|
||||
{
|
||||
var item = listview_destinations.Items[index];
|
||||
|
||||
var destinationFromTag = item.Tag as IDestination;
|
||||
if (item.Checked && destinationFromTag != null)
|
||||
{
|
||||
destinations.Add(destinationFromTag.Designation);
|
||||
}
|
||||
}
|
||||
coreConfiguration.OutputDestinations = destinations;
|
||||
coreConfiguration.CaptureDelay = (int) numericUpDownWaitTime.Value;
|
||||
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
|
||||
coreConfiguration.UpdateCheckInterval = (int) numericUpDown_daysbetweencheck.Value;
|
||||
|
||||
coreConfiguration.IconSize = new Size((int) numericUpdownIconSize.Value, (int) numericUpdownIconSize.Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (checkbox_autostartshortcut.Checked)
|
||||
{
|
||||
// It's checked, so we set the RunUser if the RunAll isn't set.
|
||||
// Do this every time, so the executable is correct.
|
||||
if (!StartupHelper.HasRunAll())
|
||||
{
|
||||
StartupHelper.SetRunUser();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Delete both settings if it's unchecked
|
||||
if (StartupHelper.HasRunAll())
|
||||
{
|
||||
StartupHelper.DeleteRunAll();
|
||||
}
|
||||
if (StartupHelper.HasRunUser())
|
||||
{
|
||||
StartupHelper.DeleteRunUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warn().WriteLine(e, "Problem checking registry, ignoring for now: ");
|
||||
}
|
||||
}
|
||||
|
||||
private void Settings_cancelClick(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void Settings_okayClick(object sender, EventArgs e)
|
||||
{
|
||||
if (CheckSettings())
|
||||
{
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
SaveSettings();
|
||||
StoreFields();
|
||||
HotkeyHandler.RegisterHotkeys();
|
||||
|
||||
// Make sure the current language & settings are reflected in the Main-context menu
|
||||
MainForm.Instance.UpdateUi();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabcontrol.SelectTab(tab_output);
|
||||
}
|
||||
}
|
||||
|
||||
private void BrowseClick(object sender, EventArgs e)
|
||||
{
|
||||
// Get the storage location and replace the environment variables
|
||||
folderBrowserDialog1.SelectedPath = FilenameHelper.FillVariables(textbox_storagelocation.Text, false);
|
||||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Only change if there is a change, otherwise we might overwrite the environment variables
|
||||
if (folderBrowserDialog1.SelectedPath != null && !folderBrowserDialog1.SelectedPath.Equals(FilenameHelper.FillVariables(textbox_storagelocation.Text, false)))
|
||||
{
|
||||
textbox_storagelocation.Text = folderBrowserDialog1.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TrackBarJpegQualityScroll(object sender, EventArgs e)
|
||||
{
|
||||
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
|
||||
private void BtnPatternHelpClick(object sender, EventArgs e)
|
||||
{
|
||||
var filenamepatternText = Language.GetString(LangKey.settings_message_filenamepattern);
|
||||
// Convert %NUM% to ${NUM} for old language files!
|
||||
filenamepatternText = Regex.Replace(filenamepatternText, "%([a-zA-Z_0-9]+)%", @"${$1}");
|
||||
MessageBox.Show(filenamepatternText, Language.GetString(LangKey.settings_filenamepattern));
|
||||
}
|
||||
|
||||
private void Listview_pluginsSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: Configure
|
||||
//button_pluginconfigure.Enabled = PluginHelper.Instance.IsSelectedItemConfigurable(listview_plugins);
|
||||
}
|
||||
|
||||
private void Button_pluginconfigureClick(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: Configure
|
||||
//PluginHelper.Instance.ConfigureSelectedItem(listview_plugins);
|
||||
}
|
||||
|
||||
private void Combobox_languageSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Get the combobox values BEFORE changing the language
|
||||
//EmailFormat selectedEmailFormat = GetSelected<EmailFormat>(combobox_emailformat);
|
||||
var selectedWindowCaptureMode = GetSelected<WindowCaptureModes>(combobox_window_capture_mode);
|
||||
if (combobox_language.SelectedItem != null)
|
||||
{
|
||||
Log.Debug().WriteLine("Setting language to: " + (string) combobox_language.SelectedValue);
|
||||
Language.CurrentLanguage = (string) combobox_language.SelectedValue;
|
||||
}
|
||||
// Reflect language changes to the settings form
|
||||
UpdateUi();
|
||||
|
||||
// Reflect Language changes form
|
||||
ApplyLanguage();
|
||||
|
||||
// Update the email & windows capture mode
|
||||
//SetEmailFormat(selectedEmailFormat);
|
||||
SetWindowCaptureMode(selectedWindowCaptureMode);
|
||||
}
|
||||
|
||||
private void Combobox_window_capture_modeSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var mode = GetSelected<WindowCaptureModes>(combobox_window_capture_mode);
|
||||
if (WindowsVersion.IsWindowsVistaOrLater)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case WindowCaptureModes.Aero:
|
||||
colorButton_window_background.Visible = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
colorButton_window_background.Visible = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the destination settings
|
||||
/// </summary>
|
||||
private void CheckDestinationSettings()
|
||||
{
|
||||
var clipboardDestinationChecked = false;
|
||||
var pickerSelected = checkbox_picker.Checked;
|
||||
var destinationsEnabled = !coreConfiguration.IsWriteProtected("Destinations");
|
||||
listview_destinations.Enabled = destinationsEnabled;
|
||||
|
||||
foreach (int index in listview_destinations.CheckedIndices)
|
||||
{
|
||||
var item = listview_destinations.Items[index];
|
||||
if (!(item.Tag is IDestination destinationFromTag) ||
|
||||
!destinationFromTag.Designation.Equals(typeof(ClipboardDestination).GetDesignation()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
clipboardDestinationChecked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pickerSelected)
|
||||
{
|
||||
listview_destinations.Enabled = false;
|
||||
foreach (int index in listview_destinations.CheckedIndices)
|
||||
{
|
||||
var item = listview_destinations.Items[index];
|
||||
item.Checked = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Prevent multiple clipboard settings at once, see bug #3435056
|
||||
if (clipboardDestinationChecked)
|
||||
{
|
||||
checkbox_copypathtoclipboard.Checked = false;
|
||||
checkbox_copypathtoclipboard.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkbox_copypathtoclipboard.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DestinationsCheckStateChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckDestinationSettings();
|
||||
}
|
||||
|
||||
protected override void OnFieldsFilled()
|
||||
{
|
||||
// the color radio button is not actually bound to a setting, but checked when monochrome/grayscale are not checked
|
||||
if (!radioBtnGrayScale.Checked && !radioBtnMonochrome.Checked)
|
||||
{
|
||||
radioBtnColorPrint.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the enable state of the expert settings
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
private void ExpertSettingsEnableState(bool state)
|
||||
{
|
||||
listview_clipboardformats.Enabled = state;
|
||||
checkbox_autoreducecolors.Enabled = state;
|
||||
checkbox_optimizeforrdp.Enabled = state;
|
||||
checkbox_thumbnailpreview.Enabled = state;
|
||||
textbox_footerpattern.Enabled = state;
|
||||
textbox_counter.Enabled = state;
|
||||
checkbox_suppresssavedialogatclose.Enabled = state;
|
||||
checkbox_checkunstableupdates.Enabled = state;
|
||||
checkbox_minimizememoryfootprint.Enabled = state;
|
||||
checkbox_reuseeditor.Enabled = state;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called if the "I know what I am doing" on the settings form is changed
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CheckboxEnableExpertCheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is CheckBox checkBox)
|
||||
{
|
||||
ExpertSettingsEnableState(checkBox.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
private void Radiobutton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
combobox_window_capture_mode.Enabled = radiobuttonWindowCapture.Checked;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>116, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="colorButton_window_background.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABcAAAAYCAYAAAARfGZ1AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAACF0lE
|
||||
QVRIS7XT327SYBjH8ecOvAVvwXgHnngFxMQTPTE6zeaBi908MU6m4UCncWjAEVmN2Az8s25DibjF1VEd
|
||||
FaJkEUQsE9bZjbG4RWMW4Cd9E5YKpR6QNvkmTfo+nzRPWlqtAk5FaqUBp6JCE3cqym824FSU0xuwS1zM
|
||||
wht8jofTsu05K4M+/2jALn8oiuS3PfRfdGP0No/QnGJ73mzRynoddk0IMXgnRXAch2q1iqGr4wg+S9jO
|
||||
tDzKrNXRrbm3eQZXKhWGy7IMTdvAyT4OE1MLXedaHn1s4la1YF3XIUkSw8PhMEQxilRKxbnBEZxyF3Dn
|
||||
6U/LecOkdLmO9lqwpmnI5XLw+XxQFAUezw0EAhEEgyLy+S2cv/wIx4ZVTMa2OwzDpA/fa2jPWEWpVGKw
|
||||
sQqe5+FyuZr4XQbPziZQLv/CrfthHO1L4/illQ7DMCm5WkN7xlehqiqD4/E4W0XrjQ24WNxh8Iz0BYdd
|
||||
r1hWjiUeiioYdnuRSMgdcKFQxZh/Co+jSQYePCKwLPHlYg1W8eI79HPXIAgv91eRzW7APfYAT+Kf9mcO
|
||||
HLqHAc+ypUFLX/fQrUBkEWcvXMH8fBqZzBoGhq6Db/6p5vOnR6Su87SQ/QO7fMJrnDgzyDLu/3fe/Jxi
|
||||
md9wKhJTuzCHHi+zRZH3OzDXo/2PRaGlbZjrFTdbFHyzBacif3wTTkXjL3Q4Fd2cWYdT/QX1oojdNG2w
|
||||
yQAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
|
@ -237,9 +237,6 @@
|
|||
<Compile Include="Forms\CaptureForm.Designer.cs">
|
||||
<DependentUpon>CaptureForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\AnimatingBaseForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\LanguageDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -258,12 +255,6 @@
|
|||
<Compile Include="Forms\PrintOptionsDialog.Designer.cs">
|
||||
<DependentUpon>PrintOptionsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.Designer.cs">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ToolStripMenuSelectList.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
@ -307,9 +298,6 @@
|
|||
<EmbeddedResource Include="Forms\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sounds.resx" />
|
||||
<None Include="greenshot.manifest" />
|
||||
<None Include="Languages\Help\help-en-US.html">
|
||||
|
|
|
@ -70,11 +70,6 @@ namespace Greenshot
|
|||
.RegisterType<AboutForm>()
|
||||
.AsSelf();
|
||||
|
||||
// TODO: Should be removed
|
||||
builder
|
||||
.RegisterType<SettingsForm>()
|
||||
.AsSelf();
|
||||
|
||||
// Configuration
|
||||
builder
|
||||
.RegisterAssemblyTypes(ThisAssembly)
|
||||
|
|
|
@ -1100,7 +1100,7 @@ namespace Greenshot.Helpers
|
|||
// }
|
||||
//}
|
||||
|
||||
using (var captureForm = new CaptureForm(_capture, _windows))
|
||||
using (var captureForm = new CaptureForm(CoreConfig, _capture, _windows))
|
||||
{
|
||||
// Make sure the form is hidden after showing, even if an exception occurs, so all errors will be shown
|
||||
DialogResult result;
|
||||
|
|
|
@ -28,10 +28,10 @@ using System.Drawing;
|
|||
using System.Drawing.Printing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Forms;
|
||||
using Dapplo.Ini;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Common.Extensions;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Core;
|
||||
using Greenshot.Addons.Core.Enums;
|
||||
using Greenshot.Addons.Interfaces;
|
||||
|
@ -50,19 +50,27 @@ namespace Greenshot.Helpers
|
|||
public class PrintHelper : IDisposable
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private static readonly ICoreConfiguration CoreConfig = IniConfig.Current.Get<ICoreConfiguration>();
|
||||
private readonly ICoreConfiguration _coreConfig;
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
private readonly ICaptureDetails _captureDetails;
|
||||
private PrintDialog _printDialog = new PrintDialog();
|
||||
private PrintDocument _printDocument = new PrintDocument();
|
||||
|
||||
private ISurface _surface;
|
||||
|
||||
public PrintHelper(ISurface surface, ICaptureDetails captureDetails)
|
||||
public PrintHelper(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ISurface surface,
|
||||
ICaptureDetails captureDetails)
|
||||
{
|
||||
_coreConfig = coreConfiguration;
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
|
||||
_surface = surface;
|
||||
_captureDetails = captureDetails;
|
||||
_printDialog.UseEXDialog = true;
|
||||
_printDocument.DocumentName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfig.OutputFileFilenamePattern, captureDetails);
|
||||
_printDocument.DocumentName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConfiguration.OutputFileFilenamePattern, captureDetails);
|
||||
_printDocument.PrintPage += DrawImageForPrint;
|
||||
_printDialog.Document = _printDocument;
|
||||
}
|
||||
|
@ -168,7 +176,7 @@ namespace Greenshot.Helpers
|
|||
|
||||
private bool IsColorPrint()
|
||||
{
|
||||
return !CoreConfig.OutputPrintGrayscale && !CoreConfig.OutputPrintMonochrome;
|
||||
return !_coreConfig.OutputPrintGrayscale && !_coreConfig.OutputPrintMonochrome;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -177,16 +185,16 @@ namespace Greenshot.Helpers
|
|||
/// <returns>result of the print dialog, or null if the dialog has not been displayed by config</returns>
|
||||
private DialogResult? ShowPrintOptionsDialog()
|
||||
{
|
||||
DialogResult? ret = null;
|
||||
if (CoreConfig.OutputPrintPromptOptions)
|
||||
if (!_coreConfig.OutputPrintPromptOptions)
|
||||
{
|
||||
using (var printOptionsDialog = new PrintOptionsDialog())
|
||||
return null;
|
||||
}
|
||||
|
||||
using (var printOptionsDialog = new PrintOptionsDialog(_coreConfig, _greenshotLanguage))
|
||||
{
|
||||
ret = printOptionsDialog.ShowDialog();
|
||||
return printOptionsDialog.ShowDialog();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void DrawImageForPrint(object sender, PrintPageEventArgs e)
|
||||
{
|
||||
|
@ -198,15 +206,15 @@ namespace Greenshot.Helpers
|
|||
var disposeImage = ImageOutput.CreateBitmapFromSurface(_surface, printOutputSettings, out var bitmap);
|
||||
try
|
||||
{
|
||||
var alignment = CoreConfig.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
|
||||
var alignment = _coreConfig.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
|
||||
|
||||
// prepare timestamp
|
||||
float footerStringWidth = 0;
|
||||
float footerStringHeight = 0;
|
||||
string footerString = null; //DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
|
||||
if (CoreConfig.OutputPrintFooter)
|
||||
if (_coreConfig.OutputPrintFooter)
|
||||
{
|
||||
footerString = FilenameHelper.FillPattern(CoreConfig.OutputPrintFooterPattern, _captureDetails, false);
|
||||
footerString = FilenameHelper.FillPattern(_coreConfig.OutputPrintFooterPattern, _captureDetails, false);
|
||||
using (var f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular))
|
||||
{
|
||||
footerStringWidth = e.Graphics.MeasureString(footerString, f).Width;
|
||||
|
@ -229,7 +237,7 @@ namespace Greenshot.Helpers
|
|||
var gu = GraphicsUnit.Pixel;
|
||||
var imageRect = bitmap.GetBounds(ref gu);
|
||||
// rotate the image if it fits the page better
|
||||
if (CoreConfig.OutputPrintAllowRotate)
|
||||
if (_coreConfig.OutputPrintAllowRotate)
|
||||
{
|
||||
if (pageRect.Width > pageRect.Height && imageRect.Width < imageRect.Height || pageRect.Width < pageRect.Height && imageRect.Width > imageRect.Height)
|
||||
{
|
||||
|
@ -244,10 +252,10 @@ namespace Greenshot.Helpers
|
|||
NativeSizeFloat size = imageRect.Size;
|
||||
var printRect = new NativeRect(0, 0, size.Round());
|
||||
// scale the image to fit the page better
|
||||
if (CoreConfig.OutputPrintAllowEnlarge || CoreConfig.OutputPrintAllowShrink)
|
||||
if (_coreConfig.OutputPrintAllowEnlarge || _coreConfig.OutputPrintAllowShrink)
|
||||
{
|
||||
var resizedRect = ScaleHelper.GetScaledSize(imageRect.Size, pageRect.Size, false);
|
||||
if (CoreConfig.OutputPrintAllowShrink && resizedRect.Width < printRect.Width || CoreConfig.OutputPrintAllowEnlarge && resizedRect.Width > printRect.Width)
|
||||
if (_coreConfig.OutputPrintAllowShrink && resizedRect.Width < printRect.Width || _coreConfig.OutputPrintAllowEnlarge && resizedRect.Width > printRect.Width)
|
||||
{
|
||||
printRect = printRect.Resize(resizedRect.Round());
|
||||
}
|
||||
|
@ -255,7 +263,7 @@ namespace Greenshot.Helpers
|
|||
|
||||
// align the image
|
||||
printRect = ScaleHelper.GetAlignedRectangle(printRect, new NativeRect(0, 0, new NativeSizeFloat(pageRect.Width, pageRect.Height).Round()), alignment).Round();
|
||||
if (CoreConfig.OutputPrintFooter)
|
||||
if (_coreConfig.OutputPrintFooter)
|
||||
{
|
||||
//printRect = new NativeRect(0, 0, printRect.Width, printRect.Height - (dateStringHeight * 2));
|
||||
using (var f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular))
|
||||
|
@ -278,15 +286,15 @@ namespace Greenshot.Helpers
|
|||
{
|
||||
// TODO:
|
||||
// add effects here
|
||||
if (CoreConfig.OutputPrintMonochrome)
|
||||
if (_coreConfig.OutputPrintMonochrome)
|
||||
{
|
||||
var threshold = CoreConfig.OutputPrintMonochromeThreshold;
|
||||
var threshold = _coreConfig.OutputPrintMonochromeThreshold;
|
||||
printOutputSettings.Effects.Add(new MonochromeEffect(threshold));
|
||||
printOutputSettings.ReduceColors = true;
|
||||
}
|
||||
|
||||
// the invert effect should probably be the last
|
||||
if (CoreConfig.OutputPrintInverted)
|
||||
if (_coreConfig.OutputPrintInverted)
|
||||
{
|
||||
printOutputSettings.Effects.Add(new InvertEffect());
|
||||
}
|
||||
|
|
|
@ -79,11 +79,8 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\Greenshot.Addon.OCR"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\Greenshot.Addon.OCR"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName).config" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\Greenshot.Addon.OCR
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"
|
||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName).config" "$(SolutionDir)Greenshot\bin\$(Configuration)\Addons\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue