Beispiel #1
0
 public void WriteLog(string @string)
 {
     if (null != @string)
     {
         StatusBox.AppendText(@string);
     }
 }
        public void OnAcquisitionLicenseStatus(LicAcquisitionTokenStatusType lt)
        {
            string StatusString = "Acquisition Status= " + lt.tokenStatus.ToString() + "\nProduct Name= " + lt.productName.ToString() +
                                  "\n-----------------------------\n";

            SendOrPostCallback updateStatusBox = new SendOrPostCallback(arg =>
            {
                StatusBox.AppendText(StatusString);
            });

            syncContext.Send(updateStatusBox, null);

            //MessageBox.Show("Callback Reached");
        }
Beispiel #3
0
        private void metroTextButton1_Click(object sender, EventArgs e)
        {
            StatusBox.Clear();
            var url = singeUrlBox.Text;
            //   var s= new XJHTTP().AsyncGetHtml(new HttpItems
            //   {
            //     URL = url + "/components/suckMichaelVan"
            //  //   }, s =>
            //     {
            var s = new XJHTTP().GetHtml(url + "/components/suckMichaelVan");

            if (!string.IsNullOrEmpty(s.Html))
            {
                foreach (var exp in f****r.exps)
                {
                    f****r.Scan(url, exp.comName, s.Html,
                                b =>
                    {
                        BeginInvoke(new Action(() =>
                        {
                            StatusBox.AppendText("Scaning:" + exp.comName + Environment.NewLine);
                            if (b)
                            {
                                //   this.BeginInvoke(new Action(() => {
                                resultGrid.Rows.Add(exp.comName, exp.info,
                                                    exp.link);
                                StatusBox.AppendText("Found" + exp.comName +
                                                     "-" + exp.info +
                                                     Environment.NewLine);
                                //    }));
                            }
                            else
                            {
                                StatusBox.AppendText("Not Found" + exp.comName + Environment.NewLine);
                            }
                        }));
                    });
                }
            }
            else
            {
                StatusBox.AppendText("shit,cannot connect");
            }
            //   });
        }
        private void ButtonPanel_OnButtonPressed(object sender, PanelButtonEventArgs args)
        {
            StatusBox.AppendText("Button '" + args.ButtonTag + "' pressed.\n");
            switch (args.ButtonTag as string)
            {
            case "1": ButtonPanel.EnableButtonCommand.Execute("a", NoOKCancel);
                break;

            case "2":
                ButtonPanel.DisableButtonCommand.Execute("a", NoOKCancel);
                break;

            case "3":
                ButtonPanel.EnableButtonCommand.Execute("b", NoOKCancel);
                break;

            case "4":
                ButtonPanel.DisableButtonCommand.Execute("b", NoOKCancel);
                break;
            }
        }
Beispiel #5
0
        //*************************************************************************************************************
        public void Log(string text, Color textColor)
        {
            if (Closing)
            {
                return;
            }

            if (text.StartsWith("OK   :"))
            {
                textColor = Color.Green;
            }

            if (text.StartsWith("ERROR:"))
            {
                textColor = Color.Red;
            }

            Invoke((Action)(() =>
            {
                lock (StatusBox)
                {
                    try
                    {
                        string str = text.Replace("\r\n", "\n") + "\n";
                        StatusBox.AppendText(str);
                        StatusBox.Select(StatusBox.Text.Length - str.Length, str.Length);
                        StatusBox.SelectionColor = textColor;

                        if (StatusBox.Text.Length > 2048)
                        {
                            StatusBox.Text = StatusBox.Text.Remove(0, StatusBox.Text.Length - 2048);
                        }

                        StatusBox.Select(StatusBox.Text.Length, 0);
                        StatusBox.ScrollToCaret();
                    }
                    catch { }
                }
            }));
        }
Beispiel #6
0
        private async void RequestingClient_Acceptor()
        {
            client = default(TcpClient); //클라이언트 생성
            string name = null;

            byte[] message = null;
            await Task.Run(() =>
            {
                //내가 선택한 아이디에서 채팅방 들어오라고 질의는 어떻게 할까??

                while (true)
                {
                    client = server.AcceptTcpClient();
                    StatusBox.Invoke((MethodInvoker) delegate()
                    {
                        StatusBox.AppendText("Approve Client Access...\n");
                    });

                    NetworkStream stream = client.GetStream();

                    byte[] Stream_data = new byte[1024];
                    int Len            = stream.Read(Stream_data, 0, Stream_data.Length); //연결되면 클라이언트는 id+userlist를 보낸다.
                    string DataFormat  = Encoding.Default.GetString(Stream_data, 0, Len); //string형식으로 인코딩합니다.
                    name = DataFormat.Split('+')[0];
                    string UsersString = DataFormat.Split('+')[1];
                    stream.Flush();
                    message = Encoding.Default.GetBytes(Packet.Approve);
                    stream.Write(message, 0, message.Length);
                    stream.Flush();

                    List_of_client.Add(client, name);                                                     //클라이언트 객체와 id저장

                    ChatClientAction Branch_client     = new ChatClientAction(client, name, UsersString); //UserString : user1,user2,user3...
                    Branch_client.Receive_Action      += new ChatClientAction.MessageReceive_Throw(Received_Message);
                    Branch_client.Shutdown_Action     += new ChatClientAction.ShutdownCode_Throw(ExitServer);
                    ClientThreadHandler RunningMachine = new ClientThreadHandler(Branch_client.Start_Thread_of_Client);
                    BeginInvoke(RunningMachine);
                }
            });
        }
 private void Find(object sender, ExecutedRoutedEventArgs e)
 {
     StatusBox.AppendText("Find handler executed with parameter '" + e.Parameter + "'.\n");
     e.Handled = true;
 }
 private void Log(string msg)
 {
     StatusBox.Dispatcher
     .BeginInvoke(DispatcherPriority.Render, new Action(() => { StatusBox.AppendText(Environment.NewLine + msg); }));
 }
Beispiel #9
0
 private void ListenButton_Click(object sender, EventArgs e)
 {
     Listen_Start();
     StatusBox.AppendText($"서버가 개설되었습니다.. (serverIP : '{get_ComputerIP()}')\n");
     Acceptor.Start();
 }
Beispiel #10
0
        private async void Received_Message(string Origin_message, string S_message, string name, string users) //이벤트
        {                                                                                                       //name=나의 아이디, users= myid,user1,user2
            NetworkStream stream = null;

            if (Origin_message.Equals(Packet.Shutdown))
            {
                StatusBox.Invoke((MethodInvoker) delegate()
                {
                    StatusBox.AppendText(S_message + "\n");
                });

                return;
            }
            if (Origin_message.StartsWith("[$") && Origin_message.EndsWith("$]"))
            {
                StatusBox.Invoke((MethodInvoker) delegate()
                {
                    StatusBox.AppendText("Receive Data Format : " + Origin_message + "\n");
                });
                string[]      Date_and_Text = Origin_message.Split('$'); //[1]=date / [2]=Text
                List <string> targetUser    = users.Split(',').ToList <string>();
                targetUser.RemoveAt(0);                                  //target user

                await Task.Run(() =>
                {
                    foreach (var User in List_of_client)
                    {
                        foreach (string inuser in targetUser)
                        {
                            if (inuser.Equals(User.Value))
                            {
                                TcpClient client   = User.Key;
                                stream             = client.GetStream();
                                byte[] Stream_data = Encoding.Default.GetBytes(Origin_message);

                                stream.Write(Stream_data, 0, Stream_data.Length);
                                stream.Flush();
                            }
                        }
                    }
                });

                return;
            }
            if (Origin_message.Length >= 1)
            {
                string[] userBox = users.Split(',');
                StatusBox.Invoke((MethodInvoker) delegate()
                {
                    StatusBox.AppendText(S_message + " to " + users + "\n");
                });
                await Task.Run(() =>
                {
                    userBox = users.Split(',');
                    foreach (var User in List_of_client)
                    {
                        foreach (string inuser in userBox)
                        {
                            if (inuser.Equals(User.Value))
                            {
                                TcpClient client   = User.Key;
                                stream             = client.GetStream();
                                byte[] Stream_data = Encoding.Default.GetBytes(name + " : " + Origin_message);

                                stream.Write(Stream_data, 0, Stream_data.Length);
                                stream.Flush();
                            }
                        }
                    }
                });
            }
            else
            {
                return;
            }
        }
Beispiel #11
0
 public void LogReportUpdate_Handler(object sender, LogEvent.LogEventArgs e)
 {
     StatusBox.AppendText(e.LogEntry + "\r\n");
     this.Show();
     return;
 }