Exemplo n.º 1
0
        private async void GRIDipgwMain_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            if (!((PageStatus == IPGWstatus.Choosing) || (PageStatus == IPGWstatus.Multing)))
            {
                return;
            }
            IPGWmain.Opacity = 0.5;
            if (!(PageStatus == IPGWstatus.Choosing))
            {
                PageStatus = IPGWstatus.Nothing;
                STRBDconnectEnd.Begin();
                return;
            }
            PageStatus = IPGWstatus.Connecting;
            STRBDconnecting.Begin();
            TXTBLKblue.Text   = "";
            TXTBLKgreen.Text  = "";
            TXTBLKred.Text    = "";
            TXTBLKyellow.Text = "";
            IPGWMsg msg = await IPGWUtil.DoConnection(ConnectType);

            try
            {
                Constants.BoxPage.ShowMessage(msg.Content, msg.Title);
            }
            catch
            {
                Constants.BoxPage.ShowMessage("连接网关失败!");
            }
            PageStatus = IPGWstatus.Nothing;
            STRBDconnecting.Stop();
            STRBDconnectEnd.Begin();
        }
Exemplo n.º 2
0
        private async void GRIDipgwMain_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            switch (PageStatus)
            {
            case IPGWstatus.Multing:
            {
                Reset();
            } break;

            case IPGWstatus.Choosing:
            {
                STRBDgreenRoll.Stop();
                STRBDredRoll.Stop();
                STRBDyellowRoll.Stop();
                STRBDblueRoll.Stop();
                PageStatus = IPGWstatus.Connecting;
                DoConnection(ConnectType, "");
                await Task.Delay(1000);

                STRBDconnecting.SkipToFill();
                STRBDconnecting.Stop();
                PageStatus  = IPGWstatus.Nothing;
                ConnectType = IPGW_type.None;
                STRBDcircle1.Begin();
            }
            break;

            default:
            {
            } break;
            }
        }
Exemplo n.º 3
0
 private void IPGWmain_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
 {
     if (!(PageStatus == IPGWstatus.Beginning))
     {
         return;
     }
     PageStatus = IPGWstatus.Multing;
 }
Exemplo n.º 4
0
        private void ELPSin_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            PageStatus = IPGWstatus.Multing;
            var tempRect = PATHslid.Data as RectangleGeometry;

            HistoryX = tempRect.Rect.X;
            HistoryY = tempRect.Rect.Y;
        }
Exemplo n.º 5
0
 private void IPGWmain_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     if (!(PageStatus == IPGWstatus.Beginning))
     {
         return;
     }
     PageStatus       = IPGWstatus.Nothing;
     IPGWmain.Opacity = 0.5;
     STRBDconnectEnd.Begin();
 }
Exemplo n.º 6
0
 private void BDred_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     if (!(PageStatus == IPGWstatus.Choosing))
     {
         return;
     }
     PageStatus     = IPGWstatus.Multing;
     ConnectType    = IPGW_type.None;
     TXTBLKred.Text = "";
     STRBDredDec.Begin();
 }
Exemplo n.º 7
0
 private void BDyellow_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     if (!(PageStatus == IPGWstatus.Multing))
     {
         return;
     }
     PageStatus        = IPGWstatus.Choosing;
     ConnectType       = IPGW_type.DisconnectAll;
     TXTBLKyellow.Text = "断开所有连接";
     STRBDyellowInc.Begin();
 }
Exemplo n.º 8
0
 private void BDblue_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     if (!(PageStatus == IPGWstatus.Multing))
     {
         return;
     }
     PageStatus      = IPGWstatus.Choosing;
     ConnectType     = IPGW_type.ConnectFree;
     TXTBLKblue.Text = "连接免费";
     STRBDblueInc.Begin();
 }
Exemplo n.º 9
0
 private void PATHyellow_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     if (PageStatus != IPGWstatus.Multing)
     {
         return;
     }
     PageStatus  = IPGWstatus.Choosing;
     ConnectType = IPGW_type.ConnectNofree;
     SetTitle("连接收费地址");
     STRBDyellowRoll.Begin();
 }
Exemplo n.º 10
0
 private void PATHgreen_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     if (PageStatus != IPGWstatus.Multing)
     {
         return;
     }
     PageStatus  = IPGWstatus.Choosing;
     ConnectType = IPGW_type.Disconnect;
     SetTitle("断开连接");
     STRBDgreenRoll.Begin();
 }
Exemplo n.º 11
0
 private void PATHyellow_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     if (PageStatus != IPGWstatus.Choosing)
     {
         return;
     }
     PageStatus = IPGWstatus.Multing;
     SetTitle("北大网关");
     ConnectType = IPGW_type.None;
     STRBDyellowRoll.Stop();
     PROJyellow.RotationY = 0;
 }
Exemplo n.º 12
0
        private void Reset()
        {
            SetTitle("北大网关");
            RectangleGeometry tempRec = PATHslid.Data as RectangleGeometry;
            Rect re = tempRec.Rect;

            re.X          = HistoryX;
            re.Y          = HistoryY;
            tempRec.Rect  = re;
            PATHslid.Data = tempRec;
            PageStatus    = IPGWstatus.Nothing;
            ConnectType   = IPGW_type.None;
            STRBDconnectEnd.Begin();
        }
Exemplo n.º 13
0
 private void IPGWmain_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     PageStatus       = IPGWstatus.Beginning;
     IPGWmain.Opacity = 1;
     STRBDlinkShow.Begin();
 }
Exemplo n.º 14
0
 private void ELPSin_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     PageStatus = IPGWstatus.Nothing;
     STRBDconnectEnd.Begin();
 }
Exemplo n.º 15
0
 private void ELPSin_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     PageStatus = IPGWstatus.Beginning;
     STRBDconnectStart.Begin();
 }
Exemplo n.º 16
0
        private async void DoConnection(IPGW_type connectType, String hintString)
        {
            String type = "connect";
            String free = "2";

            if (connectType == IPGW_type.ConnectNofree)
            {
                free = "1";
            }
            else if (connectType == IPGW_type.Disconnect)
            {
                type = "disconnect";
            }
            else if (connectType == IPGW_type.DisconnectAll)
            {
                type = "disconnectall";
            }
            //if (!Constants.isLogin()) ;//日后加入登录内容
            List <Parameters> paramList = new List <Parameters>();

            /**
             * 这两句仅用于测试!!!
             * 必须改掉!
             */
            //Constants.username = "******";
            //Constants.password = "******";



            paramList.Add(new Parameters("uid", Constants.username));
            paramList.Add(new Parameters("password", Constants.password));
            paramList.Add(new Parameters("operation", type));
            paramList.Add(new Parameters("range", free));
            paramList.Add(new Parameters("timeout", "-1"));
            Reset();
            PageStatus = IPGWstatus.Connecting;
            STRBDconnectEnd.Begin();


            Parameters parameter = await WebConnection.Connect("https://its.pku.edu.cn:5428/ipgatewayofpku", paramList);

            if (!"200".Equals(parameter.name))
            {
                if ("-1".Equals(parameter.name))
                {
                    Constants.BoxPage.ShowMessage("无法连接网络");
                }
                else
                {
                    Constants.BoxPage.ShowMessage("无法连接到服务器 (HTTP " + parameter.name + ")");
                }
            }
            else
            {
                Dictionary <String, String> map = GetReturnMsg(parameter.value);
                if (!map.ContainsKey("SUCCESS"))
                {
                    Constants.BoxPage.ShowMessage("网关连接失败,请重试");
                    STRBDconnecting.Stop();
                    return;
                }
                String  successMsg = map["SUCCESS"];
                Boolean success    = "YES".Equals(successMsg);

                if (connectType == IPGW_type.ConnectFree || connectType == IPGW_type.ConnectNofree)
                {
                    if (success)
                    {
                        String scope = "";
                        if ("f".Equals(map["SCOPE"].Trim()))
                        {
                            scope = "免费地址";
                        }
                        else if ("international".Equals(map["SCOPE"].Trim()))
                        {
                            scope = "收费地址";
                        }
                        hintString = scope + "\r\n"
                                     + "IP: " + map["IP"] + "\r\n当前连接数:" + map["CONNECTIONS"] + "\r\n"
                                     + "已用时长: " + map["FR_TIME"] + "\r\n" + "账户余额:" + map["BALANCE"];
                        if (free.Equals("1"))
                        {
                            Boolean whether_get_bing = false;
                            String  his_str          = Editor.getString("bing_history", "");
                            try
                            {
                                if (!his_str.Equals(""))
                                {
                                    DateTime history = DateTime.Parse(his_str);
                                    int      span    = DateTime.Now.Day - history.Day;
                                    if (span >= 1 || span < 0)
                                    {
                                        whether_get_bing = true;
                                    }
                                }
                                else
                                {
                                    whether_get_bing = true;
                                }
                            }
                            catch { }
                            if (whether_get_bing)
                            {
                                await GetBingToday();
                            }
                        }
                        // 显示对话框
                        //两个Lib的函数?仍然没看懂
                        Constants.BoxPage.ShowMessage(hintString, "连接状态:已连接");
                    }
                    else
                    {
                        Constants.BoxPage.ShowMessage(map["REASON"], "连接失败");
                        //一个Lib的函数,未实现
                    }
                    STRBDconnecting.Stop();
                    return;
                }
                if (connectType == IPGW_type.Disconnect)
                {
                    if (success)
                    {
                        Constants.BoxPage.ShowMessage("", "断开连接成功");
                    }
                    else
                    {
                        Constants.BoxPage.ShowMessage(map["REASON"], "断开连接失败");
                        STRBDconnecting.Stop();
                        return;
                    }
                }
                if (connectType == IPGW_type.DisconnectAll)
                {
                    if (success)
                    {
                        Constants.BoxPage.ShowMessage("", "断开全部连接成功");
                    }
                    else
                    {
                        Constants.BoxPage.ShowMessage(map["REASON"], "断开全部连接失败");
                        STRBDconnecting.Stop();
                        return;
                    }
                }
            }
        }