I have noticed a large, vertical space in my task dialog (the space between the command links' titles and instruction texts) which looks really bad. It started to appear right after I upgraded WindowsAPICodePack to version 1.1.
Here's the code:
TaskDialog td = new TaskDialog();
var b1 = new TaskDialogCommandLink("b1", "foo", "bar");
var b2 = new TaskDialogCommandLink("b2", "one", "two");
td.Controls.Add(b1);
td.Controls.Add(b2);
td.Caption = "Caption";
td.InstructionText = "InstructionText";
td.Text = "Text";
td.Show();
Here's the result:
Before, "bar" would appear right below "foo", but now it looks as if there's an empty line between the two. Is this a problem on my end (and would anyone know what it might be) or are you guys also experiencing this?
I've gotten the same bug in the 1.1 release. It seems to be due to the TaskDialogCommandLink
class's toString
method string.Format
with Environment.NewLine
, which doesn't map cleanly when passed to the TaskDialog itself.
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}",
Text ?? string.Empty,
(!string.IsNullOrEmpty(Text) && !string.IsNullOrEmpty(instruction)) ?
Environment.NewLine : string.Empty,
instruction ?? string.Empty);
}
I use an implementation subclass anyway to make the arguments easier, and over-rode the method to pass a string containing a simple '\n', although I don't need to internationalize my application and so can do things a little more simply.
public override string ToString()
{
string str;
bool noLabel = string.IsNullOrEmpty(this.Text);
bool noInstruction = string.IsNullOrEmpty(this.Instruction);
if (noLabel & noInstruction)
{
str = string.Empty;
}
else if (!noLabel & noInstruction)
{
str = this.Text;
}
else if (noLabel & !noInstruction)
{
str = base.Instruction;
}
else
{
str = this.Text + "\n" + this.Instruction;
}
return str;
}