public override void PreAllocResources() { base.PreAllocResources(); float fWidth = 0, fHeight = 0; _font = GUIFontManager.GetFont(_fontName); if (null == _font) { return; } _font.GetTextExtent("afy", ref fWidth, ref fHeight); try { _itemHeight = (int)(fHeight); float fTotalHeight = (float)_height; _itemsPerPage = (int)Math.Floor(fTotalHeight / (fHeight * _lineSpacing)); if (_itemsPerPage == 0) { _itemsPerPage = 1; } } catch (Exception) { _itemHeight = 1; _itemsPerPage = 1; } }
/// <summary> /// Allocates the control its DirectX resources. /// </summary> public override void AllocResources() { base.AllocResources(); _imageCheckMarkFocused.AllocResources(); _imageCheckMarkNonFocused.AllocResources(); _font = GUIFontManager.GetFont(_fontName); }
/// <summary> /// This function is called after all of the XmlSkinnable fields have been filled /// with appropriate data. /// Use this to do any construction work other than simple data member assignments, /// for example, initializing new reference types, extra calculations, etc.. /// </summary> public override sealed void FinalizeConstruction() { base.FinalizeConstruction(); GUILocalizeStrings.LocalizeLabel(ref _label); // The labelTail is used to fill the backend of a scrolling label for both wrapping and non-wrapping labels // The wrapString is the text that joins the back to the front of a wrapping label (not used if the label should not wrap). if (_userWrapString.Length > 0) { _labelTail = "" + _userWrapString[_userWrapString.Length - 1]; _wrapString = _userWrapString.Substring(0, _userWrapString.Length - 1); } _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName, _label, _textColor, _textAlignment, _textVAlignment, false, _shadowAngle, _shadowDistance, _shadowColor) { CacheFont = false, ParentControl = this }; _labelControl.SetAnimations(Animations); if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } if (_label.IndexOf("#", System.StringComparison.Ordinal) >= 0) { _containsProperty = true; } }
/// <summary> /// This function is called after all of the XmlSkinnable fields have been filled /// with appropriate data. /// Use this to do any construction work other than simple data member assignments, /// for example, initializing new reference types, extra calculations, etc.. /// </summary> public override sealed void FinalizeConstruction() { base.FinalizeConstruction(); if (_fontName == null) { _fontName = string.Empty; } if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } GUILocalizeStrings.LocalizeLabel(ref _labelText); if (_labelText == null) { _labelText = string.Empty; } if (_labelText.IndexOf("#") >= 0) { _containsProperty = true; } CachedLabel(); }
public override void FinalizeConstruction() { base.FinalizeConstruction(); int x1 = 16; int y1 = 16; GUIGraphicsContext.ScalePosToScreenResolution(ref x1, ref y1); _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _textureFocusName); _imageFocused.ParentControl = this; _imageFocused.DimColor = DimColor; _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _textureNoFocusName); _imageNonFocused.ParentControl = this; _imageNonFocused.DimColor = DimColor; _imageBackground = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height, _backgroundTextureName); _imageBackground.ParentControl = this; _imageBackground.DimColor = DimColor; _imageLeft = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureWidth, _leftTextureHeight, _leftTextureName); _imageLeft.DimColor = DimColor; _imageLeft.ParentControl = this; _imageLeftFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureFocusWidth, _leftTextureFocusHeight, _leftFocusName); _imageLeftFocus.ParentControl = this; _imageLeftFocus.DimColor = DimColor; _imageRight = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureWidth, _rightTextureHeight, _rightTextureName); _imageRight.ParentControl = this; _imageRight.DimColor = DimColor; _imageRightFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureFocusWidth, _rightTextureFocusHeight, _rightFocusName); _imageRightFocus.ParentControl = this; _imageRightFocus.DimColor = DimColor; if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } GUILocalizeStrings.LocalizeLabel(ref _label); _imageFocused.Filtering = false; _imageNonFocused.Filtering = false; _imageBackground.Filtering = false; _imageLeft.Filtering = false; _imageLeftFocus.Filtering = false; _imageRight.Filtering = false; _imageRightFocus.Filtering = false; _labelControl = new GUILabelControl(_parentControlId); _labelControl.CacheFont = true; _labelControl.ParentControl = this; _labelControl.SetShadow(_shadowAngle, _shadowDistance, _shadowColor); }
public override void FinalizeConstruction() { base.FinalizeConstruction(); _font = GUIFontManager.GetFont(_fontName); if (_property.IndexOf("#", StringComparison.Ordinal) >= 0) { _containsProperty = true; } }
/// <summary> /// Set the text of the control. /// </summary> /// <param name="strFontName">The font name.</param> /// <param name="strLabel">The text.</param> /// <param name="dwColor">The font color.</param> public void SetLabel(string strFontName, string strLabel, long dwColor) { if (strFontName == null || strLabel == null) { return; } _label = strLabel; _textColor = dwColor; _fontName = strFontName; _font = GUIFontManager.GetFont(_fontName); }
private static void ThreadActivateTheme(object param) { if (!(param is ThreadParams)) { Log.Error("param at ThreadActivateTheme has wrong type"); return; } ThreadParams threadParams = (ThreadParams)param; GUIWaitCursor.Show(); // Need to initialize fonts and references if they change based on the theme. // Check current theme. bool initFonts = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml")); bool initReferences = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml")); // Change the theme and save this new setting. SetTheme(threadParams._themeName); SkinSettings.Save(); // Check new theme. initFonts = initFonts || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml"); initReferences = initReferences || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml"); // Reset fonts if needed. if (initFonts) { // Reinitializing the device while changing fonts freezes the UI. // Add some sleep() to present the wait cursor animation for at least some user feedback. Thread.Sleep(500); GUIFontManager.ClearFontCache(); GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml")); GUIFontManager.InitializeDeviceObjects(); Thread.Sleep(500); } // Force a reload of the control references if needed. if (initReferences) { GUIControlFactory.ClearReferences(); } // Reactivate the current window and refocus on the control used to change the theme. // This applies the new theme to the current window immediately. GUIWindowManager.ResetAllControls(); GUIWindowManager.SendThreadCallbackAndWait((p1, p2, p3) => { GUIWindowManager.ActivateWindow(p1, true, true, (int)p3); return(0); }, GUIWindowManager.ActiveWindow, 0, threadParams._focusControlId); GUIWaitCursor.Hide(); }
public override void AllocResources() { if (null == _font) { return; } base.AllocResources(); _upDownControl.AllocResources(); _font = GUIFontManager.GetFont(_fontName); _upDownControl.WindowId = this._windowId; Calculate(); }
/// <summary> /// Allocate any direct3d sources /// </summary> public override void AllocResources() { _propertyHasChanged = true; if (_registeredForEvent == false) { GUIPropertyManager.OnPropertyChanged -= GUIPropertyManager_OnPropertyChanged; GUIPropertyManager.OnPropertyChanged += GUIPropertyManager_OnPropertyChanged; _registeredForEvent = true; } _font = GUIFontManager.GetFont(_fontName); Update(); base.AllocResources(); }
public override void FinalizeConstruction() { base.FinalizeConstruction(); _upDownControl = new GUISpinControl(_controlId, _controlId, _spinControlPositionX, _spinControlPositionY, _spinControlWidth, _spinControlHeight, _upTextureName, _downTextureName, _upTextureNameFocus, _downTextureNameFocus, _fontName, _colorSpinColor, GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT, Alignment.ALIGN_LEFT); _upDownControl.ParentControl = this; _font = GUIFontManager.GetFont(_fontName); if (_property.IndexOf("#") >= 0) { _containsProperty = true; } SetText(_property); }
public static void ChangeLanguage(string language) { GUIFontManager.ClearFontCache(); if (_stringProvider == null) { Load(language); } else { _stringProvider.ChangeLanguage(GetCultureName(language)); if (_stringProvider.Characters > GUIGraphicsContext.CharsInCharacterSet) { GUIGraphicsContext.CharsInCharacterSet = _stringProvider.Characters; } } }
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 AllocResources() { base.AllocResources(); _font = GUIFontManager.GetFont(_fontName); _imageTop.AllocResources(); _imageBottom.AllocResources(); _imageMid.AllocResources(); _imageRight.AllocResources(); _imageLeft.AllocResources(); _imageFillBackground.AllocResources(); _imageFill1.AllocResources(); _imageFill2.AllocResources(); _imageFill3.AllocResources(); if (_imageFillMarker != null) { _imageFillMarker.AllocResources(); _imageFillMarker.Height = _height - 6; _imageFillMarker.Filtering = false; } _imageTick.AllocResources(); _imageLogo.AllocResources(); _imageTop.Filtering = false; _imageBottom.Filtering = false; _imageMid.Filtering = false; _imageRight.Filtering = false; _imageLeft.Filtering = false; _imageFill1.Filtering = false; _imageFill2.Filtering = false; _imageFill3.Filtering = false; _imageTick.Filtering = false; if (_height == 0) { _height = _imageRight.TextureHeight; } // _imageTop.Height=_height; _imageRight.Height = _height; _imageLeft.Height = _height; _imageMid.Height = _height; _imageFill1.Height = _height - 6; _imageFill2.Height = _height - 6; _imageFill3.Height = _height - 6; //_imageTick.Height=_height; }
/// <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(); _imageCheckMarkFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _checkMarkWidth, _checkMarkHeight, _checkMarkFocusTextureName); _imageCheckMarkFocused.ParentControl = this; _imageCheckMarkFocused.DimColor = DimColor; _imageCheckMarkNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _checkMarkWidth, _checkMarkHeight, _checkMarkNoFocusTextureName); _imageCheckMarkNonFocused.ParentControl = this; _imageCheckMarkNonFocused.DimColor = DimColor; if (_fontName != "" && _fontName != "-") { _font = GUIFontManager.GetFont(_fontName); } GUILocalizeStrings.LocalizeLabel(ref _label); }
/// <summary> /// Allocates the control its DirectX resources. /// </summary> public override void AllocResources() { base.AllocResources(); _frameCounter = 0; _imageFocused.AllocResources(); _imageNonFocused.AllocResources(); _width = _imageFocused.Width; _height = _imageFocused.Height; _imageBackground.AllocResources(); _imageLeft.AllocResources(); _imageLeftFocus.AllocResources(); _imageRight.AllocResources(); _imageRightFocus.AllocResources(); _font = GUIFontManager.GetFont(_fontName); PositionLeftAndRightImages(); _labelControl.AllocResources(); }
/// <summary> /// Allocates the control its DirectX resources. /// </summary> public override void AllocResources() { _font = GUIFontManager.GetFont(_fontName); }
public static bool Render(float timePassed, GUILayers layers) { bool uiVisible = false; if (GUIGraphicsContext.BlankScreen) { return(false); } int videoLayer = (int)LayerType.Video; if (GUIGraphicsContext.ShowBackground == false) { if (_layers[videoLayer] != null) { if (_layers[videoLayer].ShouldRenderLayer()) { _layers[videoLayer].RenderLayer(timePassed); GUIFontManager.Present(); } } } List <int> layerCount = new List <int>(); int startLayer = 0; int endLayer = MAX_LAYERS; if (layers == GUILayers.under) { endLayer = videoLayer - 1; } else if (layers == GUILayers.over) { startLayer = videoLayer + 1; } for (int i = startLayer; i < endLayer; ++i) { if (_layers[i] != null) { if (_layers[i].ShouldRenderLayer()) { if (GUIGraphicsContext.ShowBackground == false && i == videoLayer) { continue; } _layers[i].RenderLayer(timePassed); GUIFontManager.Present(); if (videoLayer != i) { uiVisible = true; } if (!layerCount.Contains(i)) { layerCount.Add(i); } } } } // For madVR, first check along all layers to inform that UI is displaying // Check for madVR when GUI/OSD/Dialog is displayed, we should go to latency mode if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && GUIGraphicsContext.InVmr9Render) { for (var i = 0; i < MAX_LAYERS; ++i) { if (_layers[i] == null) { continue; } GetValue(layerCount, i); } foreach (var layer in from layer in layerCount where _layers[layer] != null where _layers[layer].ShouldRenderLayer() where videoLayer != layer select layer) { uiVisible = true; } } return(uiVisible); }
/// <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); }