/// <summary>
    /// This method gets called when the control is created and all properties has been set
    /// It allows the control todo any initialization
    /// </summary>
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                           _focusedTextureName);
      _imageFocused.ParentControl = this;
      _imageFocused.Filtering = false;
      _imageFocused.DimColor = DimColor;
      _imageFocused.SetBorder(_strBorderTF, _borderPositionTF, _borderTextureRepeatTF, _borderTextureRotateTF,
                              _borderTextureFileNameTF, _borderColorKeyTF, _borderHasCornersTF,
                              _borderCornerTextureRotateTF);

      _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                              _nonFocusedTextureName);
      _imageNonFocused.ParentControl = this;
      _imageNonFocused.Filtering = false;
      _imageNonFocused.DimColor = DimColor;
      _imageNonFocused.SetBorder(_strBorderTNF, _borderPositionTNF, _borderTextureRepeatTNF, _borderTextureRotateTNF,
                                 _borderTextureFileNameTNF, _borderColorKeyTNF, _borderHasCornersTNF,
                                 _borderCornerTextureRotateTNF);
      GUILocalizeStrings.LocalizeLabel(ref _label);


      if (_scrollStartDelay < 0)
      {
        _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                            _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false,
                                            _shadowAngle, _shadowDistance, _shadowColor);
        ((GUILabelControl)_labelControl).ParentControl = this;
        ((GUILabelControl)_labelControl).DimColor = DimColor;
        ((GUILabelControl)_labelControl).TextAlignment = _textAlignment;
        ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment;
      }
      else
      {
        _labelControl = new GUIFadeLabel(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                         _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP,
                                         _shadowAngle, _shadowDistance, _shadowColor,
                                         _userWrapString);
        ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment;
        ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment;
        ((GUIFadeLabel)_labelControl).AllowScrolling = false;
        ((GUIFadeLabel)_labelControl).AllowFadeIn = false;
      }

      string spinFontName = _fontName;
      if (_spinTextInButton)
      {
        // When the spin control font name is null the spin control will not render the text.
        // _spinTextInButton will render the spin control text in the button label.
        spinFontName = null;
      }

      _spinControl = new GUISpinControl(GetID, 0, _positionX + _width - _spinWidth, _positionY, _spinWidth,
                                        _spinHeight, _upTextureName, _downTextureName,
                                        _upTextureNameFocus, _downTextureNameFocus,
                                        spinFontName, _textColor, _spinType, _spinAlignment);
      _spinControl.ParentControl = this;
      _spinControl.DimColor = DimColor;
      _spinControl.ShowRange = _showRange;
      _spinControl.Digits = _digits;
      _spinControl.SetReverse(_reverse);
      _spinControl.Orientation = _orientation;
      _spinControl.CycleItems = _cycleItems;
      _spinControl.SetShadow(_shadowAngle, _shadowDistance, _shadowColor);
      _spinControl.PrefixText = _prefixText;
      _spinControl.SuffixText = _suffixText;
      _spinControl.TextOffsetX = _spinTextOffsetX;
      _spinControl.TextOffsetY = _spinTextOffsetY;

      // Pass all of the subitems to the spin control.
      for (int i = 0; i < SubItemCount; ++i)
      {
        _spinControl.AddSubItem(GetSubItem(i));
      }
      for (int i = 0; i < SubItemCount; ++i)
      {
        RemoveSubItem(i);
      }
    }
示例#2
0
    /// <summary>
    /// This method gets called when the control is created and all properties has been set
    /// It allows the control todo any initialization
    /// </summary>
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                           _focusedTextureName);
      _imageFocused.ParentControl = this;
      _imageFocused.Filtering = false;
      _imageFocused.DimColor = DimColor;
      _imageFocused.SetBorder(_strBorderTF, _borderPositionTF, _borderTextureRepeatTF, _borderTextureRotateTF,
        _borderTextureFileNameTF, _borderColorKeyTF, _borderHasCornersTF, _borderCornerTextureRotateTF);
      TileFillTF = _textureFocusTileFill;
      _imageFocused.MaskFileName = _strMaskTF;

      _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                              _nonFocusedTextureName);
      _imageNonFocused.ParentControl = this;
      _imageNonFocused.Filtering = false;
      _imageNonFocused.DimColor = DimColor;
      _imageNonFocused.SetBorder(_strBorderTNF, _borderPositionTNF, _borderTextureRepeatTNF, _borderTextureRotateTNF,
        _borderTextureFileNameTNF, _borderColorKeyTNF, _borderHasCornersTNF, _borderCornerTextureRotateTNF);
      TileFillTNF = _textureNoFocusTileFill;
      _imageNonFocused.MaskFileName = _strMaskTNF;

      _prefixText = _prefixText + _prefixTextJoin;
      _suffixText = _suffixTextJoin + _suffixText;

      GUILocalizeStrings.LocalizeLabel(ref _label);
      GUILocalizeStrings.LocalizeLabel(ref _prefixText);
      GUILocalizeStrings.LocalizeLabel(ref _suffixText);
      GUILocalizeStrings.LocalizeLabel(ref _dialogTitle);

      if (_hoverFilename != string.Empty)
      {
        GUIGraphicsContext.ScaleRectToScreenResolution(ref _hoverX, ref _hoverY, ref _hoverWidth, ref _hoverHeight);
        _hoverImage = LoadAnimationControl(_parentControlId, _controlId, _hoverX, _hoverY, _hoverWidth, _hoverHeight,
                                           _hoverFilename);
        _hoverImage.ParentControl = this;
        _hoverImage.DimColor = DimColor;
        _hoverImage.ColourDiffuse = ColourDiffuse;
        _hoverImage.SetBorder(_strBorderH, _borderPositionH, _borderTextureRepeatH, _borderTextureRotateH,
          _borderTextureFileNameH, _borderColorKeyH, _borderHasCornersH, _borderCornerTextureRotateH);
        TileFillH = _hoverTileFill;
        _hoverImage.MaskFileName = _strMaskH;
      }

      if (_scrollStartDelay < 0)
      {
        _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                            _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false,
                                            _shadowAngle, _shadowDistance, _shadowColor);
        ((GUILabelControl)_labelControl).ParentControl = this;
        ((GUILabelControl)_labelControl).DimColor = DimColor;
        ((GUILabelControl)_labelControl).TextAlignment = _textAlignment;
        ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment;

        // If the value should be displayed in the button but the alignment is not left then we need another control to display the right aligned
        // button value.
        if (_valueTextInButtonAlignment == Alignment.ALIGN_RIGHT)
        {
          _valueLabelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                                   _label, _textColor, Alignment.ALIGN_RIGHT, VAlignment.ALIGN_TOP, false,
                                                   _shadowAngle, _shadowDistance, _shadowColor);
          ((GUILabelControl)_valueLabelControl).ParentControl = this;
          ((GUILabelControl)_valueLabelControl).DimColor = DimColor;
          ((GUILabelControl)_valueLabelControl).TextVAlignment = _textVAlignment;
        }
      }
      else
      {
        _labelControl = new GUIFadeLabel(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                         _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP,
                                        _shadowAngle, _shadowDistance, _shadowColor,
                                         _userWrapString);
        ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment;
        ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment;
        ((GUIFadeLabel)_labelControl).AllowScrolling = false;
        ((GUIFadeLabel)_labelControl).AllowFadeIn = false;

        // If the value should be displayed in the button but the alignment is not left then we need another control to display the right aligned
        // button value.
        if (_valueTextInButtonAlignment == Alignment.ALIGN_RIGHT)
        {
          _valueLabelControl = new GUIFadeLabel(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                                _textColor, Alignment.ALIGN_RIGHT, VAlignment.ALIGN_TOP,
                                                _shadowAngle, _shadowDistance, _shadowColor,
                                                _userWrapString);
          ((GUIFadeLabel)_valueLabelControl).ParentControl = this;
          ((GUIFadeLabel)_valueLabelControl).DimColor = DimColor;
          ((GUIFadeLabel)_valueLabelControl).TextVAlignment = _textVAlignment;
          ((GUIFadeLabel)_valueLabelControl).AllowScrolling = false;
          ((GUIFadeLabel)_valueLabelControl).AllowFadeIn = false;
        }
      }

      // Build elements for the specified button mode.
      switch (_buttonMode)
      {
        case ButtonMode.BUTTON_MODE_SPIN_LIST:

          string spinFontName = _fontName;
          if (_valueTextInButton)
          {
            // When the spin control font name is null the spin control will not render the text.
            // _valueTextInButton will render the spin control text in the button label.
            spinFontName = null;
          }

          _spinControl = new GUISpinControl(GetID, 0, _positionX + _width - _spinWidth, _positionY, _spinWidth,
                                              _spinHeight, _upTextureName, _downTextureName,
                                              _upTextureNameFocus, _downTextureNameFocus,
                                              spinFontName, _textColor, _spinType, _spinAlignment);
          _spinControl.ParentControl = this;
          _spinControl.DimColor = DimColor;
          _spinControl.ShowRange = _showRange;
          _spinControl.Digits = _digits;
          _spinControl.SetReverse(_reverse);
          _spinControl.Orientation = _orientation;
          _spinControl.CycleItems = _cycleItems;
          _spinControl.SetShadow(_shadowAngle, _shadowDistance, _shadowColor);
          _spinControl.PrefixText = _prefixText;
          _spinControl.SuffixText = _suffixText;
          _spinControl.TextOffsetX = _spinTextOffsetX;
          _spinControl.TextOffsetY = _spinTextOffsetY;
          break;

        case ButtonMode.BUTTON_MODE_DIALOG_LIST:
          break;
      }

      // Add subitems to the menu.
      int value = 0;
      for (int i = 0; i < SubItemCount; ++i)
      {
        string strItem = GUIPropertyManager.GetProperty((string)GetSubItem(i));
        if (strItem == null || strItem == "")
        {
          // Refetch the subitem if a property value was not returned.
          strItem = (string)GetSubItem(i);
        }

        // Allow for the subitem to be a CSV list of values.  If it is then add each item in the CSV list.
        ArrayList items = new ArrayList(strItem.Split(new char[] { ',' }));
        for (int j=0; j < items.Count; j++)
        {
          AddItem(items[j].ToString(), value++);
        }
      }

      for (int i = 0; i < SubItemCount; ++i)
      {
        RemoveSubItem(i);
      }

      // If specified, bind the selection.
      if (_binding.Length > 0)
      {
        bindToValue(_binding);
      }

      // Initialize the controls properties.
      SetProperties();
    }