Ejemplo n.º 1
0
        /// <summary>
        /// Raises the element property changed event.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">The event arguments</param>
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            FancyButton formsButton = Element as FancyButton;

            if (formsButton != null && e.PropertyName == FancyButton.PlaceholderProperty.PropertyName)
            {
                _pressedDownColor = formsButton.PressedDownColor;
            }
        }
Ejemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            Android.Widget.Button thisButton  = Control as Android.Widget.Button;
            FancyButton           formsButton = (FancyButton)Element;

            _pressedDownColor = formsButton.PressedDownColor;
            thisButton.Touch += (object sender, Android.Views.View.TouchEventArgs e2) => {
                if (e2.Event.Action == MotionEventActions.Down)
                {
                    thisButton.SetBackgroundColor(_pressedDownColor.ToAndroid());
                }
                else if (e2.Event.Action == MotionEventActions.Up)
                {
                    thisButton.SetBackgroundColor(Xamarin.Forms.Color.Default.ToAndroid());
                }
            };
        }
Ejemplo n.º 3
0
        private void _loadShortcuts()
        {
            int row = 0;

            foreach (var keyPair in ApplicationShortcut.KeyBindings2)
            {
                string actionName = keyPair.Key;

                if (actionName == SdeStrings.AutoGenerated)
                {
                    continue;
                }

                var binding = keyPair.Value;

                Label l = new Label {
                    Content = actionName
                };
                WpfUtilities.SetGridPosition(l, row, 0);
                _gridShortcuts.Children.Add(l);

                Border b = new Border();
                b.Margin          = new Thickness(3);
                b.BorderThickness = new Thickness(1);
                b.BorderBrush     = WpfUtilities.LostFocusBrush;

                Grid grid = new Grid();
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(-1, GridUnitType.Auto)
                });

                TextBox tb = new TextBox {
                    Text = binding.KeyGesture.DisplayString
                };
                tb.BorderThickness = new Thickness(0);
                tb.Padding         = new Thickness(0);
                tb.IsReadOnly      = true;
                b.Child            = tb;

                grid.Children.Add(b);

                FancyButton button = new FancyButton();
                button.ImagePath  = "reset.png";
                button.Width      = 20;
                button.Height     = 20;
                button.Visibility = Visibility.Collapsed;
                button.Margin     = new Thickness(0, 0, 3, 0);
                button.Click     += delegate {
                    button.Visibility = Visibility.Collapsed;
                    binding.Reset();
                    tb.Text = binding.KeyGesture.DisplayString;
                    SdeAppConfiguration.Remapper.Remove(actionName);
                    b.BorderBrush = WpfUtilities.LostFocusBrush;
                };

                if (binding.CanReset)
                {
                    button.Visibility = Visibility.Visible;
                }

                WpfUtilities.SetGridPosition(button, 0, 1);
                grid.Children.Add(button);

                WpfUtilities.SetGridPosition(grid, row, 1);
                _gridShortcuts.Children.Add(grid);
                _gridShortcuts.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(-1, GridUnitType.Auto)
                });

                tb.GotFocus += delegate {
                    b.BorderThickness = new Thickness(2);

                    if (b.BorderBrush == Brushes.Red)
                    {
                        return;
                    }

                    b.BorderBrush = WpfUtilities.GotFocusBrush;
                };

                tb.LostFocus += delegate {
                    b.BorderThickness = new Thickness(1);

                    if (b.BorderBrush == Brushes.Red)
                    {
                        return;
                    }

                    b.BorderBrush = WpfUtilities.LostFocusBrush;
                };

                tb.PreviewKeyDown += delegate(object sender, KeyEventArgs e) {
                    if (e.Key == Key.Escape || e.Key == Key.Tab)
                    {
                        return;
                    }

                    bool valid;
                    tb.Text = _make(e.Key, Keyboard.Modifiers, out valid);

                    try {
                        if (!valid)
                        {
                            throw new Exception();
                        }

                        var b2       = binding;
                        var shortcut = ApplicationShortcut.Make(null, e.Key, Keyboard.Modifiers);

                        while (b2 != null)
                        {
                            b2.Set(shortcut);
                            b2 = b2.Next;
                        }

                        if (binding.CanReset)
                        {
                            button.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            button.Visibility = Visibility.Collapsed;
                        }

                        SdeAppConfiguration.Remapper[actionName] = tb.Text;
                        ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);

                        b.BorderThickness = new Thickness(2);
                        b.BorderBrush     = WpfUtilities.GotFocusBrush;
                    }
                    catch {
                        b.BorderThickness = new Thickness(2);
                        b.BorderBrush     = Brushes.Red;
                        button.Visibility = Visibility.Visible;
                    }
                    e.Handled = true;
                };

                row++;
            }
        }
 // Use this for initialization
 void Start()
 {
     GUIMaster = GameObject.FindGameObjectWithTag ("GUI Master").GetComponent<cscript_GUI_master>();
     BackButton = new FancyButton("Back To Menu", Screen.width / 2 - 250, Screen.height / 2 + 310, 500, 60, 0.5f, 2);
 }