mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -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.")]
|
||||
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")]
|
||||
public int UpdateCheckInterval { get; set; }
|
||||
|
||||
|
|
|
@ -36,13 +36,16 @@ namespace Greenshot.Base.Core
|
|||
/// <summary>
|
||||
/// Method to get all the destinations from the plugins
|
||||
/// </summary>
|
||||
/// <param name="excludeHidden">Whether or not to excluded hidden destinations. Default is false.</param>
|
||||
/// <returns>List of IDestination</returns>
|
||||
public static IEnumerable<IDestination> GetAllDestinations()
|
||||
public static IEnumerable<IDestination> GetAllDestinations(bool excludeHidden = false)
|
||||
{
|
||||
return SimpleServiceProvider.Current.GetAllInstances<IDestination>()
|
||||
.Where(destination => destination.IsActive)
|
||||
.Where(destination => CoreConfig.ExcludeDestinations == null ||
|
||||
!CoreConfig.ExcludeDestinations.Contains(destination.Designation)).OrderBy(p => p.Priority).ThenBy(p => p.Description);
|
||||
.Where(destination => !excludeHidden || CoreConfig.HiddenDestinations == null || !CoreConfig.HiddenDestinations.Contains(destination.Designation))
|
||||
.Where(destination => CoreConfig.ExcludeDestinations == null || !CoreConfig.ExcludeDestinations.Contains(destination.Designation))
|
||||
.OrderBy(p => p.Priority)
|
||||
.ThenBy(p => p.Description);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Greenshot.Base;
|
||||
using Greenshot.Base.Core;
|
||||
using Greenshot.Base.Interfaces;
|
||||
|
@ -38,6 +40,7 @@ namespace Greenshot.Destinations
|
|||
|
||||
public override int Priority => 1;
|
||||
|
||||
private readonly Func<IDestination, bool> _isNotPickerPredicate = (destination) => !destination.Designation.Equals(nameof(WellKnownDestinations.Picker));
|
||||
|
||||
/// <summary>
|
||||
/// Export the capture with the destination picker
|
||||
|
@ -48,22 +51,9 @@ namespace Greenshot.Destinations
|
|||
/// <returns>true if export was made</returns>
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
|
||||
{
|
||||
List<IDestination> destinations = new List<IDestination>();
|
||||
|
||||
foreach (var destination in SimpleServiceProvider.Current.GetAllInstances<IDestination>())
|
||||
{
|
||||
if ("Picker".Equals(destination.Designation))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!destination.IsActive)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
destinations.Add(destination);
|
||||
}
|
||||
List<IDestination> destinations = DestinationHelper.GetAllDestinations(true)
|
||||
.Where(_isNotPickerPredicate)
|
||||
.ToList();
|
||||
|
||||
// No Processing, this is done in the selected destination (if anything was selected)
|
||||
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.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Dapplo.Windows.DesktopWindowsManager;
|
||||
using Dapplo.Windows.Dpi;
|
||||
using Greenshot.Base;
|
||||
|
@ -52,6 +53,7 @@ namespace Greenshot.Forms
|
|||
private readonly ToolTip _toolTip = new ToolTip();
|
||||
private bool _inHotkey;
|
||||
private int _daysBetweenCheckPreviousValue;
|
||||
private readonly NativeSize _scaledIconSize;
|
||||
|
||||
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
|
||||
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>
|
||||
|
@ -421,21 +427,27 @@ namespace Greenshot.Forms
|
|||
checkbox_picker.Checked = false;
|
||||
|
||||
listview_destinations.Items.Clear();
|
||||
var scaledIconSize = DpiCalculator.ScaleWithDpi(coreConfiguration.IconSize, NativeDpiMethods.GetDpi(Handle));
|
||||
listview_destinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
||||
|
||||
listview_hiddenDestinations.Items.Clear();
|
||||
listview_hiddenDestinations.ListViewItemSorter = new ListviewWithDestinationComparer();
|
||||
|
||||
ImageList imageList = new ImageList
|
||||
{
|
||||
ImageSize = scaledIconSize
|
||||
ImageSize = _scaledIconSize
|
||||
};
|
||||
|
||||
listview_destinations.SmallImageList = imageList;
|
||||
int imageNr = -1;
|
||||
listview_hiddenDestinations.SmallImageList = imageList;
|
||||
|
||||
int currentImageIndex = -1;
|
||||
foreach (IDestination currentDestination in DestinationHelper.GetAllDestinations())
|
||||
{
|
||||
Image destinationImage = currentDestination.DisplayIcon;
|
||||
if (destinationImage != null)
|
||||
{
|
||||
imageList.Images.Add(currentDestination.DisplayIcon);
|
||||
imageNr++;
|
||||
currentImageIndex++;
|
||||
}
|
||||
|
||||
if (nameof(WellKnownDestinations.Picker).Equals(currentDestination.Designation))
|
||||
|
@ -445,18 +457,12 @@ namespace Greenshot.Forms
|
|||
}
|
||||
else
|
||||
{
|
||||
ListViewItem item;
|
||||
if (destinationImage != null)
|
||||
{
|
||||
item = listview_destinations.Items.Add(currentDestination.Description, imageNr);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = listview_destinations.Items.Add(currentDestination.Description);
|
||||
}
|
||||
bool isSelected = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
||||
bool isHidden = coreConfiguration.HiddenDestinations.Contains(currentDestination.Designation);
|
||||
int? imageIndex = destinationImage != null ? currentImageIndex : null;
|
||||
|
||||
item.Tag = currentDestination;
|
||||
item.Checked = coreConfiguration.OutputDestinations.Contains(currentDestination.Designation);
|
||||
listview_destinations.Items.Add(CreateDestinationListViewItem(currentDestination, isSelected, imageIndex));
|
||||
listview_hiddenDestinations.Items.Add(CreateDestinationListViewItem(currentDestination, isHidden, imageIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,6 +480,17 @@ namespace Greenshot.Forms
|
|||
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()
|
||||
{
|
||||
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.HiddenDestinations = hiddenDestinations;
|
||||
coreConfiguration.CaptureDelay = (int) numericUpDownWaitTime.Value;
|
||||
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
|
||||
coreConfiguration.UpdateCheckInterval = (int) numericUpDown_daysbetweencheck.Value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue