avalonia porting process

visual items tweaked, fixed some crashing when you forget to search
This commit is contained in:
Wyatt J. Miller 2022-06-30 17:50:23 -04:00
parent a3be695c76
commit 65e1214242
7 changed files with 60 additions and 42 deletions

View File

@ -3,8 +3,14 @@
<component name="AvaloniaProject"> <component name="AvaloniaProject">
<option name="projectPerEditor"> <option name="projectPerEditor">
<map> <map>
<entry key="DeskHubSharpRevised/AboutWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/App.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" /> <entry key="DeskHubSharpRevised/App.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/DetailWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/ErrorWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/FeedbackWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/HelpWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/MainWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" /> <entry key="DeskHubSharpRevised/MainWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
<entry key="DeskHubSharpRevised/SearchWindow.axaml" value="DeskHubSharpRevised/DeskHubSharpRevised.csproj" />
</map> </map>
</option> </option>
</component> </component>

View File

@ -1,3 +1,4 @@
using System.Collections;
using System.Diagnostics; using System.Diagnostics;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
@ -10,9 +11,21 @@ namespace DeskHubSharpRevised;
public partial class DetailWindow : Window public partial class DetailWindow : Window
{ {
// Private members
private readonly RepoDetail _repoDetail;
private readonly ComboBox? _cmbbox_branches_items;
private TextBlock? _txtblk_language_text;
private Label? _lbl_reponame_content;
private TextBlock? _txtblk_watchers_text;
private TextBlock? _txtblk_stargazers_text;
private TextBlock? _txtblk_forks_text;
private Request _request;
private Owner _owner;
public DetailWindow() public DetailWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif
@ -22,10 +35,6 @@ public partial class DetailWindow : Window
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
private RepoDetail _repoDetail;
private Request _request;
private Owner _owner;
public DetailWindow(RepoDetail repoDetail) public DetailWindow(RepoDetail repoDetail)
{ {
@ -33,26 +42,32 @@ public partial class DetailWindow : Window
_repoDetail = repoDetail; _repoDetail = repoDetail;
_request = new Request(_repoDetail.name); _request = new Request(_repoDetail.name);
_cmbbox_branches_items = this.Find<ComboBox>("cmbbox_branches");
_txtblk_language_text = this.Find<TextBlock>("txtblk_language");
_txtblk_watchers_text = this.Find<TextBlock>("txtblk_watchers");
_txtblk_stargazers_text = this.Find<TextBlock>("txtblk_stargazers");
_txtblk_forks_text = this.Find<TextBlock>("txtblk_forks");
_lbl_reponame_content = this.Find<Label>("lbl_reponame");
RepoInfo info = new RepoInfo(); RepoInfo info = new RepoInfo();
_request.PerformBranchRequest(); _request.PerformBranchRequest();
var stuff = info.GetBranchNameComboBox(); var stuff = info.GetBranchNameComboBox();
cmbbox_branches.Items= stuff; _cmbbox_branches_items.Items = stuff;
if (_repoDetail.language != null) if (_repoDetail.language != null)
{ {
txtblk_language.Text = $"This repo is mostly {_repoDetail.language} code."; _txtblk_language_text.Text = $"This repo is mostly {_repoDetail.language} code.";
} }
else else
{ {
txtblk_language.Text = "This repo doesn't have any code."; _txtblk_language_text.Text = "This repo doesn't have any code.";
} }
lbl_reponame.Content = _repoDetail.full_name; _lbl_reponame_content.Content = _repoDetail.full_name;
txtblk_stargazers.Text = $"This repo has {_repoDetail.stargazers_count} stargazers."; _txtblk_stargazers_text.Text = $"This repo has {_repoDetail.stargazers_count} stargazers.";
txtblk_watchers.Text = $"This repo has {_repoDetail.watchers_count} watchers."; _txtblk_watchers_text.Text = $"This repo has {_repoDetail.watchers_count} watchers.";
txtblk_forks.Text = $"This repo has {_repoDetail.forks_count} forks."; _txtblk_forks_text.Text = $"This repo has {_repoDetail.forks_count} forks.";
} }
private void btn_close_Click(object sender, RoutedEventArgs e) private void btn_close_Click(object sender, RoutedEventArgs e)

View File

@ -2,9 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d"
x:Class="DeskHubSharpRevised.FeedbackWindow" x:Class="DeskHubSharpRevised.FeedbackWindow"
Title="FeedbackWindow"> Title="Feedback - DeskHubSharp" Height="450" Width="800">
<Grid> <Grid>
<Label x:Name="lbl_title" Content="Feedback" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontSize="20"/> <Label x:Name="lbl_title" Content="Feedback" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontSize="20"/>
<TextBox x:Name="txtbox_name" HorizontalAlignment="Left" Height="23" Margin="43,159,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/> <TextBox x:Name="txtbox_name" HorizontalAlignment="Left" Height="23" Margin="43,159,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>

View File

@ -4,17 +4,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="DeskHubSharpRevised.MainWindow" x:Class="DeskHubSharpRevised.MainWindow"
Title="DeskHubSharp" Height="450" Width="805" CanResize="False" Title="DeskHubSharp" Height="500" Width="805" CanResize="False"
TransparencyLevelHint="AcrylicBlur" TransparencyLevelHint="AcrylicBlur"
Background="Transparent"> Background="Transparent">
<Grid> <Grid>
<Button x:Name="btn_searchuser" Content="Search User" HorizontalAlignment="Left" Margin="10,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" Click="btn_search_Click"/> <Button x:Name="btn_searchuser" Content="Search" HorizontalAlignment="Left" Margin="10,450,0,0" VerticalAlignment="Top" Width="90" Click="btn_search_Click"/>
<Button x:Name="btn_detail" Content="Detail" HorizontalAlignment="Left" Margin="90,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" Click="btn_detail_Click"/> <Button x:Name="btn_detail" Content="Detail" HorizontalAlignment="Left" Margin="105,450,0,0" VerticalAlignment="Top" Width="75" Click="btn_detail_Click"/>
<Button x:Name="btn_feedback" Content="Feedback" HorizontalAlignment="Left" Margin="170,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFD9A1FF" Click="btn_feedback_Click"/> <Button x:Name="btn_feedback" Content="Feedback" HorizontalAlignment="Left" Margin="185,450,0,0" VerticalAlignment="Top" Width="90" Click="btn_feedback_Click"/>
<Button x:Name="btn_help" Content="Help" HorizontalAlignment="Left" Margin="250,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFFF9D" Click="btn_help_Click"/> <Button x:Name="btn_help" Content="Help" HorizontalAlignment="Left" Margin="280,450,0,0" VerticalAlignment="Top" Width="75" Click="btn_help_Click"/>
<Button x:Name="btn_about" Content="About" HorizontalAlignment="Left" Margin="627,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFAFFBAB" Click="btn_about_Click"/> <Button x:Name="btn_about" Content="About" HorizontalAlignment="Left" Margin="627,450,0,0" VerticalAlignment="Top" Width="75" Click="btn_about_Click"/>
<Button x:Name="btn_exit" Content="Exit" HorizontalAlignment="Left" Margin="707,450,0,0" VerticalAlignment="Top" Width="75" Click="btn_exit_Click"/>
<Button x:Name="btn_exit" Content="Exit" HorizontalAlignment="Left" Margin="707,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFF9999" Click="btn_exit_Click"/>
<TextBlock x:Name="txtblk_username" Margin="563,99,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="27" FontSize="16" HorizontalAlignment="Left" Width="224"/> <TextBlock x:Name="txtblk_username" Margin="563,99,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="27" FontSize="16" HorizontalAlignment="Left" Width="224"/>
<TextBlock x:Name="txtblk_url" HorizontalAlignment="Left" Margin="563,161,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="23" Width="217" FontSize="14"/> <TextBlock x:Name="txtblk_url" HorizontalAlignment="Left" Margin="563,161,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="23" Width="217" FontSize="14"/>
<TextBlock x:Name="txtblk_bio" HorizontalAlignment="Left" Margin="563,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="109" Width="217" FontSize="14" Text="-"/> <TextBlock x:Name="txtblk_bio" HorizontalAlignment="Left" Margin="563,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="109" Width="217" FontSize="14" Text="-"/>
@ -23,13 +22,13 @@
<Label x:Name="lbl_realname" Content="Name:" HorizontalAlignment="Left" Margin="563,10,0,0" VerticalAlignment="Top" Height="24" Width="224" FontSize="11" Padding="2,5,5,5"/> <Label x:Name="lbl_realname" Content="Name:" HorizontalAlignment="Left" Margin="563,10,0,0" VerticalAlignment="Top" Height="24" Width="224" FontSize="11" Padding="2,5,5,5"/>
<Label x:Name="lbl_username" Content="Username:" HorizontalAlignment="Left" Margin="563,74,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/> <Label x:Name="lbl_username" Content="Username:" HorizontalAlignment="Left" Margin="563,74,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/>
<Label x:Name="lbl_url" Content="GitHub URL:" HorizontalAlignment="Left" Margin="563,131,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/> <Label x:Name="lbl_url" Content="GitHub URL:" HorizontalAlignment="Left" Margin="563,131,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/>
<Label x:Name="lbl_email" Content="Email:" HorizontalAlignment="Left" Margin="563,192,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/> <Label x:Name="lbl_email" Content="Website:" HorizontalAlignment="Left" Margin="563,192,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/>
<Label x:Name="lbl_bio" Content="Bio:" HorizontalAlignment="Left" Margin="563,249,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.079,0.397" Padding="2,5,5,5"/> <Label x:Name="lbl_bio" Content="Bio:" HorizontalAlignment="Left" Margin="563,249,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/>
<ListBox x:Name="ListBox" HorizontalAlignment="Left" Height="265" Margin="10,10,0,0" VerticalAlignment="Top" Width="519"/> <ListBox x:Name="ListBox" HorizontalAlignment="Left" Height="265" Margin="10,10,0,0" VerticalAlignment="Top" Width="519"/>
<TextBlock x:Name="txtblk_repocount" HorizontalAlignment="Left" Margin="10,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="65" Width="235" RenderTransformOrigin="0.496,0.482"/> <TextBlock x:Name="txtblk_repocount" HorizontalAlignment="Left" Margin="10,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="65" Width="235" RenderTransformOrigin="0.496,0.482"/>
<ComboBox x:Name="cmbbox_sort" HorizontalAlignment="Left" Margin="330,280,0,0" VerticalAlignment="Top" Width="199"/> <ComboBox x:Name="cmbbox_sort" HorizontalAlignment="Left" Margin="330,280,0,0" VerticalAlignment="Top" Width="199"/>
<Button x:Name="btn_sort" Content="Sort" HorizontalAlignment="Left" Margin="250,280,0,0" VerticalAlignment="Top" Width="75" Click="btn_sort_Click" Height="22"/> <Button x:Name="btn_sort" Content="Sort" HorizontalAlignment="Left" Margin="250,281,0,0" VerticalAlignment="Top" Width="75" Click="btn_sort_Click"/>
<Button x:Name="btn_searchrepo" Content="Search Repository" HorizontalAlignment="Left" Margin="250,307,0,0" VerticalAlignment="Top" Width="109" Click="btn_searchrepo_Click"/> <Button x:Name="btn_searchrepo" Content="Search Repository" HorizontalAlignment="Left" Margin="250,326,0,0" VerticalAlignment="Top" Width="109" Click="btn_searchrepo_Click"/>
<TextBox x:Name="txtbox_searchbox" HorizontalAlignment="Left" Height="20" Margin="364,307,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="165" RenderTransformOrigin="0.131,-0.913"/> <TextBox x:Name="txtbox_searchbox" HorizontalAlignment="Left" Height="20" Margin="364,325,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="165" RenderTransformOrigin="0.131,-0.913"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -68,6 +68,7 @@ namespace DeskHubSharpRevised
private async void btn_search_Click(object sender, RoutedEventArgs e) private async void btn_search_Click(object sender, RoutedEventArgs e)
{ {
this.cmbbox_sort = this.Find<ComboBox>("cmbbox_sort");
SearchWindow search = new SearchWindow(); SearchWindow search = new SearchWindow();
await search.ShowDialog(this); await search.ShowDialog(this);
_repoDetail = RequestList.repoDetail; _repoDetail = RequestList.repoDetail;
@ -92,23 +93,18 @@ namespace DeskHubSharpRevised
txtblk_email.Text = _user.blog; txtblk_email.Text = _user.blog;
txtblk_realname.Text = _user.name; txtblk_realname.Text = _user.name;
txtblk_repocount.Text = $"{_user.login} has {_user.public_repos} public repositories."; txtblk_repocount.Text = $"{_user.login} has {_user.public_repos} public repositories.";
_request = new Request();
cmbbox_sort.Items = _request.PerformGetSort();
} }
} }
public void ShowErrorMessage(string message) public void ShowErrorMessage(string message)
{ {
ErrorWindow err = new ErrorWindow(); ErrorWindow err = new ErrorWindow();
try err.lbl_title = err.Find<Label>("lbl_title");
{ err.lbl_title.Content = "Did you search a user? Try that first.";
err.lbl_title.Content = "Oops!"; err.txtblk_error = err.Find<TextBlock>("txtblk_error");
err.txtblk_error.Text = message; err.txtblk_error.Text = message;
}
catch (NullReferenceException e)
{
err.lbl_title.Content = "Oops!";
err.txtblk_error.Text = message;
}
err.Show(); err.Show();
} }

View File

@ -7,7 +7,7 @@
Title="Search - DeskHubSharp" Height="200" Width="500" CanResize="False"> Title="Search - DeskHubSharp" Height="200" Width="500" CanResize="False">
<Grid> <Grid>
<Label x:Name="lbl_search" Content="Search" HorizontalAlignment="Left" Margin="17,15,0,0" VerticalAlignment="Top" FontSize="20" Padding="2,5,5,5"/> <Label x:Name="lbl_search" Content="Search" HorizontalAlignment="Left" Margin="17,15,0,0" VerticalAlignment="Top" FontSize="20" Padding="2,5,5,5"/>
<TextBox x:Name="txtbox_query" HorizontalAlignment="Left" Height="23" Margin="17,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="465"/> <TextBox x:Name="txtbox_query" Text="{Binding userResponse}" HorizontalAlignment="Left" Height="23" Margin="17,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="465"/>
<Label x:Name="lbl_user" Content="User:" HorizontalAlignment="Left" Margin="17,52,0,0" VerticalAlignment="Top" Padding="3,5,5,5" RenderTransformOrigin="0.686,0.474"/> <Label x:Name="lbl_user" Content="User:" HorizontalAlignment="Left" Margin="17,52,0,0" VerticalAlignment="Top" Padding="3,5,5,5" RenderTransformOrigin="0.686,0.474"/>
<Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93" Click="btn_search_Click"/> <Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93" Click="btn_search_Click"/>
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="407,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFA1A1" Click="btn_close_Click"/> <Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="407,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFA1A1" Click="btn_close_Click"/>

View File

@ -10,12 +10,14 @@ namespace DeskHubSharpRevised;
public partial class SearchWindow : Window public partial class SearchWindow : Window
{ {
public string userResponse { get; set; }
private Request _request; private Request _request;
private ObservableCollection<RepoDetail> _repoDetail; private ObservableCollection<RepoDetail> _repoDetail;
public SearchWindow() public SearchWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif
@ -33,7 +35,7 @@ public partial class SearchWindow : Window
private void btn_search_Click(object sender, RoutedEventArgs e) private void btn_search_Click(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrEmpty(txtbox_query.Text)) if (string.IsNullOrEmpty(userResponse))
{ {
var parentWindow = this; var parentWindow = this;
ErrorWindow err = new ErrorWindow(); ErrorWindow err = new ErrorWindow();
@ -42,7 +44,7 @@ public partial class SearchWindow : Window
} }
else else
{ {
_request = new Request(txtbox_query.Text); _request = new Request(userResponse);
_request.PerformSearchRequest(); _request.PerformSearchRequest();
_request.PerformUserRequest(); _request.PerformUserRequest();
this.Close(); this.Close();