added sort and search buttons
This commit is contained in:
parent
1e8d6b4b25
commit
735d92147c
Binary file not shown.
Binary file not shown.
@ -12,7 +12,7 @@ namespace DeskHubSharp
|
||||
private string _query;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class
|
||||
/// Override constructor for the class
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
public Request(string query)
|
||||
@ -21,6 +21,14 @@ namespace DeskHubSharp
|
||||
_api = new ApiDataService(_query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the class
|
||||
/// </summary>
|
||||
public Request()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the search request
|
||||
/// </summary>
|
||||
@ -55,5 +63,12 @@ namespace DeskHubSharp
|
||||
return owner;
|
||||
}
|
||||
|
||||
public List<string> PerformGetSort()
|
||||
{
|
||||
Sort sort = new Sort();
|
||||
var sortTerms = sort.GetSortTerms();
|
||||
return sortTerms;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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"/>
|
||||
<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"/>
|
||||
<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>
|
||||
|
@ -25,17 +25,18 @@ namespace DeskHubSharp
|
||||
private User _userDetail;
|
||||
private Request _request;
|
||||
private RepoInfo _repoInfo;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
//ShowDataGridItems();
|
||||
_request = new Request();
|
||||
cmbbox_sort.ItemsSource = _request.PerformGetSort();
|
||||
}
|
||||
|
||||
private void btn_detail_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_repoDetail = RequestList.repoDetail;
|
||||
RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
|
||||
DetailWindow detail = new DetailWindow(repo);
|
||||
detail.Show();
|
||||
@ -84,7 +85,8 @@ namespace DeskHubSharp
|
||||
SearchWindow search = new SearchWindow();
|
||||
search.ShowDialog();
|
||||
RepoInfo info = new RepoInfo();
|
||||
|
||||
_repoDetail = RequestList.repoDetail;
|
||||
|
||||
var stuff = info.GetRepoInfoList();
|
||||
|
||||
if (stuff.Count == 0)
|
||||
@ -117,6 +119,54 @@ namespace DeskHubSharp
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,22 @@ using System.Threading.Tasks;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
// This code was generated by a tool.
|
||||
|
@ -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>
|
||||
// This code was generated by a tool.
|
||||
|
@ -1 +1 @@
|
||||
17ecdc8fee3d6393cca5a22f6abf5748d0b3401c
|
||||
f6a02c2d6dac7b2ec0bdf4f3374969b628104441
|
||||
|
@ -4,16 +4,16 @@
|
||||
winexe
|
||||
C#
|
||||
.cs
|
||||
C:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\obj\Debug\
|
||||
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\obj\Debug\
|
||||
DeskHubSharp
|
||||
none
|
||||
false
|
||||
DEBUG;TRACE
|
||||
C:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\App.xaml
|
||||
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
|
||||
7-86569338
|
||||
|
||||
27-1010967837
|
||||
20-856998346
|
||||
20415715258
|
||||
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
|
||||
|
||||
False
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\AboutWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\DetailWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\ErrorWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\FeedbackWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\HelpWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\MainWindow.xaml;;
|
||||
FC:\Users\mill1159\Desktop\DeskHubSharp\DeskHubSharp\SearchWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\AboutWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\DetailWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\ErrorWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\FeedbackWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\HelpWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\MainWindow.xaml;;
|
||||
FC:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\SearchWindow.xaml;;
|
||||
|
||||
|
@ -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>
|
||||
// This code was generated by a tool.
|
||||
@ -361,6 +361,12 @@ namespace DeskHubSharp {
|
||||
return;
|
||||
case 22:
|
||||
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;
|
||||
case 23:
|
||||
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));
|
||||
|
@ -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>
|
||||
// This code was generated by a tool.
|
||||
@ -361,6 +361,12 @@ namespace DeskHubSharp {
|
||||
return;
|
||||
case 22:
|
||||
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;
|
||||
case 23:
|
||||
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));
|
||||
|
Reference in New Issue
Block a user