public static SetProperty ( string tag, string tagvalue ) : void | ||
tag | string | property name |
tagvalue | string | property value |
return | void |
/// <summary> /// Set all skin booleans to false. Does not save to disk; call Save() afterward. /// </summary> public static void ResetAllSkinBool() { Dictionary <int, SkinBool> .Enumerator enumer = _skinBoolSettings.GetEnumerator(); while (enumer.MoveNext()) { SkinBool skin = enumer.Current.Value; skin.Value = false; // Save the setting as a property if specified as such. The boolean value is converted as a string representation. GUIPropertyManager.SetProperty(skin.Name, skin.Value.ToString()); } }
/// <summary> /// Set all the skin strings to empty. Does not save to disk; call Save() afterward. /// </summary> public static void ResetAllSkinString() { Dictionary <int, SkinString> .Enumerator enumer = _skinStringSettings.GetEnumerator(); while (enumer.MoveNext()) { SkinString skin = enumer.Current.Value; skin.Value = ""; // Save the setting as a property if specified as such. GUIPropertyManager.SetProperty(skin.Name, skin.Value); } }
/// <summary> /// Translate the skin boolean, create the skin boolean if not found. /// </summary> /// <param name="setting"></param> /// <param name="kind"></param> /// <returns></returns> public static int TranslateSkinBool(string setting, Kind kind) { lock (_skinBoolSettings) { foreach (int iKey in _skinBoolSettings.Keys.ToList()) { SkinBool skin = _skinBoolSettings[iKey]; if (skin.Name == setting) { if (skin.Kind == Kind.TRANSIENT && kind == Kind.PERSISTENT) { skin.Kind = kind; _skinBoolSettings[iKey] = skin; } return(iKey); } } } SkinBool newBool = new SkinBool(); newBool.Name = setting; newBool.Value = false; newBool.Kind = kind; // Create the setting as a property if not already present. The boolean value is converted as a string representation. if (!GUIPropertyManager.PropertyIsDefined(newBool.Name)) { GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString()); } else { try { newBool.Value = bool.Parse(GUIPropertyManager.GetProperty(newBool.Name)); } catch (FormatException ex) { // Value is set to false. Log.Warn("SkinSettings: Boolean setting value is not a valid boolean name={0} value={1} {2}", newBool.Name, newBool.Value, ex.Message); } } int key; lock (_skinBoolSettings) // Lock dictionary, we might be saving, should not alter structre { key = _skinBoolSettings.Count; _skinBoolSettings[key] = newBool; } return(key); }
/// <summary> /// Set a skin boolean using the specified key. Saves changes to disk immediatley. /// </summary> /// <param name="key"></param> /// <param name="newValue"></param> public static void SetSkinBool(int key, bool newValue) { SkinBool skinBool = null; if (_skinBoolSettings.TryGetValue(key, out skinBool)) { skinBool.Value = newValue; _skinBoolSettings[key] = skinBool; // Save the setting as a property. The boolean value is converted as a string representation. GUIPropertyManager.SetProperty(skinBool.Name, skinBool.Value.ToString()); // Save change to disk immediately. Save(); } }
/// <summary> /// Set a skin string using the specified key. Saves changes to disk immediatley. /// </summary> /// <param name="key"></param> /// <param name="newValue"></param> public static void SetSkinString(int key, string newValue) { SkinString skin = null; if (_skinStringSettings.TryGetValue(key, out skin)) { skin.Value = newValue; _skinStringSettings[key] = skin; // Save the setting as a property. GUIPropertyManager.SetProperty(skin.Name, skin.Value); // Save change to disk immediately. Save(); } }
/// <summary> /// Translate the skin string, create the skin string if not found. /// </summary> /// <param name="line"></param> /// <param name="kind"></param> /// <returns></returns> public static int TranslateSkinString(string line, Kind kind) { lock (_skinStringSettings) { foreach (int iKey in _skinStringSettings.Keys.ToList()) { SkinString skin = _skinStringSettings[iKey]; if (skin.Name == line) { if (skin.Kind == Kind.TRANSIENT && kind == Kind.PERSISTENT) { skin.Kind = kind; _skinStringSettings[iKey] = skin; } return(iKey); } } } SkinString newString = new SkinString(); newString.Name = line; newString.Value = line; newString.Kind = kind; // Create the setting as a property if not already present. if (!GUIPropertyManager.PropertyIsDefined(newString.Name)) { GUIPropertyManager.SetProperty(newString.Name, newString.Value); } else { newString.Value = GUIPropertyManager.GetProperty(newString.Name); } int key; lock (_skinStringSettings) //Lock the dictionary, it might be getting saved at the moment { key = _skinStringSettings.Count; _skinStringSettings[key] = newString; } return(key); }
/// <summary> /// Translate the skin boolean, create the skin boolean if not found. /// </summary> /// <param name="setting"></param> /// <param name="kind"></param> /// <returns></returns> public static int TranslateSkinBool(string setting, Kind kind) { Dictionary <int, SkinBool> .Enumerator enumer = _skinBoolSettings.GetEnumerator(); while (enumer.MoveNext()) { SkinBool skin = enumer.Current.Value; if (skin.Name == setting) { return(enumer.Current.Key); } } SkinBool newBool = new SkinBool(); newBool.Name = setting; newBool.Value = false; newBool.Kind = kind; // Create the setting as a property if not already present. The boolean value is converted as a string representation. if (!GUIPropertyManager.PropertyIsDefined(newBool.Name)) { GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString()); } else { try { newBool.Value = bool.Parse(GUIPropertyManager.GetProperty(newBool.Name)); } catch (FormatException) { // Value is set to false. Log.Warn("SkinSettings: Boolean setting value is not a valid boolean name={0} value={1}", newBool.Name, newBool.Value); } } int key; lock (_skinBoolSettings) // Lock dictionary, we might be saving, should not alter structre { key = _skinBoolSettings.Count; _skinBoolSettings[key] = newBool; } return(key); }
/// <summary> /// Initialize ThemeManager, should be called when a new skin is loaded. /// </summary> public static void Init(string name) { // Set the current theme. SetTheme(name); // Set a property with a comma-separated list of theme names. string themesCSV = ""; ArrayList themes = GetSkinThemes(); for (int i = 0; i < themes.Count; i++) { themesCSV += "," + themes[i]; } if (themesCSV.Length > 0) { themesCSV = themesCSV.Substring(1); } GUIPropertyManager.SetProperty("#skin.themes", themesCSV); }
/// <summary> /// Translate the skin string, create the skin string if not found. /// </summary> /// <param name="line"></param> /// <param name="kind"></param> /// <returns></returns> public static int TranslateSkinString(string line, Kind kind) { Dictionary <int, SkinString> .Enumerator enumer = _skinStringSettings.GetEnumerator(); while (enumer.MoveNext()) { SkinString skin = enumer.Current.Value; if (skin.Name == line) { return(enumer.Current.Key); } } SkinString newString = new SkinString(); newString.Name = line; newString.Value = line; newString.Kind = kind; // Create the setting as a property if not already present. if (!GUIPropertyManager.PropertyIsDefined(newString.Name)) { GUIPropertyManager.SetProperty(newString.Name, newString.Value); } else { newString.Value = GUIPropertyManager.GetProperty(newString.Name); } int key; lock (_skinStringSettings) //Lock the dictionary, it might be getting saved at the moment { key = _skinStringSettings.Count; _skinStringSettings[key] = newString; } return(key); }
/// <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); }
public override void Render(float timePassed) { //base.Render(timePassed); _timeElapsed += timePassed; // If there is no font do not render. if (null == _font) { base.Render(timePassed); return; } // If the control is not visible do not render. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } int dwPosY = _positionY; // Render the buttons first. for (int i = 0; i < _itemsPerPage; i++) { if (i + _offset < _listItems.Count) { // render item bool gotFocus = false; if (_drawFocus && i == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST) { gotFocus = true; } RenderButton(timePassed, i, _positionX, dwPosY, gotFocus); } dwPosY += _itemHeight + _spaceBetweenItems; } // Free unused textures if page has changed FreeUnusedThumbnails(); // Render new item list dwPosY = _positionY; for (int i = 0; i < _itemsPerPage; i++) { int dwPosX = _positionX; if (i + _offset < _listItems.Count) { bool gotFocus = false; if (_drawFocus && i == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST) { gotFocus = true; } // render the icon RenderIcon(timePassed, i, dwPosX + _iconOffsetX, dwPosY + _iconOffsetY, gotFocus); dwPosX += (_imageWidth + GUIGraphicsContext.ScaleHorizontal(10)); // render the text RenderLabel(timePassed, i, dwPosX, dwPosY, gotFocus); RenderPinIcon(timePassed, i, _positionX, dwPosY, gotFocus); dwPosY += _itemHeight + _spaceBetweenItems; } } RenderScrollbar(timePassed); if (Focus) { GUIPropertyManager.SetProperty("#highlightedbutton", string.Empty); } }
/// <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); }
/// <summary> /// Set the current theme /// </summary> /// <param name="name"></param> public static void SetTheme(string name) { CheckThemeVersion(ref name); GUIGraphicsContext.Theme = name; GUIPropertyManager.SetProperty("#skin.currenttheme", name); }
/// <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; } } base.Render(timePassed); // The GUIButtonControl has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); GUIPropertyManager.SetProperty("#highlightedbutton", Label); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } // render the text on the button if (Disabled) { if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = _disabledColor; } else { ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = _disabledColor; } _labelControl.SetPosition(_textOffsetX + _positionX, _textOffsetY + _positionY); _labelControl.Render(timePassed); } else { if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = _disabledColor; } else { ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = _textColor; } _labelControl.SetPosition(_textOffsetX + _positionX, _textOffsetY + _positionY); _labelControl.Render(timePassed); } base.Render(timePassed); if (_spinControl != null) { int off = 5; GUIGraphicsContext.ScaleHorizontal(ref off); _spinControl.SetPosition(_imageNonFocused.XPosition + _imageNonFocused.Width - off - 2 * _spinControlWidth, _imageNonFocused.YPosition + (_imageNonFocused.Height - _spinControlHeight) / 2); _spinControl.Render(timePassed); } //base.Render(timePassed); }