public SetPosition ( int dwPosX, int dwPosY ) : void | ||
dwPosX | int | |
dwPosY | int | |
리턴 | void |
public override void SetPosition(int posX, int posY) { base.SetPosition(posX, posY); _imageFocused.SetPosition(posX, posY); _imageNonFocused.SetPosition(posX, posY); _imageAlternativeFocused.SetPosition(posX, posY); _imageAlternativeNonFocused.SetPosition(posX, posY); }
/// <summary> /// Update the subcontrols with the current position of the progress control /// </summary> protected override void Update() { base.Update(); _imageBackGround.SetPosition(_positionX, _positionY); _imageLeft.SetPosition(_positionX, _positionY); _imageMid.SetPosition(_positionX, _positionY); _imageRight.SetPosition(_positionX, _positionY); }
/// <summary> /// Sets the position of the control. /// </summary> /// <param name="dwPosX">The X position.</param> /// <param name="dwPosY">The Y position.</param> public override void SetPosition(int dwPosX, int dwPosY) { if (dwPosX < 0) { return; } if (dwPosY < 0) { return; } base.SetPosition(dwPosX, dwPosY); _imageFocused.SetPosition(dwPosX, dwPosY); _imageNonFocused.SetPosition(dwPosX, dwPosY); }
/// 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); }
/// <summary> /// Perform an update after a change has occured. E.g. change to a new position. /// </summary> protected override void Update() { base.Update(); _imageFocused.Width = _width; _imageFocused.Height = _height; _imageNonFocused.Width = _width; _imageNonFocused.Height = _height; _imageBackground.Width = _width; _imageBackground.Height = _height; _imageFocused.SetPosition(_positionX, _positionY); _imageNonFocused.SetPosition(_positionX, _positionY); _imageBackground.SetPosition(_positionX, _positionY); PositionLeftAndRightImages(); }
public static void Init() { if (_countLabel == null) { _countLabel = new GUILabelControl(0); _countLabel.FontName = "waitcursor"; _countLabel.TextColor = 0x66ffffff; _countLabel.TextAlignment = Alignment.ALIGN_CENTER; _countLabel.TextVAlignment = VAlignment.ALIGN_MIDDLE; _countLabel.Width = 96; _countLabel.Height = 96; } if (_animation == null) { _animation = new GUIAnimation(); string themedFilename; foreach (string filename in Directory.GetFiles(GUIGraphicsContext.Skin + @"\media\", "common.waiting.*.png")) { themedFilename = GUIGraphicsContext.GetThemedSkinFile(filename); _animation.Filenames.Add(Path.GetFileName(themedFilename)); } // dirty hack because the files are 96x96 - unfortunately no property gives the correct size at runtime when init is called :S int scaleWidth = (GUIGraphicsContext.Width / 2) - 48; int scaleHeigth = (GUIGraphicsContext.Height / 2) - 48; _animation.SetPosition(scaleWidth, scaleHeigth); // broken!? _animation.HorizontalAlignment = HorizontalAlignment.Center; _animation.VerticalAlignment = VerticalAlignment.Center; Log.Debug("GUIWaitCursor: init at position {0}:{1}", scaleWidth, scaleHeigth); _animation.AllocResources(); _animation.Duration = new Duration(800); _animation.RepeatBehavior = RepeatBehavior.Forever; } }
private void PositionLeftAndRightImages() { // Position right arrow int x1 = 8; int x2 = 16; GUIGraphicsContext.ScaleHorizontal(ref x1); GUIGraphicsContext.ScaleHorizontal(ref x2); int dwPosX = (_positionX + _width - x1) - x2; int y1 = 16; GUIGraphicsContext.ScaleVertical(ref y1); int dwPosY = _positionY + (_height - y1) / 2; _imageRight.SetPosition(dwPosX, dwPosY); _imageRightFocus.SetPosition(dwPosX, dwPosY); // Position left arrow dwPosX = _positionX + x1; _imageLeft.SetPosition(dwPosX, dwPosY); _imageLeftFocus.SetPosition(dwPosX, dwPosY); }
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) { 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> /// Sets the position of the control. /// </summary> /// <param name="dwPosX">The X position.</param> /// <param name="dwPosY">The Y position.</param> public override void SetPosition(int dwPosX, int dwPosY) { base.SetPosition(dwPosX, dwPosY); _imageFocused.SetPosition(dwPosX, dwPosY); _imageNonFocused.SetPosition(dwPosX, dwPosY); }
/// <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 static void Init() { if (_countLabel == null) { _countLabel = new GUILabelControl(0); _countLabel.FontName = "waitcursor"; _countLabel.TextColor = 0x66ffffff; _countLabel.TextAlignment = Alignment.ALIGN_CENTER; _countLabel.TextVAlignment = VAlignment.ALIGN_MIDDLE; _countLabel.Width = 96; _countLabel.Height = 96; } if (_animation == null) { _animation = new GUIAnimation(); string themedFilename; foreach (string filename in Directory.GetFiles(GUIGraphicsContext.Skin + @"\media\", "common.waiting.*.png")) { themedFilename = GUIGraphicsContext.GetThemedSkinFile(filename); _animation.Filenames.Add(Path.GetFileName(themedFilename)); } // dirty hack because the files are 96x96 - unfortunately no property gives the correct size at runtime when init is called :S int scaleWidth = (GUIGraphicsContext.Width / 2) - 48; int scaleHeigth = (GUIGraphicsContext.Height / 2) - 48; _animation.SetPosition(scaleWidth, scaleHeigth); // broken!? _animation.HorizontalAlignment = HorizontalAlignment.Center; _animation.VerticalAlignment = VerticalAlignment.Center; Log.Debug("GUIWaitCursor: init at position {0}:{1}", scaleWidth, scaleHeigth); _animation.AllocResources(); _animation.Duration = new Duration(800); _animation.RepeatBehavior = RepeatBehavior.Forever; } }
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); }