Ejemplo n.º 1
0
        protected override void Init(Controllers.UiController controller, object binding, DefinitionFile definition)
        {
            base.Init(controller, binding, definition);

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(TransformGroup));

            _reverse = DefinitionResolver.Get <bool>(controller, binding, file["Reverse"], false);

            List <DefinitionFile> drawableFiles = file["Drawables"] as List <DefinitionFile>;

            if (drawableFiles != null)
            {
                foreach (var def in drawableFiles)
                {
                    ButtonDrawable drawable = def.CreateInstance(controller, binding) as ButtonDrawable;

                    if (drawable != null)
                    {
                        _drawables.Add(drawable);
                    }
                }
            }

            _transitionPushed = (file["TransitionEffect"] as DefinitionFile).CreateInstance(controller, binding) as TransitionEffect;
        }
Ejemplo n.º 2
0
        protected override void Init(UiController controller, object binding, DefinitionFile definition)
        {
            base.Init(controller, binding, definition);

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(Text));

            string font        = DefinitionResolver.GetString(controller, binding, file["Font"]);
            int    fontSize    = DefinitionResolver.Get <int>(controller, binding, file["FontSize"], 0);
            int    fontSpacing = DefinitionResolver.Get <int>(controller, binding, file["FontSpacing"], 0);

            _lineHeight = DefinitionResolver.Get <int>(controller, binding, file["LineHeight"], 100);

            _font = new UiFont(font, fontSize, fontSpacing);

            _textRotation = DefinitionResolver.Get <TextRotation>(controller, binding, file["TextRotation"], TextRotation.None);

            HorizontalContentAlignment horzAlign = DefinitionResolver.Get <HorizontalContentAlignment>(controller, binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Center);
            VerticalContentAlignment   vertAlign = DefinitionResolver.Get <VerticalContentAlignment>(controller, binding, file["VerticalContentAlignment"], VerticalContentAlignment.Center);

            _pathEllipsis = DefinitionResolver.Get <bool>(controller, binding, file["PathEllipsis"], false);

            _line = DefinitionResolver.Get <int>(controller, binding, file["Line"], -1);

            if (_pathEllipsis || _line >= 0)
            {
                _stringBuilder = new StringBuilder();
            }

            _textAlign = UiHelper.TextAlignFromContentAlignment(horzAlign, vertAlign);
            _text      = DefinitionResolver.GetSharedString(controller, binding, file["Text"]);
        }
Ejemplo n.º 3
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiImage));

            _image         = DefinitionResolver.GetShared <Texture2D>(Controller, Binding, file["Image"], null);
            _stretch       = DefinitionResolver.Get <Stretch>(Controller, Binding, file["Stretch"], Stretch.Uniform);
            _color         = DefinitionResolver.GetColorWrapper(Controller, Binding, file["Color"]) ?? new ColorWrapper();
            _rotationSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["RotationSpeed"], 0);
            _scaleByUnit   = DefinitionResolver.Get <bool>(Controller, Binding, file["ScaleByUnit"], true);
            _scale         = DefinitionResolver.Get(Controller, Binding, file["Scale"], Scale.One);

            _image.ValueChanged += _image_ValueChanged;

            switch (DefinitionResolver.Get <ResampleFilter>(Controller, Binding, file["ResampleFilter"], ResampleFilter.Default))
            {
            case ResampleFilter.Point:
                _samplerState = SamplerState.PointClamp;
                break;

            case ResampleFilter.Linear:
                _samplerState = SamplerState.LinearClamp;
                break;

            case ResampleFilter.Anisotropic:
                _samplerState = SamplerState.AnisotropicClamp;
                break;
            }

            return(true);
        }
Ejemplo n.º 4
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiText));

            FontName    = file["Font"] as string;
            FontSize    = DefinitionResolver.Get <int>(Controller, Binding, file["FontSize"], 0);
            FontSpacing = DefinitionResolver.Get <int>(Controller, Binding, file["FontSpacing"], 0);
            LineHeight  = DefinitionResolver.Get <int>(Controller, Binding, file["LineHeight"], 100);
            Justify     = DefinitionResolver.Get <bool>(Controller, Binding, file["Justify"], false);

            _indent    = DefinitionResolver.Get <Length>(Controller, Binding, file["Indent"], Length.Zero);
            _lineWidth = DefinitionResolver.Get <Length>(Controller, Binding, file["LineWidth"], Length.Stretch);

            Text = DefinitionResolver.GetString(Controller, Binding, file["Text"]) ?? string.Empty;

            TextColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["TextColor"]) ?? UiLabel.DefaultTextColor;

            HorizontalContentAlignment horzAlign = DefinitionResolver.Get <HorizontalContentAlignment>(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Left);
            VerticalContentAlignment   vertAlign = DefinitionResolver.Get <VerticalContentAlignment>(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Top);

            TextAlign = UiHelper.TextAlignFromContentAlignment(horzAlign, vertAlign);

            return(true);
        }
Ejemplo n.º 5
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiListBox));

            _vertical = DefinitionResolver.Get <Mode>(Controller, Binding, file["Mode"], Mode.Vertical) == Mode.Vertical;

            _template = (DefinitionFile)file["Template"];

            _items = (IItemsProvider)DefinitionResolver.GetValueFromMethodOrField(Controller, Binding, file["Items"]);
            _items.Subscribe(this);

            _rule = DefinitionResolver.Get <ScrollingService.ExceedRule>(Controller, Binding, file["ExceedRule"], ScrollingService.ExceedRule.Allow);

            _maxScrollExceed = DefinitionResolver.Get <Length>(Controller, Binding, file["MaxScrollExceed"], ScrollingService.MaxScrollExceed);

            _reverse = DefinitionResolver.Get <bool>(Controller, Binding, file["Reverse"], false);

            _wheelSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["WheelScrollSpeed"], 0);

            _additionalTemplates = file["AdditionalTemplates"] as Dictionary <Type, DefinitionFile>;

            _maxAddOneTime   = DefinitionResolver.Get <int>(Controller, Binding, file["MaxAddOneTime"], 32);
            _maxAddFirstTime = DefinitionResolver.Get <int>(Controller, Binding, file["MaxAddFirstTime"], _maxAddOneTime);

            return(true);
        }
Ejemplo n.º 6
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiExpandingBorder));

            _expanded = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Expanded"], true);

            _expandWidth  = DefinitionResolver.Get <Length>(Controller, Binding, file["ExpandedWidth"], PositionParameters.Width);
            _expandHeight = DefinitionResolver.Get <Length>(Controller, Binding, file["ExpandedHeight"], PositionParameters.Height);

            _expandSpeed = DefinitionResolver.Get <int>(Controller, Binding, file["ExpandTime"], 0);

            _expandedValue = _expanded.Value ? 1 : 0;

            RegisterDelegate("CollapseFinished", file["CollapseFinished"]);
            RegisterDelegate("ExpandFinished", file["ExpandFinished"]);
            RegisterDelegate("ExpandStarted", file["ExpandStarted"]);

            if (_expandSpeed > 0)
            {
                _expandSpeed = 1000 / _expandSpeed;
            }
            else
            {
                _expandSpeed = 10000;
            }

            _expanded.ValueChanged += _expanded_ValueChanged;
            return(true);
        }
Ejemplo n.º 7
0
        protected virtual void Init(UiController controller, object binding, DefinitionFile definition)
        {
            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(ButtonDrawable));

            float changeTime = (float)DefinitionResolver.Get <double>(controller, binding, file["ChangeTime"], 0) / 1000.0f;

            _changeSpeed = changeTime > 0 ? 1 / changeTime : 10000;

            _colorDisabled = DefinitionResolver.GetColorWrapper(controller, binding, file["ColorDisabled"]);
            _colorReleased = DefinitionResolver.GetColorWrapper(controller, binding, file["ColorReleased"]);
            _colorPushed   = DefinitionResolver.GetColorWrapper(controller, binding, file["ColorPushed"]);

            _margin = DefinitionResolver.Get <Margin>(controller, binding, file["Margin"], Margin.None);

            _opacity = (float)DefinitionResolver.Get <double>(controller, binding, file["Opacity"], 1);

            if (file["Special"] != null)
            {
                _specialState = DefinitionResolver.Get <bool>(controller, binding, file["Special"], false);
            }
            else
            {
                _specialState = null;
            }

            if (file["Checked"] != null)
            {
                _checkedState = DefinitionResolver.Get <bool>(controller, binding, file["Checked"], false);
            }
            else
            {
                _checkedState = null;
            }
        }
Ejemplo n.º 8
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiStackPanel));

            StackMode             = DefinitionResolver.Get(Controller, Binding, file["Mode"], Mode.Vertical);
            _spacing              = DefinitionResolver.Get(Controller, Binding, file["Spacing"], Length.Zero);
            _padding              = DefinitionResolver.Get(Controller, Binding, file["Padding"], Length.Zero);
            _notifyParentOnResize = DefinitionResolver.Get(Controller, Binding, file["NotifyParentOnResize"], true);

            _wrap = DefinitionResolver.Get(Controller, Binding, file["Wrap"], false);

            _horizontalContentAlignment = DefinitionResolver.Get(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Left);
            _verticalContentAlignment   = DefinitionResolver.Get(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Top);

            _expanded = DefinitionResolver.GetShared(Controller, Binding, file["Expanded"], true);

            _expandSpeed   = DefinitionResolver.Get(Controller, Binding, file["ExpandTime"], 0);
            _collapseSpeed = DefinitionResolver.Get(Controller, Binding, file["CollapseTime"], (int)_expandSpeed);

            _expandedValue = _expanded.Value ? 1 : 0;

            if (_expandSpeed > 0)
            {
                _expandSpeed = 1000 / _expandSpeed;
            }
            else
            {
                _expandSpeed = 10000;
            }

            if (_collapseSpeed > 0)
            {
                _collapseSpeed = 1000 / _collapseSpeed;
            }
            else
            {
                _collapseSpeed = 10000;
            }

            RegisterDelegate("CollapseFinished", file["CollapseFinished"]);
            RegisterDelegate("ExpandFinished", file["ExpandFinished"]);
            RegisterDelegate("ExpandStarted", file["ExpandStarted"]);

            TryInitChildren(definition);


            _expanded.ValueChanged += _expanded_ValueChanged;

            return(true);
        }
Ejemplo n.º 9
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiLabel));

            string fontName    = file["Font"] as string;
            int    fontSize    = DefinitionResolver.Get <int>(Controller, Binding, file["FontSize"], 0);
            int    fontSpacing = DefinitionResolver.Get <int>(Controller, Binding, file["FontSpacing"], 0);

            _font = new UiFont(fontName, fontSize, fontSpacing);

            _lineHeight = DefinitionResolver.Get <int>(Controller, Binding, file["LineHeight"], 100);

            _textMargin = DefinitionResolver.Get <Margin>(Controller, Binding, file["TextMargin"], Margin.None);

            _rotation = DefinitionResolver.Get <TextRotation>(Controller, Binding, file["TextRotation"], TextRotation.None);

            _maxWidth = DefinitionResolver.Get <Length>(Controller, Binding, file["MaxWidth"], new Length(pixels: int.MaxValue));

            Text = DefinitionResolver.GetSharedString(Controller, Binding, file["Text"]);

            if (Text == null)
            {
                return(false);
            }

            TextColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["TextColor"]) ?? DefaultTextColor;

            HorizontalContentAlignment horzAlign = DefinitionResolver.Get <HorizontalContentAlignment>(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Auto);
            VerticalContentAlignment   vertAlign = DefinitionResolver.Get <VerticalContentAlignment>(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Auto);

            if (horzAlign == HorizontalContentAlignment.Auto)
            {
                horzAlign = UiHelper.ContentAlignFromAlignment(PositionParameters.HorizontalAlignment);
            }

            if (vertAlign == VerticalContentAlignment.Auto)
            {
                vertAlign = UiHelper.ContentAlignFromAlignment(PositionParameters.VerticalAlignment);
            }

            TextAlign = UiHelper.TextAlignFromContentAlignment(horzAlign, vertAlign);

            if (DefinitionResolver.Get <bool>(Controller, Binding, file["AutoSizeUpdate"], false))
            {
                Text.ValueChanged += Text_ValueChanged;
            }

            return(true);
        }
Ejemplo n.º 10
0
        bool IDefinitionClass.Init(UiController controller, object binding, DefinitionFile definition)
        {
            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(QuickSeparatorLine));

            _color = DefinitionResolver.GetColorWrapper(controller, binding, file["Color"]);

            _left  = DefinitionResolver.Get <Length>(controller, binding, file["Left"], Length.Zero);
            _right = DefinitionResolver.Get <Length>(controller, binding, file["Right"], Length.Zero);

            return(true);
        }
Ejemplo n.º 11
0
        protected override void Init(UiController controller, object binding, DefinitionFile definition)
        {
            base.Init(controller, binding, definition);

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(Image));

            _image = DefinitionResolver.Get <Texture2D>(controller, binding, file["Image"], null);
            _scale = DefinitionResolver.Get(controller, binding, file["Scale"], Scale.One);
            _horizontalAlignment = DefinitionResolver.Get <HorizontalContentAlignment>(controller, binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Center);
            _verticalAlignment   = DefinitionResolver.Get <VerticalContentAlignment>(controller, binding, file["VerticalContentAlignment"], VerticalContentAlignment.Center);
        }
Ejemplo n.º 12
0
        protected override void Init(UiController controller, object binding, DefinitionFile definition)
        {
            base.Init(controller, binding, definition);

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(Icon));

            _horzAlign = DefinitionResolver.Get <HorizontalContentAlignment>(controller, binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Center);
            _vertAlign = DefinitionResolver.Get <VerticalContentAlignment>(controller, binding, file["VerticalContentAlignment"], VerticalContentAlignment.Center);
            _stretch   = DefinitionResolver.Get <Stretch>(controller, binding, file["Stretch"], Stretch.None);
            _scale     = (float)DefinitionResolver.Get <double>(controller, binding, file["Scale"], 1);
        }
Ejemplo n.º 13
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            var file = new DefinitionFileWithStyle(definition, typeof(UiContainer));

            _clipChildren = DefinitionResolver.Get <bool>(Controller, Binding, file["ClipChildren"], false);
            return(true);
        }
Ejemplo n.º 14
0
        protected override void Init(UiController controller, object binding, DefinitionFile definition)
        {
            base.Init(controller, binding, definition);

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(NinePatchBackground));

            _imageDisabled = DefinitionResolver.Get <NinePatchImage>(controller, binding, file["ImageDisabled"], null);
            _imageReleased = DefinitionResolver.Get <NinePatchImage>(controller, binding, file["ImageReleased"], null);
            _imagePushed   = DefinitionResolver.Get <NinePatchImage>(controller, binding, file["ImagePushed"], null);
            _scaleByUnit   = DefinitionResolver.Get <bool>(controller, binding, file["ScaleByUnit"], false);
            _scale         = (float)DefinitionResolver.Get <double>(controller, binding, file["Scale"], 1);
        }
Ejemplo n.º 15
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiListBox));

            _selectionColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["SelectionColor"]);

            return(true);
        }
Ejemplo n.º 16
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiView));

            _zoom = DefinitionResolver.GetShared <int>(Controller, Binding, file["Zoom"], 1);

            return(true);
        }
Ejemplo n.º 17
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiColoredLabel));

            Colors = DefinitionResolver.Get <Color[]>(Controller, Binding, file["Colors"], null);

            return(true);
        }
Ejemplo n.º 18
0
        bool IDefinitionClass.Init(UiController controller, object binding, DefinitionFile definition)
        {
            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(NinePatchBackground));

            _image       = DefinitionResolver.Get <NinePatchImage>(controller, binding, file["Image"], null);
            _scaleByUnit = DefinitionResolver.Get <bool>(controller, binding, file["ScaleByUnit"], false);
            _scale       = (float)DefinitionResolver.Get <double>(controller, binding, file["Scale"], 1);
            _color       = DefinitionResolver.GetColorWrapper(controller, binding, file["Color"]) ?? new ColorWrapper();

            _margin = DefinitionResolver.Get <Margin>(controller, binding, file["Margin"], Margin.None);

            return(true);
        }
Ejemplo n.º 19
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiCheckBox));

            Checked = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Checked"], false);

            return(true);
        }
Ejemplo n.º 20
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiQuickList));

            _items = DefinitionResolver.GetValueFromMethodOrField(Controller, Binding, file["Items"]) as IItemsProvider;

            if (_items == null)
            {
                return(false);
            }

            _items.Subscribe(this);

            _rowHeight       = DefinitionResolver.Get <Length>(Controller, Binding, file["RowHeight"], Length.Default);
            _separatorHeight = DefinitionResolver.Get <Length>(Controller, Binding, file["SeparatorHeight"], Length.Zero);

            _maxScrollExceed = DefinitionResolver.Get <Length>(Controller, Binding, file["MaxScrollExceed"], ScrollingService.MaxScrollExceed);
            _reversed        = DefinitionResolver.Get <bool>(Controller, Binding, file["Reversed"], false);

            _wheelSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["WheelScrollSpeed"], 0);
            _rule       = DefinitionResolver.Get <ScrollingService.ExceedRule>(Controller, Binding, file["ExceedRule"], ScrollingService.ExceedRule.Allow);

            _columns = new List <QuickColumnDefinition>();

            List <DefinitionFile> columnsDef = file["Columns"] as List <DefinitionFile>;

            if (columnsDef == null)
            {
                throw new Exception("Columns not defined!");
            }

            foreach (var cd in columnsDef)
            {
                QuickColumnDefinition columnDefinitionObj = cd.CreateInstance(Controller, Binding) as QuickColumnDefinition;
                _columns.Add(columnDefinitionObj);
            }

            DefinitionFile separatorDef = file["Separator"] as DefinitionFile;

            if (separatorDef != null)
            {
                _separator = separatorDef.CreateInstance(Controller, Binding) as QuickSeparator;
            }

            return(true);
        }
Ejemplo n.º 21
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiEditBoxBase));

            Hint = DefinitionResolver.GetSharedString(Controller, Binding, file["Hint"]) ?? new SharedString();

            _maxLength           = DefinitionResolver.Get(Controller, Binding, file["MaxLength"], int.MaxValue);
            _inputType           = DefinitionResolver.Get(Controller, Binding, file["InputType"], TextInputType.NormalText);
            _lostFocusCancels    = DefinitionResolver.Get(Controller, Binding, file["CancelOnLostFocus"], false);
            _focusedShared       = DefinitionResolver.GetShared(Controller, Binding, file["IsFocused"], false);
            _focusedShared.Value = false;

            string filter = DefinitionResolver.GetString(Controller, Binding, file["Filter"]);

            if (!filter.IsNullOrEmpty())
            {
                _filter = new List <char>(filter.ToCharArray());
            }

            _focusedShared.ValueChanged += (bool focused) =>
            {
                if (focused)
                {
                    CurrentlyFocused = this;
                }
                else if (CurrentlyFocused == this)
                {
                    CurrentlyFocused = null;
                }
            };

            if (_inputType == TextInputType.Password)
            {
                _password = new SharedString();
            }

            RegisterDelegate("TextApply", file["TextApply"]);
            RegisterDelegate("TextChanged", file["TextChanged"]);
            RegisterDelegate("TextCancel", file["TextCancel"]);

            RegisterDelegate("LostFocus", file["LostFocus"]);
            RegisterDelegate("Return", file["Return"]);

            return(true);
        }
Ejemplo n.º 22
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiHorizontalGradient));

            _leftColor  = DefinitionResolver.GetColorWrapper(Controller, Binding, file["LeftColor"]);
            _rightColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["RightColor"]);

            return(true);
        }
Ejemplo n.º 23
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiVerticalGradient));

            _topColor    = DefinitionResolver.GetColorWrapper(Controller, Binding, file["TopColor"]);
            _bottomColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["BottomColor"]);

            return(true);
        }
Ejemplo n.º 24
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiRadioButton));

            SelectedValue = DefinitionResolver.GetShared <int>(Controller, Binding, file["SelectedValue"], -1);
            Value         = DefinitionResolver.Get <int>(Controller, Binding, file["Value"], 0);

            return(true);
        }
Ejemplo n.º 25
0
        protected override bool Init(object controller, object binding, Sitana.Framework.Ui.DefinitionFiles.DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiEditBox));

            _fontSize          = DefinitionResolver.Get <int>(Controller, Binding, file["NativeInputFontSize"], 20);
            _nativeInputMargin = DefinitionResolver.Get <Margin>(Controller, Binding, file["NativeInputMargin"], Margin.None);
            _nativeInputAlign  = DefinitionResolver.Get <Align>(Controller, Binding, file["NativeInputAlign"], Align.Left);
            return(true);
        }
Ejemplo n.º 26
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiSpritePresenter));

            _spriteInstance          = DefinitionResolver.Get <Sprite>(Controller, Binding, file["Sprite"], null).CreateInstance();
            _spriteInstance.Sequence = DefinitionResolver.GetString(Controller, Binding, file["Sequence"]);

            return(true);
        }
Ejemplo n.º 27
0
        protected void TryInitChildren(DefinitionFile definition)
        {
            DefinitionFileWithStyle file     = new DefinitionFileWithStyle(definition, typeof(UiContainer));
            List <DefinitionFile>   children = file["Children"] as List <DefinitionFile>;

            if (_autoCreateChildren)
            {
                CreateChildren(children);
            }
            else
            {
                _childrenDefinition = children;
            }
        }
Ejemplo n.º 28
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiSlider));

            _vertical = DefinitionResolver.Get <Mode>(Controller, Binding, file["Mode"], Mode.Horizontal) == Mode.Vertical;

            _maxValue = DefinitionResolver.GetShared <int>(Controller, Binding, file["MaxValue"], 100);
            _minValue = DefinitionResolver.GetShared <int>(Controller, Binding, file["MinValue"], 0);
            _value    = DefinitionResolver.GetShared <int>(Controller, Binding, file["Value"], 0);

            RegisterDelegate("ValueChanged", file["ValueChanged"]);

            List <DefinitionFile> drawableFiles = file["ThumbDrawables"] as List <DefinitionFile>;

            if (drawableFiles != null)
            {
                foreach (var def in drawableFiles)
                {
                    ButtonDrawable drawable = def.CreateInstance(Controller, Binding) as ButtonDrawable;

                    if (drawable != null)
                    {
                        _thumbDrawables.Add(drawable);
                    }
                }
            }

            drawableFiles = file["TrackDrawables"] as List <DefinitionFile>;

            if (drawableFiles != null)
            {
                foreach (var def in drawableFiles)
                {
                    ButtonDrawable drawable = def.CreateInstance(Controller, Binding) as ButtonDrawable;

                    if (drawable != null)
                    {
                        _trackDrawables.Add(drawable);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 29
0
        protected override bool Init(object controller, object binding, Sitana.Framework.Ui.DefinitionFiles.DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiEditBox));

            _textInput = new TextInput(this, _inputType);

            _lostFocusCancels = DefinitionResolver.Get <bool>(Controller, Binding, file["CancelOnLostFocus"], false);

            return(true);
        }
Ejemplo n.º 30
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if (!base.Init(controller, binding, definition))
            {
                return(false);
            }

            var file = new DefinitionFileWithStyle(definition, typeof(UiScrollView));

            _mode       = DefinitionResolver.Get <Scroller.Mode>(Controller, Binding, file["Mode"], Scroller.Mode.BothDrag);
            _rule       = DefinitionResolver.Get <ScrollingService.ExceedRule>(Controller, Binding, file["ExceedRule"], ScrollingService.ExceedRule.Allow);
            _wheelSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["WheelScrollSpeed"], 0);

            return(true);
        }
Ejemplo n.º 31
0
        protected override bool Init(object controller, object binding, DefinitionFile definition)
        {
            if(!base.Init(controller, binding, definition))
            {
                return false;
            }

            DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiScrollBar));

            _grid = DefinitionResolver.GetShared<AutomataGrid>(Controller, Binding, file["AutomataGrid"], null);
            _editEnabled = DefinitionResolver.GetShared<bool>(Controller, Binding, file["EditEnabled"], true);

            _zoom = DefinitionResolver.GetShared<double>(Controller, Binding, file["Zoom"], 16);

            _colors = DefinitionResolver.Get<Color[]>(Controller, Binding, file["Colors"], null);
            _gridColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["GridColor"]);

            _stateToPaint = DefinitionResolver.GetShared<int>(Controller, Binding, file["StateToPaint"], 0);

            _calculatedForSize = new Point(_grid.Value.Width, _grid.Value.Height);

            return true;
        }