Skip to content

Commit

Permalink
Admins can now turn off global chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor W committed Dec 11, 2017
1 parent 1cc1fea commit ede39a0
Show file tree
Hide file tree
Showing 11 changed files with 1,240 additions and 528 deletions.
10 changes: 10 additions & 0 deletions Hawkchat/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="admin\AdminTools.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="admin\AdminTools.Designer.cs">
<DependentUpon>AdminTools.cs</DependentUpon>
</Compile>
<Compile Include="BannedWindow.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -105,7 +111,11 @@
<Compile Include="RegisterForm.Designer.cs">
<DependentUpon>RegisterForm.cs</DependentUpon>
</Compile>
<Compile Include="utils\Constants.cs" />
<Compile Include="utils\Utils.cs" />
<EmbeddedResource Include="admin\AdminTools.resx">
<DependentUpon>AdminTools.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BannedWindow.resx">
<DependentUpon>BannedWindow.cs</DependentUpon>
</EmbeddedResource>
Expand Down
52 changes: 50 additions & 2 deletions Hawkchat/Client/LoginWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class LoginWindow : VisualForm

public static long ACCOUNTID;
public static string USERNAME, AVATAR_URL;
private MainWindow mainWindow;

public LoginWindow()
{
Expand All @@ -36,6 +37,8 @@ public LoginWindow()
client = new SimpleTcpClient().Connect("server ip", 3289);
#endif

client.DataReceived += Client_DataReceived;


}
catch (Exception)
Expand All @@ -48,6 +51,35 @@ public LoginWindow()
}
}

public static string REASON;

private void Client_DataReceived(object sender, SimpleTCP.Message e)
{

if (e.MessageString.Contains("command"))
{
JObject json = JObject.Parse(e.MessageString);

string command = json["command"].ToString();

switch (command)
{

case "DISABLEMESSAGING":
REASON = json["reason"].ToString();
mainWindow.ReceivedDisableMessaging();

break;

case "ENABLEMESSAGING":
mainWindow.ReceivedEnableMessaging();
break;

}

}
}

public static SimpleTcpClient client;

private void btnLogin_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -106,9 +138,25 @@ private void btnLogin_Click(object sender, EventArgs e)

//MessageBox.Show("Your report about this user has been sent. You will receive information once this matter has been resolved.", "Hawkchat", MessageBoxButtons.OK, MessageBoxIcon.Information);

MainWindow mainWindow = new MainWindow();

mainWindow = new MainWindow();
mainWindow.Show();

if (returnedJson["information"].ToString().Equals("MESSAGINGDISABLED"))
{

REASON = returnedJson["reason"].ToString();
mainWindow.ReceivedDisableMessaging();

}
else if (returnedJson["information"].ToString().Equals("MESSAGINGENABLED"))
{

mainWindow.ReceivedEnableMessaging();

}


this.Hide();

}
Expand Down
970 changes: 453 additions & 517 deletions Hawkchat/Client/MainWindow.Designer.cs

Large diffs are not rendered by default.

68 changes: 66 additions & 2 deletions Hawkchat/Client/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using Hawkchat.Client.admin;
using Hawkchat.Client.utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand All @@ -18,6 +20,32 @@ public MainWindow()
InitializeComponent();
}

public void ReceivedEnableMessaging()
{

BeginInvoke((Action)(() =>
{

txtMessage.Enabled = true;
txtMessage.Text = "";
btnSendMessage.Enabled = true;

}));
}

public void ReceivedDisableMessaging()
{

BeginInvoke((Action)(() =>
{

txtMessage.Enabled = false;
txtMessage.Text = LoginWindow.REASON;
btnSendMessage.Enabled = false;

}));
}

private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{

Expand All @@ -33,17 +61,53 @@ private void MainWindow_Load(object sender, EventArgs e)
groupBoxUserInfo.Text = LoginWindow.USERNAME;
lblLoggedInUserStatus.Text = "Online";
lblLoggedInUserStatus.ForeColor = Color.Green;

if (LoginWindow.USERNAME.Equals("Connor") || LoginWindow.USERNAME.Equals("Ethan"))
{

btnPerformModeration.Visible = true;

}
else
{

btnPerformModeration.Visible = false;

}

this.Text = "Hawk Chat";
this.Size = Constants.SMALL_WINDOW;



btnEndConversation.Visible = false;
visualPanel1.Visible = false;
btnReportUser.Visible = false;
btnRequestMore.Visible = false;
btnSendMessage.Visible = false;

txtMessage.Visible = false;


this.Update();

}


private void visualButton1_Click(object sender, EventArgs e)
{




}

private void btnPerformModeration_Click(object sender, EventArgs e)
{

AdminTools adminTools = new AdminTools();

adminTools.ShowDialog();

}
}
}
20 changes: 17 additions & 3 deletions Hawkchat/Client/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@
qdsAAAAASUVORK5CYII=
</value>
</data>
<metadata name="visualContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="resource.Image11" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
Expand All @@ -323,6 +320,23 @@
vECz+Ph4Fd3PEmgc08F9SJ4KK6ZDzj0jKfIjWUG/Hohs6kJkXwtETCUopaaGV5f4d4klp6SkHJJqklWd
srpphf2FHylfeIOivYG5ciMgVumCyCYFqWJHkMtYeafMKW1XOOQEa5cTVfY5pZwDirIphvkDtXtObc5T
qdsAAAAASUVORK5CYII=
</value>
</data>
<data name="resource.Image12" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAoBJREFUOE91kltLFGEYxye888YL8QP4Baov4FUSontynVkb19U8G9VFRAhBS4Wz
K5qkEIRhWUpexJJFBMLqzjhpoe2uh+xCIehCndmdGW1vjB1d/8377iE1e+AHL/M+/997GuasQtRWfBT3
XEDU7SJkx7bi3PT/C2DOHcXqzmei7GQmVqdmou40hY7ZSTJHenLt/xYNx9mY1XyEOIvjkG9kjvTk2k8W
2SJd+YxwHiqxes48Tnqeu3gwy6lmiEd6ksfB+yvILHD4HfdAXebxc8WLrZUG/Ipxatq6k1wsW6nAYune
3f4ho6P1cJdvg1HfjqS3DeGbjRh53YSJlU6Mr3djYr0LobXOw76vz4dci6lSGt7tC5doQXE02TNuGp5O
GFw7NItQbRNcNRyqWQ73xq5i7Fs3XlqSF+vXce3zrOkQ1VEu/KOESQZnW/WAuK/7p2A03KCCtboWeG0e
XKpmKS5fPYYjHVQwsnYbzQursEuJfYektDJaQJzWgxJ0YQZGVy8VjLt8qMyFCZU1LHqeNlNBb/wJ3J+2
4JQTsMvKNKMHxQ0qIFi70JrvoNfhLYTzdPkbMbR8H03W6iRMBZKycVJgoVmSvvYHuFzbgkpbPYWMeWEA
vvm/4YKgcIRjhAZjaHgUh+dhmMIPLoN7m932CQE5QuESjwm+93/BrZEd+EZ1iveVDvfMqXD+EgvPKETM
vECz+Ph4Fd3PEmgc08F9SJ4KK6ZDzj0jKfIjWUG/Hohs6kJkXwtETCUopaaGV5f4d4klp6SkHJJqklWd
srpphf2FHylfeIOivYG5ciMgVumCyCYFqWJHkMtYeafMKW1XOOQEa5cTVfY5pZwDirIphvkDtXtObc5T
qdsAAAAASUVORK5CYII=
</value>
</data>
</root>
Loading

0 comments on commit ede39a0

Please sign in to comment.