Example #1
0
        private async void Start()
        {
            App ap = (App)App.Current;

            port.IsEnabled = false;
            mode++;
            // TODO: add waiting animation

            if (await ap.CreateListener())
            {
                await Task.Delay(100);// If successfully connected, play green animation

                anim.Stop();
                int i = 0;
                while (i < 20)
                {
                    i++; t++;
                    byte v = (byte)(240 - 105 * Math.Pow(Math.Sin(2 * t / 31.8 + 1), 24));
                    Circle.Fill = new SolidColorBrush(Color.FromArgb(255, v, 240, v));
                    AnimCSize();
                    await Task.Delay(20);
                }
                anim.Start();
            }
            else
            {
                anim.Stop();//  If not connected, play red animation
                int i = 0;
                while (i < 20)
                {
                    i++; t++;
                    byte v = (byte)(240 - 105 * Math.Pow(Math.Sin(2 * i / 31.8 + 1), 24));
                    Circle.Fill = new SolidColorBrush(Color.FromArgb(255, 240, v, v));
                    AnimCSize();
                    await Task.Delay(20);
                }
                anim.Start();
            }
        }
Example #2
0
        private async void run_Click(object sender, RoutedEventArgs e)
        {
            port.IsEnabled = false;
            try
            {
                //Hook up an event handler to call when connections are received.
                string myIP = Networking.GetLocalIp();
                ipadress.Text = ("my IP: " + myIP);
                await Networking.sendIP(myIP);

                //Start listening for incoming TCP connections on the specified port.
                //You can specify any port that's not currently in use.
                App ap = (App)Application.Current;
                await ap.CreateListener();
            }
            catch (Exception ex)
            {
                //Handle exception.
                cons.Text += "\nError while creating listener:";
                cons.Text += "\n" + ex.Message;
            }
        }
Example #3
0
        private async void Circle_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            App ap = (App)App.Current;

            mode++;
            if (await ap.CreateListener())
            {
                await Task.Delay(100);

                anim.Stop();
                int i = 0;
                while (i < 20)
                {
                    i++; t++;
                    byte v = (byte)(240 - 105 * Math.Pow(Math.Sin(2 * t / 31.8 + 1), 24));
                    Circle.Fill = new SolidColorBrush(Color.FromArgb(255, v, 240, v));
                    AnimCSize();
                    await Task.Delay(20);
                }
                anim.Start();
            }
            else
            {
                anim.Stop();
                int i = 0;
                while (i < 20)
                {
                    i++; t++;
                    byte v = (byte)(240 - 105 * Math.Pow(Math.Sin(2 * i / 31.8 + 1), 24));
                    Circle.Fill = new SolidColorBrush(Color.FromArgb(255, 240, v, v));
                    AnimCSize();
                    await Task.Delay(20);
                }
                anim.Start();
            }
        }