/// <summary> /// Creates the element and retrieves all information from the control /// </summary> /// <param name="control">GUIControl</param> public ProgressControlElement(GUIControl control) : base(control) { _progressControl = control as GUIProgressControl; if (_progressControl != null) { _leftBitmap = LoadBitmap(_progressControl.BackTextureLeftName); _midBitmap = LoadBitmap(_progressControl.BackTextureMidName); _rightBitmap = LoadBitmap(_progressControl.BackTextureRightName); _backgroundBitmap = LoadBitmap(_progressControl.BackGroundTextureName); _percentage = GetPercentage(); } }
/// <summary> /// Allocates the control its DirectX resources. /// </summary> public override void AllocResources() { Dispose(); base.AllocResources(); _upDownControl.AllocResources(); _verticalScrollbar.AllocResources(); _font = GUIFontManager.GetFont(_fontName); _font2 = GUIFontManager.GetFont(_fontName2Name); float fHeight = (float)_itemHeight + _spaceBetweenItems; float fTotalHeight = _height - _upDownControl.Height - 5; _itemsPerPage = (int)(fTotalHeight / fHeight); _listButtons = new List<GUIControl>(); _labelControls1 = new List<GUILabelControl>(); _labelControls2 = new List<GUILabelControl>(); _labelControls3 = new List<GUILabelControl>(); AllocButtons(); for (int i = 0; i < _itemsPerPage; ++i) { GUILabelControl cntl1 = new GUILabelControl(_controlId, 0, 0, 0, 0, 0, _fontName, "", _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false, _shadowAngle, _shadowDistance, _shadowColor); GUILabelControl cntl2 = new GUILabelControl(_controlId, 0, 0, 0, 0, 0, _fontName2Name, "", _textColor2, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false, _shadowAngle, _shadowDistance, _shadowColor); GUILabelControl cntl3 = new GUILabelControl(_controlId, 0, 0, 0, 0, 0, _fontName2Name, "", _textColor3, Alignment.ALIGN_RIGHT, VAlignment.ALIGN_TOP, false, _shadowAngle, _shadowDistance, _shadowColor); if (_backgroundTextureName != string.Empty && _leftTextureName != string.Empty && _midTextureName != string.Empty && _rightTextureName != string.Empty) { GUIProgressControl progressCtl = new GUIProgressControl(_controlId, 0, 0, 0, GUIGraphicsContext.ScaleHorizontal(_widthProgressBar), GUIGraphicsContext.ScaleVertical(_heightProgressBar), _backgroundTextureName, _leftTextureName, _midTextureName, _rightTextureName); progressCtl.ParentControl = this; progressCtl.AllocResources(); progressCtl.Visible = false; _listProgresses.Add(progressCtl); } cntl1.ParentControl = this; cntl2.ParentControl = this; cntl3.ParentControl = this; cntl1.AllocResources(); cntl2.AllocResources(); cntl3.AllocResources(); cntl1.DimColor = DimColor; cntl2.DimColor = DimColor; cntl3.DimColor = DimColor; _labelControls1.Add(cntl1); _labelControls2.Add(cntl2); _labelControls3.Add(cntl3); } int iPages = 1; if (_listItems.Count > 0) { iPages = _itemsPerPage == 0 ? 0 : _listItems.Count / _itemsPerPage; if (_itemsPerPage != 0) { if ((_listItems.Count % _itemsPerPage) != 0) { iPages++; } } } _upDownControl.SetRange(1, iPages); _upDownControl.Value = 1; _upDownControl.DimColor = DimColor; _verticalScrollbar.DimColor = DimColor; }