<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace InterfaceTest
{
    public partial class MainForm : Form
    {
        private bool MouseClick = false;
        private List<int> SavedPointX = new List<int>();
        private List<int> SavedPointY = new List<int>();
        private int _tcpPort = 22;
        private string _server = "172.16.17.32";
        private bool DONE = false;

        public MainForm()
        {
            InitializeComponent();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            MouseClick = true;
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            MouseClick = false;
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            // Drawing
            if (MouseClick == true)
            {
                Form frm = (MainForm)sender;
                Graphics g = frm.CreateGraphics();

                Bitmap bmOnePixel = new Bitmap(1, 1);
                bmOnePixel.SetPixel(0, 0, Color.Black);
                g.DrawImage(bmOnePixel, new Point(e.X, e.Y));
                g.Dispose();

                SavedPointX.Add(e.X);
                SavedPointY.Add(e.Y);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Graphics g = CreateGraphics();
            List<int> Direction = new List<int>();

            // Calculate Direction
            for (int i = 0; i < SavedPointX.Count - 1; i++)
                Direction.Add(GetDirection(SavedPointX[i], SavedPointY[i], SavedPointX[i + 1], SavedPointY[i + 1]));

            //Check Training Mode 
            if (radioButton1.Checked)
            {
                if (Convert.ToInt32(textBox1.Text) >= 0 && Convert.ToInt32(textBox1.Text) <= 9)
                {

                    CPacket packet = new CPacket(CPacket.Kind.TRAINING_SET, Convert.ToInt32(textBox1.Text), Direction.ToArray());
                    Thread th = new Thread(new ParameterizedThreadStart(run));
                    th.Start(packet);
                }
                else
                    MessageBox.Show("error");
            }
            //Check Analysis Mode
            else if (radioButton2.Checked)
            {
                CPacket packet = new CPacket(CPacket.Kind.REQUEST, 1, Direction);
                Thread th = new Thread(new ParameterizedThreadStart(run));
                th.Start(packet);

            }
            //Don`t checking
            else
            {
                MessageBox.Show("radioButton을 check해주세요.");
            }

            g.Clear(System.Drawing.SystemColors.Control);
            SavedPointX.Clear();
            SavedPointY.Clear();
        }

        private int GetDirection(int x1, int y1, int x2, int y2)
        {
            int direction=0;
            double x3, y3;
            double angle;

            x3 = x2 - x1;
            y3 = y2 - y1;



            if (x3 == 0)
            {
                x3 = 0.00000001;
            }

            angle = Math.Atan(y3 / x3);

            if (0 <= angle && angle < Constants.PI / 4)
                direction = 0;
            else if (Constants.PI / 4 <= angle && angle < Constants.PI / 2)
                direction = 1;
            else if (Constants.PI / 2 <= angle && angle < Constants.PI * 3 / 4)
                direction = 2;
            else if (Constants.PI * 3 / 4 <= angle && angle < Constants.PI)
                direction = 3;
            else if (Constants.PI <= angle && angle < Constants.PI * 5 / 4)
                direction = 4;
            else if (Constants.PI * 5 / 4 <= angle && angle < Constants.PI * 3 / 2)
                direction = 5;
            else if (Constants.PI * 3 / 2 <= angle && angle < Constants.PI * 7 / 4)
                direction = 6;
            else if (Constants.PI * 7 / 4 <= angle && angle < Constants.PI * 2)
                direction = 7;

            /*
            if (x3 < 0)
                angle += (Constants.PI);

            if (x2 >= x1 && y2 >= y1)
                angle += 2 * Constants.PI;

            direction = (int)(angle * 8 / Constants.PI + 1) / 2;

            switch (direction)
            {
                case 0:
                case 8:
                    direction = 0;
                    break;
                case 1:
                    direction = 1;
                    break;
                case 2:
                    direction = 2;
                    break;
                case 3:
                    direction = 3;
                    break;
                case 4:
                    direction = 4;
                    break;
                case 5:<commit_msg>direction change 2<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace InterfaceTest
{
    public partial class MainForm : Form
    {
        private bool MouseClick = false;
        private List<int> SavedPointX = new List<int>();
        private List<int> SavedPointY = new List<int>();
        private int _tcpPort = 22;
        private string _server = "172.16.17.32";
        private bool DONE = false;

        public MainForm()
        {
            InitializeComponent();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            MouseClick = true;
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            MouseClick = false;
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            // Drawing
            if (MouseClick == true)
            {
                Form frm = (MainForm)sender;
                Graphics g = frm.CreateGraphics();

                Bitmap bmOnePixel = new Bitmap(1, 1);
                bmOnePixel.SetPixel(0, 0, Color.Black);
                g.DrawImage(bmOnePixel, new Point(e.X, e.Y));
                g.Dispose();

                SavedPointX.Add(e.X);
                SavedPointY.Add(e.Y);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Graphics g = CreateGraphics();
            List<int> Direction = new List<int>();

            // Calculate Direction
            for (int i = 0; i < SavedPointX.Count - 1; i++)
                Direction.Add(GetDirection(SavedPointX[i], SavedPointY[i], SavedPointX[i + 1], SavedPointY[i + 1]));

            //Check Training Mode 
            if (radioButton1.Checked)
            {
                if (Convert.ToInt32(textBox1.Text) >= 0 && Convert.ToInt32(textBox1.Text) <= 9)
                {

                    CPacket packet = new CPacket(CPacket.Kind.TRAINING_SET, Convert.ToInt32(textBox1.Text), Direction.ToArray());
                    Thread th = new Thread(new ParameterizedThreadStart(run));
                    th.Start(packet);
                }
                else
                    MessageBox.Show("error");
            }
            //Check Analysis Mode
            else if (radioButton2.Checked)
            {
                CPacket packet = new CPacket(CPacket.Kind.REQUEST, 1, Direction);
                Thread th = new Thread(new ParameterizedThreadStart(run));
                th.Start(packet);

            }
            //Don`t checking
            else
            {
                MessageBox.Show("radioButton을 check해주세요.");
            }

            g.Clear(System.Drawing.SystemColors.Control);
            SavedPointX.Clear();
            SavedPointY.Clear();
        }

        private int GetDirection(int x1, int y1, int x2, int y2)
        {
            int direction=0;
            double x3, y3;
            //double angle;
            x3 = x2 - x1;
            y3 = y1 - y2;
            double angle = Math.Atan((double)y3 / (double)Math.Abs(x3));
            if (x3 < 0)
            {
                if (angle < -Math.PI * 3 / 8)
                {
                    return 6;
                }
                else if (angle >= -Math.PI * 3 / 8 && angle < -Math.PI / 8)
                {
                    return 5;
                }
                else if (angle >= -Math.PI / 8 && angle < Math.PI / 8)
                {
                    return 4;
                }
                else if (angle >= Math.PI / 8 && angle < Math.PI * 3 / 8)
                {
                    return 3;
                }
                else if (angle >= Math.PI * 3 / 8)
                {
                    return 2;
                }
            }
            else
            {
                if (angle < -Math.PI * 3 / 8)
                {
                    return 6;
                }
                else if (angle >= -Math.PI * 3 / 8 && angle < -Math.PI / 8)
                {
                    return 7;
                }
                else if (angle >= -Math.PI / 8 && angle < Math.PI / 8)
                {
                    return 0;
                }
                else if (angle >= Math.PI / 8 && angle < Math.PI * 3 / 8)
                {
                    return 1;
                }
                else if (angle >= Math.PI * 3 / 8)
                {
                    return 2;
                }
            }
            /*
            x3 = x2 - x1;
            y3 = y1 - y2;



            if (x3 == 0)
            {
                x3 = 0.00000001;
            }
            if(y3>=0 && x3 >=0)
                angle = Math.Atan(y3 / x3);


            if (0 <= angle && angle < Constants.PI / 4)
                direction = 0;
            else if (Constants.PI / 4 <= angle && angle < Constants.PI / 2)
                direction = 1;
            else if (Constants.PI / 2 <= angle && angle < Constants.PI * 3 / 4)
                direction = 2;
            else if (Constants.PI * 3 / 4 <= angle && angle < Constants.PI)
                direction = 3;
            else if (Constants.PI <= angle && angle < Constants.PI * 5 / 4)
                direction = 4;
            else if (Constants.PI * 5 / 4 <= angle && angle < Constants.PI * 3 / 2)
                direction = 5;
            else if (Constants.PI * 3 / 2 <= angle && angle < Constants.PI * 7 / 4)
                direction = 6;
            else if (Constants.PI * 7 / 4 <= angle && angle < Constants.PI * 2)
                direction = 7;
            */
            /*
            if (x3 < 0)
                angle += (Constants.PI);

            if (x2 >= x1 && y2 >= y1)
                angle += 2 * Constants.PI;

            direction = (int)(angle * 8 / Constants.PI + 1) / 2;

            switch (direction)
            {
                case 0:
                case 8:
                    direction = 0;
                    break;
                case 1:
                    direction = 1;
                    break;
                case 2:
                    direction = 2;
                    break;
                case 3:
                    direction = 3;
                    break;
                case 4:
                    direction = 4;
                    break;
                case 5:
{'fraction_non_alphanumeric': 0.10117136659436009, 'fraction_numerical': 0.02438177874186551, 'mean_word_length': 1.0846446011937059, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5000997', 'n_tokens_mistral': 3378, 'n_tokens_neox': 3010, 'n_words': 810}