/// Renders the control. /// </summary> public override void Render(float timePassed) { if (!IsVisible) { base.Render(timePassed); return; } if (Disabled) { base.Render(timePassed); return; } if (!GUIGraphicsContext.MouseSupport) { IsVisible = false; base.Render(timePassed); return; } int iHeight = _imageBackGround.Height; _imageBackGround.Height = iHeight; float fPercent = (float)_percentage; float fPosXOff = (fPercent / 100.0f); // Scale handle-parts for resolution. Background is already scaled in parent control int handleHeight = _imageLeft.TextureHeight; GUIGraphicsContext.ScaleVertical(ref handleHeight); _imageLeft.Height = handleHeight; _imageRight.Height = handleHeight; int handleWidth = _imageLeft.TextureWidth; GUIGraphicsContext.ScaleVertical(ref handleWidth); _imageLeft.Width = handleWidth; _imageRight.Width = handleWidth; _widthKnob = (int)(2 * _imageLeft.Width); _startX = _imageBackGround.XPosition; _endX = _startX + _imageBackGround.Width - _widthKnob; fPosXOff *= (float)(_endX - _startX); _startPositionXKnob = _startX + (int)fPosXOff; _imageBackGround.Render(timePassed); int iXPos = _startPositionXKnob; int iYPos = _imageBackGround.YPosition + ((_imageBackGround.Height / 2) - (_imageLeft.Height / 2)); _imageLeft.SetPosition(iXPos, iYPos); _imageLeft.Render(timePassed); iXPos += _imageLeft.Width; _imageRight.SetPosition(iXPos, iYPos); _imageRight.Render(timePassed); base.Render(timePassed); }
public override void Render(float timePassed) { if (!Dimmed) { if (GUIGraphicsContext.Overlay != _isOverlayAllowed) { GUIGraphicsContext.Overlay = _parentWin.IsOverlayAllowed = _isOverlayAllowed; } _imageFocused.Render(timePassed); GUIFontManager.Present(); } else { _imageNonFocused.Render(timePassed); } base.Render(timePassed); }
public override void Render(float timePassed) { bool isFocused = this.Focus; if (!isFocused) { _CurrentActiveButton = ActiveButton.Main; } if (IsEditImageHot) { Focus = false; } int xPos = 0; int yPos = 0; if (!_SuppressActiveButtonReset && Focus && _CurrentActiveButton == ActiveButton.Main) { _imageFocused.Render(timePassed); } else { _imageNonFocused.Render(timePassed); } xPos = _imageNonFocused.XPosition + UpBtnXOffset; yPos = _imageNonFocused.YPosition + UpBtnYOffset; ImgUpButtonFocused.SetPosition(xPos, yPos); ImgUpButtonNormal.SetPosition(xPos, yPos); if (ImgUpButtonDisabled != null) { ImgUpButtonDisabled.SetPosition(xPos, yPos); } if (isFocused && _CurrentActiveButton == ActiveButton.Up && _UpButtonEnabled) { ImgUpButtonFocused.Render(timePassed); } else { if (!_UpButtonEnabled && ImgUpButtonDisabled != null) { ImgUpButtonDisabled.Render(timePassed); } else { ImgUpButtonNormal.Render(timePassed); } } xPos = _imageNonFocused.XPosition + DownBtnXOffset; yPos = _imageNonFocused.YPosition + DownBtnYOffset; ImgDownButtonFocused.SetPosition(xPos, yPos); ImgDownButtonNormal.SetPosition(xPos, yPos); if (ImgDownButtonDisabled != null) { ImgDownButtonDisabled.SetPosition(xPos, yPos); } if (isFocused && _CurrentActiveButton == ActiveButton.Down && _DownButtonEnabled) { ImgDownButtonFocused.Render(timePassed); } else { if (!_DownButtonEnabled && ImgDownButtonDisabled != null) { ImgDownButtonDisabled.Render(timePassed); } else { ImgDownButtonNormal.Render(timePassed); } } xPos = _imageNonFocused.XPosition + DeleteBtnXOffset; yPos = _imageNonFocused.YPosition + DeleteBtnYOffset; ImgDeleteButtonFocused.SetPosition(xPos, yPos); ImgDeleteButtonNormal.SetPosition(xPos, yPos); if (ImgDeleteButtonDisabled != null) { ImgDeleteButtonDisabled.SetPosition(xPos, yPos); } if (isFocused && _CurrentActiveButton == ActiveButton.Delete && _DeleteButtonEnabled) { ImgDeleteButtonFocused.Render(timePassed); } else { if (!_DeleteButtonEnabled && ImgDeleteButtonDisabled != null) { ImgDeleteButtonDisabled.Render(timePassed); } else { ImgDeleteButtonNormal.Render(timePassed); } } base.Render(timePassed); }
/// <summary> /// Renders the GUICheckButton. /// </summary> public override void Render(float timePassed) { string labelText = _label; // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // Set the selection based on the user specified condition. if (_selected.Length != 0) { try { Selected = bool.Parse(GUIPropertyManager.Parse(_selected, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS)); } catch (System.Exception) { Log.Debug("GUICheckButton: id={0} <selected> expression does not return a boolean value", GetID); } } // The GUICheckButton has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } int labelWidth = _width - 2 * _textOffsetX; if (_textPadding > 0) { labelWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding); } if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; // render the text on the button if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).TextAlignment = _textAlignment; ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment; ((GUILabelControl)_labelControl).Label = labelText; ((GUILabelControl)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } else { ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment; ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment; ((GUIFadeLabel)_labelControl).Label = labelText; ((GUIFadeLabel)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (labelWidth / 2)); break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_labelControl.Height / 2)); break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); x = 0; y = 0; switch (_markAlignment) { case Alignment.ALIGN_LEFT: x = _markOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _markOffsetX - checkMark.Width; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (checkMark.Width / 2)); break; } switch (_markVAlignment) { case VAlignment.ALIGN_TOP: y = _markOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _markOffsetY - checkMark.Height; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (checkMark.Height / 2)); break; } checkMark.SetPosition(x, y); checkMark.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the GUICheckMarkControl. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // Set the selection based on the user specified condition. if (_selected.Length != 0) { try { Selected = bool.Parse(GUIPropertyManager.Parse(_selected, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS)); } catch (System.Exception ex) { Log.Debug("GUICheckMarkControl: id={0} <selected> expression does not return a boolean value {1}", GetID, ex.Message); } } if (Focus) { GUIPropertyManager.SetProperty("#highlightedbutton", _label); } int dwTextPosX = _positionX; int dwCheckMarkPosX = _positionX; _rectangle.X = _positionY; _rectangle.Y = _positionY; _rectangle.Height = _imageCheckMarkFocused.Height; if (null != _font) { if (_alignment == Alignment.ALIGN_LEFT) { // calculate the position of the checkmark if the text appears at the left side of the checkmark float fTextHeight = 0, fTextWidth = 0; _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight); dwCheckMarkPosX += ((int)(fTextWidth) + 5); _rectangle.X = _positionX; _rectangle.Width = 5 + (int)fTextWidth + _imageCheckMarkFocused.Width; } else { // put text at the right side of the checkmark dwTextPosX = (dwCheckMarkPosX + _imageCheckMarkFocused.Width + 5); float fTextHeight = 0, fTextWidth = 0; _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight); _rectangle.X = dwTextPosX; _rectangle.Width = (dwTextPosX + (int)fTextWidth + 5) - dwTextPosX; } if (Disabled) { // If disabled, draw the text in the disabled color. _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1); } else { // Draw focused text and shadow if (Focus) { if (_shadow) { _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1, 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000)); } else { _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1); } } // Draw non-focused text and shadow else { if (_shadow) { _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1, 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000)); } else { _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1); } } } } // Render the selected checkmark image if (_isSelected) { _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY); _imageCheckMarkFocused.Render(timePassed); } else { // Render the non-selected checkmark image _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY); _imageCheckMarkNonFocused.Render(timePassed); } base.Render(timePassed); }
/// <summary> /// Renders the control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } string strValue = ""; float fRange = 0.0f; float fPos = 0.0f; float fPercent = 0.0f; float fTextWidth = 0, fTextHeight = 0; GUIFont _font = GUIFontManager.GetFont(_valueFont); switch (_spinType) { // Float based slider case GUISpinControl.SpinType.SPIN_CONTROL_TYPE_FLOAT: if (null != _font && _showValue) { strValue = String.Format("{0}", _floatValue); _font.DrawText((float)_positionX, (float)_positionY, _textColor, strValue, Alignment.ALIGN_LEFT, -1); _font.GetTextExtent(strValue, ref fTextWidth, ref fTextHeight); _imageBackGround.SetPosition(_positionX + (int)fTextWidth + 10, _positionY); } fRange = (float)(_floatEndValue - _floatStartValue); fPos = (float)(_floatValue - _floatStartValue); fPercent = (fPos / fRange) * 100.0f; _percentage = (int)fPercent; break; // Integer based slider case GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT: if (null != _font && _showValue) { strValue = String.Format("{0}/{1}", _intValue, _intEndValue); _font.DrawText((float)_positionX, (float)_positionY, _textColor, strValue, Alignment.ALIGN_LEFT, -1); _font.GetTextExtent(strValue, ref fTextWidth, ref fTextHeight); _imageBackGround.SetPosition(_positionX + (int)fTextWidth + 10, _positionY); } fRange = (float)(_intEndValue - _intStartValue); fPos = (float)(_intValue - _intStartValue); _percentage = (int)((fPos / fRange) * 100.0f); break; } //int iHeight=25; _imageBackGround.Render(timePassed); //_imageBackGround.SetHeight(iHeight); //_height = _imageBackGround.Height; //_width = _imageBackGround.Width + (int)fTextWidth + 10; float fWidth = (float)(_imageBackGround.TextureWidth - _imageMid.TextureWidth); //-20.0f; fPos = (float)_percentage; fPos /= 100.0f; fPos *= fWidth; fPos += (float)_imageBackGround.XPosition; //fPos += 10.0f; if ((int)fWidth > 1) { if (Focus) { _imageMidFocus.SetPosition((int)fPos, _imageBackGround.YPosition); _imageMidFocus.Render(timePassed); } else { _imageMid.SetPosition((int)fPos, _imageBackGround.YPosition); _imageMid.Render(timePassed); } } base.Render(timePassed); }
/// <summary> /// Renders the GUICheckMarkControl. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } if (Focus) { GUIPropertyManager.SetProperty("#highlightedbutton", _label); } int dwTextPosX = _positionX; int dwCheckMarkPosX = _positionX; _rectangle.X = _positionY; _rectangle.Y = _positionY; _rectangle.Height = _imageCheckMarkFocused.Height; if (null != _font) { if (_alignment == Alignment.ALIGN_LEFT) { // calculate the position of the checkmark if the text appears at the left side of the checkmark float fTextHeight = 0, fTextWidth = 0; _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight); dwCheckMarkPosX += ((int)(fTextWidth) + 5); _rectangle.X = _positionX; _rectangle.Width = 5 + (int)fTextWidth + _imageCheckMarkFocused.Width; } else { // put text at the right side of the checkmark dwTextPosX = (dwCheckMarkPosX + _imageCheckMarkFocused.Width + 5); float fTextHeight = 0, fTextWidth = 0; _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight); _rectangle.X = dwTextPosX; _rectangle.Width = (dwTextPosX + (int)fTextWidth + 5) - dwTextPosX; } if (Disabled) { // If disabled, draw the text in the disabled color. _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1); } else { // Draw focused text and shadow if (Focus) { if (_shadow) { _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1, 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000)); } else { _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1); } } // Draw non-focused text and shadow else { if (_shadow) { _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1, 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000)); } else { _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1); } } } } // Render the selected checkmark image if (_isSelected) { _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY); _imageCheckMarkFocused.Render(timePassed); } else { // Render the non-selected checkmark image _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY); _imageCheckMarkNonFocused.Render(timePassed); } base.Render(timePassed); }
public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } if (Disabled) { base.Render(timePassed); return; } } if (_propertyLabel.Length > 0) { string m_strText = GUIPropertyManager.Parse(_propertyLabel); if (m_strText.Length > 0) { try { Percentage1 = float.Parse(m_strText); } catch (Exception) {} if (Percentage1 < 0 || Percentage1 > 100) { Percentage1 = 0; } } } if (Label1.Length > 0) { string strText = GUIPropertyManager.Parse(Label1); if (strText.Length > 0) { try { Percentage1 = float.Parse(strText); } catch (Exception) {} if (Percentage1 < 0 || Percentage1 > 100) { Percentage1 = 0; } } } if (Label2.Length > 0) { string strText = GUIPropertyManager.Parse(Label2); if (strText.Length > 0) { try { Percentage2 = float.Parse(strText); } catch (Exception) {} if (Percentage2 < 0 || Percentage2 > 100) { Percentage2 = 0; } } } if (Label3.Length > 0) { string strText = GUIPropertyManager.Parse(Label3); if (strText.Length > 0) { try { Percentage3 = float.Parse(strText); } catch (Exception) {} if (Percentage3 < 0 || Percentage3 > 100) { Percentage3 = 0; } } } int xPos = _positionX; _imageLeft.SetPosition(xPos, _positionY); xPos = _positionX + _imageLeft.TextureWidth; _imageMid.SetPosition(xPos, _positionY); int iWidth = _width - (_imageLeft.TextureWidth + _imageRight.TextureWidth); _imageMid.Width = iWidth; xPos = iWidth + _positionX + _imageLeft.TextureWidth; _imageRight.SetPosition(xPos, _positionY); _imageLeft.Render(timePassed); _imageRight.Render(timePassed); _imageMid.Render(timePassed); int iWidth1 = 0, iWidth2 = 0, iWidth3 = 0; iWidth -= 2 * _fillBackgroundOffsetX; float fWidth = iWidth; int iCurPos = 0; // render fillbkg xPos = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX; _imageFillBackground.Width = iWidth; _imageFillBackground.Height = _imageMid.TextureHeight - _fillBackgroundOffsetY * 2; _imageFillBackground.SetPosition(xPos, _positionY + _fillBackgroundOffsetY); _imageFillBackground.Render(timePassed); // render first color int xoff = GUIGraphicsContext.ScaleHorizontal(3); xPos = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX + xoff; int yPos = _imageFillBackground.YPosition + (_imageFillBackground.Height / 2) - (_fillBackgroundHeight / 2); if (yPos < _positionY) { yPos = _positionY; } fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)Percentage1; iWidth1 = (int)Math.Floor(fWidth); if (iWidth1 > 0) { _imageFill1.Height = _fillBackgroundHeight; _imageFill1.Width = iWidth1; _imageFill1.SetPosition(xPos, yPos); _imageFill1.Render(timePassed); // red } iCurPos = iWidth1 + xPos; //render 2nd color float fPercent; if (Percentage2 >= Percentage1) { fPercent = Percentage2 - Percentage1; } else { fPercent = 0; } fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)fPercent; iWidth2 = (int)Math.Floor(fWidth); if (iWidth2 > 0) { _imageFill2.Width = iWidth2; _imageFill2.Height = _fillBackgroundHeight; _imageFill2.SetPosition(iCurPos, yPos); _imageFill2.Render(timePassed); } iCurPos = iWidth1 + iWidth2 + xPos; if (Percentage3 >= Percentage2) { //render 3th color fPercent = Percentage3 - Percentage2; } else { fPercent = 0; } fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)fPercent; iWidth3 = (int)Math.Floor(fWidth); if (iWidth3 > 0) { _imageFill3.Width = iWidth3; _imageFill3.Height = _fillBackgroundHeight; _imageFill3.SetPosition(iCurPos, yPos); _imageFill3.Render(timePassed); } // render ticks _imageTick.Height = _imageTick.TextureHeight; _imageTick.Width = _imageTick.TextureWidth; int posx1 = 10; int posx2 = 20; int posy1 = 3; GUIGraphicsContext.ScaleHorizontal(ref posx1); GUIGraphicsContext.ScaleHorizontal(ref posx2); GUIGraphicsContext.ScaleVertical(ref posy1); for (int i = 0; i <= 100; i += 10) { float fpos = (float)_positionX + _imageLeft.TextureWidth + posx1; fWidth = (float)(iWidth - posx2); fWidth /= 100.0f; fWidth *= (float)i; _imageTick.SetPosition((int)(fpos + fWidth), (int)_positionY + posy1); _imageTick.Render(timePassed); } // render top _imageTop.Height = GUIGraphicsContext.ScaleVertical(_imageTop.TextureHeight); _imageTop.Width = GUIGraphicsContext.ScaleHorizontal(_imageTop.TextureWidth); xPos = iCurPos - (_imageTop.Width / 2); _imageTop.SetPosition(xPos, _positionY - _imageTop.Height + _topTextureOffsetY - GUIGraphicsContext.ScaleVertical(1)); _imageTop.Render(timePassed); //render tick @ current position _imageTick.Height = _imageFillBackground.TextureHeight; _imageTick.Width = _imageTick.TextureWidth * 2; _imageTick.SetPosition((int)(_imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageTick.Width / 2)), (int)_imageFillBackground.YPosition); _imageTick.Render(timePassed); // render bottom xPos = _imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageBottom.TextureWidth / 2); _imageBottom.SetPosition(xPos, _positionY + _imageMid.TextureHeight); _imageBottom.Render(timePassed); //render logo float fx = (float)_imageBottom.XPosition; fx += (((float)_imageBottom.TextureWidth) / 2f); fx -= (((float)_imageLogo.TextureWidth) / 2f); float fy = (float)_imageBottom.YPosition; fy += (((float)_imageBottom.TextureHeight) / 2f); fy -= (((float)_imageLogo.TextureHeight) / 2f); _imageLogo.SetPosition((int)fx, (int)fy); _imageLogo.Render(timePassed); if (_font != null) { float fW = 0, fH = 0; float fHeight = 0; string strText = ""; // render top text if (_labelTop.Length > 0) { strText = GUIPropertyManager.Parse(_labelTop); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)_imageTop.TextureWidth) / 2.0f; fHeight = ((float)_imageTop.TextureHeight) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_imageTop.XPosition + fWidth, (float)2 + _imageTop.YPosition + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } // render left text if (_labelLeft.Length > 0) { strText = GUIPropertyManager.Parse(_labelLeft); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)_imageLeft.TextureWidth) / 2.0f; fHeight = ((float)_imageLeft.TextureHeight) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_positionX + fWidth, (float)_positionY + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } // render right text if (_labelRight.Length > 0) { strText = GUIPropertyManager.Parse(_labelRight); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)_imageRight.TextureWidth) / 2.0f; fHeight = ((float)_imageRight.TextureHeight) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_imageRight.XPosition + fWidth, (float)_imageRight.YPosition + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } } base.Render(timePassed); }
public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } if (Disabled) { base.Render(timePassed); return; } } if (_propertyLabel.Length > 0) { string m_strText = GUIPropertyManager.Parse(_propertyLabel); if (m_strText.Length > 0 && !m_strText.Contains(@"#")) { try { Percentage1 = float.Parse(m_strText); } catch (Exception ex) { Log.Error("GUITVProgressControl: Render() {0}", ex.Message); } if (Percentage1 < 0 || Percentage1 > 100) { Percentage1 = 0; } } } if (Label1.Length > 0) { string strText = GUIPropertyManager.Parse(Label1); if (strText.Length > 0 && !strText.Contains(@"#")) { try { Percentage1 = float.Parse(strText); } catch (Exception ex) { Log.Error("GUITVProgressControl: Render2() {0}", ex.Message); } if (Percentage1 < 0 || Percentage1 > 100) { Percentage1 = 0; } } } if (Label2.Length > 0) { string strText = GUIPropertyManager.Parse(Label2); if (strText.Length > 0 && !strText.Contains(@"#")) { try { Percentage2 = float.Parse(strText); } catch (Exception ex) { Log.Error("GUITVProgressControl: Render3() {0}", ex.Message); } if (Percentage2 < 0 || Percentage2 > 100) { Percentage2 = 0; } } } if (Label3.Length > 0) { string strText = GUIPropertyManager.Parse(Label3); if (strText.Length > 0 && !strText.Contains(@"#")) { try { Percentage3 = float.Parse(strText); } catch (Exception ex) { Log.Error("GUITVProgressControl: Render4() {0}", ex.Message); } if (Percentage3 < 0 || Percentage3 > 100) { Percentage3 = 0; } } } //parse labels for markers //only going to parse if the values are different than the current value string tempStarts = GUIPropertyManager.Parse(LabelMarkerStarts); string tempEnds = GUIPropertyManager.Parse(LabelMarkerEnds); if (_markerStarts != tempStarts || _markerEnds != tempEnds) { parseMarkerValues(tempStarts, tempEnds); _markerStarts = tempStarts; _markerEnds = tempEnds; } int iWidthLeft = _imageLeft.TextureWidth; int iHeightLeft = _imageLeft.TextureHeight; int iWidthRight = _imageRight.TextureWidth; int iHeightRight = _imageRight.TextureHeight; GUIGraphicsContext.ScaleHorizontal(ref iWidthLeft); GUIGraphicsContext.ScaleHorizontal(ref iWidthRight); GUIGraphicsContext.ScaleVertical(ref iHeightLeft); GUIGraphicsContext.ScaleVertical(ref iHeightRight); int xPos = _positionX; _imageLeft.SetPosition(xPos, _positionY); _imageLeft.Height = iHeightLeft; _imageLeft.Width = iWidthLeft; xPos = _positionX + iWidthLeft; _imageMid.SetPosition(xPos, _positionY); int iWidth = _width - (iWidthLeft + iWidthRight); _imageMid.Width = iWidth; xPos = iWidth + _positionX + iWidthLeft; _imageRight.SetPosition(xPos, _positionY); _imageRight.Height = iHeightRight; _imageRight.Width = iWidthRight; _imageLeft.Render(timePassed); _imageRight.Render(timePassed); _imageMid.Render(timePassed); int iWidth1 = 0, iWidth2 = 0, iWidth3 = 0; iWidth -= 2 * _fillBackgroundOffsetX; float fWidth = iWidth; int iCurPos = 0; // render fillbkg xPos = _positionX + iWidthLeft + _fillBackgroundOffsetX; _imageFillBackground.Width = iWidth; _imageFillBackground.Height = _imageMid.TextureHeight - _fillBackgroundOffsetY * 2; _imageFillBackground.SetPosition(xPos, _positionY + _fillBackgroundOffsetY); _imageFillBackground.Render(timePassed); int xoff = GUIGraphicsContext.ScaleHorizontal(3); xPos = _positionX + iWidthLeft + _fillBackgroundOffsetX + xoff; int yPos = _imageFillBackground.YPosition + (_imageFillBackground.Height / 2) - (_fillBackgroundHeight / 2); iWidth -= 2 * xoff; if (yPos < _positionY) { yPos = _positionY; } //render commercial markers fWidth = (float)iWidth; fWidth /= 100.0f; calculateMarkerSizeAndPosition(xPos, yPos, fWidth); for (int i = 0; i < _markerYPositions.Count || i < _markerXPositions.Count || i < _markerWidths.Count; i++) { _imageFillMarker.Width = _markerWidths[i]; _imageFillMarker.SetPosition(_markerXPositions[i], _markerYPositions[i]); _imageFillMarker.Render(timePassed); } //render first color xPos = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX + xoff; fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)Percentage1; iWidth1 = (int)Math.Floor(fWidth); if (iWidth1 > 0) { _imageFill1.Height = _fillBackgroundHeight; _imageFill1.Width = iWidth1; _imageFill1.SetPosition(xPos, yPos); _imageFill1.Render(timePassed); // red } iCurPos = iWidth1 + xPos; //render 2nd color float fPercent; if (Percentage2 >= Percentage1) { fPercent = Percentage2 - Percentage1; } else { fPercent = 0; } fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)fPercent; iWidth2 = (int)Math.Floor(fWidth); if (iWidth2 > 0) { _imageFill2.Width = iWidth2; _imageFill2.Height = _fillBackgroundHeight; _imageFill2.SetPosition(iCurPos, yPos); _imageFill2.Render(timePassed); } iCurPos = iWidth1 + iWidth2 + xPos; if (Percentage3 >= Percentage2) { //render 3th color fPercent = Percentage3 - Percentage2; } else { fPercent = 0; } fWidth = (float)iWidth; fWidth /= 100.0f; fWidth *= (float)fPercent; iWidth3 = (int)Math.Floor(fWidth); if (iWidth3 > 0) { _imageFill3.Width = iWidth3; _imageFill3.Height = _fillBackgroundHeight; _imageFill3.SetPosition(iCurPos, yPos); _imageFill3.Render(timePassed); } // render ticks _imageTick.Height = _imageTick.TextureHeight; _imageTick.Width = _imageTick.TextureWidth; int posx1 = 10; int posx2 = 20; int posy1 = 3; GUIGraphicsContext.ScaleHorizontal(ref posx1); GUIGraphicsContext.ScaleHorizontal(ref posx2); GUIGraphicsContext.ScaleVertical(ref posy1); for (int i = 0; i <= 100; i += 10) { float fpos = (float)_positionX + iWidthLeft + posx1; fWidth = (float)(iWidth - posx2); fWidth /= 100.0f; fWidth *= (float)i; _imageTick.SetPosition((int)(fpos + fWidth), (int)_positionY + posy1); _imageTick.Render(timePassed); } // render top _imageTop.Height = GUIGraphicsContext.ScaleVertical(_imageTop.TextureHeight); _imageTop.Width = GUIGraphicsContext.ScaleHorizontal(_imageTop.TextureWidth); xPos = iCurPos - (_imageTop.Width / 2); _imageTop.SetPosition(xPos, _positionY - _imageTop.Height + _topTextureOffsetY - GUIGraphicsContext.ScaleVertical(1)); _imageTop.Render(timePassed); //render tick @ current position _imageTick.Height = _imageFillBackground.TextureHeight; _imageTick.Width = _imageTick.TextureWidth * 2; _imageTick.SetPosition((int)(_imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageTick.Width / 2)), (int)_imageFillBackground.YPosition); _imageTick.Render(timePassed); // render bottom _imageBottom.Height = GUIGraphicsContext.ScaleVertical(_imageBottom.TextureHeight); _imageBottom.Width = GUIGraphicsContext.ScaleHorizontal(_imageBottom.TextureWidth); xPos = _imageTop.XPosition + (_imageTop.Width / 2) - (_imageBottom.Width / 2); _imageBottom.SetPosition(xPos, _positionY + _imageMid.Height); _imageBottom.Render(timePassed); //render logo _imageLogo.Height = GUIGraphicsContext.ScaleVertical(_imageLogo.TextureHeight); _imageLogo.Width = GUIGraphicsContext.ScaleHorizontal(_imageLogo.TextureWidth); float fx = (float)_imageBottom.XPosition; fx += (((float)_imageBottom.Width) / 2f); fx -= (((float)_imageLogo.TextureWidth) / 2f); float fy = (float)_imageBottom.YPosition; fy += (((float)_imageBottom.Height) / 2f); fy -= (((float)_imageLogo.Height) / 2f); _imageLogo.SetPosition((int)fx, (int)fy); _imageLogo.Render(timePassed); if (_font != null) { float fW = 0, fH = 0; float fHeight = 0; string strText = ""; // render top text if (_labelTop.Length > 0) { strText = GUIPropertyManager.Parse(_labelTop); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)_imageTop.Width) / 2.0f; fHeight = ((float)_imageTop.Height) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_imageTop.XPosition + fWidth, (float)2 + _imageTop.YPosition + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } // render left text if (_labelLeft.Length > 0) { strText = GUIPropertyManager.Parse(_labelLeft); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)iWidthLeft) / 2.0f; fHeight = ((float)iHeightLeft) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_positionX + fWidth, (float)_positionY + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } // render right text if (_labelRight.Length > 0) { strText = GUIPropertyManager.Parse(_labelRight); _font.GetTextExtent(strText, ref fW, ref fH); fW /= 2.0f; fH /= 2.0f; fWidth = ((float)iWidthRight) / 2.0f; fHeight = ((float)iHeightRight) / 2.0f; fWidth -= fW; fHeight -= fH; _font.DrawText((float)_imageRight.XPosition + fWidth, (float)_imageRight.YPosition + fHeight, _textColor, strText, Alignment.ALIGN_LEFT, -1); } } base.Render(timePassed); }
/// <summary> /// Renders the GUICheckButton. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // The GUICheckButton has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } int labelWidth = _width - 2 * _textOffsetX; if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; // render the text on the button _labelControl.TextAlignment = _textAlignment; _labelControl.TextVAlignment = _textVAlignment; _labelControl.Label = _label; _labelControl.TextColor = Disabled ? _disabledColor : Focus ? _textColor : _textColorNoFocus; int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (labelWidth / 2)); break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_labelControl.Height / 2)); break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); x = 0; y = 0; switch (_markAlignment) { case Alignment.ALIGN_LEFT: x = _markOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _markOffsetX - checkMark.Width; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (checkMark.Width / 2)); break; } switch (_markVAlignment) { case VAlignment.ALIGN_TOP: y = _markOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _markOffsetY - checkMark.Height; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (checkMark.Height / 2)); break; } checkMark.SetPosition(x, y); checkMark.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // Are we in selection mode _showSelect = Focus; if (_showSelect) { // Yes, render the select control // render background, left and right arrow _imageBackground.Render(timePassed); long dwTextColor = Focus ? _textColor : _textColorNoFocus; // User has moved left... if (_leftSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _leftSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageLeftFocus.Render(timePassed); // If we are moving left render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageLeft.Render(timePassed); } // User has moved right... if (_rightSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _rightSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageRightFocus.Render(timePassed); // If we are moving right render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageRight.Render(timePassed); } // Render text if a current item is available if (SelectedItem >= 0 && null != _font && SelectedItem < _subItemList.Count) { _labelControl.FontName = _font.FontName; if (_textPadding > 0) { _width -= GUIGraphicsContext.ScaleHorizontal(_textPadding); } if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _imageLeft.Width - _textOffsetX, _textOffsetY + _positionY); } else { _labelControl.SetPosition(_positionX + _imageLeft.Width + _textOffsetX, _textOffsetY + _positionY); } _labelControl.TextColor = dwTextColor; _labelControl.TextAlignment = _textAlignment; _labelControl.Label = (string)_subItemList[SelectedItem]; _labelControl.Width = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX); if (_labelControl.Width <= 0) { base.Render(timePassed); return; } _labelControl.Render(timePassed); } } // No, render a normal button else { if (!IsVisible) { base.Render(timePassed); return; } if (Focus) { _imageFocused.Render(timePassed); } else { _imageNonFocused.Render(timePassed); } if (!string.IsNullOrEmpty(_label) && _font != null) { _labelControl.FontName = _font.FontName; if (_textPadding2 > 0) { _width -= GUIGraphicsContext.ScaleHorizontal(_textPadding2); } if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _textOffsetX2, _textOffsetY2 + _positionY); } else { _labelControl.SetPosition(_textOffsetX2 + _positionX, _textOffsetY2 + _positionY); } if (Disabled || _subItemList.Count == 0) { _labelControl.TextColor = _disabledColor; } else { _labelControl.TextColor = Focus ? _textColor : _textColorNoFocus; } _labelControl.TextAlignment = _textAlignment; _labelControl.Label = _label; _labelControl.Width = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX); if (_labelControl.Width <= 0) { base.Render(timePassed); return; } _labelControl.Render(timePassed); } } base.Render(timePassed); }
/// <summary> /// Renders the GUIButtonControl. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // The GUIButtonControl has the focus or the focused look is being maintained. // _keepLook forces the render of the focused (or hovered) image when focus may have been lost. // _keepLook is managed by onleft,onright,onup,ondown actions. if (Focus || _keepLook) { // Apply the dim color to the render if _keepLook is set; avoid affecting Dimmed otherwise. if (_keepLook) { _imageFocused.Dimmed = true; } //render the focused image _imageFocused.Render(timePassed); if (_hoverImage != null) { _hoverImage.Render(timePassed); } } else { //render the non-focused image _imageNonFocused.Render(timePassed); } int labelWidth = _width; if (_textOffsetXHasMargin) { labelWidth = _width - 2 * _textOffsetX; } if (_textPadding > 0) { labelWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding); } if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).TextAlignment = _textAlignment; ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment; ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } else { ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment; ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment; ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } // render the text on the button int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + _width / 2 - labelWidth / 2; if (labelWidth > _width) { x += TextOffsetX; } break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + _height / 2 - _labelControl.Height / 2; break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the GUISpinButton. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // The GUISpinButton has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } // Compute with of label so that the text does not overlap the spin controls. int labelWidth = _width - (2 * _textOffsetX) - (2 * _spinWidth) - _textOffsetX; if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; // render the text on the button if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).TextAlignment = _textAlignment; ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment; ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } else { ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment; ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment; ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (labelWidth / 2)); break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_labelControl.Height / 2)); break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); x = 0; y = 0; switch (_spinAlignment) { case Alignment.ALIGN_LEFT: x = _spinOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _spinOffsetX - _spinControl.Width; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (_spinControl.Width / 2)); break; } switch (_spinVAlignment) { case VAlignment.ALIGN_TOP: y = _spinOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _spinOffsetY - _spinControl.Height; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_spinControl.Height / 2)); break; } _spinControl.SetPosition(x, y); _spinControl.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the progress control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } if (Disabled) { base.Render(timePassed); return; } } if (_containsProperty) { string m_strText = GUIPropertyManager.Parse(_property); if (m_strText != string.Empty) { float p; Single.TryParse(m_strText, out p); Percentage = p; } } // Render the background int iBkgHeight = _height; //GUIGraphicsContext.ScaleVertical(ref iBkgHeight); // fixing scaling bug _imageBackGround.Height = iBkgHeight; _imageBackGround.SetPosition(_imageBackGround.XPosition, _imageBackGround.YPosition); _imageBackGround.Render(timePassed); int iWidthLeft = _imageLeft.TextureWidth; int iHeightLeft = (_innerheight != -1) ? _innerheight : _imageLeft.TextureHeight; // Legacy skin don't use innerheight int iWidthRight = _imageRight.TextureWidth; int iHeightRight = (_innerheight != -1) ? _innerheight : _imageRight.TextureHeight; GUIGraphicsContext.ScaleHorizontal(ref iWidthLeft); GUIGraphicsContext.ScaleHorizontal(ref iWidthRight); GUIGraphicsContext.ScaleVertical(ref iHeightLeft); GUIGraphicsContext.ScaleVertical(ref iHeightRight); int offset = (_offset != -1) ? _offset : 12; // Legacy offset GUIGraphicsContext.ScaleHorizontal(ref offset); int iWidthMid = (_midWidth != 0) ? _midWidth : _imageMid.TextureWidth; int iHeightMid = (_midHeight != 0) ? _midHeight : _imageMid.TextureHeight; GUIGraphicsContext.ScaleHorizontal(ref iWidthMid); GUIGraphicsContext.ScaleVertical(ref iHeightMid); int midOffsetX = (_midOffsetX != -1) ? _midOffsetX : 0; int midOffsetY = (_midOffsetY != -1) ? _midOffsetY : 0; GUIGraphicsContext.ScaleHorizontal(ref midOffsetX); GUIGraphicsContext.ScaleVertical(ref midOffsetY); float fWidth = _percentage; if (fWidth > 100.0f) { fWidth = 100.0f; } if (_onlyMidTexture) { fWidth *= (float)(iWidthMid); fWidth /= 100.0f; int iXPos = _imageBackGround.XPosition + midOffsetX; int iYPos = _imageBackGround.YPosition + midOffsetY; if (_percentage > 0 && fWidth > 1) { _imageMid.SetPosition(iXPos, iYPos); _imageMid.Height = iHeightMid; _imageMid.Width = (int)Math.Abs(fWidth); _imageMid.SetPosition(iXPos, iYPos); _imageMid.Render(timePassed); } } else { fWidth *= (float)(_imageBackGround.Width - 2 * offset - iWidthLeft - iWidthRight); fWidth /= 100.0f; int iXPos = offset + _imageBackGround.XPosition; int iYPos = _imageBackGround.YPosition + (iBkgHeight - iHeightLeft) / 2; _imageLeft.SetPosition(iXPos, iYPos); _imageLeft.Height = iHeightLeft; _imageLeft.Width = iWidthLeft; _imageLeft.SetPosition(iXPos, iYPos); _imageLeft.Render(timePassed); iXPos += iWidthLeft; if (_percentage > 0 && fWidth > 1) { _imageMid.SetPosition(iXPos, iYPos); _imageMid.Height = iHeightLeft; _imageMid.Width = (int)Math.Abs(fWidth); _imageMid.SetPosition(iXPos, iYPos); _imageMid.Render(timePassed); iXPos += (int)fWidth; } _imageRight.SetPosition(iXPos, iYPos); _imageRight.Height = iHeightRight; _imageRight.Width = iWidthRight; _imageRight.SetPosition(iXPos, iYPos); _imageRight.Render(timePassed); } base.Render(timePassed); }
/// <summary> /// Renders the progress control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } if (Disabled) { base.Render(timePassed); return; } } int tb = 0; try { tb = Int32.Parse(GUIPropertyManager.Parse("#statusbarTB")); } catch (Exception ex) { Log.Error("GUIStatusbarControl render: " + ex.Message); } if (_containsProperty) { string m_strText = GUIPropertyManager.Parse(_property); if (m_strText != string.Empty) { try { Percentage = Int32.Parse(m_strText); if (Percentage <= -1) { base.Render(timePassed); return; } if (Percentage > 100) { Percentage = 100; } } catch (Exception ex) { Log.Error("GUIStatusbarControl render2: " + ex.Message); } } } int yPosTop = 0; try { yPosTop = Convert.ToInt16(_top); } catch (Exception ex) { Log.Error("GUIStatusbarControl render3: " + ex.Message); } // Render the background int iBkgHeight = _height; _imageBackground.Height = iBkgHeight; if (tb == 1) { _imageBackground.SetPosition(_imageBackground.XPosition, yPosTop); } else { _imageBackground.SetPosition(_imageBackground.XPosition, _imageBackground.YPosition); } _imageBackground.Render(timePassed); int iWidthLeft = _imageLeft.TextureWidth; int iHeightLeft = _imageLeft.TextureHeight; int iWidthRight = _imageRight.TextureWidth; int iHeightRight = _imageRight.TextureHeight; GUIGraphicsContext.ScaleHorizontal(ref iWidthLeft); GUIGraphicsContext.ScaleHorizontal(ref iWidthRight); GUIGraphicsContext.ScaleVertical(ref iHeightLeft); GUIGraphicsContext.ScaleVertical(ref iHeightRight); //iHeight=20; float fWidth = (float)_percentage; fWidth /= 100.0f; fWidth *= (float)(_imageBackground.Width - 24 - iWidthLeft - iWidthRight); int off = 12; GUIGraphicsContext.ScaleHorizontal(ref off); int iXPos = off + _imageBackground.XPosition; int iYPos = 0; if (tb == 1) { // top iYPos = yPosTop + (iBkgHeight - iHeightLeft) / 2; } else { // bottom iYPos = _imageBackground.YPosition + (iBkgHeight - iHeightLeft) / 2; } //_imageLeft.SetHeight(iHeight); _imageLeft.SetPosition(iXPos, iYPos); _imageLeft.Height = iHeightLeft; _imageLeft.Width = iWidthLeft; _imageLeft.SetPosition(iXPos, iYPos); _imageLeft.Render(timePassed); iXPos += iWidthLeft; if (_percentage > 0 && (int)fWidth > 1) { _imageMid.SetPosition(iXPos, iYPos); _imageMid.Height = iHeightLeft; //_imageMid.TextureHeight; _imageMid.Width = (int)fWidth; _imageMid.SetPosition(iXPos, iYPos); _imageMid.Render(timePassed); iXPos += (int)fWidth; } //_imageRight.SetHeight(iHeight); _imageRight.SetPosition(iXPos, iYPos); _imageRight.Height = iHeightRight; _imageRight.Width = iWidthRight; _imageRight.SetPosition(iXPos, iYPos); _imageRight.Render(timePassed); base.Render(timePassed); }
public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { if (_setVideoWindow) { // Here is to hide video window madVR when skin didn't handle video overlay (the value need to be different from Process() player like VMR7) GUIGraphicsContext.VideoWindow = new Rectangle(0, 0, 0, 0); } base.Render(timePassed); return; } } if (!GUIGraphicsContext.Calibrating) { float x = base.XPosition; float y = base.YPosition; GUIGraphicsContext.Correct(ref x, ref y); _videoWindows[0].X = (int)x; _videoWindows[0].Y = (int)y; _videoWindows[0].Width = base.Width; _videoWindows[0].Height = base.Height; if (_setVideoWindow) { GUIGraphicsContext.VideoWindow = _videoWindows[0]; } if (GUIGraphicsContext.ShowBackground) { if (Focus) { x = base.XPosition; y = base.YPosition; int xoff = 5; int yoff = 5; int w = 10; int h = 10; GUIGraphicsContext.ScalePosToScreenResolution(ref xoff, ref yoff); GUIGraphicsContext.ScalePosToScreenResolution(ref w, ref h); _imageFocusRectangle.SetPosition((int)x - xoff, (int)y - yoff); _imageFocusRectangle.Width = base.Width + w; _imageFocusRectangle.Height = base.Height + h; _imageFocusRectangle.Render(timePassed); } if (GUIGraphicsContext.graphics != null) { GUIGraphicsContext.graphics.FillRectangle(Brushes.Black, _videoWindows[0].X, _videoWindows[0].Y, base.Width, base.Height); } else { //image.SetPosition(_videoWindows[0].X,_videoWindows[0].Y); //image.Width=_videoWindows[0].Width; //image.Height=_videoWindows[0].Height; if (GUIGraphicsContext.VideoWindow.Width < 1) { thumbImage.Render(timePassed); } else { blackImage.Render(timePassed); // causes flickering in fullscreen } } } else { if (GUIGraphicsContext.graphics != null) { GUIGraphicsContext.graphics.FillRectangle(Brushes.Black, _videoWindows[0].X, _videoWindows[0].Y, base.Width, base.Height); } } } base.Render(timePassed); }
public override void Render(float timePassed) { string labelText = _label; // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // The GUIButtonControl has the focus if (Focus) { int dwAlphaCounter = _frameCounter + 2; int dwAlphaChannel; if ((dwAlphaCounter % 128) >= 64) { dwAlphaChannel = dwAlphaCounter % 64; } else { dwAlphaChannel = 63 - (dwAlphaCounter % 64); } dwAlphaChannel += 192; SetAlpha(dwAlphaChannel); if (_isSelected) { _imageFocused.Render(timePassed); } else { _imageAlternativeFocused.Render(timePassed); } _frameCounter++; } else { SetAlpha(0xff); if (_isSelected) { _imageNonFocused.Render(timePassed); } else { _imageAlternativeNonFocused.Render(timePassed); } } int labelWidth = _width; if (_textOffsetXHasMargin) { labelWidth = _width - 2 * _textOffsetX; } if (_textPadding > 0) { labelWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding); } if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; // render the text on the button if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).TextAlignment = _textAlignment; ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment; ((GUILabelControl)_labelControl).Label = labelText; ((GUILabelControl)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } else { ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment; ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment; ((GUIFadeLabel)_labelControl).Label = labelText; ((GUIFadeLabel)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (labelWidth / 2)); break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_labelControl.Height / 2)); break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } if (Focus) { _showSelect = true; } else { _showSelect = false; } // Are we in selection mode if (_showSelect) { // Yes, render the select control // render background, left and right arrow _imageBackground.Render(timePassed); long dwTextColor = Focus ? _textColor : _textColorNoFocus; // User has moved left... if (_leftSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _leftSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageLeftFocus.Render(timePassed); // If we are moving left // render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageLeft.Render(timePassed); } // User has moved right... if (_rightSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _rightSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageRightFocus.Render(timePassed); // If we are moving right // render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageRight.Render(timePassed); } // Render text if a current item is available if (SelectedItem >= 0 && null != _font && SelectedItem < _subItemList.Count) { _labelControl.FontName = _font.FontName; if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _imageLeft.Width - _textOffsetX, _textOffsetY + _positionY); } else { _labelControl.SetPosition(_positionX + _imageLeft.Width + _textOffsetX, _textOffsetY + _positionY); } _labelControl.TextColor = dwTextColor; _labelControl.TextAlignment = _textAlignment; _labelControl.Label = (string)_subItemList[SelectedItem]; _labelControl.Width = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX); _labelControl.Render(timePassed); } /* * // Select current item, if user doesn't * // move left or right for 1.5 sec. * long dwTicksSpan=DateTime.Now.Ticks-_ticks; * dwTicksSpan/=10000; * if ((float)(dwTicksSpan/1000)>0.8f) * { * // User hasn't moved disable selection mode... * _showSelect=false; * * // ...and send a thread message. * // (Sending a message with SendMessage * // can result in a GPF.) * GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED,WindowId,GetID, ParentID ,0,0,null); * GUIWindowManager.SendThreadMessage(message); * _updateNeeded=true; * } */ } // if (_showSelect) else { // No, render a normal button if (!IsVisible) { base.Render(timePassed); return; } if (Focus) { /* * int dwAlphaCounter = _frameCounter+2; * int dwAlphaChannel; * if ((dwAlphaCounter%128)>=64) * dwAlphaChannel = dwAlphaCounter%64; * else * dwAlphaChannel = 63-(dwAlphaCounter%64); * * dwAlphaChannel += 192; * SetAlpha(dwAlphaChannel ); * _imageFocused.IsVisible=true; * _imageNonFocused.IsVisible=false; * _frameCounter++;*/ _imageFocused.Render(timePassed); } else { //SetAlpha(0xff); _imageNonFocused.Render(timePassed); } if (_label != null && _label.Length > 0 && _font != null) { _labelControl.FontName = _font.FontName; if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _textOffsetX2, _textOffsetY2 + _positionY); } else { _labelControl.SetPosition(_textOffsetX2 + _positionX, _textOffsetY2 + _positionY); } if (Disabled || _subItemList.Count == 0) { _labelControl.TextColor = _disabledColor; } else { _labelControl.TextColor = Focus ? _textColor : _textColorNoFocus; } _labelControl.TextAlignment = _textAlignment; _labelControl.Label = _label; _labelControl.Render(timePassed); } } base.Render(timePassed); }