private void UpdateStatusText(string status) { if (StatusBox.InvokeRequired) { StatusBox.Invoke(new Action <string>(UpdateStatusText), status); } else { StatusBox.Text = status; } }
private void TimerTickEvt(object sender, EventArgs e) { if (StatusBox.InvokeRequired) { StatusBox.Invoke(new Action(() => StatusBox.Text = string.Empty)); } else { StatusBox.Text = string.Empty; } using (Timer timer = (Timer)sender as Timer) { timer.Dispose(); } }
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 SetPersonFloor(string status) { StatusBox.Invoke((MethodInvoker)(() => { FloorsPersonBox.Text = status + FloorsPersonBox.Text.Substring((Convert.ToInt32(status) + DataBase.Direction).ToString().Length); })); }
private void SetPersonStatus(string status) { StatusBox.Invoke((MethodInvoker)(() => { StatusBox.Text = status; })); }
public void SetElevatorStatus(string status) { System.Media.SoundPlayer player = new System.Media.SoundPlayer { SoundLocation = Environment.CurrentDirectory + @"\..\..\Sounds\" }; StatusBox.Invoke((MethodInvoker)(() => { ElevatorBox.Text = status; })); switch (status) { case "Go emty to call": CloseStatusPic.Invoke((MethodInvoker)(() => { CloseStatusPic.Visible = false; })); WaitStatusPic.Invoke((MethodInvoker)(() => { WaitStatusPic.Visible = false; })); CallStatusPic.Invoke((MethodInvoker)(() => { CallStatusPic.Visible = true; })); player.SoundLocation += "call"; break; case "Stand": StopStatusPic.Invoke((MethodInvoker)(() => { StopStatusPic.Visible = true; })); UpStatusPic.Invoke((MethodInvoker)(() => { UpStatusPic.Visible = false; })); DownStatusPic.Invoke((MethodInvoker)(() => { DownStatusPic.Visible = false; })); CallStatusPic.Invoke((MethodInvoker)(() => { CallStatusPic.Visible = false; })); player.SoundLocation += "stop"; break; case "Open doors": StopStatusPic.Invoke((MethodInvoker)(() => { StopStatusPic.Visible = false; })); OpenStatusPic.Invoke((MethodInvoker)(() => { OpenStatusPic.Visible = true; })); player.SoundLocation += "open"; break; case "Check mode": CheckStatusPic.Invoke((MethodInvoker)(() => { CheckStatusPic.Visible = true; })); OpenStatusPic.Invoke((MethodInvoker)(() => { OpenStatusPic.Visible = false; })); OverloadStatusPic.Invoke((MethodInvoker)(() => { OverloadStatusPic.Visible = false; })); player.SoundLocation += "check"; break; case "Close doors": CheckStatusPic.Invoke((MethodInvoker)(() => { CheckStatusPic.Visible = false; })); CloseStatusPic.Invoke((MethodInvoker)(() => { CloseStatusPic.Visible = true; })); player.SoundLocation += "close"; break; case "Carry up": UpStatusPic.Invoke((MethodInvoker)(() => { UpStatusPic.Visible = true; })); CloseStatusPic.Invoke((MethodInvoker)(() => { CloseStatusPic.Visible = false; })); player.SoundLocation += "up"; break; case "Carry down": DownStatusPic.Invoke((MethodInvoker)(() => { DownStatusPic.Visible = true; })); CloseStatusPic.Invoke((MethodInvoker)(() => { CloseStatusPic.Visible = false; })); player.SoundLocation += "down"; break; case "Standby mode": WaitStatusPic.Invoke((MethodInvoker)(() => { WaitStatusPic.Visible = true; })); CloseStatusPic.Invoke((MethodInvoker)(() => { CloseStatusPic.Visible = false; })); player.SoundLocation += "wait"; break; case "Signal Overload": OverloadStatusPic.Invoke((MethodInvoker)(() => { OverloadStatusPic.Visible = true; })); CheckStatusPic.Invoke((MethodInvoker)(() => { CheckStatusPic.Visible = false; })); player.SoundLocation += "overload"; break; } player.SoundLocation += new Random().Next(0, 3).ToString() + ".wav"; player.Play(); }
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; } }
private void _OnChanged(object sender, RecordChangedEventArgs <LVPL_BUSBAR> e) { if (e.ChangeType != ChangeType.None) { var changedEntity = e.Entity; Console.WriteLine("DML operation: " + e.ChangeType); switch (e.ChangeType) { case ChangeType.Delete: StatusBox.Invoke(new Action(() => StatusBox.Text = "Delete")); try { Console.WriteLine("OBJECTID: " + changedEntity.OBJECTID); Console.WriteLine("SHAPE: " + changedEntity.SHAPE); } catch (Exception error) { Console.WriteLine("Excption: ", error); } finally { LoadCollectionData(changedEntity.OBJECTID, e.ChangeType); } break; case ChangeType.Insert: StatusBox.Invoke(new Action(() => StatusBox.Text = "Insert")); try { Console.WriteLine("OBJECTID: " + changedEntity.OBJECTID); Console.WriteLine("SHAPE: " + changedEntity.SHAPE); } catch (Exception error) { Console.WriteLine("Excption: ", error); } finally { LoadCollectionData(changedEntity.OBJECTID, e.ChangeType); } break; case ChangeType.Update: StatusBox.Invoke(new Action(() => StatusBox.Text = "Update")); try { Console.WriteLine("OBJECTID: " + changedEntity.OBJECTID); Console.WriteLine("SHAPE: " + changedEntity.SHAPE); } catch (Exception error) { Console.WriteLine("Excption: ", error); } finally { LoadCollectionData(changedEntity.OBJECTID, e.ChangeType); } break; } } }