コード例 #1
0
ファイル: GUIPresenter.cs プロジェクト: brownard/MyEmulators2
        public void Load(GUIFacadeControl facade, ImageSwapper backdrop, DBItem startupItem, bool launch, GUILabelControl showVideoPreviewControl, GUIListControl goodmergeList, GUIButtonControl detailsPlayButton)
        {
            this.facade                  = facade;
            this.goodmergeList           = goodmergeList;
            this.backdrop                = backdrop;
            this.showVideoPreviewControl = showVideoPreviewControl;
            this.detailsPlayButton       = detailsPlayButton;

            clearGUIProperties();
            currentLayout = -1;

            int prevWindow = GUIWindowManager.GetPreviousActiveWindow();

            if (GUIWindowManager.ActiveWindow == prevWindow || prevWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO)
            {
                launchStartupItem = false;
                Refresh(true); //Catch when MP is refreshing plugin after resizing/restoring and maintain current view
            }
            else
            {
                resetStartupItem(startupItem);
                this.launchStartupItem = launch;
                SortProperty           = ListItemProperty.DEFAULT; //set skin property
                GUIPropertyManager.SetProperty("#Emulators2.sortenabled", "no");
                currentView = ViewState.Items;
                setFacadeVisibility(true);
                loadStartupItems(0);
            }
            //resume import if previously paused
            resumeImporter();
        }
コード例 #2
0
ファイル: CellControl.cs プロジェクト: thomasr3/MediaPortal-1
        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();
        }
コード例 #3
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;
     }
 }
コード例 #4
0
 public MainPresenter(GUIFacadeControl facade, GUIImage[] stars, GUIImage bg_description, GUITextScrollUpControl text_description, GUIButtonControl button_view, GUILabelControl gamelabel_year, GUILabelControl gamelabel_genre, GUILabelControl gamelabel_company, GUILabelControl gamelabel_latestplay, GUILabelControl gamelabel_playcount)
 {
     this.facade               = facade;
     this.stars                = stars;
     this.bg_description       = bg_description;
     this.text_description     = text_description;
     this.button_view          = button_view;
     this.gamelabel_year       = gamelabel_year;
     this.gamelabel_genre      = gamelabel_genre;
     this.gamelabel_company    = gamelabel_company;
     this.gamelabel_latestplay = gamelabel_latestplay;
     this.gamelabel_playcount  = gamelabel_playcount;
 }
コード例 #5
0
        private string GetSingleLabelFromControl(GUIControl control)
        {
            if (control.GetType() == typeof(GUILabelControl))
            {
                GUILabelControl label = (GUILabelControl)control;
                return(label.Label);
            }
            else if (control.GetType() == typeof(GUIFadeLabel))
            {
                GUIFadeLabel label = (GUIFadeLabel)control;
                return(label.Label);
            }

            return(null);
        }
コード例 #6
0
ファイル: ScoreCenterGui.cs プロジェクト: mbekoe/scorecenter
        private GUIControl CreateControl(int posX, int posY, int width, int height,
                                         ColumnDisplay.Alignment alignment,
                                         string label, string font, int fontSize, Style style, int nbMax, int columnIndex)
        {
            // always start with a space
            string strLabel = " " + label;

            // shrink text for small labels
            if (nbMax <= 6 && strLabel.Length > nbMax)
            {
                strLabel = strLabel.Substring(0, nbMax);
            }

            int px = posX;

            if (alignment == ColumnDisplay.Alignment.Right)
            {
                px = posX + width;
            }

            // create the control
            GUIControl control = null;

            try
            {
                GUILabelControl labelControl = new GUILabelControl(GetID);

                labelControl._positionX    = px;
                labelControl._positionY    = posY;
                labelControl._width        = width;
                labelControl._height       = height;
                labelControl.FontName      = font;
                labelControl.Label         = strLabel;
                labelControl.TextColor     = style.ForeColor;
                labelControl.TextAlignment = ConvertAlignment(alignment);

                control = labelControl;
            }
            catch (Exception exc)
            {
                Tools.LogError(String.Format("bad {0}", strLabel), exc);
                control = null;
            }

            return(control);
        }
コード例 #7
0
        public bool GetDialogInfo(GUIWindow.Window dialogWindow, ref string DialogTitle, ref string DialogHighlightedItem)
        {
            GUIListControl control = null;
            bool           focus   = false;

            switch (dialogWindow)
            {
            case GUIWindow.Window.WINDOW_DIALOG_YES_NO:
            case GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO:
            {
                GUIDialogYesNo window = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)dialogWindow);
                DialogTitle = string.Empty;
                foreach (object obj16 in window.controlList)
                {
                    if (obj16.GetType() == typeof(GUIFadeLabel))
                    {
                        GUIFadeLabel label3 = obj16 as GUIFadeLabel;
                        if (DialogTitle == string.Empty)
                        {
                            if (label3.Label != string.Empty)
                            {
                                DialogTitle = label3.Label;
                            }
                        }
                        else if (label3.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + label3.Label;
                        }
                    }
                    if (obj16.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control14 = obj16 as GUILabelControl;
                        if (DialogTitle == string.Empty)
                        {
                            if (control14.Label != string.Empty)
                            {
                                DialogTitle = control14.Label;
                            }
                        }
                        else if (control14.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + control14.Label;
                        }
                    }
                    if (obj16.GetType() == typeof(GUIButtonControl))
                    {
                        GUIButtonControl control15 = obj16 as GUIButtonControl;
                        if (!control15.Focus)
                        {
                            continue;
                        }
                        DialogHighlightedItem = control15.Description;
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_PROGRESS:
            {
                GUIDialogProgress progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)dialogWindow);
                foreach (object obj6 in progress.controlList)
                {
                    if (obj6.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control6 = obj6 as GUILabelControl;
                        if (control6.GetID == 1)
                        {
                            DialogTitle = control6.Label;
                        }
                    }
                }
                foreach (object obj7 in progress.controlList)
                {
                    if (obj7.GetType() == typeof(GUIProgressControl))
                    {
                        GUIProgressControl control7 = obj7 as GUIProgressControl;
                        DialogHighlightedItem = "Progress: " + control7.Percentage.ToString() + "%";
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_SELECT:
            {
                GUIDialogSelect select = (GUIDialogSelect)GUIWindowManager.GetWindow((int)dialogWindow);
                control = null;
                focus   = false;
                foreach (object obj9 in select.controlList)
                {
                    if (obj9.GetType() == typeof(GUIListControl))
                    {
                        control = obj9 as GUIListControl;
                        focus   = control.Focus;
                    }
                }
                if ((control != null) & focus)
                {
                    string strLabel = string.Empty;
                    string str5     = string.Empty;
                    string strThumb = string.Empty;
                    string strIndex = string.Empty;
                    control.GetSelectedItem(ref strLabel, ref str5, ref strThumb, ref strIndex);
                    DialogHighlightedItem = strLabel;
                }
                else
                {
                    foreach (object obj10 in select.controlList)
                    {
                        if (obj10.GetType() == typeof(GUIButtonControl))
                        {
                            GUIButtonControl control10 = obj10 as GUIButtonControl;
                            if (control10.Focus)
                            {
                                DialogHighlightedItem = control10.Description;
                            }
                        }
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_OK:
            {
                GUIDialogOK gok = (GUIDialogOK)GUIWindowManager.GetWindow((int)dialogWindow);
                foreach (object obj5 in gok.controlList)
                {
                    if (obj5.GetType() == typeof(GUIButtonControl))
                    {
                        GUIButtonControl control4 = obj5 as GUIButtonControl;
                        if (control4.Focus)
                        {
                            DialogHighlightedItem = control4.Description;
                            Settings.Instance.LogInfo(
                                "MiniDisplay.GetDialogInfo(): found WINDOW_DIALOG_OK buttoncontrol ID = {0} Label = \"{1}\" Desc = \"{2}\"",
                                control4.GetID, control4.Label, control4.Description);
                        }
                    }
                    if (obj5.GetType() == typeof(GUIFadeLabel))
                    {
                        GUIFadeLabel label = obj5 as GUIFadeLabel;
                        if (DialogTitle == string.Empty)
                        {
                            if (label.Label != string.Empty)
                            {
                                DialogTitle = label.Label;
                            }
                        }
                        else if (label.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + label.Label;
                        }
                    }
                    if (obj5.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control5 = obj5 as GUILabelControl;
                        if (DialogTitle == string.Empty)
                        {
                            if (control5.Label != string.Empty)
                            {
                                DialogTitle = control5.Label;
                            }
                            continue;
                        }
                        if (control5.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + control5.Label;
                        }
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_SELECT2:
            {
                GUIDialogSelect2 select2 = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)dialogWindow);
                control = null;
                focus   = false;
                foreach (object obj11 in select2.controlList)
                {
                    if (obj11.GetType() == typeof(GUIListControl))
                    {
                        control = obj11 as GUIListControl;
                        focus   = control.Focus;
                    }
                }
                if ((control != null) & focus)
                {
                    string str7     = string.Empty;
                    string str8     = string.Empty;
                    string str9     = string.Empty;
                    string strIndex = string.Empty;
                    control.GetSelectedItem(ref str7, ref str8, ref str9, ref strIndex);
                    DialogHighlightedItem = str7;
                }
                else
                {
                    foreach (object obj12 in select2.controlList)
                    {
                        if (obj12.GetType() == typeof(GUIButtonControl))
                        {
                            GUIButtonControl control11 = obj12 as GUIButtonControl;
                            if (control11.Focus)
                            {
                                DialogHighlightedItem = control11.Description;
                            }
                        }
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_MENU:
            {
                GUIDialogMenu menu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)dialogWindow);
                foreach (object obj13 in menu.controlList)
                {
                    if (obj13.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control12 = obj13 as GUILabelControl;
                        if (!control12.Label.Trim().ToLowerInvariant().Equals("menu"))
                        {
                            DialogTitle = control12.Label;
                        }
                    }
                }
                control = null;
                focus   = false;
                foreach (object obj14 in menu.controlList)
                {
                    if (obj14.GetType() == typeof(GUIListControl))
                    {
                        control = obj14 as GUIListControl;
                        focus   = control.Focus;
                    }
                }
                if ((control != null) & focus)
                {
                    string str10    = string.Empty;
                    string str11    = string.Empty;
                    string str12    = string.Empty;
                    string strIndex = string.Empty;
                    control.GetSelectedItem(ref str10, ref str11, ref str12, ref strIndex);
                    DialogHighlightedItem = str10;
                }
                else
                {
                    foreach (object obj15 in menu.controlList)
                    {
                        if (obj15.GetType() == typeof(GUIButtonControl))
                        {
                            GUIButtonControl control13 = obj15 as GUIButtonControl;
                            if (control13.Focus)
                            {
                                DialogHighlightedItem = control13.Description;
                            }
                        }
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_RATING:
            {
                GUIDialogSetRating rating = (GUIDialogSetRating)GUIWindowManager.GetWindow((int)dialogWindow);
                DialogTitle = string.Empty;
                foreach (object obj8 in rating.controlList)
                {
                    if (obj8.GetType() == typeof(GUIFadeLabel))
                    {
                        GUIFadeLabel label2 = obj8 as GUIFadeLabel;
                        if (DialogTitle == string.Empty)
                        {
                            if (label2.Label != string.Empty)
                            {
                                DialogTitle = label2.Label;
                            }
                        }
                        else if (label2.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + label2.Label;
                        }
                    }
                    if (obj8.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control8 = obj8 as GUILabelControl;
                        if (DialogTitle == string.Empty)
                        {
                            if (control8.Label != string.Empty)
                            {
                                DialogTitle = control8.Label;
                            }
                        }
                        else if (control8.Label != string.Empty)
                        {
                            DialogTitle = DialogTitle + " - " + control8.Label;
                        }
                    }
                    if (obj8.GetType() == typeof(GUIButtonControl))
                    {
                        GUIButtonControl control9 = obj8 as GUIButtonControl;
                        if (!control9.Focus)
                        {
                            continue;
                        }
                        DialogHighlightedItem = control9.Description;
                    }
                }
                return(true);
            }

            case GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT:
            {
                GUIDialogMenuBottomRight right = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)dialogWindow);
                DialogTitle = string.Empty;
                foreach (object obj2 in right.controlList)
                {
                    if (obj2.GetType() == typeof(GUILabelControl))
                    {
                        GUILabelControl control2 = obj2 as GUILabelControl;
                        if (!control2.Label.Trim().ToLowerInvariant().Equals("menu") && (control2.Label != string.Empty))
                        {
                            if (DialogTitle == string.Empty)
                            {
                                DialogTitle = control2.Label;
                            }
                            else
                            {
                                DialogTitle = DialogTitle + " - " + control2.Label;
                            }
                        }
                    }
                }
                control = null;
                focus   = false;
                foreach (object obj3 in right.controlList)
                {
                    if (obj3.GetType() == typeof(GUIListControl))
                    {
                        control = obj3 as GUIListControl;
                        focus   = control.Focus;
                    }
                }
                if ((control != null) & focus)
                {
                    string str      = string.Empty;
                    string str2     = string.Empty;
                    string str3     = string.Empty;
                    string strIndex = string.Empty;
                    control.GetSelectedItem(ref str, ref str2, ref str3, ref strIndex);
                    DialogHighlightedItem = str;
                }
                else
                {
                    foreach (object obj4 in right.controlList)
                    {
                        if (obj4.GetType() == typeof(GUIButtonControl))
                        {
                            GUIButtonControl control3 = obj4 as GUIButtonControl;
                            if (control3.Focus)
                            {
                                DialogHighlightedItem = control3.Description;
                            }
                        }
                    }
                }
                return(true);
            }
            }
            return(false);
        }
コード例 #8
0
        /// <summary>
        /// On Message
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
            {
                // fetch settings for the current capture card
                _cropSettings = TvCropManager.CropSettings;
                GUILabelControl cardLabel = GetControl((int)Controls.CONTROL_CARD_LABEL) as GUILabelControl;
                cardLabel.Visible = false;

                foreach (int iCtl in Enum.GetValues(typeof(Controls)))
                {
                    if (GetControl(iCtl) is GUISpinControl)
                    {
                        GUISpinControl cntl = (GUISpinControl)GetControl(iCtl);
                        cntl.ShowRange = false;
                    }
                }
                GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_TOP);
                for (int i = 0; i <= 200; ++i)
                {
                    GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_TOP, i.ToString());
                }
                GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_TOP, _cropSettings.Top);
                GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM);
                for (int i = 0; i <= 200; ++i)
                {
                    GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM, i.ToString());
                }
                GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_BOTTOM, _cropSettings.Bottom);
                GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_LEFT);
                for (int i = 0; i <= 200; ++i)
                {
                    GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_LEFT, i.ToString());
                }
                GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_LEFT, _cropSettings.Left);
                GUIControl.ClearControl(GetID, (int)Controls.CONTROL_CROP_RIGHT);
                for (int i = 0; i <= 200; ++i)
                {
                    GUIControl.AddItemLabelControl(GetID, (int)Controls.CONTROL_CROP_RIGHT, i.ToString());
                }
                GUIControl.SelectItemControl(GetID, (int)Controls.CONTROL_CROP_RIGHT, _cropSettings.Right);

                break;
            }

            case GUIMessage.MessageType.GUI_MSG_CLICKED:
            {
                int iControl = message.SenderControlId;
                if (iControl == (int)Controls.CONTROL_EXIT)
                {
                    Close();
                }
                else if (iControl == (int)Controls.CONTROL_CROP_TOP)
                {
                    // do not use message.Label, because it's empty for "page up/down", causing exceptions
                    _cropSettings.Top = (GetControl(iControl) as GUISpinControl).Value;
                }
                else if (iControl == (int)Controls.CONTROL_CROP_BOTTOM)
                {
                    _cropSettings.Bottom = (GetControl(iControl) as GUISpinControl).Value;
                }
                else if (iControl == (int)Controls.CONTROL_CROP_LEFT)
                {
                    _cropSettings.Left = (GetControl(iControl) as GUISpinControl).Value;
                }
                else if (iControl == (int)Controls.CONTROL_CROP_RIGHT)
                {
                    _cropSettings.Right = (GetControl(iControl) as GUISpinControl).Value;
                }

                // ativate & save settings for the current capture card
                TvCropManager.CropSettings = _cropSettings;

                break;
            }
            }
            return(base.OnMessage(message));
        }
コード例 #9
0
        protected void Update(bool selectCurrentShow)
        {
            lock (this)
            {
                if (GUIWindowManager.ActiveWindowEx != this.GetID)
                {
                    return;
                }

                // Skin settings may have changed via the MP GUI, reload them.
                LoadSkinSettings();

                // sets button visible state
                UpdateGroupButton();

                GUIButton3PartControl cntlChannelGroup = GetControl((int)Controls.CHANNEL_GROUP_BUTTON) as GUIButton3PartControl;
                cntlChannelGroup.RenderLeft           = false;
                cntlChannelGroup.RenderRight          = false;
                cntlChannelGroup.StretchIfNotRendered = true;
                if (_useColorsForButtons)
                {
                    cntlChannelGroup.ColourDiffuse = _guideColorGroupButton;
                }

                _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, labelTime.TextAlignment, 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 = GUIControl.Alignment.ALIGN_LEFT;
                    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;

                            imgBut.OverlayFileNameTFL  = buttonTemplate.OverlayFileNameTFL;
                            imgBut.OverlayFileNameTNFL = buttonTemplate.OverlayFileNameTNFL;
                            imgBut.OverlayFileNameTFM  = buttonTemplate.OverlayFileNameTFM;
                            imgBut.OverlayFileNameTNFM = buttonTemplate.OverlayFileNameTNFM;
                            imgBut.OverlayFileNameTFR  = buttonTemplate.OverlayFileNameTFR;
                            imgBut.OverlayFileNameTNFR = buttonTemplate.OverlayFileNameTNFR;
                        }
                        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.StretchIfNotRendered = true;
                    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.ImageAlignment == GUIControl.Alignment.ALIGN_CENTER);
                        imgBut.IconZoom            = cntlChannelImg.Zoom;
                    }
                    imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
                    imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
                    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
                {
                    TvBusinessLayer layer = new TvBusinessLayer();

                    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;
                        }
                    }
                    Dictionary <int, List <Program> > programs = layer.GetProgramsForAllChannels(Utils.longtodate(iStart),
                                                                                                 Utils.longtodate(iEnd),
                                                                                                 visibleChannels);
                    // 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;

                    int channelCount = _channelCount;
                    if (_previousChannelCount > channelCount)
                    {
                        channelCount = _previousChannelCount;
                    }

                    for (int iChannel = 0; iChannel < channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            GuideChannel tvGuideChannel = (GuideChannel)_channelList[chan];
                            RenderChannel(ref programs, 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();

                if (_showGenreKey)
                {
                    RenderGenreKey();
                }
            }
        }
コード例 #10
0
ファイル: GUIStatsAndInfo.cs プロジェクト: RoChess/mvcentral
        protected override void OnPageLoad()
        {
            base.OnPageLoad();

            // Listen for background events
            mvCentralCore.ProcessManager.Progress += new ProcessProgressDelegate(ProcessManager_Progress);
            // Set initial propery valuesus
            GUIPropertyManager.SetProperty("#mvCentral.Metadata.Update.Progress", Localization.Inactive);
            GUIPropertyManager.SetProperty("#mvCentral.Artwork.Update.Progress", Localization.Inactive);

            GUILabelControl.SetControlLabel(GetID, (int)GUIControls.versionLabel, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            List <DBTrackInfo>  videoList  = DBTrackInfo.GetAll();
            List <DBArtistInfo> artistList = DBArtistInfo.GetAll();

            // Set stats
            GUILabelControl.SetControlLabel(GetID, (int)GUIControls.videoCountLabel, string.Format(Localization.VideoCount, videoList.Count, artistList.Count));
            // Set Hierachy
            GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.History);
            // Get the most viewed video
            videoList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return(p2.ActiveUserSettings.WatchedCount.CompareTo(p1.ActiveUserSettings.WatchedCount)); });
            if (videoList[0].ActiveUserSettings.WatchedCount == 0)
            {
                GUIPropertyManager.SetProperty("#mvCentral.MostPlayed", " ");
            }
            else
            {
                GUIPropertyManager.SetProperty("#mvCentral.MostPlayed", videoList[0].Track);
            }

            favVideoImage.FileName = videoList[0].ArtFullPath;

            try
            {
                // Set the Top ten list - sure there is a neater way of doing this....
                if (videoList[0].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen1.Label = string.Format(" 1 - {0} - {1}", videoList[0].ArtistInfo[0].Artist.ToString(), videoList[0].Track.ToString());
                }

                if (videoList[1].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen2.Label = string.Format(" 2 - {0} - {1}", videoList[1].ArtistInfo[0].Artist, videoList[1].Track);
                }

                if (videoList[2].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen3.Label = string.Format(" 3 - {0} - {1}", videoList[2].ArtistInfo[0].Artist, videoList[2].Track);
                }

                if (videoList[3].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen4.Label = string.Format(" 4 - {0} - {1}", videoList[3].ArtistInfo[0].Artist, videoList[3].Track);
                }

                if (videoList[4].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen5.Label = string.Format(" 5 - {0} - {1}", videoList[4].ArtistInfo[0].Artist, videoList[4].Track);
                }

                if (videoList[5].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen6.Label = string.Format(" 6 - {0} - {1}", videoList[5].ArtistInfo[0].Artist, videoList[5].Track);
                }

                if (videoList[6].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen7.Label = string.Format(" 7 - {0} - {1}", videoList[6].ArtistInfo[0].Artist, videoList[6].Track);
                }

                if (videoList[7].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen8.Label = string.Format(" 8 - {0} - {1}", videoList[7].ArtistInfo[0].Artist, videoList[7].Track);
                }

                if (videoList[8].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen9.Label = string.Format(" 9 - {0} - {1}", videoList[8].ArtistInfo[0].Artist, videoList[8].Track);
                }

                if (videoList[9].ActiveUserSettings.WatchedCount > 0)
                {
                    topTen10.Label = string.Format("10 - {0} - {1}", videoList[9].ArtistInfo[0].Artist, videoList[9].Track);
                }
            }
            catch { }

            // Get the most viewed artist
            int          watchedCount      = 0;
            int          higestWatchCount  = 0;
            DBArtistInfo mostWatchedArtist = null;

            foreach (DBArtistInfo artist in artistList)
            {
                List <DBTrackInfo> artistTracks = DBTrackInfo.GetEntriesByArtist(artist);
                watchedCount = 0;
                foreach (DBTrackInfo track in artistTracks)
                {
                    watchedCount += track.ActiveUserSettings.WatchedCount;
                }
                if (watchedCount > higestWatchCount)
                {
                    higestWatchCount  = watchedCount;
                    mostWatchedArtist = artist;
                }
            }
            if (mostWatchedArtist != null)
            {
                GUIPropertyManager.SetProperty("#mvCentral.FavArtist", mostWatchedArtist.Artist);
                favArtistImage.FileName = mostWatchedArtist.ArtThumbFullPath;
            }
            else
            {
                GUIPropertyManager.SetProperty("#mvCentral.FavArtist", " ");
            }
        }