コード例 #1
0
        private void btnHostResolve_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            txIP.Text = "";

            if (RscUtils.IsIpAddress(txHostName.Text))
            {
                txIP.Text = "ERR: IP can not be resolved!";
            }
            else
            {
                var endpoint = new DnsEndPoint(txHostName.Text, 0);
                DeviceNetworkInformation.ResolveHostNameAsync(endpoint, OnHostResolved, null);
            }
        }
コード例 #2
0
        private void OnOK()
        {
            bool bGoBack = true;

            if (!DeviceNetworkInformation.IsNetworkAvailable)
            {
                ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
                connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
                connectionSettingsTask.Show();

                return;
            }

            if (m_AppInput != null)
            {
                string strRes = txSvrIP.Text;

                //NoEmpty...
                if (m_AppInput.GetFlag(1).Length > 0)
                {
                    strRes = strRes.Trim();

                    if (strRes.Length == 0)
                    {
                        MessageBox.Show("Value must not be empty!");
                        return;
                    }
                }

                /*
                 * //FileName...
                 * if( m_AppInput.GetFlag(1).Length > 0 )
                 * {
                 *      strRes = strRes.Trim();
                 *
                 *      string strChk = "\\/:*?\"<>|";
                 *      foreach( char cChk in strChk )
                 *      {
                 *              if( strRes.IndexOf( cChk ) >= 0 )
                 *              {
                 *                      MessageBox.Show("Value must not contain characters of '" + strChk + "'!");
                 *                      return;
                 *              }
                 *      }
                 * }
                 */

                bGoBack = false;

                if (RscUtils.IsIpAddress(strRes))
                {
                    /*
                     * MessageBox.Show("IP Address is not allowed here!");
                     * return;
                     */

                    DoOk();
                }
                else
                {
                    prsBar.Visibility = Rsc.Visible;

                    var endpoint = new DnsEndPoint(strRes, 0);
                    DeviceNetworkInformation.ResolveHostNameAsync(endpoint, OnHostResolved, null);
                }
            }

            if (bGoBack)
            {
                this.NavigationService.GoBack();
            }
        }