Exemple #1
0
        private void TextureControlOnMouseUp(object sender, MouseEventArgs e)
        {
            Point offset = Mouse.LDragOffset;

            if (Math.Abs(offset.X) < 5 && Math.Abs(offset.Y) < 5)
            {
                if (PlotState != 0 && _currentPin == null && _pinTimer > Time.Ticks)
                {
                    ushort x = (ushort)(e.X + 5);
                    ushort y = (ushort)e.Y;

                    NetClient.Socket.Send
                    (
                        new PMapMessage
                        (
                            LocalSerial,
                            1,
                            0,
                            x,
                            y
                        )
                    );

                    AddPin(x, y);
                }
            }

            _currentPin = null;
            _lastPoint  = Point.Zero;
        }
Exemple #2
0
 protected override void OnDisappearing()
 {
     base.OnDisappearing();
     PinControl.Dispose();
     Tgr.Tapped -= Tgr_Tapped;
     PinControl.OnPinEntered -= PinEntered;
 }
        private void PinControl_PinChanged(object sender, PinChangedArgs e)
        {
            PinControl s = (PinControl)sender;

            try
            {
                int pin = s.PinIndex;
                if (!_loaded || _arduino == null)
                {
                    return;
                }
                switch (e.Pincap)
                {
                case PinModes.Output:
                    if (e.Value >= 1)
                    {
                        _arduino.SetDO(pin, true);
                    }
                    else
                    {
                        _arduino.SetDO(pin, false);
                    }
                    break;

                case PinModes.PWM:
                    _arduino.SetPWM(pin, e.Value);
                    break;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error setting/geting pin state.\r\nMaybe incorrect modell selected", "I/O Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void Init()
        {
            var instructionLabel = new Label
            {
                Text                    = AppResources.SetPINDirection,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalTextAlignment = TextAlignment.Center,
                Style                   = (Style)Application.Current.Resources["text-muted"]
            };

            PinControl = new PinControl();
            PinControl.OnPinEntered += PinEntered;
            PinControl.Label.SetBinding <PinPageModel>(Label.TextProperty, s => s.LabelText);
            PinControl.Entry.SetBinding <PinPageModel>(Entry.TextProperty, s => s.PIN);

            var stackLayout = new StackLayout
            {
                Padding  = new Thickness(30, 40),
                Spacing  = 20,
                Children = { PinControl.Label, instructionLabel, PinControl.Entry }
            };

            var tgr = new TapGestureRecognizer();

            tgr.Tapped += Tgr_Tapped;
            PinControl.Label.GestureRecognizers.Add(tgr);
            instructionLabel.GestureRecognizers.Add(tgr);

            Title   = AppResources.SetPIN;
            Content = stackLayout;
            Content.GestureRecognizers.Add(tgr);
            BindingContext = Model;
        }
Exemple #5
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     Tgr.Tapped += Tgr_Tapped;
     PinControl.OnPinEntered += PinEntered;
     PinControl.InitEvents();
     PinControl.Entry.FocusWithDelay();
 }
Exemple #6
0
        protected override void OnMouseDown(int x, int y, MouseButtonType button)
        {
            _pinTimer = Time.Ticks + 300;

            if (UIManager.MouseOverControl is PinControl pin)
            {
                _currentPin = pin;
            }
        }
Exemple #7
0
        protected override void OnMouseDown(int x, int y, MouseButton button)
        {
            _pinTimer = Engine.Ticks + 300;

            if (Engine.UI.MouseOverControl is PinControl pin)
            {
                _currentPin = pin;
            }
        }
Exemple #8
0
        public void AddPin(int x, int y)
        {
            PinControl c = new PinControl(x, y);

            c.X         += c.Width + 5;
            c.Y         += c.Height;
            c.NumberText = (_container.Count + 1).ToString();
            _container.Add(c);
            Add(c);
        }
        private void PinControl_PinModeChanged(object sender, PinModeChangedArgs e)
        {
            PinControl s = (PinControl)sender;

            try
            {
                if (!_loaded || _arduino == null)
                {
                    return;
                }
                _arduino.SetPinMode(s.PinIndex, e.Pincap);
                s.Value = 0;
            }
            catch (Exception)
            {
                MessageBox.Show("Error setting/geting pin state.\r\nMaybe incorrect modell selected", "I/O Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #10
0
        public void Init()
        {
            var instructionLabel = new Label
            {
                Text                    = "Enter your PIN code.",
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalTextAlignment = TextAlignment.Center,
                Style                   = (Style)Application.Current.Resources["text-muted"]
            };

            PinControl = new PinControl();
            PinControl.OnPinEntered += PinEntered;
            PinControl.Label.SetBinding <PinPageModel>(Label.TextProperty, s => s.LabelText);
            PinControl.Entry.SetBinding <PinPageModel>(Entry.TextProperty, s => s.PIN);

            var logoutButton = new ExtendedButton
            {
                Text            = AppResources.LogOut,
                Command         = new Command(async() => await LogoutAsync()),
                VerticalOptions = LayoutOptions.End,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                BackgroundColor = Color.Transparent,
                Uppercase       = false
            };

            var stackLayout = new StackLayout
            {
                Padding  = new Thickness(30, 40),
                Spacing  = 20,
                Children = { PinControl.Label, instructionLabel, logoutButton, PinControl.Entry }
            };

            var tgr = new TapGestureRecognizer();

            tgr.Tapped += Tgr_Tapped;
            PinControl.Label.GestureRecognizers.Add(tgr);
            instructionLabel.GestureRecognizers.Add(tgr);

            Title   = "Verify PIN";
            Content = stackLayout;
            Content.GestureRecognizers.Add(tgr);
            BindingContext = Model;
        }
Exemple #11
0
 private void Clock_StateChanged(PinControl sender, LogicState s)
 {
     if (Clock.State == LogicState.Indeterminate)
     {
         Q.State = LogicState.Indeterminate;
     }
     else
     {
         if (Clock.State == LogicState.Low)
         {
             Q.State = D.State;
         }
         else if (Clock.State == LogicState.High && D.State == LogicState.Low)
         {
             Q.State = LogicState.Low;
         }
         else if (Clock.State == LogicState.High && D.State == LogicState.High)
         {
             Q.State = LogicState.High;
         }
     }
 }
Exemple #12
0
        public void Init()
        {
            var instructionLabel = new Label
            {
                Text                    = AppResources.SetPINDirection,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalTextAlignment = TextAlignment.Center,
                Style                   = (Style)Application.Current.Resources["text-muted"]
            };

            PinControl = new PinControl();
            PinControl.Label.SetBinding(Label.TextProperty, nameof(PinPageModel.LabelText));
            PinControl.Entry.SetBinding(Entry.TextProperty, nameof(PinPageModel.PIN));

            var stackLayout = new StackLayout
            {
                Padding  = new Thickness(30, 40),
                Spacing  = 20,
                Children = { PinControl.Label, instructionLabel, PinControl.Entry }
            };

            Tgr = new TapGestureRecognizer();
            PinControl.Label.GestureRecognizers.Add(Tgr);
            instructionLabel.GestureRecognizers.Add(Tgr);

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
            }

            Title   = AppResources.SetPIN;
            Content = stackLayout;
            Content.GestureRecognizers.Add(Tgr);
            BindingContext = Model;
        }
Exemple #13
0
 protected override void OnMouseUp(int x, int y, MouseButtonType button)
 {
     base.OnMouseUp(x, y, button);
     _currentPin = null;
     _lastPoint  = Point.Zero;
 }
Exemple #14
0
 private void Q_StateChanged(PinControl sender, LogicState s)
 {
     _Q.State = (!(Bit) new Bit(Q.State)).Value;
 }
Exemple #15
0
 //create pin
 void SpawnPin()
 {
     currentPin = GameObject.Instantiate(pinPrefab, spawnPoint.position, pinPrefab.transform.rotation).GetComponent <PinControl>(); //the three parameters are object, location and rotation
 }
Exemple #16
0
 private void R_StateChanged(PinControl sender, LogicState s)
 {
     //if(Clock.State == LogicState.High)
     Eval();
 }