Exemplo n.º 1
0
        //чатик
        public void RunListenPort()
        {
            byte[] bytes = new byte[1024];

            int bytesRec1 = client.Receive(bytes);

            string Adder = String.Format(Encoding.UTF8.GetString(bytes, 0, bytesRec1));

            if (Adder.Length > 1)
            {
                string SubAdder = Adder.Substring(0, 2);
                if (SubAdder == "#D")
                {
                    string[] SubSubAdder = Adder.Substring(2, Adder.Length - 2).Split(Convert.ToChar("-"));
                    foreach (string keker in SubSubAdder)
                    {
                        RTB1.AppendText(keker + "_");
                    }

                    FileConnectForm.tet(SubSubAdder);
                }
                else
                {
                    infoPole.Items.Add(Adder);
                }
            }
            else
            {
                infoPole.Items.Add(Adder);
            }
        }
Exemplo n.º 2
0
        private void FilesConnectButton_Click(object sender, EventArgs e)
        {
            FileConnectForm FileConnectForm1 = new FileConnectForm();

            FileConnectForm1.Show();
        }
Exemplo n.º 3
0
        public void RunListenFiles()
        {
            while (true)
            {
                if (PrinyatFile == false)
                {
                    byte[] bytes = new byte[999999999];

                    int bytesRec1 = client2.Receive(bytes);

                    string Adder = String.Format(Encoding.UTF8.GetString(bytes, 0, bytesRec1));

                    if (Adder.Length > 3)
                    {
                        if (Adder.Substring(0, 2) == "#S")
                        {
                            FileStarted = true;
                            PrinyatFile = true;
                            PriemType   = "File";
                            infoPole.Items.Add("Start translation");

                            if (Adder.Substring(2, 1) == "[")
                            {
                                ReNameRash = Adder.Substring(3, Adder.IndexOf("]") - 3);
                            }
                        }
                        else
                        {
                            if (Adder.Substring(0, 2) == "#T")
                            {
                                FileStarted = true;
                                PrinyatFile = true;
                                PriemType   = "SpisokOfDirect";
                                infoPole.Items.Add("Start translation");
                            }
                            else
                            {
                                if (Adder.Substring(0, 2) == "#N")
                                {
                                    FileStarted = true;
                                    PrinyatFile = true;
                                    PriemType   = "TreeNode";
                                    infoPole.Items.Add("Start translation");

                                    if (Adder.Substring(2, 1) == "[")
                                    {
                                        ReNameRash = Adder.Substring(3, Adder.IndexOf("]") - 3);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    int bytesRec1 = 0;

                    byte[] bytes = new byte[1024];

                    if (client2.Available != 0)
                    {
                        bytesRec1 = client2.Receive(bytes);
                    }
                    else
                    {
                        Thread.Sleep(200);

                        if (client2.Available != 0)
                        {
                            bytesRec1 = client2.Receive(bytes);
                        }
                        else
                        {
                            FileStarted = false;
                        }
                    }

                    if (FileStarted == true)
                    {
                        Array.Resize(ref bytes, bytesRec1);
                        Array.Resize(ref b, b.Length + bytesRec1);
                        bytes.CopyTo(b, b.Length - bytesRec1);
                    }

                    if (FileStarted == false)
                    {
                        if (PriemType == "File")
                        {
                            File.WriteAllBytes("D:\\PomoikaSiSharp\\" + ReNameRash, b);

                            Array.Resize(ref b, 0);
                            PrinyatFile = false;
                            infoPole.Items.Add("End translation");
                        }

                        if (PriemType == "SpisokOfDirect")
                        {
                            //переслать с помощью делегата в treeView
                            FileConnectForm.GetTreeView1(b);

                            Array.Resize(ref b, 0);
                            PrinyatFile = false;
                            infoPole.Items.Add("End translation");
                        }
                    }
                }
            }
        }