Changed the destination picker behavior to not sort, this makes it possible to do the sorting in the destinations itself. OneNote places the current page on top, the printer list also starts with the default... etc.

This commit is contained in:
RKrom 2014-07-29 16:13:12 +02:00
commit cc7f303e08
9 changed files with 31 additions and 8 deletions

View file

@ -91,7 +91,23 @@ namespace Greenshot.Destinations {
/// </summary>
/// <returns>IEnumerable<IDestination></returns>
public override IEnumerable<IDestination> DynamicDestinations() {
PrinterSettings settings = new PrinterSettings();
string defaultPrinter = settings.PrinterName;
List<string> printers = new List<string>();
foreach (string printer in PrinterSettings.InstalledPrinters) {
printers.Add(printer);
}
printers.Sort(delegate(string p1, string p2) {
if(defaultPrinter.Equals(p1)) {
return -1;
}
if(defaultPrinter.Equals(p2)) {
return 1;
}
return p1.CompareTo(p2);
});
foreach(string printer in printers) {
yield return new PrinterDestination(printer);
}
}

View file

@ -73,6 +73,13 @@ namespace Greenshot {
public static List<IImageEditor> Editors {
get {
try {
editorList.Sort(delegate(IImageEditor e1, IImageEditor e2) {
return e1.Surface.CaptureDetails.Title.CompareTo(e2.Surface.CaptureDetails.Title);
});
} catch(Exception ex) {
LOG.Warn("Sorting of editors failed.", ex);
}
return editorList;
}
}

View file

@ -24,8 +24,8 @@ Bugs resolved:
* BUG-1653: Accessibility issues: Editor "File" menu entry can't be activated and missing translations
Changes:
* We cleaned up the dynamic destination context-menu: if an entry (e.g export to the editor) has child items (export to open editors) the parent is still selectable, we also no longer repeat the parent in the children.
* Dynamic destination context-menu: If a destination has child items the parent is still selectable and executes the default export, we now no longer repeat the parent in the children.
* Dynamic destination context-menu: We are now leaving the sorting to the destination code, this allows us to e.g. show the default printer on top of the list.
1.1.9.13-g01ce82d Windows 8.1 & Box bug-fix Release

View file

@ -133,7 +133,7 @@ namespace GreenshotOfficePlugin {
}
public override IEnumerable<IDestination> DynamicDestinations() {
Dictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
IDictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
if (inspectorCaptions != null) {
foreach (string inspectorCaption in inspectorCaptions.Keys) {
yield return new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]);

View file

@ -54,6 +54,7 @@ namespace Greenshot.Interop.Office {
}
}
}
currentWorkbooks.Sort();
return currentWorkbooks;
}

View file

@ -56,8 +56,8 @@ namespace Greenshot.Interop.Office {
/// A method to retrieve all inspectors which can act as an export target
/// </summary>
/// <returns>List<string> with inspector captions (window title)</returns>
public static Dictionary<string, OlObjectClass> RetrievePossibleTargets() {
Dictionary<string, OlObjectClass> inspectorCaptions = new Dictionary<string, OlObjectClass>();
public static IDictionary<string, OlObjectClass> RetrievePossibleTargets() {
IDictionary<string, OlObjectClass> inspectorCaptions = new SortedDictionary<string, OlObjectClass>();
try {
using (IOutlookApplication outlookApplication = GetOutlookApplication()) {
if (outlookApplication == null) {

View file

@ -69,7 +69,7 @@ namespace Greenshot.Interop.Office {
} catch (Exception ex) {
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
}
foundPresentations.Sort();
return foundPresentations;
}

View file

@ -227,6 +227,7 @@ namespace Greenshot.Interop.Office {
} catch (Exception ex) {
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
}
openDocuments.Sort();
return openDocuments;
}

View file

@ -321,8 +321,6 @@ namespace GreenshotPlugin.Core {
LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message);
}
if (subDestinations.Count > 0) {
subDestinations.Sort();
ToolStripMenuItem destinationMenuItem = null;
if (useDynamicsOnly && subDestinations.Count == 1) {