A GUIControl for displaying text.
Наследование: GUIControl
Пример #1
0
        /// <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;
            }
        }
Пример #2
0
        public override void FinalizeConstruction()
        {
            base.FinalizeConstruction();

            _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                 _focusedTextureName);
            _imageFocused.ParentControl = this;

            _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                    _nonFocusedTextureName);
            _imageNonFocused.ParentControl = this;

            _imageAlternativeFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width,
                                                            _height, _alternativeFocusTextureName);
            _imageAlternativeFocused.ParentControl = this;

            _imageAlternativeNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width,
                                                               _height, _alternativeNonFocusTextureName);
            _imageAlternativeNonFocused.ParentControl = this;
            GUILocalizeStrings.LocalizeLabel(ref _label);

            _shadow = (_shadowAngle > 0) || (_shadowDistance > 0);

            _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                                _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_MIDDLE, false,
                                                _shadowAngle, _shadowDistance, _shadowColor);
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;
            _labelControl.DimColor       = DimColor;
            _labelControl.ParentControl  = this;
        }
Пример #3
0
 private void StripWrapString(GUILabelControl labelControl)
 {
     if (labelControl.Label.Length - _wrapString.Length >= 0)
     {
         labelControl.Label = labelControl.Label.Substring(0, labelControl.Label.Length - _wrapString.Length);
     }
     return;
 }
Пример #4
0
        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);
        }
Пример #5
0
 /// <summary>
 /// Creates the element and retrieves all information from the control
 /// </summary>
 /// <param name="control">GUIControl</param>
 public LabelElement(GUIControl control)
     : base(control)
 {
     _label = control as GUILabelControl;
       if (_label != null)
       {
     _font = GetFont(_label.FontName);
     _brush = new SolidBrush(GetColor(_label.TextColor));
     _labelString = _label.Label;
       }
 }
Пример #6
0
        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;
            }
        }
Пример #7
0
        /// <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();
            _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                 _focusedTextureName);
            _imageFocused.ParentControl = this;
            _imageFocused.Filtering     = false;
            _imageFocused.DimColor      = DimColor;
            _imageFocused.SetBorder(_strBorderTF, _borderPositionTF, _borderTextureRepeatTF, _borderTextureRotateTF,
                                    _borderTextureFileNameTF, _borderColorKeyTF, _borderHasCornersTF,
                                    _borderCornerTextureRotateTF);

            _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                    _nonFocusedTextureName);
            _imageNonFocused.ParentControl = this;
            _imageNonFocused.Filtering     = false;
            _imageNonFocused.DimColor      = DimColor;
            _imageNonFocused.SetBorder(_strBorderTNF, _borderPositionTNF, _borderTextureRepeatTNF, _borderTextureRotateTNF,
                                       _borderTextureFileNameTNF, _borderColorKeyTNF, _borderHasCornersTNF,
                                       _borderCornerTextureRotateTNF);
            GUILocalizeStrings.LocalizeLabel(ref _label);

            _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                                _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false,
                                                _shadowAngle, _shadowDistance, _shadowColor);
            _labelControl.ParentControl  = this;
            _labelControl.DimColor       = DimColor;
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;

            checkMark = new GUICheckMarkControl(0, 0, _positionX + _width - _checkMarkWidth, _positionY, _checkMarkWidth,
                                                _checkMarkHeight, _checkMarkFocusTextureName, _checkMarkNoFocusTextureName,
                                                _checkMarkWidth, _checkMarkWidth, Alignment.ALIGN_LEFT);
            checkMark.ParentControl = this;
            checkMark.DimColor      = DimColor;
        }
Пример #8
0
        private void Update(bool selectCurrentShow)
        {
            lock (this)
            {
                if (GUIWindowManager.ActiveWindowEx != this.GetID)
                {
                    return;
                }

                // sets button visible state
                UpdateGroupButton();

                _updateTimer = DateTime.Now;
                GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

                // Find first day in TVGuide and set spincontrol position
                int iDay = CalcDays();
                for (; iDay < 0; ++iDay)
                {
                    _viewingTime = _viewingTime.AddDays(1.0);
                }
                for (; iDay >= MaxDaysInGuide; --iDay)
                {
                    _viewingTime = _viewingTime.AddDays(-1.0);
                }
                cntlDay.Value = iDay;

                int xpos, ypos;
                GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
                GUIImage cntlChannelImg = (GUIImage)GetControl((int)Controls.CHANNEL_IMAGE_TEMPLATE);
                GUILabelControl cntlChannelLabel = (GUILabelControl)GetControl((int)Controls.CHANNEL_LABEL_TEMPLATE);
                GUILabelControl labelTime = (GUILabelControl)GetControl((int)Controls.LABEL_TIME1);
                GUIImage cntlHeaderBkgImg = (GUIImage)GetControl((int)Controls.IMG_TIME1);
                GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);


                _titleDarkTemplate = GetControl((int)Controls.LABEL_TITLE_DARK_TEMPLATE) as GUILabelControl;
                _titleTemplate = GetControl((int)Controls.LABEL_TITLE_TEMPLATE) as GUILabelControl;
                _genreDarkTemplate = GetControl((int)Controls.LABEL_GENRE_DARK_TEMPLATE) as GUILabelControl;
                _genreTemplate = GetControl((int)Controls.LABEL_GENRE_TEMPLATE) as GUILabelControl;

                _programPartialRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
                _programRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;
                _programNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
                _programNotRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                _programRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RUNNING) as GUIButton3PartControl;

                _showChannelLogos = cntlChannelImg != null;
                if (_showChannelLogos)
                {
                    cntlChannelImg.IsVisible = false;
                }
                cntlChannelLabel.IsVisible = false;
                cntlHeaderBkgImg.IsVisible = false;
                labelTime.IsVisible = false;
                cntlChannelTemplate.IsVisible = false;
                int iLabelWidth = (cntlPanel.XPosition + cntlPanel.Width - labelTime.XPosition) / 4;

                // add labels for time blocks 1-4
                int iHour, iMin;
                iMin = _viewingTime.Minute;
                _viewingTime = _viewingTime.AddMinutes(-iMin);
                iMin = (iMin / _timePerBlock) * _timePerBlock;
                _viewingTime = _viewingTime.AddMinutes(iMin);

                DateTime dt = new DateTime();
                dt = _viewingTime;

                for (int iLabel = 0; iLabel < 4; iLabel++)
                {
                    xpos = iLabel * iLabelWidth + labelTime.XPosition;
                    ypos = labelTime.YPosition;

                    GUIImage img = GetControl((int)Controls.IMG_TIME1 + iLabel) as GUIImage;
                    if (img == null)
                    {
                        img = new GUIImage(GetID, (int)Controls.IMG_TIME1 + iLabel, xpos, ypos, iLabelWidth - 4,
                                           cntlHeaderBkgImg.RenderHeight, cntlHeaderBkgImg.FileName, 0x0);
                        img.AllocResources();
                        GUIControl cntl2 = (GUIControl)img;
                        Add(ref cntl2);
                    }

                    img.IsVisible = !_singleChannelView;
                    img.Width = iLabelWidth - 4;
                    img.Height = cntlHeaderBkgImg.RenderHeight;
                    img.SetFileName(cntlHeaderBkgImg.FileName);
                    img.SetPosition(xpos, ypos);
                    img.DoUpdate();

                    GUILabelControl label = GetControl((int)Controls.LABEL_TIME1 + iLabel) as GUILabelControl;
                    if (label == null)
                    {
                        label = new GUILabelControl(GetID, (int)Controls.LABEL_TIME1 + iLabel, xpos, ypos, iLabelWidth,
                                                    cntlHeaderBkgImg.RenderHeight, labelTime.FontName, String.Empty,
                                                    labelTime.TextColor, GuideBase.TimeAlignment, labelTime.TextVAlignment, false,
                                                    labelTime.ShadowAngle, labelTime.ShadowDistance, labelTime.ShadowColor);
                        label.AllocResources();
                        GUIControl cntl = (GUIControl)label;
                        this.Add(ref cntl);
                    }
                    iHour = dt.Hour;
                    iMin = dt.Minute;
                    string strTime = dt.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                    label.Label = " " + strTime;
                    dt = dt.AddMinutes(_timePerBlock);

                    label.TextAlignment = GuideBase.TimeAlignment;
                    label.IsVisible = !_singleChannelView;
                    label.Width = iLabelWidth;
                    label.Height = cntlHeaderBkgImg.RenderHeight;
                    label.FontName = labelTime.FontName;
                    label.TextColor = labelTime.TextColor;
                    label.SetPosition(xpos, ypos);
                }

                // add channels...
                int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition;
                int iItemHeight = cntlChannelTemplate.Height;

                _channelCount = (int)(((float)iHeight) / ((float)iItemHeight));
                for (int iChan = 0; iChan < _channelCount; ++iChan)
                {
                    xpos = cntlChannelTemplate.XPosition;
                    ypos = cntlChannelTemplate.YPosition + iChan * iItemHeight;

                    //this.Remove((int)Controls.IMG_CHAN1+iChan);
                    GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChan) as GUIButton3PartControl;
                    if (imgBut == null)
                    {
                        string strChannelImageFileName = String.Empty;
                        if (_showChannelLogos)
                        {
                            strChannelImageFileName = cntlChannelImg.FileName;
                        }

                        // Use a template control if it exists, otherwise use default values.
                        GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                        if (buttonTemplate != null)
                        {
                            buttonTemplate.IsVisible = false;
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               buttonTemplate.TexutureFocusLeftName,
                                                               buttonTemplate.TexutureFocusMidName,
                                                               buttonTemplate.TexutureFocusRightName,
                                                               buttonTemplate.TexutureNoFocusLeftName,
                                                               buttonTemplate.TexutureNoFocusMidName,
                                                               buttonTemplate.TexutureNoFocusRightName,
                                                               strChannelImageFileName);

                            imgBut.TileFillTFL = buttonTemplate.TileFillTFL;
                            imgBut.TileFillTNFL = buttonTemplate.TileFillTNFL;
                            imgBut.TileFillTFM = buttonTemplate.TileFillTFM;
                            imgBut.TileFillTNFM = buttonTemplate.TileFillTNFM;
                            imgBut.TileFillTFR = buttonTemplate.TileFillTFR;
                            imgBut.TileFillTNFR = buttonTemplate.TileFillTNFR;
                        }
                        else
                        {
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               "tvguide_button_selected_left.png",
                                                               "tvguide_button_selected_middle.png",
                                                               "tvguide_button_selected_right.png",
                                                               "tvguide_button_light_left.png",
                                                               "tvguide_button_light_middle.png",
                                                               "tvguide_button_light_right.png",
                                                               strChannelImageFileName);
                        }
                        imgBut.AllocResources();
                        GUIControl cntl = (GUIControl)imgBut;
                        Add(ref cntl);
                    }

                    imgBut.Width = cntlChannelTemplate.Width - 2; //labelTime.XPosition-cntlChannelImg.XPosition;
                    imgBut.Height = cntlChannelTemplate.Height - 2; //iItemHeight-2;
                    imgBut.SetPosition(xpos, ypos);
                    imgBut.FontName1 = cntlChannelLabel.FontName;
                    imgBut.TextColor1 = cntlChannelLabel.TextColor;
                    imgBut.Label1 = String.Empty;
                    imgBut.RenderLeft = false;
                    imgBut.RenderRight = false;
                    imgBut.SetShadow1(cntlChannelLabel.ShadowAngle, cntlChannelLabel.ShadowDistance, cntlChannelLabel.ShadowColor);

                    if (_showChannelLogos)
                    {
                        imgBut.TexutureIcon = cntlChannelImg.FileName;
                        imgBut.IconOffsetX = cntlChannelImg.XPosition;
                        imgBut.IconOffsetY = cntlChannelImg.YPosition;
                        imgBut.IconWidth = cntlChannelImg.RenderWidth;
                        imgBut.IconHeight = cntlChannelImg.RenderHeight;
                        imgBut.IconKeepAspectRatio = cntlChannelImg.KeepAspectRatio;
                        imgBut.IconCentered = cntlChannelImg.Centered;
                        imgBut.IconZoom = cntlChannelImg.Zoom;
                    }
                    imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
                    imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
                    imgBut.ColourDiffuse = 0xffffffff;
                    imgBut.DoUpdate();
                }

                UpdateHorizontalScrollbar();
                UpdateVerticalScrollbar();

                GetChannels(false);


                string day;
                switch (_viewingTime.DayOfWeek)
                {
                    case DayOfWeek.Monday:
                        day = GUILocalizeStrings.Get(657);
                        break;
                    case DayOfWeek.Tuesday:
                        day = GUILocalizeStrings.Get(658);
                        break;
                    case DayOfWeek.Wednesday:
                        day = GUILocalizeStrings.Get(659);
                        break;
                    case DayOfWeek.Thursday:
                        day = GUILocalizeStrings.Get(660);
                        break;
                    case DayOfWeek.Friday:
                        day = GUILocalizeStrings.Get(661);
                        break;
                    case DayOfWeek.Saturday:
                        day = GUILocalizeStrings.Get(662);
                        break;
                    default:
                        day = GUILocalizeStrings.Get(663);
                        break;
                }
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.SDOW", day);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Month", _viewingTime.Month.ToString());
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Day", _viewingTime.Day.ToString());

                //day = String.Format("{0} {1}-{2}", day, _viewingTime.Day, _viewingTime.Month);
                day = Utils.GetShortDayString(_viewingTime);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Day", day);

                //2004 03 31 22 20 00
                string strStart = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                                _viewingTime.Year, _viewingTime.Month, _viewingTime.Day,
                                                _viewingTime.Hour, _viewingTime.Minute, 0);
                DateTime dtStop = new DateTime();
                dtStop = _viewingTime;
                dtStop = dtStop.AddMinutes(_numberOfBlocks * _timePerBlock - 1);
                iMin = dtStop.Minute;
                string strEnd = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                              dtStop.Year, dtStop.Month, dtStop.Day,
                                              dtStop.Hour, iMin, 0);

                long iStart = Int64.Parse(strStart);
                long iEnd = Int64.Parse(strEnd);


                LoadSchedules(false);

                if (_channelOffset > _channelList.Count)
                {
                    _channelOffset = 0;
                    _cursorX = 0;
                }

                for (int i = 0; i < controlList.Count; ++i)
                {
                    GUIControl cntl = (GUIControl)controlList[i];
                    if (cntl.GetID >= GUIDE_COMPONENTID_START)
                    {
                        cntl.IsVisible = false;
                    }
                }

                if (_singleChannelView)
                {
                    // show all buttons (could be less visible if channels < rows)
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                        if (imgBut != null)
                            imgBut.IsVisible = true;
                    }

                    Channel channel = (Channel)_channelList[_singleChannelNumber].channel;
                    setGuideHeadingVisibility(false);
                    RenderSingleChannel(channel);
                }
                else
                {
                    List<Channel> visibleChannels = new List<Channel>();

                    int chan = _channelOffset;
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            visibleChannels.Add(_channelList[chan].channel);
                        }
                        chan++;
                        if (chan >= _channelList.Count && visibleChannels.Count < _channelList.Count)
                        {
                            chan = 0;
                        }
                    }

                    _controller.RefreshChannelsEpgData(visibleChannels, Utils.longtodate(iStart), Utils.longtodate(iEnd));

                    // make sure the TV Guide heading is visiable and the single channel labels are not.
                    setGuideHeadingVisibility(true);
                    SetSingleChannelLabelVisibility(false);
                    chan = _channelOffset;

                    int firstButtonYPos = 0;
                    int lastButtonYPos = 0;

                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            GuideBaseChannel tvGuideChannel = _channelList[chan];
                            RenderChannel(iChannel, tvGuideChannel, iStart, iEnd, selectCurrentShow);
                            // remember bottom y position from last visible button
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                if (iChannel == 0)
                                    firstButtonYPos = imgBut.YPosition;

                                lastButtonYPos = imgBut.YPosition + imgBut.Height;
                            }
                        }
                        chan++;
                        if (chan >= _channelList.Count && _channelList.Count > _channelCount)
                        {
                            chan = 0;
                        }
                        if (chan > _channelList.Count)
                        {
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                imgBut.IsVisible = false;
                            }
                        }
                    }

                    GUIImage vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
                    if (vertLine != null)
                    {
                        // height taken from last button (bottom) minus the yposition of slider plus the offset of slider in relation to first button
                        vertLine.Height = lastButtonYPos - vertLine.YPosition + (firstButtonYPos - vertLine.YPosition);
                    }
                    // update selected channel
                    _singleChannelNumber = _cursorX + _channelOffset;
                    if (_singleChannelNumber >= _channelList.Count)
                    {
                        _singleChannelNumber -= _channelList.Count;
                    }

                    // instead of direct casting us "as"; else it fails for other controls!
                    GUIButton3PartControl img = GetControl(_cursorX + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
                    if (null != img)
                    {
                        _currentChannel = (Channel)img.Data;
                    }
                }
                UpdateVerticalScrollbar();
            }
        }
Пример #9
0
    private void WordWrapText(string strText, int iMaxWidth, out ArrayList wrappedLines)
    {
      wrappedLines = new ArrayList();
      GUILabelControl cntl1 = new GUILabelControl(_controlId, 0, 0, 0, GUIGraphicsContext.Width,
                                                  GUIGraphicsContext.Height, _fontName, "", _textColor,
                                                  Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false,
                                                  _shadowAngle, _shadowDistance, _shadowColor) {ParentControl = this};
      cntl1.AllocResources();

      // start wordwrapping
      // Set a flag so we can determine initial justification effects
      //bool bStartingNewLine = true;
      //bool bBreakAtSpace = false;
      int pos = 0;
      int lpos = 0;
      int iLastSpace = -1;
      int iLastSpaceInLine = -1;
      string szLine = "";
      strText = strText.Replace("\r", " ");
      strText.Trim();
      while (pos < strText.Length)
      {
        // Get the current letter in the string
        char letter = strText[pos];

        // Handle the newline character
        if (letter == '\n')
        {
          if (szLine.Length > 0 || _listItems.Count > 0)
          {
            wrappedLines.Add(szLine);
          }
          iLastSpace = -1;
          iLastSpaceInLine = -1;
          lpos = 0;
          szLine = "";
        }
        else
        {
          if (letter == ' ')
          {
            iLastSpace = pos;
            iLastSpaceInLine = lpos;
          }

          if (lpos < 0 || lpos > 1023)
          {
            //OutputDebugString("ERRROR\n");
          }
          szLine += letter;

          string wsTmp = szLine;
          cntl1.Label = wsTmp;
          if (cntl1.TextWidth > iMaxWidth)
          {
            if (iLastSpace > 0 && iLastSpaceInLine != lpos)
            {
              szLine = szLine.Substring(0, iLastSpaceInLine);
              pos = iLastSpace;
            }
            if (szLine.Length > 0 || _listItems.Count > 0)
            {
              wrappedLines.Add(szLine);
            }
            iLastSpaceInLine = -1;
            iLastSpace = -1;
            lpos = 0;
            szLine = "";
          }
          else
          {
            lpos++;
          }
        }
        pos++;
      }
      if (lpos > 0)
      {
        wrappedLines.Add(szLine);
      }
      cntl1.SafeDispose();
    }
Пример #10
0
    /// <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);
        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;
    }
Пример #11
0
    /// <summary>
    /// Renders the text.
    /// </summary>
    /// <param name="timePassed"></param>
    /// <param name="item"></param>
    /// <param name="label">The label to render</param>
    /// <param name="bScroll">A bool indication if there is scrolling or not.</param>
    protected void RenderText(float timePassed, int item, GUILabelControl label, bool bScroll)
    {
      float fPosX = label._positionX;
      float fPosY = label._positionY;
      float fMaxWidth = label.Width;
      long dwTextColor = label.TextColor;
      string strTextToRender = label.Label;
      GUIFont font = GUIFontManager.GetFont(label.FontName);

      if (!bScroll || label.TextWidth <= fMaxWidth)
      {
        // don't scroll here => x-position is constant
        label.Render(timePassed);
        return;
      }

      float fTextHeight = 0;
      float fTextWidth = 0;
      font.GetTextExtent(strTextToRender, ref fTextWidth, ref fTextHeight);
      float fWidth = 0;

      float fPosCX = fPosX;
      float fPosCY = fPosY;

      if (fPosCX < 0)
      {
        fPosCX = 0.0f;
      }
      if (fPosCY < 0)
      {
        fPosCY = 0.0f;
      }

      if (fPosCY > GUIGraphicsContext.Height)
      {
        fPosCY = GUIGraphicsContext.Height;
      }

      float fHeight = 60.0f;
      if (fHeight + fPosCY >= GUIGraphicsContext.Height)
      {
        fHeight = GUIGraphicsContext.Height - fPosCY - 1;
      }
      if (fHeight <= 0)
      {
        return;
      }

      //float fwidth = fMaxWidth - 5.0f;
      float fwidth = fMaxWidth + 6f;

      if (fwidth < 1)
      {
        return;
      }
      if (fHeight < 1)
      {
        return;
      }

      if (fPosCX <= 0)
      {
        fPosCX = 0;
      }
      if (fPosCY <= 0)
      {
        fPosCY = 0;
      }

      Rectangle clipRect = new Rectangle
                             {
                               X = (int) fPosCX,
                               Y = (int) fPosCY,
                               Width = (int) (fwidth),
                               Height = (int) (fHeight)
                             };
      GUIGraphicsContext.BeginClip(clipRect);

      // scroll
      int iItem = _cursorX + _offset;
      _brackedText = strTextToRender;
      _brackedText += ("  " + _suffix + " ");
      font.GetTextExtent(_brackedText, ref fTextWidth, ref fTextHeight);

      if (fTextWidth > fMaxWidth)
      {
        // scrolling necessary
        fMaxWidth += 50.0f;
        _textLine2 = "";
        if (_lastItem != iItem)
        {
          _scrollPosition = 0;
          _lastItem = iItem;
          _scrollPosititionX = 0;
          _scrollOffsetX = 0.0f;
          _timeElapsed = 0.0f;
          _scrollContinuously = false;
        }
        if ((int)_timeElapsed > _scrollStartDelay || _scrollContinuously)
        {
          // Add an especially slow setting for far distance + small display + bad eyes + foreign language combination
          if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
          {
            // Advance one pixel every 3 or 2 frames
            if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
            {
              _scrollPosititionX++;
            }
          }
          else
          {
            // advance 1 - 3 pixels every frame
            _scrollPosititionX = _scrollPosititionX + (GUIGraphicsContext.ScrollSpeedHorizontal - 2);
          }

          char wTmp = _scrollPosition >= _brackedText.Length ? ' ' : _brackedText[_scrollPosition];

          font.GetTextExtent(wTmp.ToString(CultureInfo.InvariantCulture), ref fWidth, ref fHeight);
          if (_scrollPosititionX - _scrollOffsetX >= fWidth)
          {
            _scrollPosition++;
            if (_scrollPosition > _brackedText.Length)
            {
              _scrollPosition = 0;
              _scrollPosititionX = 0;
              _scrollOffsetX = 0.0f;
              _timeElapsed = 0.0f;
              _scrollContinuously = true;
            }
            else
            {
              _scrollOffsetX += fWidth;
            }
          }
          int ipos = 0;
          for (int i = 0; i < _brackedText.Length; i++)
          {
            if (i + _scrollPosition < _brackedText.Length)
            {
              _textLine2 += _brackedText[i + _scrollPosition];
            }
            else
            {
              if (ipos == 0)
              {
                _textLine2 += ' ';
              }
              else
              {
                _textLine2 += _brackedText[ipos - 1];
              }
              ipos++;
            }
          }

          if (fPosY >= 0.0)
          {
            long tc = GUIGraphicsContext.MergeAlpha((uint)dwTextColor);
            long sc = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
            if ((_shadowDistance > 0) && ((_shadowColor >> 24) > 0))
            {
              font.DrawShadowTextWidth((int)(fPosX - _scrollPosititionX + _scrollOffsetX),
                            fPosY, tc, _textLine2, Alignment.ALIGN_LEFT,
                            _shadowAngle, _shadowDistance, sc,
                            (int)(fMaxWidth - 50f + _scrollPosititionX - _scrollOffsetX));
            }
            else
            {
              font.DrawText((int)(fPosX - _scrollPosititionX + _scrollOffsetX),
                            fPosY, tc, _textLine2, Alignment.ALIGN_LEFT,
                            (int)(fMaxWidth - 50f + _scrollPosititionX - _scrollOffsetX));
            }
          }
        }
        else if (fPosY >= 0.0)
        {
          long tc = GUIGraphicsContext.MergeAlpha((uint)dwTextColor);
          long sc = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
          if ((_shadowDistance > 0) && ((_shadowColor >> 24) > 0))
          {
            font.DrawShadowTextWidth(fPosX, fPosY, tc, strTextToRender, Alignment.ALIGN_LEFT, _shadowAngle, _shadowDistance, sc, (int)(fMaxWidth - 50f));
          }
          else
          {
            font.DrawText(fPosX, fPosY, tc, strTextToRender, Alignment.ALIGN_LEFT, (int)(fMaxWidth - 50f));
          }
        }
      }
      GUIGraphicsContext.EndClip();
    }
Пример #12
0
        protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus)
        {
            if (buttonNr < 0 || buttonNr >= _listButtons.Count)
            {
                return;
            }

            GUIListItem pItem = _listItems[buttonNr + _offset];
            long        dwColor;

            dwPosX += _textOffsetX;
            bool bSelected = buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST;

            GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr];
            int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));

            if (btn != null)
            {
                dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));
            }

            if (_text2Visible && pItem.Label2.Length > 0)
            {
                if (_textOffsetY == _textOffsetY2)
                {
                    dwColor = _textColor2;
                    if (pItem.Selected)
                    {
                        dwColor = _selectedColor2;
                    }
                    if (pItem.IsRemote)
                    {
                        dwColor = _remoteColor;
                        if (pItem.IsDownloading)
                        {
                            dwColor = _downloadColor;
                        }
                    }

                    if (pItem.IsBdDvdFolder)
                    {
                        dwColor = _bdDvdDirectoryColor;
                    }

                    int xpos;
                    int ypos = dwPosY;

                    if (0 == _textOffsetX2)
                    {
                        xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                    }
                    else
                    {
                        xpos = _positionX + _textOffsetX2;
                    }

                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                label2.TextColor     = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                label2.Label         = pItem.Label2;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                dMaxWidth            = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20);
                            }
                        }
                    }
                }
            }

            if (_text1Visible)
            {
                dwColor = _textColor;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (!gotFocus)
                {
                    dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                }

                int maxWidth = dMaxWidth;
                if (_textPadding > 0)
                {
                    maxWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding);
                }

                if (maxWidth <= 0)
                {
                    base.Render(timePassed);
                }
                else
                {
                    RenderText(timePassed, buttonNr, dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, maxWidth, dwColor, pItem.Label, bSelected);
                }
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _textColor2;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor2;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (_textOffsetX2 == 0)
                {
                    dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                }
                else
                {
                    dwPosX = _positionX + _textOffsetX2;
                }

                if (_text2Visible)
                {
                    if (_labelControls2 != null && (buttonNr >= 0 && buttonNr < _labelControls2.Count))
                    {
                        GUILabelControl label2 = _labelControls2[buttonNr];
                        if (label2 != null)
                        {
                            label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                            label2.TextColor = gotFocus
                                   ? dwColor
                                   : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                            label2.Label         = pItem.Label2;
                            label2.TextAlignment = Alignment.ALIGN_RIGHT;
                            label2.FontName      = _fontName2Name;

                            float width  = label2.Width;
                            float height = label2.Height;
                            _font.GetTextExtent(label2.Label, ref width, ref height);
                            label2.Width  = (int)width + 1;
                            label2.Height = (int)height;

                            if (_textPadding2 > 0)
                            {
                                label2.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding2);
                            }

                            if (label2.Width > 0)
                            {
                                label2.Render(timePassed);
                            }
                        }
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _textColor3;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor3;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (0 == _textOffsetX3)
                {
                    dwPosX = _positionX + _textOffsetX;
                }
                else
                {
                    dwPosX = _positionX + _textOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _textOffsetY3)
                {
                    ypos += _textOffsetY2;
                }
                else
                {
                    ypos += _textOffsetY3;
                }

                if (_text3Visible)
                {
                    if (_labelControls3 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls3.Count)
                        {
                            GUILabelControl label3 = _labelControls3[buttonNr];

                            if (label3 != null)
                            {
                                label3.SetPosition(dwPosX, ypos);

                                label3.TextColor     = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                label3.Label         = pItem.Label3;
                                label3.TextAlignment = Alignment.ALIGN_LEFT;
                                label3.FontName      = _fontName2Name;

                                float width  = label3.Width;
                                float height = label3.Height;
                                _font.GetTextExtent(label3.Label, ref width, ref height);
                                label3.Width  = (int)width + 1;
                                label3.Height = (int)height;

                                if (_textPadding3 > 0)
                                {
                                    label3.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding3);
                                }

                                if (label3.Width > 0)
                                {
                                    label3.Render(timePassed);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #13
0
    /// <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();

      _imageIcon = new GUIImage(ParentID, GetID, _positionX, _positionY, 0, 0, _textureIcon, 0);
      _imageIcon2 = new GUIImage(ParentID, GetID, _positionX, _positionY, 0, 0, _textureIcon2, 0);
      _imageFocusedLeft = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedLeft, 0);
      _imageFocusedMid = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedMid, 0);
      _imageFocusedRight = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedRight, 0);
      _imageNonFocusedLeft = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureNonFocusedLeft,
                                          0);
      _imageNonFocusedMid = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureNonFocusedMid,
                                         0);
      _imageNonFocusedRight = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height,
                                           _textureNonFocusedRight, 0);
      _isSelected = false;
      _labelControl1 = new GUILabelControl(ParentID);
      _labelControl2 = new GUILabelControl(ParentID);
      _imageIcon.ParentControl = this;
      _imageIcon2.ParentControl = this;
      _imageFocusedLeft.ParentControl = this;
      _imageFocusedMid.ParentControl = this;
      _imageFocusedRight.ParentControl = this;
      _imageNonFocusedLeft.ParentControl = this;
      _imageNonFocusedMid.ParentControl = this;
      _imageNonFocusedRight.ParentControl = this;
      _labelControl1.ParentControl = this;
      _labelControl2.ParentControl = this;

      _imageFocusedLeft.DimColor = DimColor;
      _imageFocusedMid.DimColor = DimColor;
      _imageFocusedRight.DimColor = DimColor;
      _imageNonFocusedLeft.DimColor = DimColor;
      _imageNonFocusedMid.DimColor = DimColor;
      _imageNonFocusedRight.DimColor = DimColor;
      _imageIcon.DimColor = DimColor;
      _imageIcon2.DimColor = DimColor;
      _labelControl1.DimColor = DimColor;
      _labelControl2.DimColor = DimColor;
      _labelControl1.SetShadow(_shadowAngle1, _shadowDistance1, _shadowColor1);
      _labelControl2.SetShadow(_shadowAngle2, _shadowDistance2, _shadowColor2);

      _imageFocusedLeft.SetBorder(_strBorderTFL, _borderPositionTFL, _borderTextureRepeatTFL, _borderTextureRotateTFL,
                                  _borderTextureFileNameTFL, _borderColorKeyTFL, _borderHasCornersTFL,
                                  _borderCornerTextureRotateTFL);

      _imageNonFocusedLeft.SetBorder(_strBorderTNFL, _borderPositionTNFL, _borderTextureRepeatTNFL,
                                     _borderTextureRotateTNFL,
                                     _borderTextureFileNameTNFL, _borderColorKeyTNFL, _borderHasCornersTNFL,
                                     _borderCornerTextureRotateTNFL);

      _imageFocusedMid.SetBorder(_strBorderTFM, _borderPositionTFM, _borderTextureRepeatTFM, _borderTextureRotateTFM,
                                 _borderTextureFileNameTFM, _borderColorKeyTFM, _borderHasCornersTFM,
                                 _borderCornerTextureRotateTFM);

      _imageNonFocusedMid.SetBorder(_strBorderTNFM, _borderPositionTNFM, _borderTextureRepeatTNFM,
                                    _borderTextureRotateTNFM,
                                    _borderTextureFileNameTNFM, _borderColorKeyTNFM, _borderHasCornersTNFM,
                                    _borderCornerTextureRotateTNFM);

      _imageFocusedRight.SetBorder(_strBorderTFR, _borderPositionTFR, _borderTextureRepeatTFR, _borderTextureRotateTFR,
                                   _borderTextureFileNameTFR, _borderColorKeyTFR, _borderHasCornersTFR,
                                   _borderCornerTextureRotateTFR);

      _imageNonFocusedRight.SetBorder(_strBorderTNFR, _borderPositionTNFR, _borderTextureRepeatTNFR,
                                      _borderTextureRotateTNFR,
                                      _borderTextureFileNameTNFR, _borderColorKeyTNFR, _borderHasCornersTNFR,
                                      _borderCornerTextureRotateTNFR);

      _imageIcon.SetBorder(_strBorderTI, _borderPositionTI, _borderTextureRepeatTI, _borderTextureRotateTI,
                           _borderTextureFileNameTI, _borderColorKeyTI, _borderHasCornersTI,
                           _borderCornerTextureRotateTI);

      _imageIcon2.SetBorder(_strBorderTI2, _borderPositionTI2, _borderTextureRepeatTI2, _borderTextureRotateTI2,
                            _borderTextureFileNameTI2, _borderColorKeyTI2, _borderHasCornersTI2,
                            _borderCornerTextureRotateTI2);

      TileFillTFL = _textureFocusedLeftTileFill;
      TileFillTNFL = _textureNonFocusedLeftTileFill;
      TileFillTFM = _textureFocusedMidTileFill;
      TileFillTNFM = _textureNonFocusedMidTileFill;
      TileFillTFR = _textureFocusedRightTileFill;
      TileFillTNFR = _textureNonFocusedRightTileFill;
    }
Пример #14
0
 private void StripWrapString(GUILabelControl labelControl)
 {
   if (labelControl.Label.Length - _wrapString.Length >= 0)
   {
     labelControl.Label = labelControl.Label.Substring(0, labelControl.Label.Length - _wrapString.Length);
   }
   return;
 }
Пример #15
0
    public override void AllocResources()
    {
      _fontNamedKey = GUIFontManager.GetFont(_namedKeyFont);
      _fontCharKey = GUIFontManager.GetFont(_charKeyFont);
      _fontSearchText = GUIFontManager.GetFont(_inputTextFont);

      labelBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _labelBoxTexture, 1);
      labelBox.AllocResources();

      label = new GUILabelControl(GetID);
      label.FontName = _labelFont;
      label.SetShadow(_labelShadowAngle, _labelShadowDistance, _labelShadowColor);
      label.AllocResources();

      inputTextBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _inputTextBoxTexture, 1);
      inputTextBox.AllocResources();

      inputText = new GUILabelControl(GetID);
      inputText.FontName = _inputTextFont;
      inputText.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputText.AllocResources();

      inputTextCaret = new GUILabelControl(GetID);
      inputTextCaret.FontName = _inputTextFont;
      inputTextCaret.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputTextCaret.AllocResources();

      base.AllocResources();
      _isAllocated = true;
    }
Пример #16
0
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();

      _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                           _focusedTextureName);
      _imageFocused.ParentControl = this;

      _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                              _nonFocusedTextureName);
      _imageNonFocused.ParentControl = this;

      _imageAlternativeFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width,
                                                      _height, _alternativeFocusTextureName);
      _imageAlternativeFocused.ParentControl = this;

      _imageAlternativeNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width,
                                                         _height, _alternativeNonFocusTextureName);
      _imageAlternativeNonFocused.ParentControl = this;
      GUILocalizeStrings.LocalizeLabel(ref _label);

      _shadow = (_shadowAngle > 0) || (_shadowDistance > 0);

      _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                          _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_MIDDLE, false,
                                          _shadowAngle, _shadowDistance, _shadowColor);
      _labelControl.TextAlignment = _textAlignment;
      _labelControl.TextVAlignment = _textVAlignment;
      _labelControl.DimColor = DimColor;
      _labelControl.ParentControl = this;
    }
Пример #17
0
    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;
      }
    }
Пример #18
0
    public override void AllocResources()
    {
      base.AllocResources();

      m_imgFocus = new GUIImage(GetID, GetID * 10, _positionX, _positionY, this.Width, this.Height,
                                "icon_empty_focus.png",
                                0xFFFFFFFF);
      m_imgFocus.AllocResources();
      m_imgNoFocus = new GUIImage(GetID, GetID * 100, _positionX, _positionY, this.Width, this.Height,
                                  "icon_empty_nofocus.png", 0xFFFFFFFF);
      m_imgNoFocus.AllocResources();
      for (int i = 0; i < 9; i++)
      {
        m_imgOverlay[i] = new GUIImage(GetID, GetID * 1000 + i, _positionX, _positionY, this.Width, this.Height,
                                       string.Format("icon_numberplace_overlay_{0}.png", i + 1), 0xFFFFFFFF);
        m_imgOverlay[i].AllocResources();
      }

      m_label = new GUILabelControl(GetID, GetID * 1000, _positionX, _positionY, this.Width, this.Height, this.FontName,
                                    string.Empty, 0xFFFFFFFF, Alignment.ALIGN_CENTER, VAlignment.ALIGN_MIDDLE, false,
                                    _shadowAngle, _shadowDistance, _shadowColor);
      _colorOverlay = new GUIImage(GetID, GetID * 10, _positionX, _positionY, this.Width, this.Height,
                                   "icon_numberplace_colouroverlay.png", 0xFFFFFFFF);
      _colorOverlay.AllocResources();
    }
Пример #19
0
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      _imageSpinUp = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                          _upTextureName);
      _imageSpinUp.ParentControl = this;
      _imageSpinUp.DimColor = DimColor;

      _imageSpinDown = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                            _downTextureName);
      _imageSpinDown.ParentControl = this;
      _imageSpinDown.DimColor = DimColor;

      _imageSpinUpFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                               _upTextureNameFocus);
      _imageSpinUpFocus.ParentControl = this;
      _imageSpinUpFocus.DimColor = DimColor;

      _imageSpinDownFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                 _downTextureNameFocus);
      _imageSpinDownFocus.ParentControl = this;
      _imageSpinDownFocus.DimColor = DimColor;

      _imageSpinUp.Filtering = false;
      _imageSpinDown.Filtering = false;
      _imageSpinUpFocus.Filtering = false;
      _imageSpinDownFocus.Filtering = false;
      _labelControl = new GUILabelControl(_parentControlId);
      _labelControl.CacheFont = true;
      _labelControl.ParentControl = this;
      _labelControl.DimColor = DimColor;
      _labelControl.SetShadow(_shadowAngle, _shadowDistance, _shadowColor);
    }
        protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus)
        {
            // if (buttonNr + _offset < 0 || buttonNr + _offset >= _listButtons.Count) return;
            if (buttonNr < 0 || buttonNr >= _listButtons.Count)
            {
                return;
            }
            GUIListItem pItem   = _listItems[buttonNr + _offset];
            long        dwColor = _textColor;

            if (pItem.Shaded)
            {
                dwColor = ShadedColor;
            }
            if (pItem.Selected)
            {
                dwColor = _selectedColor;
            }

            dwPosX += _textOffsetX;
            bool bSelected = false;

            if (buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST)
            {
                bSelected = true;
            }

            GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr];
            int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));

            if (btn != null)
            {
                dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));
            }

            if (_text2Visible && pItem.Label2.Length > 0)
            {
                if (_textOffsetY == _textOffsetY2)
                {
                    dwColor = _textColor2;
                    if (pItem.Selected)
                    {
                        dwColor = _selectedColor2;
                    }
                    if (pItem.IsRemote)
                    {
                        dwColor = _remoteColor;
                        if (pItem.IsDownloading)
                        {
                            dwColor = _downloadColor;
                        }
                    }
                    int xpos = dwPosX;
                    int ypos = dwPosY;

                    if (0 == _textOffsetX2)
                    {
                        xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                    }

                    else
                    {
                        xpos = _positionX + _textOffsetX2;
                    }

                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                if (gotFocus)
                                {
                                    label2.TextColor = dwColor;
                                }
                                else
                                {
                                    label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }
                                label2.Label         = pItem.Label2;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                dMaxWidth            = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20);
                            }
                        }
                    }
                }
            }

            _textLine = pItem.Label;

            if (_text1Visible)
            {
                dwColor = _textColor;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (!gotFocus)
                {
                    dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                }

                RenderText(timePassed, buttonNr, (float)dwPosX,
                           (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, (float)dMaxWidth, dwColor,
                           _textLine, bSelected);
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _textColor2;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor2;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (0 == _textOffsetX2)
                {
                    dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                }

                else
                {
                    dwPosX = _positionX + _textOffsetX2;
                }

                _textLine = pItem.Label2;

                if (_text2Visible)
                {
                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                if (gotFocus)
                                {
                                    label2.TextColor = dwColor;
                                }
                                else
                                {
                                    label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }
                                label2.Label         = _textLine;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                label2.Render(timePassed);
                                label2 = null;
                            }
                        }
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _textColor3;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor3;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (0 == _textOffsetX3)
                {
                    dwPosX = _positionX + _textOffsetX;
                }

                else
                {
                    dwPosX = _positionX + _textOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _textOffsetY3)
                {
                    ypos += _textOffsetY2;
                }

                else
                {
                    ypos += _textOffsetY3;
                }

                if (_text3Visible)
                {
                    if (_labelControls3 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls3.Count)
                        {
                            GUILabelControl label3 = _labelControls3[buttonNr];

                            if (label3 != null)
                            {
                                label3.SetPosition(dwPosX, ypos);

                                if (gotFocus)
                                {
                                    label3.TextColor = dwColor;
                                }

                                else
                                {
                                    label3.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }

                                label3.Label         = pItem.Label3;
                                label3.TextAlignment = Alignment.ALIGN_LEFT;
                                label3.FontName      = _fontName2Name;
                                label3.Render(timePassed);
                                label3 = null;
                            }
                        }
                    }
                }
            }

            pItem = null;
        }
Пример #21
0
    /// <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();
      _imageFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                           _focusedTextureName);
      _imageFocused.ParentControl = this;
      _imageFocused.Filtering = false;
      _imageFocused.DimColor = DimColor;
      _imageFocused.SetBorder(_strBorderTF, _borderPositionTF, _borderTextureRepeatTF, _borderTextureRotateTF,
                              _borderTextureFileNameTF, _borderColorKeyTF, _borderHasCornersTF,
                              _borderCornerTextureRotateTF);

      _imageNonFocused = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                              _nonFocusedTextureName);
      _imageNonFocused.ParentControl = this;
      _imageNonFocused.Filtering = false;
      _imageNonFocused.DimColor = DimColor;
      _imageNonFocused.SetBorder(_strBorderTNF, _borderPositionTNF, _borderTextureRepeatTNF, _borderTextureRotateTNF,
                                 _borderTextureFileNameTNF, _borderColorKeyTNF, _borderHasCornersTNF,
                                 _borderCornerTextureRotateTNF);
      GUILocalizeStrings.LocalizeLabel(ref _label);

      _labelControl = new GUILabelControl(_parentControlId, 0, _positionX, _positionY, _width, _height, _fontName,
                                          _label, _textColor, Alignment.ALIGN_LEFT, VAlignment.ALIGN_TOP, false,
                                          _shadowAngle, _shadowDistance, _shadowColor);
      _labelControl.ParentControl = this;
      _labelControl.DimColor = DimColor;
      _labelControl.TextAlignment = _textAlignment;
      _labelControl.TextVAlignment = _textVAlignment;

      checkMark = new GUICheckMarkControl(0, 0, _positionX + _width - _checkMarkWidth, _positionY, _checkMarkWidth,
                                          _checkMarkHeight, _checkMarkFocusTextureName, _checkMarkNoFocusTextureName,
                                          _checkMarkWidth, _checkMarkHeight, Alignment.ALIGN_LEFT);
      checkMark.ParentControl = this;
      checkMark.DimColor = DimColor;
    }
Пример #22
0
    /// <summary>
    /// The constructor of the GUIButton3PartControl class.
    /// </summary>
    /// <param name="dwParentID">The parent of this control.</param>
    /// <param name="dwControlId">The ID of this control.</param>
    /// <param name="dwPosX">The X position of this control.</param>
    /// <param name="dwPosY">The Y position of this control.</param>
    /// <param name="dwWidth">The width of this control.</param>
    /// <param name="dwHeight">The height of this control.</param>
    /// <param name="strTextureFocus">The filename containing the texture of the butten, when the button has the focus.</param>
    /// <param name="strTextureNoFocus">The filename containing the texture of the butten, when the button does not have the focus.</param>
    public GUIButton3PartControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                                 string strTextureFocusLeft,
                                 string strTextureFocusMid,
                                 string strTextureFocusRight,
                                 string strTextureNoFocusLeft,
                                 string strTextureNoFocusMid,
                                 string strTextureNoFocusRight,
                                 string strTextureIcon)
      : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
    {
      _textureFocusedLeft = strTextureFocusLeft;
      _textureFocusedMid = strTextureFocusMid;
      _textureFocusedRight = strTextureFocusRight;
      _textureNonFocusedLeft = strTextureNoFocusLeft;
      _textureNonFocusedMid = strTextureNoFocusMid;
      _textureNonFocusedRight = strTextureNoFocusRight;
      _textureIcon = strTextureIcon;
      _textureIcon2 = strTextureIcon;
      _imageIcon = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, 0, 0, strTextureIcon, 0);
      _imageIcon2 = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, 0, 0, strTextureIcon, 0);
      _imageFocusedLeft = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusLeft,
                                       0);
      _imageFocusedMid = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusMid, 0);
      _imageFocusedRight = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusRight,
                                        0);
      _imageNonFocusedLeft = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                          strTextureNoFocusLeft, 0);
      _imageNonFocusedMid = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                         strTextureNoFocusMid, 0);
      _imageNonFocusedRight = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                           strTextureNoFocusRight, 0);
      _isSelected = false;
      _labelControl1 = new GUILabelControl(dwParentID);
      _labelControl2 = new GUILabelControl(dwParentID);
      _imageIcon.ParentControl = this;
      _imageIcon2.ParentControl = this;
      _imageFocusedLeft.ParentControl = this;
      _imageFocusedMid.ParentControl = this;
      _imageFocusedRight.ParentControl = this;
      _imageNonFocusedLeft.ParentControl = this;
      _imageNonFocusedMid.ParentControl = this;
      _imageNonFocusedRight.ParentControl = this;
      _labelControl1.ParentControl = this;
      _labelControl2.ParentControl = this;

      _imageFocusedLeft.DimColor = DimColor;
      _imageFocusedMid.DimColor = DimColor;
      _imageFocusedRight.DimColor = DimColor;
      _imageNonFocusedLeft.DimColor = DimColor;
      _imageNonFocusedMid.DimColor = DimColor;
      _imageNonFocusedRight.DimColor = DimColor;
      _imageIcon.DimColor = DimColor;
      _imageIcon2.DimColor = DimColor;
      _labelControl1.DimColor = DimColor;
      _labelControl2.DimColor = DimColor;

      _imageFocusedLeft.OverlayFileName = _overlayTFL;
      _imageFocusedMid.OverlayFileName = _overlayTFM;
      _imageFocusedRight.OverlayFileName = _overlayTFR;
      _imageNonFocusedLeft.OverlayFileName = _overlayTNFL;
      _imageNonFocusedMid.OverlayFileName = _overlayTNFM;
      _imageNonFocusedRight.OverlayFileName = _overlayTNFR;

      _imageIcon2.Visible = false; // Constructor creates icon2 as a copy of icon1.
    }
Пример #23
0
    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);
    }
Пример #24
0
    //void SetProperties()

    protected override void RenderSingleChannel(Channel channel)
    {
      string strLogo;
      int chan = ChannelOffset;
      for (int iChannel = 0; iChannel < _channelCount; iChannel++)
      {
        if (chan < _channelList.Count)
        {
          Channel tvChan = _channelList[chan].channel;

          strLogo = GetChannelLogo(tvChan.DisplayName);
          GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
          if (img != null)
          {
            if (_showChannelLogos)
            {
              img.TexutureIcon = strLogo;
            }
            img.Label1 = tvChan.DisplayName;
            img.Data = tvChan;
            img.IsVisible = true;
          }
        }
        chan++;
      }

      GUILabelControl channelLabel = GetControl((int)Controls.SINGLE_CHANNEL_LABEL) as GUILabelControl;
      GUIImage channelImage = GetControl((int)Controls.SINGLE_CHANNEL_IMAGE) as GUIImage;

      strLogo = GetChannelLogo(channel.DisplayName);
      if (channelImage == null)
      {
        if (strLogo.Length > 0)
        {
          channelImage = new GUIImage(GetID, (int)Controls.SINGLE_CHANNEL_IMAGE,
                                      GetControl((int)Controls.LABEL_TIME1).XPosition,
                                      GetControl((int)Controls.LABEL_TIME1).YPosition - 15,
                                      40, 40, strLogo, Color.White);
          channelImage.AllocResources();
          GUIControl temp = (GUIControl)channelImage;
          Add(ref temp);
        }
      }
      else
      {
        channelImage.SetFileName(strLogo);
      }

      if (channelLabel == null)
      {
        channelLabel = new GUILabelControl(GetID, (int)Controls.SINGLE_CHANNEL_LABEL,
                                           channelImage.XPosition + 44,
                                           channelImage.YPosition + 10,
                                           300, 40, "font16", channel.DisplayName, 4294967295, GUIControl.Alignment.Left,
                                           GUIControl.VAlignment.Top,
                                           true, 0, 0, 0xFF000000);
        channelLabel.AllocResources();
        GUIControl temp = channelLabel;
        Add(ref temp);
      }

      setSingleChannelLabelVisibility(true);

      channelLabel.Label = channel.DisplayName;
      if (strLogo.Length > 0)
      {
        channelImage.SetFileName(strLogo);
      }

      if (channelLabel != null)
      {
        channelLabel.Label = channel.DisplayName;
      }
      if (_recalculateProgramOffset)
      {
        _programs = new List<Program>();

        DateTime dtStart = DateTime.Now;
        dtStart = dtStart.AddDays(-1);

        DateTime dtEnd = dtStart.AddDays(30);

        TvBusinessLayer layer = new TvBusinessLayer();
        _programs = layer.GetPrograms(channel, dtStart, dtEnd);

        _totalProgramCount = _programs.Count;
        if (_totalProgramCount == 0)
        {
          _totalProgramCount = _channelCount;
        }

        _recalculateProgramOffset = false;
        bool found = false;
        for (int i = 0; i < _programs.Count; i++)
        {
          Program program = (Program)_programs[i];
          if (program.StartTime <= _viewingTime && program.EndTime >= _viewingTime)
          {
            _programOffset = i;
            found = true;
            break;
          }
        }
        if (!found)
        {
          _programOffset = 0;
        }
      }
      else if (_programOffset < _programs.Count)
      {
        int day = ((Program)_programs[_programOffset]).StartTime.DayOfYear;
        bool changed = false;
        while (day > _viewingTime.DayOfYear)
        {
          _viewingTime = _viewingTime.AddDays(1.0);
          changed = true;
        }
        while (day < _viewingTime.DayOfYear)
        {
          _viewingTime = _viewingTime.AddDays(-1.0);
          changed = true;
        }
        if (changed)
        {
          GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

          // Find first day in TVGuide and set spincontrol position
          int iDay = CalcDays();
          for (; iDay < 0; ++iDay)
          {
            _viewingTime = _viewingTime.AddDays(1.0);
          }
          for (; iDay >= MaxDaysInGuide; --iDay)
          {
            _viewingTime = _viewingTime.AddDays(-1.0);
          }
          cntlDay.Value = iDay;
        }
      }
      // ichan = number of rows
      for (int ichan = 0; ichan < _channelCount; ++ichan)
      {
        GUIButton3PartControl imgCh = GetControl(ichan + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
        imgCh.TexutureIcon = "";

        int iStartXPos = GetControl(0 + (int)Controls.LABEL_TIME1).XPosition;
        int height = GetControl((int)Controls.IMG_CHAN1 + 1).YPosition;
        height -= GetControl((int)Controls.IMG_CHAN1).YPosition;
        int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition;
        width -= GetControl((int)Controls.LABEL_TIME1).XPosition;

        int iTotalWidth = width * _numberOfBlocks;

        Program program;
        int offset = _programOffset;
        if (offset + ichan < _programs.Count)
        {
          program = (Program)_programs[offset + ichan];
        }
        else
        {
          // bugfix for 0 items
          if (_programs.Count == 0)
          {
            program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", string.Empty, string.Empty,
                                  Program.ProgramState.None,
                                  DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                  string.Empty, -1);
          }
          else
          {
            program = (Program)_programs[_programs.Count - 1];
            if (program.EndTime.DayOfYear == _viewingTime.DayOfYear)
            {
              program = new Program(channel.IdChannel, program.EndTime, program.EndTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
            else
            {
              program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
          }
        }

        int ypos = GetControl(ichan + (int)Controls.IMG_CHAN1).YPosition;
        int iControlId = GUIDE_COMPONENTID_START + ichan * RowID + 0 * ColID;
        GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl;
        GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;

        if (img == null)
        {
          if (buttonTemplate != null)
          {
            buttonTemplate.IsVisible = false;
            img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                            buttonTemplate.TexutureFocusLeftName,
                                            buttonTemplate.TexutureFocusMidName,
                                            buttonTemplate.TexutureFocusRightName,
                                            buttonTemplate.TexutureNoFocusLeftName,
                                            buttonTemplate.TexutureNoFocusMidName,
                                            buttonTemplate.TexutureNoFocusRightName,
                                            String.Empty);

            img.TileFillTFL = buttonTemplate.TileFillTFL;
            img.TileFillTNFL = buttonTemplate.TileFillTNFL;
            img.TileFillTFM = buttonTemplate.TileFillTFM;
            img.TileFillTNFM = buttonTemplate.TileFillTNFM;
            img.TileFillTFR = buttonTemplate.TileFillTFR;
            img.TileFillTNFR = buttonTemplate.TileFillTNFR;
          }
          else
          {
            img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                            "tvguide_button_selected_left.png",
                                            "tvguide_button_selected_middle.png",
                                            "tvguide_button_selected_right.png",
                                            "tvguide_button_light_left.png",
                                            "tvguide_button_light_middle.png",
                                            "tvguide_button_light_right.png",
                                            String.Empty);
          }
          img.AllocResources();
          img.ColourDiffuse = GetColorForGenre(program.Genre);
          GUIControl cntl = (GUIControl)img;
          Add(ref cntl);
        }
        else
        {
          if (buttonTemplate != null)
          {
            buttonTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonTemplate.TexutureNoFocusRightName;
            
            img.TileFillTFL = buttonTemplate.TileFillTFL;
            img.TileFillTNFL = buttonTemplate.TileFillTNFL;
            img.TileFillTFM = buttonTemplate.TileFillTFM;
            img.TileFillTNFM = buttonTemplate.TileFillTNFM;
            img.TileFillTFR = buttonTemplate.TileFillTFR;
            img.TileFillTNFR = buttonTemplate.TileFillTNFR;
          }
          else
          {
            img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
            img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
            img.TexutureFocusRightName = "tvguide_button_selected_right.png";
            img.TexutureNoFocusLeftName = "tvguide_button_light_left.png";
            img.TexutureNoFocusMidName = "tvguide_button_light_middle.png";
            img.TexutureNoFocusRightName = "tvguide_button_light_right.png";
          }
          img.Focus = false;
          img.SetPosition(iStartXPos, ypos);
          img.Width = iTotalWidth;
          img.ColourDiffuse = GetColorForGenre(program.Genre);
          img.IsVisible = true;
          img.DoUpdate();
        }
        img.RenderLeft = false;
        img.RenderRight = false;
        img.StretchIfNotRendered = true;

        bool bSeries = (program.IsRecordingSeries || program.IsRecordingSeriesPending || program.IsPartialRecordingSeriesPending);
        bool bConflict = program.HasConflict;
        bool bRecording = bSeries || (program.IsRecording || program.IsRecordingOncePending);

        img.Data = program;
        img.ColourDiffuse = GetColorForGenre(program.Genre);
        height = height - 10;
        height /= 2;
        int iWidth = iTotalWidth;
        if (iWidth > 10)
        {
          iWidth -= 10;
        }
        else
        {
          iWidth = 1;
        }

        DateTime dt = DateTime.Now;

        img.TextOffsetX1 = 5;
        img.TextOffsetY1 = 5;
        img.FontName1 = "font13";
        img.TextColor1 = 0xffffffff;

        img.Label1 = TVUtil.GetDisplayTitle(program);

        string strTimeSingle = String.Format("{0}",
                                             program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

        if (program.StartTime.DayOfYear != _viewingTime.DayOfYear)
        {
          img.Label1 = String.Format("{0} {1}", Utils.GetShortDayString(program.StartTime),
                                     TVUtil.GetDisplayTitle(program));
        }

        GUILabelControl labelTemplate;
        if (program.IsRunningAt(dt))
        {
          labelTemplate = _titleDarkTemplate;
        }
        else
        {
          labelTemplate = _titleTemplate;
        }

        if (labelTemplate != null)
        {
          img.FontName1 = labelTemplate.FontName;
          img.TextColor1 = labelTemplate.TextColor;
          img.TextOffsetX1 = labelTemplate.XPosition;
          img.TextOffsetY1 = labelTemplate.YPosition;
          img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
        }
        img.TextOffsetX2 = 5;
        img.TextOffsetY2 = img.Height / 2;
        img.FontName2 = "font13";
        img.TextColor2 = 0xffffffff;
        img.Label2 = "";
        if (program.IsRunningAt(dt))
        {
          img.TextColor2 = 0xff101010;
          labelTemplate = _genreDarkTemplate;
        }
        else
        {
          labelTemplate = _genreTemplate;
        }

        if (labelTemplate != null)
        {
          img.FontName2 = labelTemplate.FontName;
          img.TextColor2 = labelTemplate.TextColor;
          img.Label2 = program.Genre;
          img.TextOffsetX2 = labelTemplate.XPosition;
          img.TextOffsetY2 = labelTemplate.YPosition;
          img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
        }
        imgCh.Label1 = strTimeSingle;
        imgCh.TexutureIcon = "";

        if (program.IsRunningAt(dt))
        {
          GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate;
          if (buttonRunningTemplate != null)
          {
            buttonRunningTemplate.IsVisible = false;
            img.TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName;
            img.TileFillTFL = buttonRunningTemplate.TileFillTFL;
            img.TileFillTNFL = buttonRunningTemplate.TileFillTNFL;
            img.TileFillTFM = buttonRunningTemplate.TileFillTFM;
            img.TileFillTNFM = buttonRunningTemplate.TileFillTNFM;
            img.TileFillTFR = buttonRunningTemplate.TileFillTFR;
            img.TileFillTNFR = buttonRunningTemplate.TileFillTNFR;
          }
          else
          {
            img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
            img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
            img.TexutureFocusRightName = "tvguide_button_selected_right.png";
            img.TexutureNoFocusLeftName = "tvguide_button_left.png";
            img.TexutureNoFocusMidName = "tvguide_button_middle.png";
            img.TexutureNoFocusRightName = "tvguide_button_right.png";
          }
        }

        img.SetPosition(img.XPosition, img.YPosition);

        img.TexutureIcon = String.Empty;
        if (program.Notify)
        {
          GUIButton3PartControl buttonNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
          if (buttonNotifyTemplate != null)
          {
            buttonNotifyTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonNotifyTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonNotifyTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonNotifyTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonNotifyTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonNotifyTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonNotifyTemplate.TexutureNoFocusRightName;

            img.TileFillTFL = buttonNotifyTemplate.TileFillTFL;
            img.TileFillTNFL = buttonNotifyTemplate.TileFillTNFL;
            img.TileFillTFM = buttonNotifyTemplate.TileFillTFM;
            img.TileFillTNFM = buttonNotifyTemplate.TileFillTNFM;
            img.TileFillTFR = buttonNotifyTemplate.TileFillTFR;
            img.TileFillTNFR = buttonNotifyTemplate.TileFillTNFR;

            // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
            img.TexutureIcon = Thumbs.TvNotifyIcon;
            img.IconOffsetX = buttonNotifyTemplate.IconOffsetX;
            img.IconOffsetY = buttonNotifyTemplate.IconOffsetY;
            img.IconAlign = buttonNotifyTemplate.IconAlign;
            img.IconVAlign = buttonNotifyTemplate.IconVAlign;
            img.IconInlineLabel1 = buttonNotifyTemplate.IconInlineLabel1;
          }
          else
          {
            if (_useNewNotifyButtonColor)
            {
              img.TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png";
              img.TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png";
              img.TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png";
              img.TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png";
              img.TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png";
              img.TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png";
            }
            else
            {
              img.TexutureIcon = Thumbs.TvNotifyIcon;
            }
          }
        }
        if (bRecording)
        {
          bool bPartialRecording = program.IsPartialRecordingSeriesPending;
          GUIButton3PartControl buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;

          // Select the partial recording template if needed.
          if (bPartialRecording)
          {
            buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
          }

          if (buttonRecordTemplate != null)
          {
            buttonRecordTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName;
            
            img.TileFillTFL = buttonRecordTemplate.TileFillTFL;
            img.TileFillTNFL = buttonRecordTemplate.TileFillTNFL;
            img.TileFillTFM = buttonRecordTemplate.TileFillTFM;
            img.TileFillTNFM = buttonRecordTemplate.TileFillTNFM;
            img.TileFillTFR = buttonRecordTemplate.TileFillTFR;
            img.TileFillTNFR = buttonRecordTemplate.TileFillTNFR;

            // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
            if (bConflict)
            {
              img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
            }
            else if (bSeries)
            {
              img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
            }
            else
            {
              img.TexutureIcon = Thumbs.TvRecordingIcon;
            }
            img.IconOffsetX = buttonRecordTemplate.IconOffsetX;
            img.IconOffsetY = buttonRecordTemplate.IconOffsetY;
            img.IconAlign = buttonRecordTemplate.IconAlign;
            img.IconVAlign = buttonRecordTemplate.IconVAlign;
            img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1;
          }
          else
          {
            if (bPartialRecording && _useNewPartialRecordingButtonColor)
            {
              img.TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png";
              img.TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png";
              img.TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png";
              img.TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png";
              img.TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png";
              img.TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png";
            }
            else
            {
              if (_useNewRecordingButtonColor)
              {
                img.TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
                img.TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
                img.TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
                img.TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
                img.TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
                img.TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
              }
              else
              {
                if (bConflict)
                {
                  img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
                }
                else if (bSeries)
                {
                  img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
                }
                else
                {
                  img.TexutureIcon = Thumbs.TvRecordingIcon;
                }
              }
            }
          }
        }
      }
    }
Пример #25
0
    /// <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;
      }
    }
Пример #26
0
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();

      HasCamera = _hasCamera;
      Camera = new System.Drawing.Point(_cameraXPos, _cameraYPos);

      _font1 = GUIFontManager.GetFont(_fontName1);
      _font2 = GUIFontManager.GetFont(_fontName2);

      // Create the background.
      _imageBackground = LoadAnimationControl(_controlId, 0, _backgroundPositionX, _backgroundPositionY,
                                              _backgroundWidth, _backgroundHeight, _backgroundTextureName);
      _imageBackground.ParentControl = this;
      _imageBackground.DimColor = DimColor;

      // Create the foreground.
      _imageForeground = LoadAnimationControl(_controlId, 0, _foregroundPositionX, _foregroundPositionY,
                                              _foregroundWidth, _foregroundHeight, _foregroundTextureName);
      _imageForeground.ParentControl = this;
      _imageForeground.DimColor = DimColor;

      // Create a single focus frame for the card that is in focus.
      _frameFocus = LoadAnimationControl(0, 0,
                                         0, 0,
                                         _cardWidth, _cardHeight,
                                         _frameFocusName);
      _frameFocus.ParentControl = null;
      _frameFocus.DimColor = DimColor;
      _frameFocus.FlipY = _flipY;
      _frameFocus.DiffuseFileName = _diffuseFilename;
      _frameFocus.MaskFileName = _maskFilename;
      _frameFocus.AllocResources();

      // Create the card labels.
      int y = _positionY + _label1OffsetY;
      _label1 = new GUILabelControl(_controlId, 0,
                                    0, y,
                                    Width, 0,
                                    _fontName1, "", 0x0,
                                    Alignment.ALIGN_CENTER, VAlignment.ALIGN_TOP,
                                    false,
                                    _shadowAngle, _shadowDistance, _shadowColor);

      y = _positionY + _label2OffsetY;
      _label2 = new GUILabelControl(_controlId, 0,
                                    0, y,
                                    Width, 0,
                                    _fontName2, "", 0x0,
                                    Alignment.ALIGN_CENTER, VAlignment.ALIGN_TOP,
                                    false,
                                    _shadowAngle, _shadowDistance, _shadowColor);

      // Create the horizontal scrollbar.
      int scrollbarWidth = _scrollbarWidth;
      int scrollbarHeight = _scrollbarHeight;
      GUIGraphicsContext.ScaleHorizontal(ref scrollbarWidth);
      GUIGraphicsContext.ScaleVertical(ref scrollbarHeight);
      int scrollbarPosX = _positionX + (_width / 2) - (scrollbarWidth / 2);

      _horizontalScrollbar = new GUIHorizontalScrollbar(_controlId, 0,
                                                        scrollbarPosX, _positionY + _scrollbarOffsetY,
                                                        scrollbarWidth, scrollbarHeight,
                                                        _scrollbarBackgroundTextureName, _scrollbarLeftTextureName,
                                                        _scrollbarRightTextureName);
      _horizontalScrollbar.ParentControl = this;
      _horizontalScrollbar.DimColor = DimColor;

      // Create controls for the back of the selected card.  All of the controls are provided as a single subitem.      
      XmlDocument doc = new XmlDocument();

      if (SubItemCount > 0) // avoid exception when no SubItems are available
      {
        doc.LoadXml((string)GetSubItem(0));
        XmlNodeList nodeList = doc.DocumentElement.SelectNodes("/controls/*");
        IDictionary<string, string> defines = new Dictionary<string, string>(); // An empty set of defines.
        foreach (XmlNode node in nodeList)
        {
          try
          {
            GUIControl newControl = GUIControlFactory.Create(_windowId, node, defines, null);
            _cardBackControls.Add(newControl);
          }
          catch (Exception ex)
          {
            Log.Error("GUICoverFlow: Unable to load control. exception:{0}", ex.ToString());
          }
        }
      }
    }
Пример #27
0
    /// <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;
    }