Ejemplo n.º 1
0
        public static bool ImportActiveClients()
        {
            if (File.Exists(EnviromentManager.LBActiveClientsPath))
            {
                var lines_client = File.ReadLines(EnviromentManager.LBActiveClientsPath);
                foreach (string line in lines_client)
                {
                    Account acc;
                    try
                    {
                        acc = AccountManager.Accounts.First(a => a.Nickname == line.Split(',')[0]);
                    }
                    catch
                    {
                        continue;
                    }
                    Process pro;
                    try
                    {
                        pro = Process.GetProcessById(Int32.Parse(line.Split(',')[2]));
                    }
                    catch
                    {
                        continue;
                    }
                    if (pro != null)
                    {
                        String processStartTime;
                        try
                        {
                            processStartTime = pro.StartTime.ToString();
                        }
                        catch
                        {
                            continue;
                        }
                        if (processStartTime == line.Split(',')[3])
                        {
                            Client.ClientStatus status = (Client.ClientStatus)Int32.Parse(line.Split(',')[1]);
                            acc.Client.SetProcess(pro, status);
                            if (status.HasFlag(Client.ClientStatus.Running))
                            {
                                ActiveClients.Add(acc.Client);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            SearchForeignClients();

            return(true);
        }
Ejemplo n.º 2
0
        private void OnStatusChanged(Client.ClientStatus status)
        {
            bool available = status == Client.ClientStatus.Available;

            bProtocolType.Enabled  = available;
            bAddressFamily.Enabled = available;
            tbServer.Enabled       = available;
            tbPort.Enabled         = available;
            switch (status)
            {
            case Client.ClientStatus.Available:
                bConnect.Text = "Connect";
                if (bSend.Text != "Execute")
                {
                    bSend.Text = "Echo";
                }
                break;

            case Client.ClientStatus.Connecting:
                bConnect.Text = "Connecting..";
                if (bSend.Text != "Execute")
                {
                    bSend.Text = "Echo";
                }
                break;

            case Client.ClientStatus.Connected:
                bConnect.Text = "Disconnect";
                if (bSend.Text != "Execute")
                {
                    bSend.Text = "Send";
                }
                break;

            case Client.ClientStatus.Disconnecting:
                bConnect.Text = "Disconnecting..";
                if (bSend.Text != "Execute")
                {
                    bSend.Text = "Echo";
                }
                break;
            }
        }
Ejemplo n.º 3
0
 private void OnStatusChangedAsync(Client.ClientStatus status)
 {
     Invoke(OnStatusChangedDelegate, status);
 }