diff --git a/.vs/DeskHubSharp/v15/.suo b/.vs/DeskHubSharp/v15/.suo
index 439d2ea..56e92d6 100644
Binary files a/.vs/DeskHubSharp/v15/.suo and b/.vs/DeskHubSharp/v15/.suo differ
diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide
index b8faaf4..38364c7 100644
Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide and b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide differ
diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm
deleted file mode 100644
index 00c9850..0000000
Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm and /dev/null differ
diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal
deleted file mode 100644
index 50d6117..0000000
Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal and /dev/null differ
diff --git a/ClassDiagram.pdf b/ClassDiagram.pdf
new file mode 100644
index 0000000..6c19e34
Binary files /dev/null and b/ClassDiagram.pdf differ
diff --git a/DeskHubSharp/AboutWindow.xaml b/DeskHubSharp/AboutWindow.xaml
index e21dcc2..de8a1df 100644
--- a/DeskHubSharp/AboutWindow.xaml
+++ b/DeskHubSharp/AboutWindow.xaml
@@ -5,19 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DeskHubSharp"
mc:Ignorable="d"
- Title="About - DeskHubSharp" Height="450" Width="400" ResizeMode="NoResize">
+ Title="About - DeskHubSharp" Height="300" Width="400" ResizeMode="NoResize">
-
-
-
-
-
-
- Want to help with development?
-
-
-
+
+
+
+
This project cannot be done without the help of
johnvelis
@@ -35,5 +29,6 @@
tarkowr.
+
diff --git a/DeskHubSharp/BusinessLayer/EmailBLL.cs b/DeskHubSharp/BusinessLayer/EmailBLL.cs
index 726a6a0..f83e86d 100644
--- a/DeskHubSharp/BusinessLayer/EmailBLL.cs
+++ b/DeskHubSharp/BusinessLayer/EmailBLL.cs
@@ -13,9 +13,6 @@ namespace DeskHubSharp
{
class EmailBLL
{
- // TODO: finish this class
- // TODO: debug feedback form
-
private string _name;
private string _message;
private string _emailText;
@@ -27,6 +24,10 @@ namespace DeskHubSharp
_emailText = emailText;
}
+ ///
+ /// Checks to see if Email is valid to send
+ ///
+ ///
private bool IsValidated()
{
if (_name == "")
@@ -45,10 +46,21 @@ namespace DeskHubSharp
err.ShowDialog();
return false;
}
+ if (_emailText == "")
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.lbl_title.Content = "Oops.";
+ err.txtblk_error.Text = "Please fill in your email.";
+ err.ShowDialog();
+ return false;
+ }
return true;
}
+ ///
+ /// Creates message for user to send
+ ///
public void CreateMessage()
{
if (IsValidated())
@@ -64,13 +76,12 @@ namespace DeskHubSharp
message.Subject = $"{_name} requires your attention!";
message.Body = new TextPart("plain")
{
- Text = _message + _emailText
+ Text = _message + " " + _emailText
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
- // change credentials
client.Authenticate(email.FromEmail, email.Password);
client.Send(message);
client.Disconnect(true);
diff --git a/DeskHubSharp/BusinessLayer/RepoList.cs b/DeskHubSharp/BusinessLayer/RepoList.cs
new file mode 100644
index 0000000..02c131d
--- /dev/null
+++ b/DeskHubSharp/BusinessLayer/RepoList.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeskHubSharp
+{
+ class RepoInfo
+ {
+ public RepoInfo()
+ {
+
+ }
+
+ ///
+ /// Return a list for the list box
+ ///
+ ///
+ public List GetRepoInfoList()
+ {
+ List stuff = new List();
+
+ try
+ {
+ stuff = RequestList.repoDetail.Select(x => x.full_name).ToList();
+ }
+ catch (Exception)
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "We couldn't gather any data. Does the user exist?";
+ err.ShowDialog();
+ }
+
+ return stuff;
+ }
+
+ ///
+ /// Return a list for the combo box
+ ///
+ ///
+ public List GetBranchNameComboBox()
+ {
+ List stuff = RequestList.branchDetail.Select(x => x.name).ToList();
+ return stuff;
+ }
+ }
+}
diff --git a/DeskHubSharp/BusinessLayer/Request.cs b/DeskHubSharp/BusinessLayer/Request.cs
index 8e297aa..fb77c74 100644
--- a/DeskHubSharp/BusinessLayer/Request.cs
+++ b/DeskHubSharp/BusinessLayer/Request.cs
@@ -1,110 +1,73 @@
-using RestSharp;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
-using System.Net;
-using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
-using Newtonsoft.Json;
-using System.Collections.ObjectModel;
namespace DeskHubSharp
{
- class Request
+ public class Request
{
- // TODO: this is rudimentary, fix it
- // i.e. try catch statements\
- // TODO: find how to access a list index
- // TODO: find how to access the deserialized
-
- private string _apiEndpoint = "https://api.github.com/";
+ private ApiDataService _api;
private string _query;
- public List RepoDetail { get; set; }
-
+ ///
+ /// Override constructor for the class
+ ///
+ ///
public Request(string query)
{
_query = query;
+ _api = new ApiDataService(_query);
}
- //public Request(string query, Object function)
- //{
- // _query = query;
- //}
+ ///
+ /// Constructor for the class
+ ///
+ public Request()
+ {
+
+ }
///
- /// Calls API for repo and user data an stores it in RepoList
+ /// Performs the search request
+ ///
+ public void PerformSearchRequest()
+ {
+ _api.SearchRequest();
+ }
+
+ ///
+ /// Performs the user request
+ ///
+ public void PerformUserRequest()
+ {
+ _api.UserRequest();
+ }
+
+ ///
+ /// Performs the branch request
+ ///
+ public void PerformBranchRequest()
+ {
+ _api.BranchRequest();
+ }
+
+ ///
+ /// Performs the local owner request
///
///
- public void SearchRequest()
+ public Owner GetUserData()
{
- try
- {
- var client = new RestClient(_apiEndpoint);
- RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
-
- var response = client.Execute(requestRepo);
- var x = response.Content;
- var deserialized = JsonConvert.DeserializeObject>(x);
-
- //ObservableCollection test = new ObservableCollection()
- //{
- // new RepoDetail()
- // {
- // Login = "John",
- // Password = "pw"
- // }
- //};
-
- if (deserialized.Count() == 0)
- {
- throw new Exception();
- }
- else
- {
- RepoList.repoDetail = deserialized;
- }
- }
- catch (Exception)
- {
- ErrorWindow err = new ErrorWindow();
- err.txtblk_error.Text = "We couldn't gather repository data. Please try again";
- }
+ Owner owner = new Owner();
+ return owner;
}
-
- ///
- /// Calls API for detailed user data
- ///
- public void UserRequest()
+ public List PerformGetSort()
{
- try
- {
- var client = new RestClient(_apiEndpoint);
-
- RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
-
- var response = client.Execute(requestUser);
- string x = response.Content;
- var deserailized = JsonConvert.DeserializeObject(x);
-
- if (deserailized == null)
- {
- throw new Exception();
- }
- else
- {
- RepoList.userDetail = deserailized;
- }
-
- }
- catch (Exception)
- {
- ErrorWindow err = new ErrorWindow();
- err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
- }
-
+ Sort sort = new Sort();
+ var sortTerms = sort.GetSortTerms();
+ return sortTerms;
}
}
diff --git a/DeskHubSharp/ClassDiagram1.cd b/DeskHubSharp/ClassDiagram1.cd
new file mode 100644
index 0000000..14d5e9b
--- /dev/null
+++ b/DeskHubSharp/ClassDiagram1.cd
@@ -0,0 +1,148 @@
+
+
+
+
+
+ AAAABAAAAAQAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAA=
+ AboutWindow.xaml.cs
+
+
+
+
+
+
+ AAAIhAAAAAQAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ DetailWindow.xaml.cs
+
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAA=
+ ErrorWindow.xaml.cs
+
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAEA=
+ FeedbackWindow.xaml.cs
+
+
+
+
+
+
+ AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ HelpWindow.xaml.cs
+
+
+
+
+
+
+ AAAAhAAAAAAAAAAAQCAQAAAAAAQAAgAAAIAwBEAAAAA=
+ MainWindow.xaml.cs
+
+
+
+
+
+
+ AAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAA=
+ SearchWindow.xaml.cs
+
+
+
+
+
+
+ gAAAAgAAAAAEAAAgAAAAAAAAAAAAAAAAAAAAAEAAAAA=
+ DAL\ApiDataService.cs
+
+
+
+
+
+
+
+
+
+
+
+ Models\Branch.cs
+
+
+
+
+ QAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA=
+ Models\Branch.cs
+
+
+
+
+
+ AAAAIAAAAAAAAAAAAAIAAIAAAAAAAACAEAAAAAAAAAA=
+ BusinessLayer\EmailBLL.cs
+
+
+
+
+
+ ACAAAAAAAAAAAAAAAAAEAAAAAAAcAAAAAAAAAAAAAAA=
+ Models\License.cs
+
+
+
+
+
+ BGAAAAAAAAAAoAAQAAAAIAAAgAAJAAIUAgAAAAgAMgA=
+ Models\Owner.cs
+
+
+
+
+
+ BCIwgQSAIRCAkB8B4OwJIEAEyiANIQFYKRKI4AgFngw=
+ Models\RepoDetail.cs
+
+
+
+
+
+ AAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ BusinessLayer\RepoList.cs
+
+
+
+
+
+ AAAAAAgAAAAgAAAgAgAAAAAACADAAAAAAAAAAAAAAAA=
+ BusinessLayer\Request.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAQAAAAAIAAAAA=
+ Models\RequestList.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAA=
+ Models\Sort.cs
+
+
+
+
+
+ gAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA=
+ DAL\IDataService.cs
+
+
+
+
\ No newline at end of file
diff --git a/DeskHubSharp/DAL/ApiDataService.cs b/DeskHubSharp/DAL/ApiDataService.cs
new file mode 100644
index 0000000..22788c2
--- /dev/null
+++ b/DeskHubSharp/DAL/ApiDataService.cs
@@ -0,0 +1,126 @@
+using RestSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Mail;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using System.Collections.ObjectModel;
+
+namespace DeskHubSharp
+{
+ class ApiDataService : IDataService
+ {
+ // TODO: this is rudimentary, fix it
+ // i.e. try catch statements\
+ // TODO: Add BranchRequest function
+
+ private string _apiEndpoint;
+ private string _query;
+
+ public List RepoDetail { get; set; }
+
+ public ApiDataService(string query)
+ {
+ _query = query;
+ _apiEndpoint = DataConfig.dataConfString;
+ }
+
+ //public Request(string query, Object function)
+ //{
+ // _query = query;
+ //}
+
+ ///
+ /// Calls API for repo and basic user data
+ ///
+ ///
+ public void SearchRequest()
+ {
+ try
+ {
+ var client = new RestClient(_apiEndpoint);
+ RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
+
+ var response = client.Execute(requestRepo);
+ var x = response.Content;
+ var deserialized = JsonConvert.DeserializeObject>(x);
+
+ if (deserialized.Count == 0)
+ {
+ throw new Exception();
+ }
+ else
+ {
+ RequestList.repoDetail = deserialized;
+ }
+ }
+ catch (Exception)
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "We couldn't gather repository data. Please try again";
+ }
+ }
+
+
+ ///
+ /// Calls API for detailed user data
+ ///
+ public void UserRequest()
+ {
+ try
+ {
+ var client = new RestClient(_apiEndpoint);
+
+ RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
+
+ var response = client.Execute(requestUser);
+ string x = response.Content;
+ var deserailized = JsonConvert.DeserializeObject(x);
+
+ if (deserailized == null)
+ {
+ throw new Exception();
+ }
+ else
+ {
+ RequestList.userDetail = deserailized;
+ }
+
+ }
+ catch (NullReferenceException)
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
+ }
+
+ }
+
+ ///
+ /// Calls API for detailed branch data
+ ///
+ public void BranchRequest()
+ {
+ try
+ {
+ var client = new RestClient(_apiEndpoint);
+
+ RestRequest requestUser = new RestRequest($"/repos/{RequestList.userDetail.login}/{_query}/branches", Method.GET);
+
+ var response = client.Execute(requestUser);
+ string x = response.Content;
+ var deserailized = JsonConvert.DeserializeObject>(x);
+
+ RequestList.branchDetail = deserailized;
+ }
+ catch (NullReferenceException)
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
+ }
+ }
+
+ }
+}
diff --git a/DeskHubSharp/DAL/IDataService.cs b/DeskHubSharp/DAL/IDataService.cs
index 524d14e..1d367b8 100644
--- a/DeskHubSharp/DAL/IDataService.cs
+++ b/DeskHubSharp/DAL/IDataService.cs
@@ -8,7 +8,11 @@ namespace DeskHubSharp
{
public interface IDataService
{
- List ReadAll();
- void WriteAll(List user);
+ //List ReadAll();
+ //void WriteAll(List user);
+
+ void SearchRequest();
+ void UserRequest();
+ void BranchRequest();
}
}
diff --git a/DeskHubSharp/DAL/XmlDataService.cs b/DeskHubSharp/DAL/XmlDataService.cs
deleted file mode 100644
index 756b7b0..0000000
--- a/DeskHubSharp/DAL/XmlDataService.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Serialization;
-using System.IO;
-
-namespace DeskHubSharp
-{
- class XmlDataService
- {
- private readonly string _dataFilePath;
-
- public List ReadAll()
- {
- List Users = new List();
- XmlSerializer serializer = new XmlSerializer(typeof(List), new XmlRootAttribute("Users"));
-
- try
- {
- StreamReader reader = new StreamReader(_dataFilePath);
- using (reader)
- {
- Users = (List)serializer.Deserialize(reader);
- }
-
- }
- catch (Exception)
- {
- throw;
- }
-
- return Users;
- }
-
- public void WriteAll(List Users)
- {
- XmlSerializer serializer = new XmlSerializer(typeof(List), new XmlRootAttribute("Users"));
-
- try
- {
- StreamWriter writer = new StreamWriter(_dataFilePath);
- using (writer)
- {
- serializer.Serialize(writer, Users);
- }
- }
- catch (Exception)
- {
-
- throw;
- }
- }
-
- public XmlDataService()
- {
-
- }
-
- public XmlDataService(string datafile)
- {
- _dataFilePath = datafile;
- }
- }
-}
diff --git a/DeskHubSharp/Data/DataConfig.cs b/DeskHubSharp/Data/DataConfig.cs
index 354c259..abca955 100644
--- a/DeskHubSharp/Data/DataConfig.cs
+++ b/DeskHubSharp/Data/DataConfig.cs
@@ -8,6 +8,6 @@ namespace DeskHubSharp
{
class DataConfig
{
- public string dataConfString = "";
+ public static string dataConfString = "https://api.github.com/";
}
}
diff --git a/DeskHubSharp/DeskHubSharp.csproj b/DeskHubSharp/DeskHubSharp.csproj
index de886c3..e25d345 100644
--- a/DeskHubSharp/DeskHubSharp.csproj
+++ b/DeskHubSharp/DeskHubSharp.csproj
@@ -71,11 +71,14 @@
MSBuild:Compile
+
+
-
+
+
SearchWindow.xaml
@@ -106,9 +109,8 @@
Code
-
+
-
DetailWindow.xaml
@@ -132,7 +134,7 @@
-
+
@@ -153,6 +155,7 @@
Resources.Designer.cs
+
SettingsSingleFileGenerator
diff --git a/DeskHubSharp/DetailWindow.xaml b/DeskHubSharp/DetailWindow.xaml
index 71e3fd9..16ca90e 100644
--- a/DeskHubSharp/DetailWindow.xaml
+++ b/DeskHubSharp/DetailWindow.xaml
@@ -5,12 +5,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DeskHubSharp"
mc:Ignorable="d"
- Title="Detail - DeskHubSharp" Height="450" Width="800" ResizeMode="NoResize">
+ Title="Detail - DeskHubSharp" Height="450" Width="400" ResizeMode="NoResize">
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DeskHubSharp/DetailWindow.xaml.cs b/DeskHubSharp/DetailWindow.xaml.cs
index 6c8e563..1ffefed 100644
--- a/DeskHubSharp/DetailWindow.xaml.cs
+++ b/DeskHubSharp/DetailWindow.xaml.cs
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -21,12 +22,36 @@ namespace DeskHubSharp
public partial class DetailWindow : Window
{
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.ItemsSource = 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.";
+ }
+
lbl_reponame.Content = _repoDetail.full_name;
+ txtblk_stargazers.Text = $"This repo has {_repoDetail.stargazers_count} stargazers.";
+ txtblk_watchers.Text = $"This repo has {_repoDetail.watchers_count} watchers.";
+ txtblk_forks.Text = $"This repo has {_repoDetail.forks_count} forks.";
+
}
@@ -34,5 +59,27 @@ namespace DeskHubSharp
{
this.Close();
}
+
+ private void btn_clone_Click(object sender, RoutedEventArgs e)
+ {
+ if (cmbbox_branches.Text == "")
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "Please select a branch to clone.";
+ }
+ else
+ {
+ _owner = new Owner();
+ string link = "https://github.com/" + _repoDetail.owner.login + "/" + _repoDetail.name + "/archive/" + cmbbox_branches.Text + ".zip";
+
+ Process.Start(link);
+ }
+
+ }
+
+ private void btn_page_Click(object sender, RoutedEventArgs e)
+ {
+ Process.Start($"{_repoDetail.html_url}");
+ }
}
}
diff --git a/DeskHubSharp/HelpWindow.xaml b/DeskHubSharp/HelpWindow.xaml
index 01bbc54..47d1f1e 100644
--- a/DeskHubSharp/HelpWindow.xaml
+++ b/DeskHubSharp/HelpWindow.xaml
@@ -10,7 +10,7 @@
-
+
diff --git a/DeskHubSharp/MainWindow.xaml b/DeskHubSharp/MainWindow.xaml
index 5efccab..02f4f32 100644
--- a/DeskHubSharp/MainWindow.xaml
+++ b/DeskHubSharp/MainWindow.xaml
@@ -7,7 +7,7 @@
mc:Ignorable="d"
Title="DeskHubSharp" Height="450" Width="805" ResizeMode="NoResize">
-
+
@@ -25,7 +25,11 @@
-
+
+
+
+
+
diff --git a/DeskHubSharp/MainWindow.xaml.cs b/DeskHubSharp/MainWindow.xaml.cs
index a44c660..3899f89 100644
--- a/DeskHubSharp/MainWindow.xaml.cs
+++ b/DeskHubSharp/MainWindow.xaml.cs
@@ -22,23 +22,43 @@ namespace DeskHubSharp
public partial class MainWindow : Window
{
private ObservableCollection _repoDetail;
+ private User _userDetail;
+ private Request _request;
public MainWindow()
{
InitializeComponent();
- //ShowDataGridItems();
+ _request = new Request();
+ cmbbox_sort.ItemsSource = _request.PerformGetSort();
}
private void btn_detail_Click(object sender, RoutedEventArgs e)
{
- RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
- DetailWindow detail = new DetailWindow(repo);
- detail.ShowDialog();
+ 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("MEME REVIEW!");
+ }
+
}
private void btn_exit_Click(object sender, RoutedEventArgs e)
{
this.Close();
+ Environment.Exit(0);
}
private void btn_about_Click(object sender, RoutedEventArgs e)
@@ -62,30 +82,88 @@ namespace DeskHubSharp
private void btn_search_Click(object sender, RoutedEventArgs e)
{
SearchWindow search = new SearchWindow();
- RepoInfo info = new RepoInfo();
- Owner owner = new Owner();
search.ShowDialog();
- var stuff = info.GetRepoInfoDataGrid();
- _repoDetail = RepoList.repoDetail;
- ListBox.ItemsSource = stuff;
- txtblk_username.Text = RepoList.userDetail.login;
- txtblk_url.Text = RepoList.userDetail.html_url;
- txtblk_bio.Text = RepoList.userDetail.bio;
- txtblk_email.Text = RepoList.userDetail.blog;
- txtblk_realname.Text = RepoList.userDetail.name;
- txtblk_repocount.Text = $"{RepoList.userDetail.login} has {RepoList.userDetail.public_repos} public repositories.";
- //img_avatar.Source = RepoList.repoDetail[0].owner.avatar_url;
+ RepoInfo info = new RepoInfo();
+ _repoDetail = RequestList.repoDetail;
+
+ var stuff = info.GetRepoInfoList();
+
+ if (stuff.Count == 0)
+ {
+ 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
+ {
+ _userDetail = RequestList.userDetail;
+ ListBox.ItemsSource = stuff;
+ txtblk_username.Text = _userDetail.login;
+ txtblk_url.Text = _userDetail.html_url;
+ txtblk_bio.Text = _userDetail.bio;
+ txtblk_email.Text = _userDetail.blog;
+ txtblk_realname.Text = _userDetail.name;
+ txtblk_repocount.Text = $"{_userDetail.login} has {_userDetail.public_repos} public repositories.";
+ }
}
- private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ public void ShowErrorMessage(string message)
{
-
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = message;
+ err.ShowDialog();
}
- //public void ShowDataGridItems()
- //{
- // DataGrid.ItemsSource = RepoList.repoDetail;
- //}
+ 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")
+ {
+ 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.");
+ }
+
+ }
}
}
diff --git a/DeskHubSharp/Models/Branch.cs b/DeskHubSharp/Models/Branch.cs
new file mode 100644
index 0000000..51fa4f4
--- /dev/null
+++ b/DeskHubSharp/Models/Branch.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeskHubSharp
+{
+ public class Branch
+ {
+ public string name { get; set; }
+
+ public Commit commit { get; set; }
+
+ public class Commit
+ {
+ public string sha { get; set; }
+ public string url { get; set; }
+ }
+
+ }
+}
diff --git a/DeskHubSharp/Models/Email.cs b/DeskHubSharp/Models/Email.cs
index 22630a2..58498f3 100644
--- a/DeskHubSharp/Models/Email.cs
+++ b/DeskHubSharp/Models/Email.cs
@@ -4,7 +4,7 @@ namespace DeskHubSharp
{
private string _toEmail = "wjmiller2016@gmail.com";
private string _fromEmail = "wjmiller2016@gmail.com";
- private string _passwordEmail = "password";
+ private string _passwordEmail = "IhaveanAMDRX580";
public string Password
{
@@ -24,6 +24,9 @@ namespace DeskHubSharp
set { _toEmail = value; }
}
+ ///
+ /// Constructor for the Email class
+ ///
public Email()
{
diff --git a/DeskHubSharp/Models/License.cs b/DeskHubSharp/Models/License.cs
index c58e2ed..3b0c31b 100644
--- a/DeskHubSharp/Models/License.cs
+++ b/DeskHubSharp/Models/License.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace DeskHubSharp
{
+ ///
+ /// Class from a JSON to a C# converter
+ ///
public class License
{
///
diff --git a/DeskHubSharp/Models/Owner.cs b/DeskHubSharp/Models/Owner.cs
index 176aee5..7ceace9 100644
--- a/DeskHubSharp/Models/Owner.cs
+++ b/DeskHubSharp/Models/Owner.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace DeskHubSharp
{
+ ///
+ /// Class from a JSON to a C# converter
+ ///
public class Owner
{
///
diff --git a/DeskHubSharp/Models/RepoDetail.cs b/DeskHubSharp/Models/RepoDetail.cs
index 6833661..d6ae37b 100644
--- a/DeskHubSharp/Models/RepoDetail.cs
+++ b/DeskHubSharp/Models/RepoDetail.cs
@@ -2,6 +2,9 @@ using DeskHubSharp;
namespace DeskHubSharp
{
+
+ // TODO: The RepoDetail class is called from the code behind, fix it
+
public class RepoDetail
{
public Owner Owner { get; set; }
diff --git a/DeskHubSharp/Models/RepoInfo.cs b/DeskHubSharp/Models/RepoInfo.cs
deleted file mode 100644
index 35fe22d..0000000
--- a/DeskHubSharp/Models/RepoInfo.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DeskHubSharp
-{
- class RepoInfo
- {
- public RepoInfo()
- {
-
- }
-
- public List GetRepoInfoDataGrid()
- {
- List stuff = RepoList.repoDetail.Select(x => x.full_name).ToList();
- //stuff =+ RepoList.repoDetail.Select(x => x.name).ToList();
- return stuff;
- }
-
- }
-}
diff --git a/DeskHubSharp/Models/RepoList.cs b/DeskHubSharp/Models/RepoList.cs
deleted file mode 100644
index 47b841b..0000000
--- a/DeskHubSharp/Models/RepoList.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DeskHubSharp
-{
- class RepoList
- {
- private static ObservableCollection _repoDetail;
-
- public static User userDetail { get; set; }
-
- public static ObservableCollection repoDetail
- {
- get { return _repoDetail; }
- set { _repoDetail = value; }
- }
- }
-}
diff --git a/DeskHubSharp/Models/RequestList.cs b/DeskHubSharp/Models/RequestList.cs
new file mode 100644
index 0000000..56ab6a5
--- /dev/null
+++ b/DeskHubSharp/Models/RequestList.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeskHubSharp
+{
+ public class RequestList
+ {
+ ///
+ /// Stores everything in User, typically from the request
+ ///
+ public static User userDetail { get; set; }
+
+ ///
+ /// Stores everything sent in Branch, typically from request
+ ///
+ public static ObservableCollection branchDetail { get; set; }
+
+ ///
+ /// Stores everything sent in RepoDetail, typically from request
+ ///
+ public static ObservableCollection repoDetail { get; set; }
+ }
+}
diff --git a/DeskHubSharp/Models/Sort.cs b/DeskHubSharp/Models/Sort.cs
new file mode 100644
index 0000000..aff2434
--- /dev/null
+++ b/DeskHubSharp/Models/Sort.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeskHubSharp
+{
+ public class Sort
+ {
+ public Sort()
+ {
+
+ }
+
+ public List GetSortTerms()
+ {
+ List sortTerms = new List();
+ sortTerms.Add("A - Z");
+ sortTerms.Add("Least to most Stars");
+ sortTerms.Add("Least to most Forks");
+ sortTerms.Add("Least to most Watchers");
+
+ return sortTerms;
+ }
+ }
+}
diff --git a/DeskHubSharp/Models/User.cs b/DeskHubSharp/Models/User.cs
index 3d63337..bb98f49 100644
--- a/DeskHubSharp/Models/User.cs
+++ b/DeskHubSharp/Models/User.cs
@@ -2,6 +2,8 @@ using System.Collections.Generic;
namespace DeskHubSharp
{
+
+ // The User class is called from the code behind, fix it
public class User
{
public string login { get; set; }
diff --git a/DeskHubSharp/SearchWindow.xaml.cs b/DeskHubSharp/SearchWindow.xaml.cs
index 07c6509..5bded0a 100644
--- a/DeskHubSharp/SearchWindow.xaml.cs
+++ b/DeskHubSharp/SearchWindow.xaml.cs
@@ -19,6 +19,9 @@ namespace DeskHubSharp
///
public partial class SearchWindow : Window
{
+
+ private Request _request;
+
public SearchWindow()
{
InitializeComponent();
@@ -31,12 +34,20 @@ namespace DeskHubSharp
private void btn_search_Click(object sender, RoutedEventArgs e)
{
- Request request = new Request(txtbox_query.Text);
- request.SearchRequest();
- request.UserRequest();
- //MainWindow main = new MainWindow();
- //main.ShowDialog();
- this.Close();
+ if (txtbox_query.Text == "")
+ {
+ ErrorWindow err = new ErrorWindow();
+ err.txtblk_error.Text = "Please enter a username!";
+ err.ShowDialog();
+ }
+ else
+ {
+ _request = new Request(txtbox_query.Text);
+ _request.PerformSearchRequest();
+ _request.PerformUserRequest();
+ this.Close();
+ }
+
}
}
}
diff --git a/DeskHubSharp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/DeskHubSharp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 0190b2a..5918c2c 100644
Binary files a/DeskHubSharp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/DeskHubSharp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/DeskHubSharp/obj/Debug/DeskHubSharp.csproj.CoreCompileInputs.cache b/DeskHubSharp/obj/Debug/DeskHubSharp.csproj.CoreCompileInputs.cache
index a8ad283..3866400 100644
--- a/DeskHubSharp/obj/Debug/DeskHubSharp.csproj.CoreCompileInputs.cache
+++ b/DeskHubSharp/obj/Debug/DeskHubSharp.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-5719003caa9368fdbade249bbbe98f747b8af257
+f6a02c2d6dac7b2ec0bdf4f3374969b628104441
diff --git a/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.cache b/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.cache
index 8366d71..5c29b6e 100644
--- a/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.cache
+++ b/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.cache
@@ -12,7 +12,7 @@ DEBUG;TRACE
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
7-86569338
-25696652050
+27-1010967837
20415715258
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
diff --git a/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.i.cache b/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.i.cache
index 48ed846..b00bd68 100644
--- a/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.i.cache
+++ b/DeskHubSharp/obj/Debug/DeskHubSharp_MarkupCompile.i.cache
@@ -12,9 +12,9 @@ DEBUG;TRACE
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
7-86569338
-29498133693
+31-1209486194
20415715258
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
-False
+True
diff --git a/DeskHubSharp/obj/Debug/MainWindow.g.cs b/DeskHubSharp/obj/Debug/MainWindow.g.cs
index 36e95a9..b16f54c 100644
--- a/DeskHubSharp/obj/Debug/MainWindow.g.cs
+++ b/DeskHubSharp/obj/Debug/MainWindow.g.cs
@@ -1,4 +1,4 @@
-#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0EAA4E5953DD54A83EF84C8979256F95CA55AC47"
+#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
@@ -51,7 +51,7 @@ namespace DeskHubSharp {
#line 10 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
- internal System.Windows.Controls.Button btn_search;
+ internal System.Windows.Controls.Button btn_searchuser;
#line default
#line hidden
@@ -192,6 +192,38 @@ namespace DeskHubSharp {
#line default
#line hidden
+
+ #line 29 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ComboBox cmbbox_sort;
+
+ #line default
+ #line hidden
+
+
+ #line 30 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button btn_sort;
+
+ #line default
+ #line hidden
+
+
+ #line 31 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button btn_searchrepo;
+
+ #line default
+ #line hidden
+
+
+ #line 32 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox txtbox_searchbox;
+
+ #line default
+ #line hidden
+
private bool _contentLoaded;
///
@@ -226,10 +258,10 @@ namespace DeskHubSharp {
this.window_main = ((DeskHubSharp.MainWindow)(target));
return;
case 2:
- this.btn_search = ((System.Windows.Controls.Button)(target));
+ this.btn_searchuser = ((System.Windows.Controls.Button)(target));
#line 10 "..\..\MainWindow.xaml"
- this.btn_search.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
+ this.btn_searchuser.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
#line default
#line hidden
@@ -315,6 +347,30 @@ namespace DeskHubSharp {
case 19:
this.txtblk_repocount = ((System.Windows.Controls.TextBlock)(target));
return;
+ case 20:
+ this.cmbbox_sort = ((System.Windows.Controls.ComboBox)(target));
+ return;
+ case 21:
+ this.btn_sort = ((System.Windows.Controls.Button)(target));
+
+ #line 30 "..\..\MainWindow.xaml"
+ this.btn_sort.Click += new System.Windows.RoutedEventHandler(this.btn_sort_Click);
+
+ #line default
+ #line hidden
+ 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));
+ return;
}
this._contentLoaded = true;
}
diff --git a/DeskHubSharp/obj/Debug/MainWindow.g.i.cs b/DeskHubSharp/obj/Debug/MainWindow.g.i.cs
index 36e95a9..b16f54c 100644
--- a/DeskHubSharp/obj/Debug/MainWindow.g.i.cs
+++ b/DeskHubSharp/obj/Debug/MainWindow.g.i.cs
@@ -1,4 +1,4 @@
-#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0EAA4E5953DD54A83EF84C8979256F95CA55AC47"
+#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
@@ -51,7 +51,7 @@ namespace DeskHubSharp {
#line 10 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
- internal System.Windows.Controls.Button btn_search;
+ internal System.Windows.Controls.Button btn_searchuser;
#line default
#line hidden
@@ -192,6 +192,38 @@ namespace DeskHubSharp {
#line default
#line hidden
+
+ #line 29 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.ComboBox cmbbox_sort;
+
+ #line default
+ #line hidden
+
+
+ #line 30 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button btn_sort;
+
+ #line default
+ #line hidden
+
+
+ #line 31 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.Button btn_searchrepo;
+
+ #line default
+ #line hidden
+
+
+ #line 32 "..\..\MainWindow.xaml"
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ internal System.Windows.Controls.TextBox txtbox_searchbox;
+
+ #line default
+ #line hidden
+
private bool _contentLoaded;
///
@@ -226,10 +258,10 @@ namespace DeskHubSharp {
this.window_main = ((DeskHubSharp.MainWindow)(target));
return;
case 2:
- this.btn_search = ((System.Windows.Controls.Button)(target));
+ this.btn_searchuser = ((System.Windows.Controls.Button)(target));
#line 10 "..\..\MainWindow.xaml"
- this.btn_search.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
+ this.btn_searchuser.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
#line default
#line hidden
@@ -315,6 +347,30 @@ namespace DeskHubSharp {
case 19:
this.txtblk_repocount = ((System.Windows.Controls.TextBlock)(target));
return;
+ case 20:
+ this.cmbbox_sort = ((System.Windows.Controls.ComboBox)(target));
+ return;
+ case 21:
+ this.btn_sort = ((System.Windows.Controls.Button)(target));
+
+ #line 30 "..\..\MainWindow.xaml"
+ this.btn_sort.Click += new System.Windows.RoutedEventHandler(this.btn_sort_Click);
+
+ #line default
+ #line hidden
+ 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));
+ return;
}
this._contentLoaded = true;
}