Skip to content

Commit

Permalink
Avatar URL support
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor W committed Dec 10, 2017
1 parent b97b6b9 commit 1cc1fea
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 5,066 deletions.
2 changes: 1 addition & 1 deletion Hawkchat/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\test.png" />
<None Include="Resources\profile-default-male.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 3 additions & 1 deletion Hawkchat/Client/LoginWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class LoginWindow : VisualForm
{

public static long ACCOUNTID;
public static string USERNAME;
public static string USERNAME, AVATAR_URL;

public LoginWindow()
{
Expand Down Expand Up @@ -72,6 +72,8 @@ private void btnLogin_Click(object sender, EventArgs e)

// show main window
ACCOUNTID = long.Parse(returnedJson["accountID"].ToString());
USERNAME = txtUsername.Text.Trim();
AVATAR_URL = returnedJson["avatarURL"].ToString();

#if DEBUG
btnLogin.Enabled = true;
Expand Down
429 changes: 225 additions & 204 deletions Hawkchat/Client/MainWindow.Designer.cs

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Hawkchat/Client/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)

Environment.Exit(0);

}

private void MainWindow_Load(object sender, EventArgs e)
{

// Set the user's username and avatar URL
userProfilePicture.ImageLocation = LoginWindow.AVATAR_URL;
groupBoxUserInfo.Text = LoginWindow.USERNAME;
lblLoggedInUserStatus.Text = "Online";
lblLoggedInUserStatus.ForeColor = Color.Green;
this.Text = "Hawk Chat";

this.Update();

}

private void visualButton1_Click(object sender, EventArgs e)
{



}
}
}
4,849 changes: 0 additions & 4,849 deletions Hawkchat/Client/MainWindow.resx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Hawkchat/Client/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Hawkchat/Client/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="test" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="DefaultAvatar" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\profile-default-male.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
8 changes: 5 additions & 3 deletions Hawkchat/Client/RegisterForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ private async void btnRegister_Click(object sender, EventArgs e)
txtUsernameTaken.ForeColor = Color.Green;

txtUsernameTaken.Visible = true;
await Task.Delay(5000);
txtUsernameTaken.Visible = false;

}

Expand All @@ -96,8 +94,12 @@ private async void btnRegister_Click(object sender, EventArgs e)

LoginWindow.ACCOUNTID = long.Parse(jObject["AccountID"].ToString());
LoginWindow.USERNAME = jObject["username"].ToString();
LoginWindow.AVATAR_URL = jObject["avatarURL"].ToString();

MainWindow mainWindow = new MainWindow();

MessageBox.Show("Show the main program UI here...");
mainWindow.Show();
this.Hide();

}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Hawkchat/Client/Resources/test.png
Binary file not shown.
8 changes: 6 additions & 2 deletions Hawkchat/Server/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ public static async void ParseCommand(string command, Message message, JObject j

}

string UserID = "";
string UserID = "", avatarURL = "";

while (reader.Read())
{

UserID = reader["AccountID"].ToString();
avatarURL = reader["avatarurl"].ToString();

}

reader.Close();

jsonResponse.accountID = UserID;
jsonResponse.avatarURL = avatarURL;

string banQuery = $"SELECT * FROM bans WHERE accountid='{UserID}'";

Expand Down Expand Up @@ -115,12 +117,13 @@ public static async void ParseCommand(string command, Message message, JObject j
string usrName = json["username"].ToString();
string pwd = json["password"].ToString();
string IPAddress = json["IP"].ToString();
string avatarURLl = json["avatarURL"].ToString();

long AccountID = Util.GenerateAccountID();

SQLiteConnection sQLiteConnection = DBUtils.EstablishConnection();

int rowsAffected = await DBUtils.ExecuteNonQuery(sQLiteConnection, $"INSERT INTO users (AccountID, username, password, lastip) VALUES ('{AccountID}', '{usrName}', '{pwd}', '{IPAddress}')");
int rowsAffected = await DBUtils.ExecuteNonQuery(sQLiteConnection, $"INSERT INTO users (AccountID, username, password, avatarurl, lastip) VALUES ('{AccountID}', '{usrName}', '{pwd}', '{avatarURLl}', '{IPAddress}')");


if (rowsAffected == 1)
Expand All @@ -129,6 +132,7 @@ public static async void ParseCommand(string command, Message message, JObject j
jsonResponse.success = true;
jsonResponse.AccountID = AccountID;
jsonResponse.username = usrName;
jsonResponse.avatarURL = avatarURLl;

DBUtils.CloseConnection(sQLiteConnection);

Expand Down
6 changes: 4 additions & 2 deletions Hawkchat/Server/models/ClientModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public class ClientModel
public string IP { get; set; }

public int Port { get; set; }

public string Username { get; set; }

//public string AvatarURL { get; set; }

public Int64 UserID { get; set; }

}
}

0 comments on commit 1cc1fea

Please sign in to comment.