Dynamic tab title for publisher

This commit is contained in:
Mark van Renswoude 2021-12-20 12:19:16 +01:00
parent 3acb491c84
commit f936eee9c9
4 changed files with 35 additions and 10 deletions

View File

@ -38,13 +38,13 @@
</Label>
<Label Grid.Row="1" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelExchange}" Visibility="{Binding ExchangeVisibility}" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Exchange}" Visibility="{Binding ExchangeVisibility}" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Exchange, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
<Label Grid.Row="2" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelRoutingKey}" Visibility="{Binding ExchangeVisibility}" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding RoutingKey}" Visibility="{Binding ExchangeVisibility}" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding RoutingKey, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
<Label Grid.Row="3" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelQueue}" Visibility="{Binding QueueVisibility}" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Queue}" Visibility="{Binding QueueVisibility}" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Queue, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding QueueVisibility}" />
<Label Grid.Row="5" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelReplyTo}" />
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="1">

View File

@ -41,7 +41,7 @@ namespace PettingZoo.UI.Tab.Publisher
public bool SendToExchange
{
get => sendToExchange;
set => SetField(ref sendToExchange, value, otherPropertiesChanged: new[] { nameof(SendToQueue), nameof(ExchangeVisibility), nameof(QueueVisibility) });
set => SetField(ref sendToExchange, value, otherPropertiesChanged: new[] { nameof(SendToQueue), nameof(ExchangeVisibility), nameof(QueueVisibility), nameof(Title) });
}
@ -62,14 +62,14 @@ namespace PettingZoo.UI.Tab.Publisher
public string RoutingKey
{
get => routingKey;
set => SetField(ref routingKey, value);
set => SetField(ref routingKey, value, otherPropertiesChanged: new[] { nameof(Title) });
}
public string Queue
{
get => queue;
set => SetField(ref queue, value);
set => SetField(ref queue, value, otherPropertiesChanged: new[] { nameof(Title) });
}
@ -138,10 +138,11 @@ namespace PettingZoo.UI.Tab.Publisher
public ICommand PublishCommand => publishCommand;
// TODO make more dynamic, include entered routing key for example
#pragma warning disable CA1822 // Mark members as static - can't, it's part of the interface you silly, that would break the build
public string Title => "Publish";
#pragma warning restore CA1822
public string Title => SendToQueue
? string.IsNullOrWhiteSpace(Queue) ? PublisherViewStrings.TabTitleEmpty : string.Format(PublisherViewStrings.TabTitle, Queue)
: string.IsNullOrWhiteSpace(RoutingKey) ? PublisherViewStrings.TabTitleEmpty : string.Format(PublisherViewStrings.TabTitle, RoutingKey);
public IEnumerable<TabToolbarCommand> ToolbarCommands => toolbarCommands;

View File

@ -167,5 +167,23 @@ namespace PettingZoo.UI.Tab.Publisher {
return ResourceManager.GetString("OptionMessageTypeTapeti", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Publish: {0}.
/// </summary>
public static string TabTitle {
get {
return ResourceManager.GetString("TabTitle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Publish.
/// </summary>
public static string TabTitleEmpty {
get {
return ResourceManager.GetString("TabTitleEmpty", resourceCulture);
}
}
}
}

View File

@ -153,4 +153,10 @@
<data name="OptionMessageTypeTapeti" xml:space="preserve">
<value>Tapeti message</value>
</data>
<data name="TabTitle" xml:space="preserve">
<value>Publish: {0}</value>
</data>
<data name="TabTitleEmpty" xml:space="preserve">
<value>Publish</value>
</data>
</root>