Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/KwDrama/OST into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseop-choung committed Jun 7, 2021
2 parents 3d2de45 + 9816cf7 commit 9c47487
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
24 changes: 22 additions & 2 deletions Client/Forms/ControlChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OSTLibrary.Chats;
using OSTLibrary.Classes;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

Expand Down Expand Up @@ -36,10 +37,12 @@ public ControlChat(Chat chat, bool continuous)
{
PictureBox pic = new PictureBox();

// 이미지
// λ””μžμΈ 및 이벀트
pic.Image = chat.image;
pic.Cursor = Cursors.Hand;
pic.BackColor = Color.Transparent;
pic.SizeMode = PictureBoxSizeMode.Zoom;
pic.MouseClick += Pic_Click;

// μœ„μΉ˜ 및 크기
pic.Location = lblText.Location;
Expand Down Expand Up @@ -108,11 +111,14 @@ public ControlChat(Chat chat, bool continuous)
dataControl.Left = Width - dataControl.Width - Padding.Right;
dataControl.Anchor = AnchorStyles.Top | AnchorStyles.Right;
dataControl.BackColor = Color.LemonChiffon;

// μ‹œκ³„ μœ„μΉ˜
lblTime.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
lblTime.Left = Math.Min(dataControl.Left, Width - Padding.Right - lblTime.Width);
}

// μ±„νŒ… ν•˜λ‚˜ν•˜λ‚˜κ°€ 뢄리 되게 보일수 μžˆλŠ” μ½”λ“œ
//BackColor = Color.FromArgb(new Random(DateTime.Now.Millisecond).Next());
}

public void SetContinuous()
Expand All @@ -125,5 +131,19 @@ public void OwnerRoom_Resize(object sender, EventArgs e)
{
Width = (sender as Form).Width - 20;
}
private void Pic_Click(object sender, MouseEventArgs e)
{
string filename = "OST_" + chat.date.ToString("yyyyMMdd_HHmmss") + ".png";

if (e.Button == MouseButtons.Left)
{

PictureBox pic = sender as PictureBox;
pic.Image.Save(filename);
Process.Start(filename);
}
else if (e.Button == MouseButtons.Right)
Process.Start(Environment.CurrentDirectory);
}
}
}
20 changes: 19 additions & 1 deletion Client/Panels/PanelRegister.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ο»Ώusing Client.Forms;
using MetroFramework;
using OSTLibrary.Classes;
using OSTLibrary.Networks;
using OSTLibrary.Securities;
Expand All @@ -19,7 +20,7 @@ public PanelRegister(Form owner, SlidingType type) : base(owner, type)
Init();

organization = new Dictionary<string, string[]>();
organization.Add("지원본뢀", new string[] { "지원1νŒ€", "지원2νŒ€", "지원3νŒ€" });
organization.Add("μžμ›λ³ΈλΆ€", new string[] { "μžμ›1νŒ€", "μžμ›2νŒ€", "μžμ›3νŒ€" });
organization.Add("μ² κ°•λ³ΈλΆ€", new string[] { "μ² κ°•1νŒ€", "μ² κ°•2νŒ€", "μ² κ°•3νŒ€" });
organization.Add("μ„¬μœ λ³ΈλΆ€", new string[] { "μ„¬μœ 1νŒ€", "μ„¬μœ 2νŒ€", "μ„¬μœ 3νŒ€" });
organization.Add("μ˜μ—…λ³ΈλΆ€", new string[] { "μ˜μ—…1νŒ€", "μ˜μ—…2νŒ€", "μ˜μ—…3νŒ€" });
Expand Down Expand Up @@ -62,11 +63,28 @@ private void tleSubmit_Click(object sender, EventArgs e)
{
try
{
Program.callback.Add(PacketType.Register, ReceiveChat);
Program.Send(new RegisterPacket(new Employee(picProfile.Image, int.Parse(txtempId.Text),
SHA512.Encrypt(txtPassword.Text), txtName.Text, txtPhone.Text,
cmbCentral.SelectedItem as string, cmbTeam.SelectedItem as string, txtRank.Text)));
}
catch (FormatException) { }
}

void ReceiveChat(Packet p)
{
Program.callback.Remove(PacketType.Register);

Invoke(new MethodInvoker(() =>
{
if ((p as RegisterPacket).success)
{
MetroMessageBox.Show(this, "성곡", "사원 등둝", MessageBoxButtons.OK, MessageBoxIcon.Information);
Swipe(false);
}
else
MetroMessageBox.Show(this, "μ‹€νŒ¨", "사원 등둝", MessageBoxButtons.OK, MessageBoxIcon.Error);
}));
}
}
}
17 changes: 8 additions & 9 deletions Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void Main()
static void Recieve()
{
byte[] readBuffer = null, lengthBuffer = new byte[4];
while (true)
while (client.Connected)
{
// νŒ¨ν‚· 읽기
try
Expand Down Expand Up @@ -89,12 +89,7 @@ static void Recieve()

// νŒ¨ν‚· λ°›λŠ” 도쀑 μ˜ˆμ™Έκ°€ λ°œμƒν–ˆμ„ λ•Œ
// μ„œλ²„μ™€ 연결이 μ’…λ£Œλ˜μ—ˆλ‹€λ©΄ μž¬μ‹œμž‘ ν›„ 접속 μ‹œλ„
if (!client.Connected)
{
Application.Exit();
Process.Start(Application.ExecutablePath);
return;
}
break;
}

// νŒ¨ν‚· λ²ˆμ—­
Expand All @@ -109,8 +104,9 @@ static void Recieve()
MessageBox.Show(formMain, ex.ToString(), "Deserialize",
MessageBoxButtons.OK, MessageBoxIcon.Error)));

// μˆ˜μ‹  버퍼 리셋
while (ns.ReadByte() != -1) ;
// νŒ¨ν‚· λ°›λŠ” 도쀑 μ˜ˆμ™Έκ°€ λ°œμƒν–ˆμ„ λ•Œ
// μ„œλ²„μ™€ 연결이 μ’…λ£Œλ˜μ—ˆλ‹€λ©΄ μž¬μ‹œμž‘ ν›„ 접속 μ‹œλ„
break;
}
if (pakcetObj == null) continue;

Expand All @@ -120,6 +116,9 @@ static void Recieve()
if (callback.ContainsKey(packet.type))
callback[packet.type].Invoke(packet);
}

Application.Exit();
Process.Start(Application.ExecutablePath);
}
public static void Send(Packet packet)
{
Expand Down
Binary file added Document/OSS_Team5_Project_Final.pptx
Binary file not shown.
Binary file added Document/free-powerpoint-ppt-template-1012.pptx
Binary file not shown.
4 changes: 1 addition & 3 deletions OSTLibrary/Networks/RegisterPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ namespace OSTLibrary.Networks
public class RegisterPacket : Packet
{
public bool success = false;
public string result;

public Employee employee;

public RegisterPacket(bool success, string result = "")
public RegisterPacket(bool success)
{
type = PacketType.Register;
this.success = success;
this.result = result;
}

public RegisterPacket(Employee employee)
Expand Down
3 changes: 2 additions & 1 deletion Server/Classes/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ public void Recieve()
else if (packet.type == PacketType.Register)
{
RegisterPacket p = packet as RegisterPacket;
if (Database.Register(p.employee))
if (p.success = Database.Register(p.employee))
{
Program.employees.Add(p.employee.id, employee = p.employee);
Log("Register", "νšŒμ›κ°€μž… 성곡");
}
else
Log("Register", "νšŒμ›κ°€μž… μ‹€νŒ¨");
Send(p);
}

// μ±„νŒ…
Expand Down

0 comments on commit 9c47487

Please sign in to comment.