Fix FormatElement labels if no content.

This commit is contained in:
Daniel Kraus 2015-08-12 10:05:50 +02:00
parent 1afa9bb14f
commit f2cb30fabb
4 changed files with 36 additions and 10 deletions

View File

@ -31,7 +31,17 @@ namespace zaaReloaded2.Controller.Elements
{ {
public override string Label public override string Label
{ {
get { return String.Format("\"{0}\"", Content); } get
{
if (String.IsNullOrEmpty(Content))
{
return "Beliebiger Text";
}
else
{
return String.Format("\"{0}\"", Content);
}
}
} }
public override void Run(Formatter.Formatter formatter) public override void Run(Formatter.Formatter formatter)

View File

@ -38,7 +38,17 @@ namespace zaaReloaded2.Controller.Elements
public override string Label public override string Label
{ {
get { return Content; } get
{
if (String.IsNullOrEmpty(Content))
{
return "Laborparameter";
}
else
{
return Content;
}
}
} }
public override void Run(zaaReloaded2.Formatter.Formatter formatter) public override void Run(zaaReloaded2.Formatter.Formatter formatter)

View File

@ -151,8 +151,8 @@ namespace zaaReloaded2.ViewModels
Properties.Settings.Default.FormatElementLabel, Properties.Settings.Default.FormatElementLabel,
new Collection<ViewModelBase>() new Collection<ViewModelBase>()
{ {
CreateFormatElementViewModel("Laborparameter", new Items()), CreateFormatElementViewModel(new Items()),
CreateFormatElementViewModel("Beliebiger Text", new CustomText()), CreateFormatElementViewModel(new CustomText()),
} }
) )
); );
@ -191,10 +191,9 @@ namespace zaaReloaded2.ViewModels
/// object and has a custom display string. The custom display string /// object and has a custom display string. The custom display string
/// is necessary because format elements do not have a canonical label. /// is necessary because format elements do not have a canonical label.
/// </summary> /// </summary>
ViewModelBase CreateFormatElementViewModel(string name, FormatElementBase element) ViewModelBase CreateFormatElementViewModel(FormatElementBase element)
{ {
FormatElementViewModel vm = new FormatElementViewModel(element); FormatElementViewModel vm = new FormatElementViewModel(element);
vm.DisplayString = name;
vm.PropertyChanged += ElementViewModel_PropertyChanged; vm.PropertyChanged += ElementViewModel_PropertyChanged;
return vm; return vm;
} }

View File

@ -30,12 +30,13 @@ namespace zaaReloaded2.ViewModels
{ {
#region Properties #region Properties
/// <summary>
/// Returns the wrapped Element's label or an explicitly
/// set display string.
/// </summary>
public override string DisplayString public override string DisplayString
{ {
get get { return Element.Label; }
{
return Element.Label;
}
} }
#endregion #endregion
@ -71,5 +72,11 @@ namespace zaaReloaded2.ViewModels
public abstract object Clone(); public abstract object Clone();
#endregion #endregion
#region Fields
string _displayString;
#endregion
} }
} }