Ejemplo n.º 1
0
 public TreeStyle(TreeStyle style) : base(style)
 {
     MarkStyle                = new ImageButtonStyle(style.MarkStyle);
     LabelStyle               = new TextBlockStyle(style.LabelStyle);
     SelectionBackground      = style.SelectionBackground;
     SelectionHoverBackground = style.SelectionHoverBackground;
 }
Ejemplo n.º 2
0
 public ImageButton(ImageButtonStyle style) : base(style)
 {
     image = new Image();
     image.SetScaling(Scaling.Fit);
     Add(image);
     SetStyle(style);
     SetSize(PreferredWidth, PreferredHeight);
 }
Ejemplo n.º 3
0
        public override void SetStyle(ButtonStyle style)
        {
            Insist.IsTrue(style is ImageButtonStyle, "style must be a ImageButtonStyle");

            base.SetStyle(style);
            this.style = (ImageButtonStyle)style;
            if (image != null)
            {
                UpdateImage();
            }
        }
Ejemplo n.º 4
0
        public void ApplyImageButtonStyle(ImageButtonStyle style)
        {
            ApplyButtonBaseStyle(style);

            var imageStyle = style.ImageStyle;

            InternalChild.ApplyWidgetStyle(imageStyle);

            Image        = imageStyle.Image;
            OverImage    = imageStyle.OverImage;
            PressedImage = imageStyle.PressedImage;
        }
Ejemplo n.º 5
0
        private void AddItems(Skin skin)
        {
            var textButtonStyle = new ImageButtonStyle
            {
                Up             = new PrimitiveDrawable(Color.DarkGray, 6, 2),
                Over           = new PrimitiveDrawable(Color.DimGray),
                Down           = new PrimitiveDrawable(Color.DimGray),
                PressedOffsetX = 0,
                PressedOffsetY = 0
            };

            int count = 0;

            foreach (var i in LoginManagerClient.GetCharacter().Equipment)
            {
                float f = GetWidth();
                if (count % 5 == 0)
                {
                    Row();
                }
                if (i != null && i.GetSprite() == null)
                {
                    i.SetSprite(TextureContainer.GetSpriteAtlasByName("Items").GetSprite(i.TextureName));
                }

                if (i != null)
                {
                    SpriteDrawable    spd = new SpriteDrawable(i.GetSprite());
                    NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(i.GetSprite(), 0, 0, 0, 0)
                    {
                        MinHeight = 48, MinWidth = 48
                    };

                    ItemButton imButton = new ItemButton(ninePatchDrawable, count, i);

                    imButton.SetTouchable(Touchable.Enabled);
                    imButton.OnHovered += delegate { OnHovered(imButton, i, skin, stage); };
                    imButton.OnExited  += delegate { OnExit(imButton, stage); };
                    imButton.OnMoved   += delegate { OnMovedAndHovered(imButton); };
                    imButton.OnClicked += delegate { OnClickedCharacter(imButton); };
                    Add(imButton).Size(48, 48).Pad(4).Expand();
                }
                else
                {
                    ItemButton imButton = new ItemButton(textButtonStyle, count, null);
                    imButton.Add(new Label("")).Expand().Left().SetAlign(Nez.UI.Align.BottomLeft);
                    imButton.SetTouchable(Touchable.Disabled);
                    Add(imButton).Size(48, 48).Pad(4).Expand();
                }
                count++;
            }
        }
Ejemplo n.º 6
0
        public ImageButton(ImageButtonStyle style)
        {
            Widget = new Image
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            if (style != null)
            {
                ApplyImageButtonStyle(style);
            }
        }
Ejemplo n.º 7
0
        public static Style CreateMapRenderButtonStyle()
        {
            var style = ImageButtonStyle.CreateImageButtonStyle();

            //btnOK
            var trigger = new Trigger()
            {
                Property = UIElement.NameProperty,
                Value    = "OK"
            };

            trigger.Setters.AddRange(GetMapRenderButtonSetters("OK"));
            style.Triggers.Add(trigger);
            //btnYes
            trigger = new Trigger()
            {
                Property = UIElement.NameProperty,
                Value    = "Yes"
            };
            trigger.Setters.AddRange(GetMapRenderButtonSetters("Yes"));
            style.Triggers.Add(trigger);
            //btnNo
            trigger = new Trigger()
            {
                Property = UIElement.NameProperty,
                Value    = "No"
            };
            trigger.Setters.AddRange(GetMapRenderButtonSetters("No"));
            style.Triggers.Add(trigger);
            //btnCancel
            trigger = new Trigger()
            {
                Property = UIElement.NameProperty,
                Value    = "Cancel"
            };
            trigger.Setters.AddRange(GetMapRenderButtonSetters("Cancel"));
            style.Triggers.Add(trigger);
            //btnClose
            trigger = new Trigger()
            {
                Property = UIElement.NameProperty,
                Value    = "Close"
            };
            trigger.Setters.AddRange(GetMapRenderButtonSetters("Close"));
            style.Triggers.Add(trigger);

            return(style);
        }
Ejemplo n.º 8
0
        public void ApplyImageButtonStyle(ImageButtonStyle style)
        {
            ApplyButtonBaseStyle(style);

            if (style.ImageStyle != null)
            {
                var imageStyle = style.ImageStyle;

                Widget.ApplyWidgetStyle(imageStyle);

                Image        = imageStyle.Image;
                OverImage    = imageStyle.OverImage;
                PressedImage = imageStyle.PressedImage;

                Widget.UpdateImageSize(imageStyle.Image);
                Widget.UpdateImageSize(imageStyle.OverImage);
                Widget.UpdateImageSize(imageStyle.PressedImage);
            }

            UpdateTextureRegion2D();
        }
Ejemplo n.º 9
0
        private void AddAbilities()
        {
            var textButtonStyle = new ImageButtonStyle
            {
                Up             = new PrimitiveDrawable(Color.DarkGray, 6, 2),
                Over           = new PrimitiveDrawable(Color.DarkGray),
                Down           = new PrimitiveDrawable(Color.DarkGray),
                PressedOffsetX = 0,
                PressedOffsetY = 0
            };

            foreach (var keybinds in KeyBindContainer.KeyBinds)
            {
                ImageButton button = new ImageButton(textButtonStyle);
                button.SetTouchable(Touchable.Enabled);
                button.Add(new Label(keybinds.BindedKey.ToString()).SetPosition(24 / 2, 24 / 2));
                button.Row();
                button.Add(new Label(keybinds.GetAbility().AbilityName).SetPosition(24 / 2, 24));
                Add(button).Size(24, 24).Pad(5);
            }
        }
Ejemplo n.º 10
0
 public WindowStyle(WindowStyle style) : base(style)
 {
     TitleStyle       = new TextBlockStyle(style.TitleStyle);
     CloseButtonStyle = new ImageButtonStyle(style.CloseButtonStyle);
 }
Ejemplo n.º 11
0
        public void ApplySplitPaneStyle(SplitPaneStyle style)
        {
            ApplyWidgetStyle(style);

            HandleStyle = style.HandleStyle;
        }
Ejemplo n.º 12
0
        void Build()
        {
            Children.Clear();
            RowDefinitions.Clear();
            image = null;
            label = null;

            if (ImageButtonStyle.HasFlag(ImageButtonStyles.Image))
            {
                image = new Image
                {
                    HorizontalOptions = ImageWidthRequest < 0 ? LayoutOptions.Fill : LayoutOptions.CenterAndExpand,
                    VerticalOptions   = ImageHeightRequest < 0 ? LayoutOptions.Fill : LayoutOptions.CenterAndExpand,
                    Aspect            = Aspect.AspectFit,
                    InputTransparent  = true
                };

                Children.Add(image);

                image.BindingContext = this;
                image.SetBinding(Image.SourceProperty, nameof(Source));
                image.InputTransparent = true;
                image.Margin           = ImageMargin;

                image.SetBinding(Image.HeightRequestProperty, nameof(ImageHeightRequest));
                image.SetBinding(Image.WidthRequestProperty, nameof(ImageWidthRequest));
            }

            if (ImageButtonStyle.HasFlag(ImageButtonStyles.Text))
            {
                label = new Label
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions   = LayoutOptions.Fill,
                    MaxLines          = 1,
                    LineBreakMode     = LineBreakMode.NoWrap,
                    InputTransparent  = true
                };

                Children.Add(label);

                label.BindingContext = this;
                label.SetBinding(Label.TextProperty, nameof(Text));
                label.SetBinding(Label.TextColorProperty, nameof(TextColor));
                label.SetBinding(Label.FontSizeProperty, nameof(FontSize));
                label.SetBinding(Label.FontFamilyProperty, nameof(FontFamily));
                label.SetBinding(Label.FontAttributesProperty, nameof(FontAttributes));
                label.SetBinding(Label.HorizontalTextAlignmentProperty, nameof(HorizontalTextAlignment));
                label.SetBinding(Label.VerticalTextAlignmentProperty, nameof(VerticalTextAlignment));
            }

            var button = new Button2
            {
                BindingContext    = this,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
            };

            button.Pressed  += Button_Pressed;
            button.Released += Button_Released;
            button.Clicked  += Button_Clicked;

            Children.Add(button);

            if (ImageButtonStyle == ImageButtonStyles.ImageText)
            {
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Star
                });
                RowDefinitions.Add(new RowDefinition {
                    Height = TextHeight
                });

                button.SetValue(Grid.RowProperty, 0);
                button.SetValue(Grid.RowSpanProperty, 2);

                image.SetValue(Grid.RowProperty, 0);
                label.SetValue(Grid.RowProperty, 1);

                //image.VerticalOptions = LayoutOptions.EndAndExpand;
            }
            else if (ImageButtonStyle == ImageButtonStyles.ImageTextStack)
            {
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Star
                });
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                RowDefinitions.Add(new RowDefinition {
                    Height = TextHeight
                });
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Star
                });

                button.SetValue(Grid.RowProperty, 0);
                button.SetValue(Grid.RowSpanProperty, 4);

                image.SetValue(Grid.RowProperty, 1);
                label.SetValue(Grid.RowProperty, 2);
            }

            AdjustOrientation();
        }
Ejemplo n.º 13
0
 public WindowStyle()
 {
     TitleStyle       = new TextBlockStyle();
     CloseButtonStyle = new ImageButtonStyle();
 }
Ejemplo n.º 14
0
 public SpinButtonStyle(SpinButtonStyle style) : base(style)
 {
     UpButtonStyle   = new ImageButtonStyle(style.UpButtonStyle);
     DownButtonStyle = new ImageButtonStyle(style.DownButtonStyle);
     TextFieldStyle  = new TextFieldStyle(style.TextFieldStyle);
 }
Ejemplo n.º 15
0
 public WindowStyle(WindowStyle style) : base(style)
 {
     TitleStyle       = style.TitleStyle != null ? new TextBlockStyle(style.TitleStyle) : null;
     CloseButtonStyle = style.CloseButtonStyle != null ? new ImageButtonStyle(style.CloseButtonStyle) : null;
 }
Ejemplo n.º 16
0
 public ItemButton(ImageButtonStyle style, int pos, WeaponItem item) : base(style)
 {
     this.item = item;
     position  = pos;
 }
Ejemplo n.º 17
0
 public SliderStyle(SliderStyle style) : base(style)
 {
     KnobStyle = new ImageButtonStyle(style.KnobStyle);
 }
Ejemplo n.º 18
0
 public TreeStyle(TreeStyle style) : base(style)
 {
     MarkStyle  = new ImageButtonStyle(style.MarkStyle);
     LabelStyle = new TextBlockStyle(style.LabelStyle);
 }
Ejemplo n.º 19
0
 public ImageButtonStyle(ImageButtonStyle style) : base(style)
 {
     ImageStyle = style.ImageStyle != null ? new PressableImageStyle(style.ImageStyle) : null;
 }
Ejemplo n.º 20
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            //Debugger.Launch();

            _spriteBatch = new GdxSpriteBatch(Context.GraphicsDevice);
            _skin        = new Skin(Context.GraphicsDevice, "Data/uiskin.json");
            _texture1    = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true);
            _texture2    = new TextureContext(Context.GraphicsDevice, "Data/badlogic.jpg", true);

            TextureRegion image        = new TextureRegion(_texture1);
            TextureRegion imageFlipped = new TextureRegion(image);

            imageFlipped.Flip(true, true);
            TextureRegion image2 = new TextureRegion(_texture2);

            _stage = new Stage(Context.GraphicsDevice.Viewport.Width, Context.GraphicsDevice.Viewport.Height, true, Context.GraphicsDevice);

            Context.Input.Processor = _stage;

            ImageButtonStyle style = new ImageButtonStyle(_skin.Get <ButtonStyle>())
            {
                ImageUp   = new TextureRegionDrawable(image),
                ImageDown = new TextureRegionDrawable(imageFlipped),
            };
            ImageButton iconButton = new ImageButton(style);

            Button buttonMulti = new TextButton("Multi\nLine\nToggle", _skin, "toggle")
            {
                IsToggle = true,
            };
            Button imgButton       = new Button(new Image(image), _skin);
            Button imgToggleButton = new Button(new Image(image), _skin, "toggle")
            {
                IsToggle = true,
            };

            Label myLabel = new Label("This is some text.", _skin);

            myLabel.TextWrapping = true;

            Table t = new Table();

            t.Row();
            t.Add(myLabel);

            t.Layout();

            CheckBox  checkbox  = new CheckBox("Check me", _skin);
            Slider    slider    = new Slider(0, 10, 1, false, _skin);
            TextField textField = new TextField("", _skin)
            {
                MessageText = "Click here!",
            };
            SelectBox  dropdown   = new SelectBox(selectEntries, _skin);
            Image      imageActor = new Image(image2);
            ScrollPane scrollPane = new ScrollPane(imageActor);

            MonoGdx.Scene2D.UI.List list = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane2       = new ScrollPane(list, _skin);
            //scrollPane2.FlickScroll = false;
            SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, _skin, "default-horizontal");

            _fpsLabel = new Label("fps:", _skin);

            Label     passwordLabel = new Label("Textfield in password mode: ", _skin);
            TextField passwordField = new TextField("", _skin)
            {
                MessageText       = "password",
                PasswordCharacter = '*',
                IsPasswordMode    = true,
            };

            Window window = new Window("Dialog", _skin);

            window.SetPosition(0, 0);
            window.Defaults().SpaceBottom = 10;
            window.Row().Configure.Fill().ExpandX();
            window.Add(iconButton);
            window.Add(buttonMulti);
            window.Add(imgButton);
            window.Add(imgToggleButton);
            window.Row();
            window.Add(checkbox);
            window.Add(slider).Configure.MinWidth(100).FillX().Colspan(3);
            window.Row();
            window.Add(dropdown).Configure.MinWidth(100).FillX();
            window.Add(textField).Configure.MinWidth(100).ExpandX().FillX().Colspan(3);
            window.Row();
            window.Add(splitPane).Configure.Fill().Expand().Colspan(4).MaxHeight(200);
            window.Row();
            window.Add(passwordLabel).Configure.Colspan(2);
            window.Add(passwordField).Configure.MinWidth(100).ExpandX().FillX().Colspan(2);

            window.Pack();

            /*textField.KeyUp += (field, c) => {
             *  if (c == '\n')
             *      field.OnscreenKeyboard.Show(false);
             * };*/

            _stage.AddActor(window);

            MonoGdx.Scene2D.UI.List list2 = new MonoGdx.Scene2D.UI.List(listEntries, _skin);
            ScrollPane scrollPane22       = new ScrollPane(list2, _skin);
            Window     window2            = new Window("ScrollPane", _skin);

            window2.SetPosition(300, 300);
            window2.Defaults().SpaceBottom = 10;
            window2.Row().Configure.Fill().ExpandX();
            window2.Add(scrollPane22).Configure.MaxHeight(250).MaxWidth(150);
            window2.Pack();

            _stage.AddActor(window2);
        }
Ejemplo n.º 21
0
 public ItemButton(ImageButtonStyle style) : base(style)
 {
 }
Ejemplo n.º 22
0
 public TreeStyle()
 {
     MarkStyle  = new ImageButtonStyle();
     LabelStyle = new TextBlockStyle();
 }
Ejemplo n.º 23
0
 public ImageButtonStyle(ImageButtonStyle style) : base(style)
 {
     ImageStyle = new PressableImageStyle(style.ImageStyle);
 }
Ejemplo n.º 24
0
 public SplitPaneStyle(SplitPaneStyle style) : base(style)
 {
     HandleStyle = new ImageButtonStyle(style.HandleStyle);
 }
Ejemplo n.º 25
0
 public SliderStyle()
 {
     KnobStyle = new ImageButtonStyle();
 }
Ejemplo n.º 26
0
 public SplitPaneStyle()
 {
     HandleStyle = new ImageButtonStyle();
 }
Ejemplo n.º 27
0
 public SliderStyle(SliderStyle style) : base(style)
 {
     KnobStyle = style.KnobStyle != null ? new ImageButtonStyle(style.KnobStyle) : null;
 }
Ejemplo n.º 28
0
 public SpinButtonStyle()
 {
     UpButtonStyle   = new ImageButtonStyle();
     DownButtonStyle = new ImageButtonStyle();
     TextFieldStyle  = new TextFieldStyle();
 }