//---------------------------------------------------------------------------------------
        public void LoadAllJson()
        {
            if (threadLoadAllJson != null)
            {
                threadLoadAllJson.Abort();
            }

            threadLoadAllJson = new Thread(new ThreadStart(delegate
            {
                StreamReader read = new StreamReader(Globals.jsonFileName);
                Vpnlist.Clear();
                int i = 0;
                while (!read.EndOfStream)
                {
                    string line = read.ReadLine();
                    VPN v       = VPN.ParseFromJson(i, line);
                    v.Click    += delegate
                    {
                        Connect(v);
                    };
                    Vpnlist.Add(v);
                    if (AVpnInfoTaken != null)
                    {
                        AVpnInfoTaken.Invoke(v.Index, v);
                    }
                    i++;
                }
                PLog(" VPN Mevcut: " + Vpnlist.Count);
                read.Close();
            }));
            threadLoadAllJson.Start();
        }
Exemplo n.º 2
0
 private void aVpnInfoTaken(int i, VPN vpn)
 {
     // GUI Threadında işlem yaptırıyor
     this.Invoke((MethodInvoker) delegate
     {
         if (flowLayoutPanel1.Controls.Contains(vpn))
         {
             progressBar1.Value = (int)((i + 1) * (100.0 / Manager.Vpnlist.Count));
             if (i == Manager.Vpnlist.Count - 1)
             {
                 SetUI(Globals.State.InfoGatheringSuccess);
             }
         }
         else
         {
             vpn.Size = new Size(flowLayoutPanel1.Size.Width - flowLayoutPanel1.Margin.Left * 2 - 20, vpn.Size.Height); //-5 ScroolBar Genişliği
             flowLayoutPanel1.Controls.Add(vpn);
         }
     });
 }
Exemplo n.º 3
0
        public static VPN ParseFromJson(int index, string fullText)
        {
            VPN temp = new VPN();

            temp.Index = index;
            temp       = Newtonsoft.Json.JsonConvert.DeserializeObject <VPN>(fullText);

            if (temp.xl2tp == "")
            {
                temp.Protocol = "pptp";
            }
            else
            {
                temp.Protocol = "l2tp";
            }

            temp.ControlSetValues();
            temp.MouseHover += delegate { temp.BackColor = temp.isInited ? Globals.vpnInitedHover : Globals.vpnUnInitedHover; };
            temp.MouseLeave += delegate { temp.BackColor = temp.isInited ? Globals.vpnInited : Globals.vpnUnInited; };
            return(temp);
        }
Exemplo n.º 4
0
 private void ConnectionStart(VPN hangiVpn)
 {
     SetUI(Globals.State.Connecting);
     Manager.InitAllVpnsAbort();
 }
 //---------------------------------------------------------------------------------------
 public void Connect(VPN v)
 {
     Connect(Vpnlist.IndexOf(v));
 }