mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Channel selection - editable textbox, error icon
This commit is contained in:
parent
431c07ee07
commit
054379d4f0
@ -42,66 +42,58 @@
|
|||||||
<TextBlock FontSize="14" Text="Deployment channel" />
|
<TextBlock FontSize="14" Text="Deployment channel" />
|
||||||
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which release channel Roblox should be downloaded from." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which release channel Roblox should be downloaded from." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding Channels, Mode=OneWay}" SelectedItem="{Binding Channel, Mode=TwoWay}" Visibility="{Binding ChannelComboBoxVisibility, Mode=OneWay}" />
|
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" IsEditable="True" ItemsSource="{Binding Channels, Mode=OneWay}" Text="{Binding SelectedChannel, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" KeyUp="ComboBox_KeyEnterUpdate" />
|
||||||
<ui:TextBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" Text="{Binding Channel, Mode=TwoWay}" Visibility="{Binding ChannelTextBoxVisibility, Mode=OneWay}" KeyUp="TextBox_KeyEnterUpdate" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ui:CardExpander.Header>
|
</ui:CardExpander.Header>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Grid>
|
<Grid Margin="0,0,4,0">
|
||||||
|
<Grid.Style>
|
||||||
|
<Style>
|
||||||
|
<Setter Property="Grid.Visibility" Value="Visible"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ChannelDeployInfo}" Value="{x:Null}">
|
||||||
|
<Setter Property="Grid.Visibility" Value="Collapsed" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Grid.Style>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid Column="0" Margin="0,0,4,0">
|
|
||||||
<Grid.Style>
|
|
||||||
<Style>
|
|
||||||
<Setter Property="Grid.Visibility" Value="Visible"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<DataTrigger Binding="{Binding ChannelDeployInfo}" Value="{x:Null}">
|
|
||||||
<Setter Property="Grid.Visibility" Value="Collapsed" />
|
|
||||||
</DataTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</Grid.Style>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="Version" />
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="Version" />
|
||||||
<TextBlock Grid.Row="0" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.Version, Mode=OneWay}" />
|
<TextBlock Grid.Row="0" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.Version, Mode=OneWay}" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="VersionGuid" />
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="VersionGuid" />
|
||||||
<TextBlock Grid.Row="1" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.VersionGuid, Mode=OneWay}" />
|
<TextBlock Grid.Row="1" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.VersionGuid, Mode=OneWay}" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,16,0" VerticalAlignment="Center" Text="Deployed" />
|
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,16,0" VerticalAlignment="Center" Text="Deployed" />
|
||||||
<TextBlock Grid.Row="2" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.Timestamp, Mode=OneWay}" />
|
<TextBlock Grid.Row="2" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ChannelDeployInfo.Timestamp, Mode=OneWay}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Column="0">
|
<Grid Column="0">
|
||||||
<Grid.Style>
|
<Grid.Style>
|
||||||
<Style>
|
<Style>
|
||||||
<Setter Property="Grid.Visibility" Value="Collapsed"/>
|
<Setter Property="Grid.Visibility" Value="Collapsed"/>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding ChannelDeployInfo}" Value="{x:Null}">
|
<DataTrigger Binding="{Binding ChannelDeployInfo}" Value="{x:Null}">
|
||||||
<Setter Property="Grid.Visibility" Value="Visible" />
|
<Setter Property="Grid.Visibility" Value="Visible" />
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
</Grid.Style>
|
</Grid.Style>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ui:ProgressRing Grid.Column="0" Margin="6" IsIndeterminate="True" />
|
<ui:ProgressRing Grid.Column="0" Margin="6" IsIndeterminate="True" Visibility="{Binding LoadingSpinnerVisibility, Mode=OneWay}" />
|
||||||
<TextBlock Grid.Column="1" Margin="16" VerticalAlignment="Center" Text="{Binding ChannelInfoLoadingText, Mode=OneWay}" />
|
<Image Grid.Column="0" Margin="6" Width="60" Height="60" Visibility="{Binding LoadingErrorVisibility, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Error.png" />
|
||||||
</Grid>
|
<TextBlock Grid.Column="1" Margin="16" VerticalAlignment="Center" Text="{Binding ChannelInfoLoadingText, Mode=OneWay}" />
|
||||||
|
|
||||||
<CheckBox Grid.Column="1" Margin="4,0,0,0" Content="Manually enter channel name" VerticalAlignment="Top" IsChecked="{Binding ManualChannelEntry, Mode=TwoWay}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardExpander>
|
</ui:CardExpander>
|
||||||
|
@ -20,14 +20,14 @@ namespace Bloxstrap.UI.Menu.Pages
|
|||||||
|
|
||||||
// https://stackoverflow.com/a/13289118/11852173
|
// https://stackoverflow.com/a/13289118/11852173
|
||||||
// yes this doesnt fully conform to xaml but whatever
|
// yes this doesnt fully conform to xaml but whatever
|
||||||
private void TextBox_KeyEnterUpdate(object sender, KeyEventArgs e)
|
private void ComboBox_KeyEnterUpdate(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
TextBox tBox = (TextBox)sender;
|
ComboBox box = (ComboBox)sender;
|
||||||
DependencyProperty prop = TextBox.TextProperty;
|
DependencyProperty prop = ComboBox.TextProperty;
|
||||||
|
|
||||||
BindingExpression binding = BindingOperations.GetBindingExpression(tBox, prop);
|
BindingExpression binding = BindingOperations.GetBindingExpression(box, prop);
|
||||||
|
|
||||||
if (binding is not null)
|
if (binding is not null)
|
||||||
binding.UpdateSource();
|
binding.UpdateSource();
|
||||||
|
@ -26,10 +26,14 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
|
|
||||||
private async Task LoadChannelDeployInfo(string channel)
|
private async Task LoadChannelDeployInfo(string channel)
|
||||||
{
|
{
|
||||||
|
LoadingSpinnerVisibility = Visibility.Visible;
|
||||||
|
LoadingErrorVisibility = Visibility.Collapsed;
|
||||||
ChannelInfoLoadingText = "Fetching latest deploy info, please wait...";
|
ChannelInfoLoadingText = "Fetching latest deploy info, please wait...";
|
||||||
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
|
||||||
|
|
||||||
ChannelDeployInfo = null;
|
ChannelDeployInfo = null;
|
||||||
|
|
||||||
|
OnPropertyChanged(nameof(LoadingSpinnerVisibility));
|
||||||
|
OnPropertyChanged(nameof(LoadingErrorVisibility));
|
||||||
|
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
||||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -47,11 +51,19 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
ChannelInfoLoadingText = "Failed to get deploy info.\nIs the channel name valid?";
|
LoadingSpinnerVisibility = Visibility.Collapsed;
|
||||||
|
LoadingErrorVisibility = Visibility.Visible;
|
||||||
|
ChannelInfoLoadingText = "Could not get deployment information. Is the channel name valid?";
|
||||||
|
|
||||||
|
OnPropertyChanged(nameof(LoadingSpinnerVisibility));
|
||||||
|
OnPropertyChanged(nameof(LoadingErrorVisibility));
|
||||||
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Visibility LoadingSpinnerVisibility { get; private set; } = Visibility.Visible;
|
||||||
|
public Visibility LoadingErrorVisibility { get; private set; } = Visibility.Collapsed;
|
||||||
|
|
||||||
public DeployInfo? ChannelDeployInfo { get; private set; } = null;
|
public DeployInfo? ChannelDeployInfo { get; private set; } = null;
|
||||||
public string ChannelInfoLoadingText { get; private set; } = null!;
|
public string ChannelInfoLoadingText { get; private set; } = null!;
|
||||||
|
|
||||||
@ -69,12 +81,16 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
|
|
||||||
public IEnumerable<string> Channels => RobloxDeployment.SelectableChannels;
|
public IEnumerable<string> Channels => RobloxDeployment.SelectableChannels;
|
||||||
|
|
||||||
public string Channel
|
public string SelectedChannel
|
||||||
{
|
{
|
||||||
get => App.Settings.Prop.Channel;
|
get => App.Settings.Prop.Channel;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
value = value.Trim();
|
value = value.Trim();
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(value))
|
||||||
|
value = RobloxDeployment.DefaultChannel;
|
||||||
|
|
||||||
Task.Run(() => LoadChannelDeployInfo(value));
|
Task.Run(() => LoadChannelDeployInfo(value));
|
||||||
App.Settings.Prop.Channel = value;
|
App.Settings.Prop.Channel = value;
|
||||||
}
|
}
|
||||||
@ -90,20 +106,14 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
// roblox typically sets channels in all lowercase, so here we find if a case insensitive match exists
|
// roblox typically sets channels in all lowercase, so here we find if a case insensitive match exists
|
||||||
string? matchingChannel = Channels.Where(x => x.ToLowerInvariant() == Channel.ToLowerInvariant()).FirstOrDefault();
|
string? matchingChannel = Channels.Where(x => x.ToLowerInvariant() == SelectedChannel.ToLowerInvariant()).FirstOrDefault();
|
||||||
Channel = string.IsNullOrEmpty(matchingChannel) ? RobloxDeployment.DefaultChannel : matchingChannel;
|
SelectedChannel = string.IsNullOrEmpty(matchingChannel) ? RobloxDeployment.DefaultChannel : matchingChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPropertyChanged(nameof(Channel));
|
OnPropertyChanged(nameof(SelectedChannel));
|
||||||
OnPropertyChanged(nameof(ChannelComboBoxVisibility));
|
|
||||||
OnPropertyChanged(nameof(ChannelTextBoxVisibility));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cant use data bindings so i have to do whatever tf this is
|
|
||||||
public Visibility ChannelComboBoxVisibility => ManualChannelEntry ? Visibility.Collapsed : Visibility.Visible;
|
|
||||||
public Visibility ChannelTextBoxVisibility => ManualChannelEntry ? Visibility.Visible : Visibility.Collapsed;
|
|
||||||
|
|
||||||
// todo - move to enum attributes?
|
// todo - move to enum attributes?
|
||||||
public IReadOnlyDictionary<string, ChannelChangeMode> ChannelChangeModes => new Dictionary<string, ChannelChangeMode>
|
public IReadOnlyDictionary<string, ChannelChangeMode> ChannelChangeModes => new Dictionary<string, ChannelChangeMode>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user