Skip to content

Commit

Permalink
UI Update (#12 from League-of-DAE-Legends/UI)
Browse files Browse the repository at this point in the history
Textboxes have placeholder text instead of regular text
  • Loading branch information
hovo-hakobyan authored Feb 2, 2024
2 parents 1861aed + 4d6f185 commit 3e9e7d9
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 56 deletions.
20 changes: 20 additions & 0 deletions SquadForger/Converter/TextToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace SquadForger.Converter
{
public class TextToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty(value as string) ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
3 changes: 0 additions & 3 deletions SquadForger/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<TabItem Header = "Squads" Background="LightGray">
<Frame Content="{Binding SquadPage}" NavigationUIVisibility="Hidden" />
</TabItem>
<TabItem Header = "Visualizer" Background="LightGray">
<Frame Content="{Binding VisualizePage}" NavigationUIVisibility="Hidden" />
</TabItem>
<TabItem Header = "Post to Discord" Background="LightGray">
<Frame Content="{Binding DiscordPage}" NavigationUIVisibility="Hidden"/>
</TabItem>
Expand Down
6 changes: 1 addition & 5 deletions SquadForger/SquadForger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converter\TextToVisibilityConverter.cs" />

<Compile Include="Model\Champions.cs" />
<Compile Include="Model\LeagueVersion.cs" />
Expand All @@ -140,16 +141,12 @@
<Compile Include="ViewModel\DiscordVM.cs" />
<Compile Include="ViewModel\MainVM.cs" />
<Compile Include="ViewModel\SquadVM.cs" />
<Compile Include="ViewModel\VisualizeVM.cs" />
<Compile Include="View\DiscordView.xaml.cs">
<DependentUpon>DiscordView.xaml</DependentUpon>
</Compile>
<Compile Include="View\SquadView.xaml.cs">
<DependentUpon>SquadView.xaml</DependentUpon>
</Compile>
<Compile Include="View\VisualizeView.xaml.cs">
<DependentUpon>VisualizeView.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -167,7 +164,6 @@
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\SquadView.xaml" />
<Page Include="View\VisualizeView.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down
1 change: 1 addition & 0 deletions SquadForger/SquadForger.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Global
{B390DD8F-015F-483E-9913-B7EF1B10A89E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B390DD8F-015F-483E-9913-B7EF1B10A89E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B390DD8F-015F-483E-9913-B7EF1B10A89E}.Release|Any CPU.Build.0 = Release|Any CPU
{B390DD8F-015F-483E-9913-B7EF1B10A89E}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 16 additions & 2 deletions SquadForger/View/SquadView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SquadForger.View"
xmlns:vm="clr-namespace:SquadForger.ViewModel"
xmlns:converter="clr-namespace:SquadForger.Converter"
mc:Ignorable="d"
d:DesignWidth="800" d:DesignHeight="450"
Title="Squad View">
<Page.DataContext>
<vm:SquadVM/>
</Page.DataContext>
<Page.Resources>
<converter:TextToVisibilityConverter x:Key="TextToVisibilityConverter"/>
</Page.Resources>
<Page.Background>
<SolidColorBrush Color="SlateGray"/>
</Page.Background>
Expand All @@ -25,7 +29,12 @@
<Button Content="Select file" Margin="10" Width="100" Command="{Binding SelectFileCommand}"></Button>
</TextBlock>
<TextBlock VerticalAlignment="Center">
<TextBox TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Text="{Binding TeamsInput}" Height="200" Width="200" Margin="10"></TextBox>
<Grid>
<TextBox x:Name="TeamsTextBox" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Text="{Binding TeamsInput}" Height="200" Width="200" Margin="10"></TextBox>
<TextBlock Text="Enter team names separated by ," Margin="10,10,0,0" Foreground="Gray" TextWrapping="Wrap"
IsHitTestVisible="False"
Visibility="{Binding Text, ElementName=TeamsTextBox, Converter={StaticResource TextToVisibilityConverter}}"/>
</Grid>
<Button Content="Add" Margin="10" Width="50" Height="30" Command="{Binding AddTeamsCommand}"></Button>
<Button Content="Clear" Margin="10" Width="50" Height="30" Command="{Binding ClearTeamsCommand}"/>
</TextBlock>
Expand All @@ -34,7 +43,12 @@
<Button Content="Safe Generate" Command="{Binding SafeGenerateCommand}" Margin="10"></Button>
</TextBlock>
<TextBlock>
<TextBox TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Width="230" Text="{Binding LeagueVersionText}" Height="30" Margin="10"/>
<Grid>
<TextBox x:Name="VersionTextBox" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Width="230" Height="30" Margin="10" Text="{Binding LeagueVersionText}"/>
<TextBlock Text="Enter valid season and patch (ie 14.1.1)" Margin="10,10,0,0" Foreground="Gray"
IsHitTestVisible="False"
Visibility="{Binding Text, ElementName=VersionTextBox, Converter={StaticResource TextToVisibilityConverter}}"/>
</Grid>
<Button Content="Custom Generate" Margin="10" Height="30" Command="{Binding CustomGenerateCommand}"/>
</TextBlock>
</StackPanel>
Expand Down
24 changes: 0 additions & 24 deletions SquadForger/View/VisualizeView.xaml

This file was deleted.

12 changes: 0 additions & 12 deletions SquadForger/View/VisualizeView.xaml.cs

This file was deleted.

1 change: 0 additions & 1 deletion SquadForger/ViewModel/MainVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class MainVM : ObservableObject
public string WindowTitle { get; private set; } = $"Squad Forger v0.0.1";
public RelayCommand OpenGithubRepoCommand { get; private set; }
public SquadView SquadPage { get; private set; } = new SquadView();
public VisualizeView VisualizePage { get; private set; } = new VisualizeView();
public DiscordView DiscordPage { get; private set; } = new DiscordView();

public MainVM()
Expand Down
7 changes: 5 additions & 2 deletions SquadForger/ViewModel/SquadVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public class SquadVM : ObservableObject
private LeagueVersion _lastVersionUsed;

public RelayCommand CustomGenerateCommand { get; private set; }
public string LeagueVersionText { get; set; }
public RelayCommand SafeGenerateCommand { get; private set; }
public string LeagueVersionText { get; set; } = "Enter valid season and patch (ie 14.1.1)";



private readonly IRandomPicker _randomPicker = new DefaultChampionPicker();

Expand All @@ -39,7 +41,6 @@ public SquadVM()
SelectFileCommand = new RelayCommand(ReadTeamsFromCsv);
AddTeamsCommand = new RelayCommand(AddTeams);
ClearTeamsCommand = new RelayCommand(ClearTeams);
TeamsInput = "Enter team names, separated by commas";
CustomGenerateCommand = new RelayCommand(CustomGenerate);
SafeGenerateCommand = new RelayCommand(SafeGenerate);

Expand Down Expand Up @@ -163,6 +164,8 @@ private void ReadTeamsFromCsv()

private void AddTeams()
{
if (TeamsInput == null) return;
if (!TeamsInput.Any()) return;
// Split the input by commas and remove empty entries
List<string> teamNames = TeamsInput.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();

Expand Down
7 changes: 0 additions & 7 deletions SquadForger/ViewModel/VisualizeVM.cs

This file was deleted.

0 comments on commit 3e9e7d9

Please sign in to comment.