Exemplo n.º 1
0
 private void Connect(VPNInfoEntity entity)
 {
     notifyIcon1.ShowBalloonTip(3000, "...", "正在尝试连接:" + entity.Ip, ToolTipIcon.Info);
     VPNConnectHelper.DialAsyncComplete -= VPNConnectHelper_DialAsyncComplete;
     VPNConnectHelper.DialAsyncComplete += new VPNConnectHelper.DialAsyncCompleteHandler(VPNConnectHelper_DialAsyncComplete2);
     VPNConnectHelper.DialAsync(entity.Ip, entity.User, entity.Pwd);
 }
Exemplo n.º 2
0
        private void gd1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex > -1 && e.RowIndex > -1 && gd1.Columns[e.ColumnIndex].DataPropertyName == "Available")
            {
                VPNInfoEntity entity = (VPNInfoEntity)gd1.Rows[e.RowIndex].DataBoundItem;
                e.Graphics.FillRectangle(Brushes.White, e.CellBounds.Location.X, e.CellBounds.Location.Y, e.CellBounds.Width - 1, e.CellBounds.Height - 1);
                Rectangle rectangle = new Rectangle(e.CellBounds.Location.X + 4, e.CellBounds.Location.Y + 4, 14, 14);
                if (entity.Available == VPNInfoEntity.AvailableStatus.Disable)
                {
                }

                switch (entity.Available)
                {
                case VPNInfoEntity.AvailableStatus.Disable:
                    e.Graphics.DrawImage(Res.Disable, rectangle);
                    break;

                case VPNInfoEntity.AvailableStatus.Enable:
                    e.Graphics.DrawImage(Res.Enable, rectangle);
                    break;

                default:
                    e.Graphics.DrawImage(Res.Normal, rectangle);
                    break;
                }

                e.Handled = true;
            }
        }
Exemplo n.º 3
0
        private void FindNext()
        {
            if (!findFlag)
            {
                return;
            }

            currTryIdx++;
            if (gd1.Rows.Count > currTryIdx && !gd1.Rows[currTryIdx].IsNewRow)
            {
                DataGridViewRow row    = gd1.Rows[currTryIdx];
                VPNInfoEntity   entity = (VPNInfoEntity)gd1.Rows[currTryIdx].DataBoundItem;
                if (entity.Ping > 0)
                {
                    currTryVPNInfoEntity = entity;
                    VPNConnectHelper.DialAsync(entity.Ip, entity.User, entity.Pwd);
                }
                else
                {
                    FindNext();
                }
            }
            else
            {
                notifyIcon1.ShowBalloonTip(5000, "...", "以搜索到列表尾!", ToolTipIcon.Info);
            }
        }
Exemplo n.º 4
0
        public static List <VPNInfoEntity> GetFeiYiVPNS()
        {
            //WebHeaderCollection headers;
            //CookieCollection cookies;
            //string ctx = HttpRequest.GetCtx(feiYiUrl, "GET", Encoding.GetEncoding("GB2312"), null, null, "", out headers, out cookies);
            string          ctx = HttpRequest.GetCtx(feiYiUrl, "GET", Encoding.GetEncoding("GB2312"));
            MatchCollection ms  = feiYiReg.Matches(ctx);

            List <VPNInfoEntity> list = new List <VPNInfoEntity>();

            foreach (Match ma in ms)
            {
                VPNInfoEntity entity = new VPNInfoEntity();
                entity.Area  = ma.Groups["area"].Value;
                entity.Ip    = ma.Groups["ip"].Value;
                entity.User  = ma.Groups["user"].Value;
                entity.Pwd   = ma.Groups["pwd"].Value;
                entity.Info1 = ma.Groups["info1"].Value;
                entity.Info2 = ma.Groups["info2"].Value;
                entity.Info3 = ma.Groups["info3"].Value;

                if (SerializHelper.DisableList.ContainsKey(SerializHelper.GetEntityKey(entity)))
                {
                    entity.Available = VPNInfoEntity.AvailableStatus.Disable;
                }

                list.Add(entity);
            }

            return(list);
        }
Exemplo n.º 5
0
 private void cmsiConnect_Click(object sender, EventArgs e)
 {
     if (gd2.SelectedRows.Count > 0)
     {
         VPNInfoEntity entity = (VPNInfoEntity)gd2.SelectedRows[0].DataBoundItem;
         Connect(entity);
     }
 }
Exemplo n.º 6
0
        public static void AddDisableEntity(VPNInfoEntity entity)
        {
            string key = GetEntityKey(entity);

            if (!DisableList.ContainsKey(key))
            {
                DisableList.Add(key, entity);
            }
        }
Exemplo n.º 7
0
 private void cmsi2Drop_Click(object sender, EventArgs e)
 {
     if (gd2.SelectedRows.Count > 0)
     {
         VPNInfoEntity entity = (VPNInfoEntity)gd2.SelectedRows[0].DataBoundItem;
         SerializHelper.RemoveEnableEntity(entity);
         SetGd2DataSource();
     }
 }
Exemplo n.º 8
0
        void ph_PingComplete(object sender, System.Net.NetworkInformation.PingCompletedEventArgs p, params object[] parameters)
        {
            int idx = 0;

            int.TryParse(parameters[0].ToString(), out idx);
            VPNInfoEntity entity = (VPNInfoEntity)gd1.Rows[idx].DataBoundItem;

            if (p.Reply.Status == System.Net.NetworkInformation.IPStatus.Success)
            {
                entity.Ping      = p.Reply.RoundtripTime;
                entity.Available = VPNInfoEntity.AvailableStatus.Unknow;
            }
            else
            {
                entity.Ping      = -1L;
                entity.Available = VPNInfoEntity.AvailableStatus.Disable;
            }

            if (idx == gd1.Rows.Count - 1)//不允许添加新行,所以最后一行不是新行.
            {
                btnPing.BeginInvoke(BtnPingHandler, true);
            }
        }
Exemplo n.º 9
0
 public static string GetEntityKey(VPNInfoEntity entity)
 {
     return(string.Format(KEY_FORMAT, entity.Ip, entity.User, entity.Pwd));
 }
Exemplo n.º 10
0
        public static void RemoveDisableEntity(VPNInfoEntity entity)
        {
            string key = GetEntityKey(entity);

            DisableList.Remove(key);
        }
Exemplo n.º 11
0
        private void gd2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            VPNInfoEntity entity = (VPNInfoEntity)gd2.Rows[e.RowIndex].DataBoundItem;

            Connect(entity);
        }