added XAML stuff

This commit is contained in:
Wyatt J. Miller 2022-06-29 13:02:15 -04:00
parent 2c4504ab3f
commit 57c3cb0fdb
15 changed files with 481 additions and 107 deletions

View File

@ -2,8 +2,23 @@
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" xmlns:unicode="clr-namespace:Avalonia.Media.TextFormatting.Unicode;assembly=Avalonia.Visuals"
mc:Ignorable="d"
x:Class="DeskHubSharpRevised.AboutWindow" x:Class="DeskHubSharpRevised.AboutWindow"
Title="AboutWindow"> Title="About - DeskHubSharp" Height="300" Width="450" CanResize="False">
Welcome to Avalonia! <Grid>
<Label x:Name="lbl_title" Content="DeskHubSharp" HorizontalAlignment="Left" Margin="2,10,10,0" VerticalAlignment="Top" FontSize="24" Width="372"/>
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="309,241,0,0" VerticalAlignment="Top" Width="75" Click="btn_close_Click" Background="#FFFFBABA"/>
<TextBlock x:Name="txtblk_about1" HorizontalAlignment="Left" Margin="10,81,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="64" Width="372">
Written and developed by Wyatt J. Miller
Copyright 2018, All rights reserved
Licensed under the MIT license
</TextBlock>
<TextBlock x:Name="txtblk_about2" HorizontalAlignment="Left" Margin="10,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="100" Width="400">
Using technologies including but not limited to Avalonia, .NET 6, Newtonsoft, RestSharp, and MailKit/MimeKit.
</TextBlock>
<TextBlock HorizontalAlignment="Left" Margin="10,200,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="44" Width="364"
Text="This project cannot be done without the help of johnvelis, NoahFlowa, ericgi231, and tarkowr." />
<TextBlock HorizontalAlignment="Left" Margin="10,57,0,0" TextWrapping="Wrap" Text="A desktop GitHub application developed in three weeks." VerticalAlignment="Top" Height="19" Width="400"/>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,34 @@
$HEADER$using Avalonia; using System;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
{
public partial class $CLASS$ : Window
{
public $CLASS$()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent() public partial class AboutWindow : Window
{ {
AvaloniaXamlLoader.Load(this); public AboutWindow()
} {
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void OnOpened(object sender, EventArgs e)
{
base.OnOpened(e);
}
}

View File

@ -1,7 +1,10 @@
<Application xmlns="https://github.com/avaloniaui" <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonia="clr-namespace:HyperText.Avalonia;assembly=HyperText.Avalonia"
x:Class="DeskHubSharpRevised.App"> x:Class="DeskHubSharpRevised.App">
<Application.Styles> <Application.Styles>
<FluentTheme Mode="Light"/> <FluentTheme Mode="Dark"/>
<avalonia:HyperLinkStyle/>
</Application.Styles> </Application.Styles>
</Application> </Application>

View File

@ -4,6 +4,18 @@
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" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DeskHubSharpRevised.DetailWindow" x:Class="DeskHubSharpRevised.DetailWindow"
Title="DetailWindow"> Title="Detail - DeskHubSharp" Height="450" Width="400" CanResize="False">
Welcome to Avalonia! <Grid>
<Label x:Name="lbl_reponame" Content="Repository Name" HorizontalAlignment="Left" Margin="10,57,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.603,-0.2" Width="374" FontSize="20"/>
<Label x:Name="lbl_title" Content="Details" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="81" FontSize="24"/>
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="309,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFABAB" Click="btn_close_Click"/>
<TextBlock x:Name="txtblk_language" HorizontalAlignment="Left" Margin="13,120,0,0" TextWrapping="Wrap" Text="This repo is mostly some code." VerticalAlignment="Top" Height="25" Width="223" FontSize="14"/>
<TextBlock x:Name="txtblk_stargazers" HorizontalAlignment="Left" Margin="13,150,0,0" TextWrapping="Wrap" Text="This repo has 0 stargazers." VerticalAlignment="Top" Height="24" Width="186" FontSize="14"/>
<ComboBox x:Name="cmbbox_branches" HorizontalAlignment="Left" Margin="13,389,0,0" VerticalAlignment="Top" Width="120" Height="19"/>
<Label x:Name="lbl_branch" Content="What branch do you want to download?" HorizontalAlignment="Left" Margin="13,358,0,0" VerticalAlignment="Top" Width="223" Padding="1,5,5,5" RenderTransformOrigin="0.537,0.517"/>
<TextBlock x:Name="txtblk_watchers" HorizontalAlignment="Left" Margin="13,179,0,0" TextWrapping="Wrap" Text="This repo has 0 watchers." VerticalAlignment="Top" Width="209" FontSize="14" Height="24"/>
<TextBlock x:Name="txtblk_forks" HorizontalAlignment="Left" Margin="13,208,0,0" TextWrapping="Wrap" Text="This repo has 0 forks." VerticalAlignment="Top" FontSize="14" Height="20" Width="223"/>
<Button x:Name="btn_page" Content="GitHub Page" HorizontalAlignment="Left" Margin="13,333,0,0" VerticalAlignment="Top" Width="88" RenderTransformOrigin="0.29,1.69" Click="btn_page_Click"/>
<Button x:Name="btn_clone" Content="Clone" HorizontalAlignment="Left" Margin="147,388,0,0" VerticalAlignment="Top" Width="75" Click="btn_clone_Click"/>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,85 @@
$HEADER$using Avalonia; using System.Diagnostics;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using DeskHubSharpRevised.BLL;
using DeskHubSharpRevised.Models;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
public partial class DetailWindow : Window
{ {
public partial class $CLASS$ : Window public DetailWindow()
{ {
public $CLASS$() InitializeComponent();
{
InitializeComponent();
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private RepoDetail _repoDetail;
private Request _request;
private Owner _owner;
public DetailWindow(RepoDetail repoDetail)
{
InitializeComponent();
_repoDetail = repoDetail;
_request = new Request(_repoDetail.name);
RepoInfo info = new RepoInfo();
_request.PerformBranchRequest();
var stuff = info.GetBranchNameComboBox();
cmbbox_branches.Items= stuff;
if (_repoDetail.language != null)
{
txtblk_language.Text = $"This repo is mostly {_repoDetail.language} code.";
}
else
{
txtblk_language.Text = "This repo doesn't have any code.";
} }
private void InitializeComponent() lbl_reponame.Content = _repoDetail.full_name;
{ txtblk_stargazers.Text = $"This repo has {_repoDetail.stargazers_count} stargazers.";
AvaloniaXamlLoader.Load(this); txtblk_watchers.Text = $"This repo has {_repoDetail.watchers_count} watchers.";
} txtblk_forks.Text = $"This repo has {_repoDetail.forks_count} forks.";
} }
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn_clone_Click(object sender, RoutedEventArgs e)
{
if (cmbbox_branches.SelectedItem.ToString() == "")
{
ErrorWindow err = new ErrorWindow();
err.txtblk_error.Text = "Please select a branch to clone.";
err.Show();
}
else
{
_owner = new Owner();
string link = "https://github.com/" + _repoDetail.owner.login + "/" + _repoDetail.name + "/archive/" + cmbbox_branches.SelectedItem + ".zip";
Process.Start(link);
}
}
private void btn_page_Click(object sender, RoutedEventArgs e)
{
Process.Start($"{_repoDetail.html_url}");
}
}

View File

@ -2,8 +2,12 @@
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.ErrorWindow" x:Class="DeskHubSharpRevised.ErrorWindow"
Title="ErrorWindow"> Title="Response - DeskHubSharp" Height="200" Width="300" CanResize="False">
Welcome to Avalonia! <Grid>
<TextBlock x:Name="txtblk_error" HorizontalAlignment="Left" Margin="10,66,0,0" TextWrapping="Wrap" Text="An error occurred. Please try again." VerticalAlignment="Top" Width="272" TextAlignment="Center" RenderTransformOrigin="0.468,-0.751"/>
<Button x:Name="btn_error_close" Content="Close" HorizontalAlignment="Left" Margin="112,128,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<Label x:Name="lbl_title" Content="Oops. It's not you, it's us." HorizontalAlignment="Left" Margin="56,10,0,0" VerticalAlignment="Top" FontSize="16"/>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,27 @@
$HEADER$using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
{
public partial class $CLASS$ : Window
{
public $CLASS$()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent() public partial class ErrorWindow : Window
{ {
AvaloniaXamlLoader.Load(this); public ErrorWindow()
} {
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}

View File

@ -5,5 +5,21 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DeskHubSharpRevised.FeedbackWindow" x:Class="DeskHubSharpRevised.FeedbackWindow"
Title="FeedbackWindow"> Title="FeedbackWindow">
Welcome to Avalonia! <Grid>
<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_feedbackmessage" HorizontalAlignment="Left" Height="117" Margin="43,213,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="406"/>
<TextBlock HorizontalAlignment="Left" Margin="43,52,0,0" TextWrapping="Wrap" Text="Is there a problem with the program? Got a new feature that you want in the program? By filling out this feedback form, you can shape development going forward! Please state your case and we will reply as soon as possible." VerticalAlignment="Top" Height="76" Width="388"/>
<Label x:Name="lbl_nametxt" Content="Name:" HorizontalAlignment="Left" Margin="43,133,0,0" VerticalAlignment="Top" Padding="2,5,5,5"/>
<Label x:Name="lbl_feedbackmessage" Content="Your message:" HorizontalAlignment="Left" Margin="43,187,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.142,0.363" Padding="2,5,5,5"/>
<Button x:Name="btn_discard" Content="Discard" HorizontalAlignment="Left" Margin="407,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFB7B7" Click="btn_discard_Click"/>
<Button x:Name="btn_send" Content="Send" HorizontalAlignment="Left" Margin="327,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFACFFC2" Click="btn_send_Click">
<Button.Resources>
<Color x:Key="Green">#FF34A853</Color>
</Button.Resources>
</Button>
<TextBox x:Name="txtbox_email" HorizontalAlignment="Left" Height="23" Margin="200,159,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="249"/>
<Label x:Name="lbl_emailtxt" Content="Email:" HorizontalAlignment="Left" Margin="200,133,0,0" VerticalAlignment="Top" Padding="3,5,5,5"/>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,34 @@
$HEADER$using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using DeskHubSharpRevised.BLL;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
public partial class FeedbackWindow : Window
{ {
public partial class $CLASS$ : Window public FeedbackWindow()
{ {
public $CLASS$() InitializeComponent();
{
InitializeComponent();
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
} }
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void btn_discard_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn_send_Click(object sender, RoutedEventArgs e)
{
EmailBLL email = new EmailBLL(txtbox_name.Text, txtbox_feedbackmessage.Text, txtbox_email.Text);
email.CreateMessage();
}
}

View File

@ -2,8 +2,20 @@
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"
xmlns:unicode="clr-namespace:Avalonia.Media.TextFormatting.Unicode;assembly=Avalonia.Visuals"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DeskHubSharpRevised.HelpWindow" x:Class="DeskHubSharpRevised.HelpWindow"
Title="HelpWindow"> Title="HelpWindow">
Welcome to Avalonia! <Grid>
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="307,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFBDBD" Click="btn_close_Click"/>
<Label x:Name="lbl_title" Content="Need some help?" HorizontalAlignment="Left" Margin="3,10,0,0" VerticalAlignment="Top" FontSize="20"/>
<TextBlock HorizontalAlignment="Left" Margin="10,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="332" Width="372">
No worries friend! We have you covered!
If you have a blank list when you first start the program, that's normal! You just have to search for somebody.
Click on the Search button and type away in the name field! If you get an error in response to your search query, that means that user doesn't exist.
If the search finds a user, the list will populate. Click on a repository of interest and click on the Detail button to view it in action.
You found a problem with the program? Great! Click on the Feedback button to send an email to me and I will respond to said email as soon as possible.
Want to know more about this program? Click on the About button to view credits.
</TextBlock>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,27 @@
$HEADER$using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
{
public partial class $CLASS$ : Window
{
public $CLASS$()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent() public partial class HelpWindow : Window
{ {
AvaloniaXamlLoader.Load(this); public HelpWindow()
} {
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}

View File

@ -2,8 +2,34 @@
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.MainWindow" x:Class="DeskHubSharpRevised.MainWindow"
Title="DeskHubSharpRevised"> Title="DeskHubSharp" Height="450" Width="805" CanResize="False"
Welcome to Avalonia! TransparencyLevelHint="AcrylicBlur"
Background="Transparent">
<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_detail" Content="Detail" HorizontalAlignment="Left" Margin="90,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" 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_help" Content="Help" HorizontalAlignment="Left" Margin="250,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFFF9D" 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_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_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_email" HorizontalAlignment="Left" Margin="563,224,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="27" Width="217" RenderTransformOrigin="0.643,0.559" FontSize="14"/>
<TextBlock x:Name="txtblk_realname" HorizontalAlignment="Left" Margin="563,34,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Height="35" Width="224" FontSize="22"/>
<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_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_bio" Content="Bio:" HorizontalAlignment="Left" Margin="563,249,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.079,0.397" Padding="2,5,5,5"/>
<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"/>
<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_searchrepo" Content="Search Repository" HorizontalAlignment="Left" Margin="250,307,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"/>
</Grid>
</Window> </Window>

View File

@ -1,12 +1,165 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using DeskHubSharpRevised.BLL;
using DeskHubSharpRevised.Models;
namespace DeskHubSharpRevised namespace DeskHubSharpRevised
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private ObservableCollection<RepoDetail> _repoDetail;
private User _user;
private Request _request;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void btn_detail_Click(object sender, RoutedEventArgs e)
{
try
{
RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
DetailWindow detail = new DetailWindow(repo);
detail.Show();
}
catch (IndexOutOfRangeException)
{
ShowErrorMessage("Please pick a repository!");
}
catch (NullReferenceException)
{
ShowErrorMessage("Please search for a user with the Search button!");
}
catch (ArgumentOutOfRangeException)
{
ShowErrorMessage("Please search for a user with the Search button!");
}
}
private void btn_exit_Click(object sender, RoutedEventArgs e)
{
this.Close();
Environment.Exit(0);
}
private void btn_about_Click(object sender, RoutedEventArgs e)
{
AboutWindow about = new AboutWindow();
about.Show();
}
private void btn_feedback_Click(object sender, RoutedEventArgs e)
{
FeedbackWindow feedback = new FeedbackWindow();
feedback.Show();
}
private void btn_help_Click(object sender, RoutedEventArgs e)
{
HelpWindow help = new HelpWindow();
help.Show();
}
private async void btn_search_Click(object sender, RoutedEventArgs e)
{
SearchWindow search = new SearchWindow();
await search.ShowDialog(this);
_repoDetail = RequestList.repoDetail;
RepoInfo info = new RepoInfo();
var stuff = info.GetRepoInfoList();
if (stuff == null)
{
txtblk_username.Text = txtblk_username.Text;
txtblk_url.Text = txtblk_url.Text;
txtblk_bio.Text = txtblk_bio.Text;
txtblk_email.Text = txtblk_email.Text;
txtblk_realname.Text = txtblk_realname.Text;
}
else
{
_user = RequestList.userDetail;
ListBox.Items = stuff;
txtblk_username.Text = _user.login;
txtblk_url.Text = _user.html_url;
txtblk_bio.Text = _user.bio;
txtblk_email.Text = _user.blog;
txtblk_realname.Text = _user.name;
txtblk_repocount.Text = $"{_user.login} has {_user.public_repos} public repositories.";
}
}
public void ShowErrorMessage(string message)
{
ErrorWindow err = new ErrorWindow();
try
{
err.lbl_title.Content = "Oops!";
err.txtblk_error.Text = message;
}
catch (NullReferenceException e)
{
err.lbl_title.Content = "Oops!";
err.txtblk_error.Text = message;
}
err.Show();
}
private void btn_sort_Click(object sender, RoutedEventArgs e)
{
try
{
string sortTerm = cmbbox_sort.SelectedItem.ToString();
if (sortTerm == "A - Z")
{
var sortedList = _repoDetail.OrderBy(x => x.full_name).ToList();
ListBox.Items = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Stars")
{
var sortedList = _repoDetail.OrderBy(c => c.stargazers_count).ToList();
ListBox.Items = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Forks")
{
var sortedList = _repoDetail.OrderBy(c => c.forks_count).ToList();
ListBox.Items = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Watchers")
{
var sortedList = _repoDetail.OrderBy(c => c.watchers_count).ToList();
ListBox.Items = sortedList.Select(x => x.full_name);
}
}
catch (NullReferenceException)
{
ShowErrorMessage("A user has not been searched. Please try again.");
}
}
private void btn_searchrepo_Click(object sender, RoutedEventArgs e)
{
try
{
string searchTerm = txtbox_searchbox.Text;
var searchedList = _repoDetail.Where(c => c.full_name.ToUpper().Contains(searchTerm.ToUpper())).ToList();
ListBox.Items = searchedList.Select(x => x.full_name);
}
catch (ArgumentNullException)
{
ShowErrorMessage("A user has not been searched. Please try again.");
}
}
} }
} }

View File

@ -4,6 +4,12 @@
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" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DeskHubSharpRevised.SearchWindow" x:Class="DeskHubSharpRevised.SearchWindow"
Title="SearchWindow"> Title="Search - DeskHubSharp" Height="200" Width="500" CanResize="False">
Welcome to Avalonia! <Grid>
<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"/>
<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_close" Content="Close" HorizontalAlignment="Left" Margin="407,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFA1A1" Click="btn_close_Click"/>
</Grid>
</Window> </Window>

View File

@ -1,22 +1,52 @@
$HEADER$using Avalonia; using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using DeskHubSharpRevised.BLL;
using DeskHubSharpRevised.Models;
namespace $NAMESPACE$ namespace DeskHubSharpRevised;
public partial class SearchWindow : Window
{ {
public partial class $CLASS$ : Window private Request _request;
private ObservableCollection<RepoDetail> _repoDetail;
public SearchWindow()
{ {
public $CLASS$() InitializeComponent();
{
InitializeComponent();
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
} }
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn_search_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(txtbox_query.Text))
{
var parentWindow = this;
ErrorWindow err = new ErrorWindow();
err.txtblk_error.Text = "Please enter a username!";
err.ShowDialog(parentWindow);
}
else
{
_request = new Request(txtbox_query.Text);
_request.PerformSearchRequest();
_request.PerformUserRequest();
this.Close();
}
}
}