added sort and search buttons

This commit is contained in:
Wyatt Miller 2018-12-07 00:43:42 -05:00
parent 1e8d6b4b25
commit 735d92147c
13 changed files with 111 additions and 26 deletions

Binary file not shown.

View File

@ -12,7 +12,7 @@ namespace DeskHubSharp
private string _query; private string _query;
/// <summary> /// <summary>
/// Constructor for the class /// Override constructor for the class
/// </summary> /// </summary>
/// <param name="query"></param> /// <param name="query"></param>
public Request(string query) public Request(string query)
@ -21,6 +21,14 @@ namespace DeskHubSharp
_api = new ApiDataService(_query); _api = new ApiDataService(_query);
} }
/// <summary>
/// Constructor for the class
/// </summary>
public Request()
{
}
/// <summary> /// <summary>
/// Performs the search request /// Performs the search request
/// </summary> /// </summary>
@ -55,5 +63,12 @@ namespace DeskHubSharp
return owner; return owner;
} }
public List<string> PerformGetSort()
{
Sort sort = new Sort();
var sortTerms = sort.GetSortTerms();
return sortTerms;
}
} }
} }

View File

@ -28,7 +28,7 @@
<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,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"/> <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"/> <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> </Grid>

View File

@ -25,17 +25,18 @@ namespace DeskHubSharp
private User _userDetail; private User _userDetail;
private Request _request; private Request _request;
private RepoInfo _repoInfo; private RepoInfo _repoInfo;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
//ShowDataGridItems(); _request = new Request();
cmbbox_sort.ItemsSource = _request.PerformGetSort();
} }
private void btn_detail_Click(object sender, RoutedEventArgs e) private void btn_detail_Click(object sender, RoutedEventArgs e)
{ {
try try
{ {
_repoDetail = RequestList.repoDetail;
RepoDetail repo = _repoDetail[ListBox.SelectedIndex]; RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
DetailWindow detail = new DetailWindow(repo); DetailWindow detail = new DetailWindow(repo);
detail.Show(); detail.Show();
@ -84,7 +85,8 @@ namespace DeskHubSharp
SearchWindow search = new SearchWindow(); SearchWindow search = new SearchWindow();
search.ShowDialog(); search.ShowDialog();
RepoInfo info = new RepoInfo(); RepoInfo info = new RepoInfo();
_repoDetail = RequestList.repoDetail;
var stuff = info.GetRepoInfoList(); var stuff = info.GetRepoInfoList();
if (stuff.Count == 0) if (stuff.Count == 0)
@ -117,6 +119,54 @@ namespace DeskHubSharp
private void btn_sort_Click(object sender, RoutedEventArgs e) private void btn_sort_Click(object sender, RoutedEventArgs e)
{ {
try
{
string sortTerm = cmbbox_sort.Text;
if (sortTerm == "A - Z")
{
var sortedList = _repoDetail.OrderBy(x => x.full_name).ToList();
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Stars")
{
// TODO: There's a bug in here
var sortedList = _repoDetail.OrderBy(c => c.stargazers_count).ToList();
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Forks")
{
var sortedList = _repoDetail.OrderBy(c => c.forks_count).ToList();
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
}
if (sortTerm == "Least to most Watchers")
{
var sortedList = _repoDetail.OrderBy(c => c.watchers_count).ToList();
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
}
}
catch (ArgumentNullException)
{
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.ItemsSource = searchedList.Select(x => x.full_name);
}
catch (ArgumentNullException)
{
ShowErrorMessage("A user has not been searched. Please try again.");
}
} }
} }

View File

@ -6,14 +6,22 @@ using System.Threading.Tasks;
namespace DeskHubSharp namespace DeskHubSharp
{ {
public static class Sort public class Sort
{ {
public enum SortBox public Sort()
{ {
Alphabettically,
MostStars, }
MostForks,
MostWatchers public List<string> GetSortTerms()
{
List<string> sortTerms = new List<string>();
sortTerms.Add("A - Z");
sortTerms.Add("Least to most Stars");
sortTerms.Add("Least to most Forks");
sortTerms.Add("Least to most Watchers");
return sortTerms;
} }
} }
} }

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5E7C2DBB667F025FC5CA90C6A4E4064F" #pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8924CF88FE4A7948C7314277251E7D79D8D8F350"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5E7C2DBB667F025FC5CA90C6A4E4064F" #pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8924CF88FE4A7948C7314277251E7D79D8D8F350"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.

View File

@ -1 +1 @@
17ecdc8fee3d6393cca5a22f6abf5748d0b3401c f6a02c2d6dac7b2ec0bdf4f3374969b628104441

View File

@ -4,16 +4,16 @@
winexe winexe
C# C#
.cs .cs
C:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\obj\Debug\ C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\obj\Debug\
DeskHubSharp DeskHubSharp
none none
false false
DEBUG;TRACE DEBUG;TRACE
C:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\App.xaml C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
7-86569338 7-86569338
27-1010967837 27-1010967837
20-856998346 20415715258
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml; AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
False False

View File

@ -1,10 +1,10 @@
 
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\AboutWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\AboutWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\DetailWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\DetailWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\ErrorWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\ErrorWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\FeedbackWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\FeedbackWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\HelpWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\HelpWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\MainWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\MainWindow.xaml;;
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\SearchWindow.xaml;; FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\SearchWindow.xaml;;

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "1E01AC040AC8F24B3F0ED293B159302B" #pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
@ -361,6 +361,12 @@ namespace DeskHubSharp {
return; return;
case 22: case 22:
this.btn_searchrepo = ((System.Windows.Controls.Button)(target)); this.btn_searchrepo = ((System.Windows.Controls.Button)(target));
#line 31 "..\..\MainWindow.xaml"
this.btn_searchrepo.Click += new System.Windows.RoutedEventHandler(this.btn_searchrepo_Click);
#line default
#line hidden
return; return;
case 23: case 23:
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target)); this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "1E01AC040AC8F24B3F0ED293B159302B" #pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
@ -361,6 +361,12 @@ namespace DeskHubSharp {
return; return;
case 22: case 22:
this.btn_searchrepo = ((System.Windows.Controls.Button)(target)); this.btn_searchrepo = ((System.Windows.Controls.Button)(target));
#line 31 "..\..\MainWindow.xaml"
this.btn_searchrepo.Click += new System.Windows.RoutedEventHandler(this.btn_searchrepo_Click);
#line default
#line hidden
return; return;
case 23: case 23:
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target)); this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));