mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 22:13:23 -07:00
Added ability to hide destinations from the picker context menu.
This commit is contained in:
parent
a3e65fee6f
commit
cf24388b08
5 changed files with 1465 additions and 1269 deletions
|
@ -212,6 +212,9 @@ namespace Greenshot.Base.Core
|
||||||
[IniProperty("ExcludeDestinations", Description = "Comma separated list of destinations which should be disabled.")]
|
[IniProperty("ExcludeDestinations", Description = "Comma separated list of destinations which should be disabled.")]
|
||||||
public List<string> ExcludeDestinations { get; set; }
|
public List<string> ExcludeDestinations { get; set; }
|
||||||
|
|
||||||
|
[IniProperty("HiddenDestinations", Description = "Comma separated list of destinations which should be hidden.")]
|
||||||
|
public List<string> HiddenDestinations { get; set; }
|
||||||
|
|
||||||
[IniProperty("UpdateCheckInterval", Description = "How many days between every update check? (0=no checks)", DefaultValue = "14")]
|
[IniProperty("UpdateCheckInterval", Description = "How many days between every update check? (0=no checks)", DefaultValue = "14")]
|
||||||
public int UpdateCheckInterval { get; set; }
|
public int UpdateCheckInterval { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,16 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method to get all the destinations from the plugins
|
/// Method to get all the destinations from the plugins
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="excludeHidden">Whether or not to excluded hidden destinations. Default is false.</param>
|
||||||
/// <returns>List of IDestination</returns>
|
/// <returns>List of IDestination</returns>
|
||||||
public static IEnumerable<IDestination> GetAllDestinations()
|
public static IEnumerable<IDestination> GetAllDestinations(bool excludeHidden = false)
|
||||||
{
|
{
|
||||||
return SimpleServiceProvider.Current.GetAllInstances<IDestination>()
|
return SimpleServiceProvider.Current.GetAllInstances<IDestination>()
|
||||||
.Where(destination => destination.IsActive)
|
.Where(destination => destination.IsActive)
|
||||||
.Where(destination => CoreConfig.ExcludeDestinations == null ||
|
.Where(destination => !excludeHidden || CoreConfig.HiddenDestinations == null || !CoreConfig.HiddenDestinations.Contains(destination.Designation))
|
||||||
!CoreConfig.ExcludeDestinations.Contains(destination.Designation)).OrderBy(p => p.Priority).ThenBy(p => p.Description);
|
.Where(destination => CoreConfig.ExcludeDestinations == null || !CoreConfig.ExcludeDestinations.Contains(destination.Designation))
|
||||||
|
.OrderBy(p => p.Priority)
|
||||||
|
.ThenBy(p => p.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Greenshot.Base;
|
using Greenshot.Base;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
|
@ -38,6 +40,7 @@ namespace Greenshot.Destinations
|
||||||
|
|
||||||
public override int Priority => 1;
|
public override int Priority => 1;
|
||||||
|
|
||||||
|
private readonly Func<IDestination, bool> _isNotPickerPredicate = (destination) => !destination.Designation.Equals(nameof(WellKnownDestinations.Picker));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Export the capture with the destination picker
|
/// Export the capture with the destination picker
|
||||||
|
@ -48,22 +51,9 @@ namespace Greenshot.Destinations
|
||||||
/// <returns>true if export was made</returns>
|
/// <returns>true if export was made</returns>
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
|
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
|
||||||
{
|
{
|
||||||
List<IDestination> destinations = new List<IDestination>();
|
List<IDestination> destinations = DestinationHelper.GetAllDestinations(true)
|
||||||
|
.Where(_isNotPickerPredicate)
|
||||||
foreach (var destination in SimpleServiceProvider.Current.GetAllInstances<IDestination>())
|
.ToList();
|
||||||
{
|
|
||||||
if ("Picker".Equals(destination.Designation))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!destination.IsActive)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
destinations.Add(destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No Processing, this is done in the selected destination (if anything was selected)
|
// No Processing, this is done in the selected destination (if anything was selected)
|
||||||
return ShowPickerMenu(true, surface, captureDetails, destinations);
|
return ShowPickerMenu(true, surface, captureDetails, destinations);
|
||||||
|
|
2638
src/Greenshot/Forms/SettingsForm.Designer.cs
generated
2638
src/Greenshot/Forms/SettingsForm.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -28,6 +28,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.DesktopWindowsManager;
|
using Dapplo.Windows.DesktopWindowsManager;
|
||||||
using Dapplo.Windows.Dpi;
|
using Dapplo.Windows.Dpi;
|
||||||
using Greenshot.Base;
|
using Greenshot.Base;
|
||||||
|
@ -52,6 +53,7 @@ namespace Greenshot.Forms
|
||||||
private readonly ToolTip _toolTip = new ToolTip();
|
private readonly ToolTip _toolTip = new ToolTip();
|
||||||
private bool _inHotkey;
|
private bool _inHotkey;
|
||||||
private int _daysBetweenCheckPreviousValue;
|
private int _daysBetweenCheckPreviousValue;
|
||||||
|
private readonly NativeSize _scaledIconSize;
|
||||||
|
|
||||||
public SettingsForm()
|
public SettingsForm()
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,10 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
// Make sure the store isn't called to early, that's why we do it manually
|
// Make sure the store isn't called to early, that's why we do it manually
|
||||||
ManualStoreFields = true;
|
ManualStoreFields = true;
|
||||||
|
|
||||||
|
// Precalculate icon size.
|
||||||
|
//TODO: This might be worth moving to a global service so that the entire UI can use it, rather than re-calculating on each form.
|
||||||
|
_scaledIconSize = DpiCalculator.ScaleWithDpi(coreConfiguration.IconSize, NativeDpiMethods.GetDpi(Handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -421,21 +427,27 @@ namespace Greenshot.Forms
|
||||||
checkbox_picker.Checked = false;
|
checkbox_picker.Checked = false;
|
||||||
|
|
||||||
listview_destinations.Items.Clear();
|
listview_destinations.Items.Clear();
|
||||||
var scaledIconSize = DpiCalculator.ScaleWithDpi(coreConfiguration.IconSize, NativeDpiMethods.GetDpi(Handle));
|
|
||||||
listview_destinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
listview_destinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
||||||
|
|
||||||
|
listview_hiddenDestinations.Items.Clear();
|
||||||
|
listview_hiddenDestinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
||||||
|
|
||||||
ImageList imageList = new ImageList
|
ImageList imageList = new ImageList
|
||||||
{
|
{
|
||||||
ImageSize = scaledIconSize
|
ImageSize = _scaledIconSize
|
||||||
};
|
};
|
||||||
|
|
||||||
listview_destinations.SmallImageList = imageList;
|
listview_destinations.SmallImageList = imageList;
|
||||||
int imageNr = -1;
|
listview_hiddenDestinations.SmallImageList = imageList;
|
||||||
|
|
||||||
|
int currentImageIndex = -1;
|
||||||
foreach (IDestination currentDestination in DestinationHelper.GetAllDestinations())
|
foreach (IDestination currentDestination in DestinationHelper.GetAllDestinations())
|
||||||
{
|
{
|
||||||
Image destinationImage = currentDestination.DisplayIcon;
|
Image destinationImage = currentDestination.DisplayIcon;
|
||||||
if (destinationImage != null)
|
if (destinationImage != null)
|
||||||
{
|
{
|
||||||
imageList.Images.Add(currentDestination.DisplayIcon);
|
imageList.Images.Add(currentDestination.DisplayIcon);
|
||||||
imageNr++;
|
currentImageIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameof(WellKnownDestinations.Picker).Equals(currentDestination.Designation))
|
if (nameof(WellKnownDestinations.Picker).Equals(currentDestination.Designation))
|
||||||
|
@ -445,18 +457,12 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ListViewItem item;
|
bool isSelected = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
||||||
if (destinationImage != null)
|
bool isHidden = coreConfiguration.HiddenDestinations.Contains(currentDestination.Designation);
|
||||||
{
|
int? imageIndex = destinationImage != null ? currentImageIndex : null;
|
||||||
item = listview_destinations.Items.Add(currentDestination.Description, imageNr);
|
|
||||||
}
|
listview_destinations.Items.Add(CreateDestinationListViewItem(currentDestination, isSelected, imageIndex));
|
||||||
else
|
listview_hiddenDestinations.Items.Add(CreateDestinationListViewItem(currentDestination, isHidden, imageIndex));
|
||||||
{
|
|
||||||
item = listview_destinations.Items.Add(currentDestination.Description);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.Tag = currentDestination;
|
|
||||||
item.Checked = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,6 +480,17 @@ namespace Greenshot.Forms
|
||||||
listview_destinations.Enabled = destinationsEnabled;
|
listview_destinations.Enabled = destinationsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ListViewItem CreateDestinationListViewItem(IDestination destination, bool isChecked, int? imageIndex = null)
|
||||||
|
{
|
||||||
|
var listViewItem = new ListViewItem(destination.Description, imageIndex ?? -1)
|
||||||
|
{
|
||||||
|
Tag = destination,
|
||||||
|
Checked = isChecked
|
||||||
|
};
|
||||||
|
|
||||||
|
return listViewItem;
|
||||||
|
}
|
||||||
|
|
||||||
private void DisplaySettings()
|
private void DisplaySettings()
|
||||||
{
|
{
|
||||||
colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;
|
colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;
|
||||||
|
@ -585,7 +602,20 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> hiddenDestinations = new List<string>();
|
||||||
|
|
||||||
|
foreach (int index in listview_hiddenDestinations.CheckedIndices)
|
||||||
|
{
|
||||||
|
ListViewItem item = listview_hiddenDestinations.Items[index];
|
||||||
|
|
||||||
|
if (item.Checked && item.Tag is IDestination hiddenDestinationFromTag)
|
||||||
|
{
|
||||||
|
hiddenDestinations.Add(hiddenDestinationFromTag.Designation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
coreConfiguration.OutputDestinations = destinations;
|
coreConfiguration.OutputDestinations = destinations;
|
||||||
|
coreConfiguration.HiddenDestinations = hiddenDestinations;
|
||||||
coreConfiguration.CaptureDelay = (int) numericUpDownWaitTime.Value;
|
coreConfiguration.CaptureDelay = (int) numericUpDownWaitTime.Value;
|
||||||
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
|
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
|
||||||
coreConfiguration.UpdateCheckInterval = (int) numericUpDown_daysbetweencheck.Value;
|
coreConfiguration.UpdateCheckInterval = (int) numericUpDown_daysbetweencheck.Value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue