/// <summary> /// Get the image for the given filename /// If the file is already in the cache than return the cache image /// </summary> /// <param name="fileName">Filename of the image</param> /// <returns>The image for the given filename</returns> public static Bitmap GetImage(string fileName) { if (_imageCache == null) { _imageCache = new Dictionary <string, Bitmap>(); } if (_imageCache.ContainsKey(fileName)) { return(_imageCache[fileName]); } Bitmap result = null; String realFileName = GUIPropertyManager.Parse(fileName); if (!Path.IsPathRooted(realFileName)) { realFileName = GUIGraphicsContext.Skin + @"\media\" + realFileName; } if (File.Exists(realFileName)) { result = new Bitmap(realFileName); UpdateBitmap(result); } if (result != null) { _imageCache.Add(fileName, result); } return(result); }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { if (_wasVisible) { GUIControl.Alignment alignment = _label.TextAlignment; RectangleF rectangle; String text = GUIPropertyManager.Parse(_label.Label); SizeF sizeF = graph.MeasureString(text, _font); int xFromAnim = 0; int yFromAnim = 0; foreach (VisualEffect effect in _label.Animations) { if (effect.CurrentState != AnimationState.None && effect.Effect == EffectType.Slide && (effect.Condition == 0 || GUIInfoManager.GetBool(effect.Condition, 0))) { xFromAnim += (int)effect.EndX; yFromAnim += (int)effect.EndY; } } int x = _label.XPosition + xFromAnim; int y = _label.YPosition + yFromAnim; if (alignment == GUIControl.Alignment.ALIGN_LEFT) { //rectangle = new RectangleF(_label.XPosition, _label.YPosition, _label._width, Math.Max(sizeF.Height, _label._height)); rectangle = new RectangleF(x, y, _label._width, Math.Max(sizeF.Height, _label._height)); } else { //rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)_label.Location.X - sizeF.Width, (float)_label.Location.Y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)_label.Location.X - (sizeF.Width / 2), (float)_label.Location.Y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height)); rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)x - sizeF.Width, (float)y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)x - (sizeF.Width / 2), (float)y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height)); } graph.DrawString(text, _font, _brush, rectangle, StringFormat.GenericTypographic); } }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { if (_wasVisible) { const string strValue = ""; Font font = GetFont("font13"); float backgroundPositionX = _slider.XPosition; float backgroundPositionY = _slider.YPosition; if (null != font) { SolidBrush brush = new SolidBrush(Color.FromArgb(255, 255, 255, 255)); graph.DrawString(GUIPropertyManager.Parse(strValue), font, brush, _slider.XPosition, _slider.YPosition); brush.Dispose(); } //backgroundPositionX += 60; //int iHeight=25; graph.DrawImage(_backgroundBitmap, backgroundPositionX, backgroundPositionY, _backgroundBitmap.Width, _backgroundBitmap.Height); //_imageBackGround.SetHeight(iHeight); float fWidth = _backgroundBitmap.Width - _sliderBitmap.Width; //-20.0f; float fPos = _percentage; fPos /= 100.0f; fPos *= fWidth; fPos += backgroundPositionX; //fPos += 10.0f; if ((int)fWidth > 1) { graph.DrawImage(_slider.IsFocused ? _sliderFocusBitmap : _sliderBitmap, fPos, backgroundPositionY); } } }
/// <summary> /// Checks, if an update for the element is needed /// </summary> /// <returns>true, if an update is needed</returns> protected override bool CheckElementSpecificForUpdate() { bool result = false; String newLabel = GUIPropertyManager.Parse(_checkMark.Label); if (!newLabel.Equals(_label)) { _label = newLabel; result = true; } if (_checkMark.Focus != _focus) { _focus = _checkMark.Focus; result = true; } if (_checkMark.Disabled != _disabled) { _disabled = _checkMark.Disabled; result = true; } if (_checkMark.Selected != _selected) { _selected = _checkMark.Selected; result = true; } return(result); }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { if (_wasVisible) { int dwTextPosX = _checkMark.XPosition; int dwCheckMarkPosX = _checkMark.XPosition; Rectangle _rectangle = new Rectangle(); _rectangle.X = _checkMark.YPosition; _rectangle.Y = _checkMark.YPosition; _rectangle.Height = _checkFocusBitmap.Height; if (null != _font) { SizeF sizeF; if (_checkMark.TextAlignment == GUIControl.Alignment.ALIGN_LEFT) { sizeF = graph.MeasureString(GUIPropertyManager.Parse(_label), _font); dwCheckMarkPosX += ((int)(sizeF.Width) + 5); } else { dwTextPosX = (dwCheckMarkPosX + _checkFocusBitmap.Width + 5); graph.MeasureString(GUIPropertyManager.Parse(_label), _font); } if (_disabled) { SolidBrush brush = new SolidBrush(_disabledColor); graph.DrawString(GUIPropertyManager.Parse(_label), _font, brush, dwTextPosX, _checkMark.YPosition); brush.Dispose(); } else { if (_focus) { SolidBrush brush = new SolidBrush(_textColor); graph.DrawString(GUIPropertyManager.Parse(_label), _font, brush, dwTextPosX, _checkMark.YPosition); brush.Dispose(); } else { SolidBrush brush = new SolidBrush(_disabledColor); graph.DrawString(GUIPropertyManager.Parse(_label), _font, brush, dwTextPosX, _checkMark.YPosition); brush.Dispose(); } } } if (_selected) { graph.DrawImage(_checkFocusBitmap, dwCheckMarkPosX, _checkMark.YPosition); } else { graph.DrawImage(_checkNoFocusBitmap, dwCheckMarkPosX, _checkMark.YPosition); } } }
/// <summary> /// Calculates the percentage of the control /// </summary> /// <returns></returns> private int GetPercentage() { float percent; float.TryParse(GUIPropertyManager.Parse(_progressControl.Property), out percent); if (percent > 100) { percent = 100; } return((int)percent); }
/// <summary> /// Checks, if an update for the element is needed /// </summary> /// <returns>true, if an update is needed</returns> protected override bool CheckElementSpecificForUpdate() { bool result = false; String newLabel = GUIPropertyManager.Parse(_label.Label); if (!newLabel.Equals(_labelString)) { _labelString = newLabel; result = true; } return(result); }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { if (_wasVisible) { if (_button.Focus) { if (_button.Selected) { if (_focusBitmap != null) { graph.DrawImage(_focusBitmap, (float)_button.Location.X, (float)_button.Location.Y, (float)_button.Size.Width, (float)_button.Size.Height); } } } else { if (_button.Selected) { if (_noFocusBitmap != null) { graph.DrawImage(_noFocusBitmap, (float)_button.Location.X, (float)_button.Location.Y, (float)_button.Size.Width, (float)_button.Size.Height); } } } int labelWidth = _button.Width - 2 * _button.TextOffsetX; if (labelWidth <= 0) { return; } SolidBrush brush = new SolidBrush(_button.Disabled ? _disabledColor : _textColor); // render the text on the button int x = 0; switch (_button.TextAlignment) { case GUIControl.Alignment.ALIGN_LEFT: x = _button.TextOffsetX + _button.XPosition; break; case GUIControl.Alignment.ALIGN_RIGHT: x = _button.XPosition + _button.Width - _button.TextOffsetX; break; } Rectangle rectangle = new Rectangle(x, _button.YPosition + _button.TextOffsetY, labelWidth, _button.Height); graph.DrawString(GUIPropertyManager.Parse(_label), _font, brush, rectangle, StringFormat.GenericTypographic); brush.Dispose(); } }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { RectangleF rectangle; SizeF stringSize = graph.MeasureString(_label, _font); if (_alignment == GUIControl.Alignment.ALIGN_LEFT) { rectangle = new RectangleF(_xPosition, _yPosition, _width, Math.Max(stringSize.Height, _height)); } else { rectangle = _alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF(_xPosition - stringSize.Width, _yPosition, _width, Math.Max(stringSize.Height, _height)) : new RectangleF(_xPosition - (stringSize.Width / 2), _yPosition - (stringSize.Height / 2), _width, Math.Max(stringSize.Height, _height)); } graph.DrawString(GUIPropertyManager.Parse(_label), _font, _brush, rectangle, StringFormat.GenericTypographic); }
protected override void OnPageLoad() { base.OnPageLoad(); Log.Instance.Info("OnPageLoad of Site Updater with PreviousWindowId '{0}'", PreviousWindowId); defaultLabelBtnSort = GUIPropertyManager.Parse(GUI_btnSort.Label); defaultLabelBtnFilterState = GUIPropertyManager.Parse(GUI_btnFilterState.Label); defaultLabelBtnFilterCreator = GUIPropertyManager.Parse(GUI_btnFilterCreator.Label); defaultLabelBtnFilterLang = GUIPropertyManager.Parse(GUI_btnFilterLang.Label); if (GUI_btnFilterState.SubItemCount == 0) { foreach (string aFilterOption in Enum.GetNames(typeof(FilterStateOption))) { GUIControl.AddItemLabelControl(GetID, GUI_btnFilterState.GetID, Translation.Instance.GetByName(aFilterOption)); } } if (GUI_btnSort.SubItemCount == 0) { foreach (string aSortOption in Enum.GetNames(typeof(SortOption))) { string[] singled = aSortOption.Split('_'); for (int i = 0; i < singled.Length; i++) { singled[i] = Translation.Instance.GetByName(singled[i]); } GUIControl.AddItemLabelControl(GetID, GUI_btnSort.GetID, string.Join(", ", singled)); } } SetFilterButtonOptions(); GUIPropertyManager.SetProperty("#OnlineVideos.HeaderLabel", PluginConfiguration.Instance.BasicHomeScreenName + ": " + Translation.Instance.ManageSites); GUIPropertyManager.SetProperty("#OnlineVideos.HeaderImage", SiteImageExistenceCache.GetImageForSite("OnlineVideos")); GUIOnlineVideos ovGuiInstance = (GUIOnlineVideos)GUIWindowManager.GetWindow(GUIOnlineVideos.WindowId); if (ovGuiInstance != null && ovGuiInstance.SelectedSite != null && ovGuiInstance.CurrentState != GUIOnlineVideos.State.sites) { selectedSite = ovGuiInstance.SelectedSite.Settings.Name; } RefreshDisplayedOnlineSites(); }
/// <summary> /// Checks, if an update for the element is needed /// </summary> /// <returns>true, if an update is needed</returns> protected override bool CheckElementSpecificForUpdate() { bool result = false; String newLabel = GUIPropertyManager.Parse(_button.Label); if (!newLabel.Equals(_label)) { _label = newLabel; result = true; } if (_button.Focus != _focus) { _focus = _button.Focus; result = true; } return(result); }
/// <summary> /// Draws the element on the given graphics /// </summary> /// <param name="graph">Graphics</param> public override void DrawElement(Graphics graph) { if (_wasVisible) { SizeF textSize = graph.MeasureString(_label, _font); RectangleF rectangle; if (_textScrollUp.TextAlignment == GUIControl.Alignment.ALIGN_LEFT) { rectangle = new RectangleF((float)_textScrollUp.Location.X, (float)_textScrollUp.Location.Y, _textScrollUp.Width, Math.Max(textSize.Height, _textScrollUp.Height)); } else { rectangle = _textScrollUp.TextAlignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)_textScrollUp.Location.X - textSize.Width, (float)_textScrollUp.Location.Y, _textScrollUp.Width, Math.Max(textSize.Height, _textScrollUp.Height)) : new RectangleF((float)_textScrollUp.Location.X - (textSize.Width / 2), (float)_textScrollUp.Location.Y - (textSize.Height / 2), _textScrollUp.Width, Math.Max(textSize.Height, _textScrollUp.Height)); } graph.DrawString(GUIPropertyManager.Parse(_label), _font, _brush, rectangle, StringFormat.GenericTypographic); } }
protected override string DoEvaluate() { string strEval = GUIPropertyManager.GetProperty(base.value); if (!string.IsNullOrEmpty(strEval) && (strEval.IndexOf('#') > -1)) { strEval = GUIPropertyManager.Parse(strEval) ?? string.Empty; } if (!string.IsNullOrEmpty(strEval) && (strEval.IndexOf('#') > -1)) { strEval = GUIPropertyManager.Parse(strEval) ?? string.Empty; } if (!string.IsNullOrEmpty(strEval) && (strEval.IndexOf('#') > -1)) { strEval = GUIPropertyManager.Parse(strEval) ?? string.Empty; } return(strEval); }
protected override string DoEvaluate() { return(GUIPropertyManager.Parse(this.value)); }