Ejemplo n.º 1
0
        private void Number_Validating(object sender, CancelEventArgs e)
        {
            int     val;
            TextBox tb = sender as TextBox;

            if (int.TryParse(tb.Text, out val))
            {
                if (val > 1023 && val < 65536)
                {
                    if (tb.Name == "HttpPortBox1")
                    {
                        PortData.Instance.httpPort = val;
                        Globals.facade.LogDebug($"Got Http Port num '{PortData.Instance.httpPort}'");
                        PortData.WriteFile();
                        return;
                    }
                    else if (tb.Name == "WebSvcPortBox1")
                    {
                        PortData.Instance.webSvcPort = val;
                        Globals.facade.LogDebug($"Got Http Port num '{PortData.Instance.webSvcPort}'");
                        PortData.WriteFile();
                        return;
                    }
                    else
                    {
                        Globals.facade.LogDebug($"Got invalid TextBox name '{tb.Name}'");
                    }
                }
            }
            tb.Undo();
            e.Cancel = true;
        }