Skip to content

Commit

Permalink
add back link funcs in login page, fix message send issue partially, …
Browse files Browse the repository at this point in the history
…new design lang
  • Loading branch information
n1d3v committed Dec 6, 2024
1 parent 552a454 commit be8c2ee
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 271 deletions.
28 changes: 25 additions & 3 deletions Naticord/Forms/DM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Drawing;
using System.Net;
using System.IO;
using System.Linq;

namespace Naticord
{
Expand All @@ -25,6 +26,7 @@ public partial class DM : Form
public long FriendID { get; }
private readonly string userPFP;
private string lastMessageAuthor = "";
private Image _lastUploadedImage = null;

public DM(long chatid, long friendid, string token, string userpfp)
{
Expand Down Expand Up @@ -284,9 +286,14 @@ private async Task SendMessage()

if (Clipboard.ContainsImage())
{
Image image = Clipboard.GetImage();
byte[] imageBytes = ImageToBytes(image);
await UploadImage(imageBytes);
Image currentImage = Clipboard.GetImage();

if (_lastUploadedImage == null || !ImagesAreEqual(_lastUploadedImage, currentImage))
{
byte[] imageBytes = ImageToBytes(currentImage);
await UploadImage(imageBytes);
_lastUploadedImage = currentImage;
}
}
}

Expand All @@ -299,6 +306,21 @@ private async Task SendMessage()
}
}

private bool ImagesAreEqual(Image img1, Image img2)
{
if (img1 == null || img2 == null)
return false;

using (MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream())
{
img1.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);
img2.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytes1 = ms1.ToArray();
byte[] bytes2 = ms2.ToArray();
return bytes1.SequenceEqual(bytes2);
}
}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.V))
Expand Down
79 changes: 56 additions & 23 deletions Naticord/Forms/Group.Designer.cs

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

29 changes: 26 additions & 3 deletions Naticord/Forms/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Drawing;
using System.Net;
using System.IO;
using System.Linq;

namespace Naticord
{
Expand All @@ -23,6 +24,7 @@ public partial class Group : Form
public long ChatID { get; }
private readonly string userPFP;
private string lastMessageAuthor = "";
private Image _lastUploadedImage = null;

public Group(long chatid, string token, string userpfp)
{
Expand Down Expand Up @@ -261,9 +263,14 @@ private async Task SendMessage()

if (Clipboard.ContainsImage())
{
Image image = Clipboard.GetImage();
byte[] imageBytes = ImageToBytes(image);
await UploadImage(imageBytes);
Image currentImage = Clipboard.GetImage();

if (_lastUploadedImage == null || !ImagesAreEqual(_lastUploadedImage, currentImage))
{
byte[] imageBytes = ImageToBytes(currentImage);
await UploadImage(imageBytes);
_lastUploadedImage = currentImage;
}
}
}

Expand All @@ -276,6 +283,22 @@ private async Task SendMessage()
}
}

private bool ImagesAreEqual(Image img1, Image img2)
{
if (img1 == null || img2 == null)
return false;

using (MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream())
{
img1.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);
img2.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytes1 = ms1.ToArray();
byte[] bytes2 = ms2.ToArray();
return bytes1.SequenceEqual(bytes2);
}
}


protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.V))
Expand Down
10 changes: 6 additions & 4 deletions Naticord/Forms/Login.Designer.cs

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

30 changes: 29 additions & 1 deletion Naticord/Forms/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,35 @@ private void githubLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs

private void discordStatusLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://discord.gg/naticord");
System.Diagnostics.Process.Start("https://discordstatus.com");
}

private void tokenLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Hide();
TokenLogin token = new TokenLogin(this);
token.Show();
}

private void proxyLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{

using (var form = new Form())
using (var label = new Label() { Text = "Enter Proxy Address:" })
using (var inputBox = new TextBox())
using (var buttonOk = new Button() { Text = "OK", DialogResult = DialogResult.OK })
{
inputBox.Text = proxyAddress;
ConfigureFormControls(form, label, inputBox, buttonOk);
form.Text = "Proxy";
form.FormBorderStyle = FormBorderStyle.Sizable;
if (form.ShowDialog() == DialogResult.OK)
{
Properties.Settings.Default.proxy = inputBox.Text.Trim();
Properties.Settings.Default.Save();
proxyAddress = Properties.Settings.Default.proxy;
}
}
}
}
}
2 changes: 1 addition & 1 deletion Naticord/Forms/Login.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<data name="$this.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAARgAAAIcCAYAAAAt97EHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DwAACw8BkvkDpQAA0RxJREFUeF7E/YmWJUtTnIHW+7/R1XSZJyEmMYOQBAgQiEliHrrvitzpkeZfmntE
DgAACw4BQL7hQQAA0RxJREFUeF7E/YmWJUtTnIHW+7/R1XSZJyEmMYOQBAgQiEliHrrvitzpkeZfmntE
7qrDtbVCEW5uPkXm3qqu7vPz8e9+9Pu3/8+PfP8eu1v/7kcuX6X/dz+adUmLeMkRq6ptedcDclx8kYP5
2IOrQe3o/az1bdQ57Vvu0KLfShf5Wb+a49BrPsb/O8SHlrNBQx/zz145i+vV9KezTk1X9+lz3dGivj1z
LZ7J4Ox86mOumN3cqa01487njx7SXcp7mmJR/5Zjakws9dXn/yM+5Eqe4uP878N2GvHF+dBfBa/iGEpz
Expand Down
Loading

0 comments on commit be8c2ee

Please sign in to comment.