3

EDIT :

I have fixed the sources of the Code Pack and uploaded an updated NuGet package :

https://www.nuget.org/packages/WindowsAPICodePack-Shell/

Thanks to dmex for the bug fix : http://archive.msdn.microsoft.com/WindowsAPICodePack/WorkItem/View.aspx?WorkItemId=108

As you can see, problem is fixed and no need to use the cumbersome syntax of Opened event:

enter image description here


When specifying an icon, the dialog height is incorrect; last command link isn't entirely visible :

enter image description here

Do you have an idea on how to fix this issue ?

Code used for showing this dialog :

var dialog = new TaskDialog
{
    Caption = Title,
    InstructionText = "Some files added are already in the collection.",
    Text = "They have been skipped."
};
dialog.Opened += (s1, e1) => { dialog.Icon = TaskDialogStandardIcon.Warning; };

var linkContinue = new TaskDialogCommandLink("Continue", "Continue", string.Empty);
linkContinue.Click += (s2, e2) =>
{
    var s = (TaskDialogCommandLink)s2;
    var taskDialog = (TaskDialog)(s.HostingDialog);
    taskDialog.Close();
};
dialog.Controls.Add(linkContinue);

var linkView = new TaskDialogCommandLink("View", "View these files", string.Empty);
linkView.Click += (s3, e3) =>
{
    var s = (TaskDialogCommandLink)s3;
    var taskDialog = (TaskDialog)(s.HostingDialog);
    taskDialog.Close();
    var window1 = new Window1 { Text = files, Title = Title };
    window1.ShowDialog();
};
dialog.Controls.Add(linkView);

dialog.Show();
aybe
  • 15,516
  • 9
  • 57
  • 105
  • @Aybe...Any idea why the GetProperty(SystemProperties.System.Photo.DateTaken) in the API doesnt return a string or a DateTime? and whatever it is returning, which I cant seem to figure out, is NOT convertible to a DateTime – dinotom Apr 24 '17 at 20:46
  • and what library is the Window1 object coming from, I cant seem to find it. – dinotom Apr 24 '17 at 21:58

1 Answers1

6

Try assigning "InstructionText" in .Opend even once again (seems to fix the problem in 1.1.0.0 as well).

        var dialog = new TaskDialog
        {
            Caption = Title,
            InstructionText = "Some files added are already in the collection.",
            Text = "They have been skipped."
        };

        dialog.Opened += (s1, e1) =>
        {
            dialog.Icon = TaskDialogStandardIcon.Warning;
            dialog.InstructionText = dialog.InstructionText; // < seems to work
        };
Nikolay
  • 10,752
  • 2
  • 23
  • 51
  • Actually there's a bug in the library preventing such syntax : icon won't be shown so that's why it's done in Opened. – aybe Jan 19 '14 at 14:39
  • Where did you get your API code pack ? Mine is from Nuget (version 1.1.0.0). – aybe Jan 19 '14 at 14:45
  • 1
    Nuget, VS2012 (NET 4.5), the "Windows7APICodePack" 1.0.0.0 (the one which comes from Microsoft) – Nikolay Jan 19 '14 at 14:47
  • 1
    It looks like in 1.0.0.0 you don't have this issue with icons - it is new to 1.1.0.0 – Nikolay Jan 19 '14 at 14:51
  • That's right but this version does not offer CommonOpenFileDialog so I'm screwed. Update your answer and I'll mark it as accepted. – aybe Jan 19 '14 at 14:58
  • 1
    Looks like setting "dialog.InstructionText" in .Opened handler second time (to the same value) fixes it for 1.1 as well (forces dialog to recalculate it's size) – Nikolay Jan 19 '14 at 15:03
  • There's a fix for the icon issue : http://archive.msdn.microsoft.com/WindowsAPICodePack/WorkItem/View.aspx?WorkItemId=108 – aybe Jan 19 '14 at 16:56
  • I've made an updated NuGet package with the bug fixed, the link is on my edit. – aybe Jan 19 '14 at 17:47