From: <mis...@us...> - 2007-09-18 21:50:14
|
Revision: 938 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=938&view=rev Author: misterd_sf Date: 2007-09-18 14:50:12 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Step1 of Mplayer 0.8 - Refactored the external player plugin for further improvements - Added osd library (MP like) - NEEDS more cpu power than MPlayer OSD - BETA !! - Can be used by other plugins - Internal Plugin for MPI. Initial Configuration wizard - Bugfixes for several small issues (e.g. handling of pause, audio stream handling) - Improved seeking. Further improvements needed. Therefor seeking is disabled, when no length can be estimated. and ...... Modified Paths: -------------- trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationForm.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationForm.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationForm.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationManager.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/MPlayer_ExtPlayer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/MPlayer_ExtPlayer.csproj trunk/plugins/My MPlayer/MPlayer_ExtPlayer/Properties/AssemblyInfo.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationForm.Designer.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationForm.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationForm.resx trunk/plugins/My MPlayer/MPlayer_GUIPlugin/MPlayer_GUIPlugin.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/MPlayer_GUIPlugin.csproj trunk/plugins/My MPlayer/MPlayer_GUIPlugin/Properties/AssemblyInfo.cs trunk/plugins/My MPlayer/My Mplayer.sln Added Paths: ----------- trunk/plugins/My MPlayer/ExternalOSDLibrary/ trunk/plugins/My MPlayer/ExternalOSDLibrary/BaseWindow.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/DialogWindow.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/BaseElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ButtonElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/CheckMarkElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/FadeLabelElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ImageElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/LabelElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ListElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ProgressControlElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/SliderElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/TextScrollUpElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ToggleButtonElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/VerticalScrollbarElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/VolumeBarElement.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/ExternalOSDLibrary.csproj trunk/plugins/My MPlayer/ExternalOSDLibrary/FullscreenWindow.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/OSDController.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/OSDForm.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/OSDWindow.cs trunk/plugins/My MPlayer/ExternalOSDLibrary/Properties/ trunk/plugins/My MPlayer/ExternalOSDLibrary/Properties/AssemblyInfo.cs trunk/plugins/My MPlayer/MPlayer-License.txt trunk/plugins/My MPlayer/MPlayer_ExtPlayer/AudioSubtitleHandler.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/ trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/AudioSection.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/AudioSection.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/AudioSection.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/ExtensionSettings.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/ExtensionSettings.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/ExtensionSettings.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/GeneralSection.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/GeneralSection.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/GeneralSection.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/StreamSection.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/StreamSection.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/StreamSection.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/SubtitleSection.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/SubtitleSection.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/SubtitleSection.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/VideoSection.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/VideoSection.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ConfigurationPanel/VideoSection.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ExternalOSDLibrary.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/IMessageHandler.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/IOSDHandler.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/InternalOSDHandler.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/Properties/Resources.Designer.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/Properties/Resources.resx trunk/plugins/My MPlayer/MPlayer_ExtPlayer/SeekingHandler.cs trunk/plugins/My MPlayer/MPlayer_ExtPlayer/VideoHandler.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationPanel/ trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationPanel/GUIConfiguration.Designer.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationPanel/GUIConfiguration.cs trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ConfigurationPanel/GUIConfiguration.resx trunk/plugins/My MPlayer/MPlayer_Installer/ trunk/plugins/My MPlayer/MPlayer_Installer/ConfigurationWizard.Designer.cs trunk/plugins/My MPlayer/MPlayer_Installer/ConfigurationWizard.cs trunk/plugins/My MPlayer/MPlayer_Installer/ConfigurationWizard.resx trunk/plugins/My MPlayer/MPlayer_Installer/Installer.cs trunk/plugins/My MPlayer/MPlayer_Installer/MPlayer_Installer.csproj trunk/plugins/My MPlayer/MPlayer_Installer/Properties/ trunk/plugins/My MPlayer/MPlayer_Installer/Properties/AssemblyInfo.cs trunk/plugins/My MPlayer/MPlayer_Installer/config.ico Removed Paths: ------------- trunk/plugins/My MPlayer/License.txt trunk/plugins/My MPlayer/Liesmich.pdf trunk/plugins/My MPlayer/Readme.pdf Property Changed: ---------------- trunk/plugins/My MPlayer/MPlayer_ExtPlayer/ trunk/plugins/My MPlayer/MPlayer_GUIPlugin/ Property changes on: trunk/plugins/My MPlayer/ExternalOSDLibrary ___________________________________________________________________ Name: svn:ignore + bin obj Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/BaseWindow.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/BaseWindow.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/BaseWindow.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,136 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using MediaPortal.GUI.Library; +using System.Windows; + +namespace ExternalOSDLibrary { + /// <summary> + /// Base class for all MP windows that can be handled by this library + /// </summary> + public abstract class BaseWindow { + #region variables + /// <summary> + /// List of all elements of the window + /// </summary> + protected List<BaseElement> _elementList; + #endregion + + #region protected methods + /// <summary> + /// Generates the elements of a window, which are stored in the UIElementCollection + /// </summary> + /// <param name="collection">Collection of all GUIControls</param> + protected void GenerateElements(UIElementCollection collection) { + _elementList = new List<BaseElement>(); + GUIControl temp; + BaseElement element; + foreach (UIElement uiElement in collection) { + temp = uiElement as GUIControl; + if (temp != null) { + element = GenerateElement(temp); + if(element!=null){ + _elementList.Add(element); + } + } + } + } + + /// <summary> + /// Generates a single element based on the type of the GUIControl + /// Supported Types: + /// - GUIListControl + /// - GUITextScrollUpControl + /// - GUICheckMarkControl + /// - GUISliderControl + /// - GUIToggleButtonControl + /// - GUIButtonControl + /// - GUIFadeLabel + /// - GUIProgressControl + /// - GUIVolumeBar + /// - GUILabelControl + /// - GUIImage + /// </summary> + /// <param name="control">Control</param> + /// <returns>Elmenet based on the GUIControl</returns> + protected BaseElement GenerateElement(GUIControl control) { + if (control.GetType() == typeof(GUIImage)) { + return new ImageElement(control); + } else if (control.GetType() == typeof(GUILabelControl)) { + return new LabelElement(control); + } else if (control.GetType() == typeof(GUIVolumeBar)) { + return new VolumeBarElement(control); + } else if (control.GetType() == typeof(GUIProgressControl)) { + return new ProgressControlElement(control); + } else if (control.GetType() == typeof(GUIFadeLabel)) { + return new FadeLabelElement(control); + } else if (control.GetType() == typeof(GUIButtonControl)) { + return new ButtonElement(control); + } else if (control.GetType() == typeof(GUIToggleButtonControl)) { + return new ToggleButtonElement(control); + } else if (control.GetType() == typeof(GUISliderControl)) { + return new SliderElement(control); + } else if (control.GetType() == typeof(GUICheckMarkControl)) { + return new CheckMarkElement(control); + } else if (control.GetType() == typeof(GUITextScrollUpControl)) { + return new TextScrollUpElement(control); + } else if (control.GetType() == typeof(GUIListControl)) { + return new ListElement(control); + } + Log.Debug("VIDEOPLAYER_OSD FOUND UNEXPECTED TYPE: " + control.GetType().ToString()); + return null; + } + #endregion + + #region public methods + /// <summary> + /// Draws the window on the given graphics + /// </summary> + /// <param name="graph">Graphics of the bitmap</param> + public void DrawWindow(Graphics graph) { + try { + if (IsWindowVisible()) { + foreach (BaseElement element in _elementList) { + element.DrawElement(graph); + } + } + } catch (Exception ex) { + Log.Error(ex); + } + } + #endregion + + #region abstract methods + /// <summary> + /// Indicates if the window is currently visible + /// </summary> + /// <returns>true, if window is visible; false otherwise</returns> + public abstract bool IsWindowVisible(); + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/DialogWindow.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/DialogWindow.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/DialogWindow.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,68 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Text; +using System.Windows.Forms; +using MediaPortal.Dialogs; +using MediaPortal.GUI.Library; +using System.Windows; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class handles all related tasks for the GUIDialogMenu (Context menu) window + /// </summary> + public class DialogWindow : BaseWindow { + #region variables + /// <summary> + /// Dialog Menu window + /// </summary> + private GUIDialogMenu _dialogWindow; + #endregion + + #region ctor + /// <summary> + /// Constructor, which creates all elements + /// </summary> + public DialogWindow() { + _dialogWindow = GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU) as GUIDialogMenu; + UIElementCollection collection = _dialogWindow.controlList; + GenerateElements(collection); + } + #endregion + + #region implemented abstract methods + /// <summary> + /// Indicates if the window is currently visible + /// </summary> + /// <returns>true, if window is visible; false otherwise</returns> + public override bool IsWindowVisible() { + return GUIWindowManager.RoutedWindow == _dialogWindow.GetID; + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/BaseElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/BaseElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/BaseElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,124 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// Base class for all gui elements + /// </summary> + public abstract class BaseElement { + #region abstract methods + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public abstract void DrawElement(Graphics graph); + #endregion + + #region protected methods + /// <summary> + /// Updates a bitmap. It converts the Color (0,0,0) and (1,1,1), so that they won't be drawn transparent + /// if the alpha value is more than 150 + /// </summary> + /// <param name="bitmap">Bitmap to update</param> + protected void updateBitmap(Bitmap bitmap) { + Color temp; + for (int i = 0; i < bitmap.Width; i++) { + for (int j = 0; j < bitmap.Height; j++) { + temp = bitmap.GetPixel(i, j); + if (temp.R == 0 && temp.G == 0 && temp.B == 0 && temp.A > 150) { + bitmap.SetPixel(i, j, Color.FromArgb(temp.A, 5, 5, 5)); + } + if (temp.R == 1 && temp.G == 1 && temp.B == 1 && temp.A > 150) { + bitmap.SetPixel(i, j, Color.FromArgb(temp.A, 5, 5, 5)); + } + } + } + } + + /// <summary> + /// Creates a color for the given value. And guarantees that it doesn't get transparent + /// </summary> + /// <param name="colorValue">Value of the color</param> + /// <returns>Color struct</returns> + protected Color GetColor(long colorValue) { + Color color = Color.FromArgb((int)colorValue); + if (color.R == 0 && color.G == 0 && color.B == 0) { + color = Color.FromArgb(5, 5, 5); + } + if (color.R == 1 && color.G == 1 && color.B == 1) { + color = Color.FromArgb(5, 5, 5); + } + return color; + } + + /// <summary> + /// Creates a font object based on the given name + /// </summary> + /// <param name="name">Name of the font</param> + /// <returns>Font </returns> + protected Font getFont(String name) { + GUIFont guiFont = GUIFontManager.GetFont(name); + Type guiFontType = typeof(GUIFont); + FieldInfo styleFieldInfo = guiFontType.GetField("_fontStyle", + BindingFlags.NonPublic | BindingFlags.Instance); + FontStyle style = (FontStyle)styleFieldInfo.GetValue(guiFont); + return new Font(guiFont.FileName, guiFont.FontSize, style); + } + + /// <summary> + /// Loads the bitmap with the given filename + /// </summary> + /// <param name="fileName">Filename of the bitmap</param> + /// <returns>Bitmap</returns> + protected Bitmap loadBitmap(String fileName) { + Bitmap result = null; + String realFileName = GUIPropertyManager.Parse(fileName); + String location = GUIGraphicsContext.Skin + @"\media\" + realFileName; + if (File.Exists(location)) { + result = new Bitmap(location); + updateBitmap(result); + } + return result; + } + #endregion + + #region public methods + /// <summary> + /// Draws the element for the cache status. Only implemented in some elements + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="cacheFill">Status of the cache</param> + public virtual void DrawCacheStatus(Graphics graph, float cacheFill) { + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ButtonElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ButtonElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ButtonElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,180 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Reflection; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUIButtoncontrol + /// </summary> + public class ButtonElement : BaseElement { + #region variables + /// <summary> + /// GUIButtonControl + /// </summary> + private GUIButtonControl _button; + + /// <summary> + /// Focus image + /// </summary> + private Bitmap _focusBitmap; + + /// <summary> + /// Non focus image + /// </summary> + private Bitmap _noFocusBitmap; + + /// <summary> + /// Hover image + /// </summary> + private Bitmap _hoverBitmap; + + /// <summary> + /// Font + /// </summary> + private Font _font; + + /// <summary> + /// Text color + /// </summary> + private Color _textColor; + + /// <summary> + /// Text color non focus + /// </summary> + private Color _textColorNoFocus; + + /// <summary> + /// Disabled text color + /// </summary> + private Color _disabledColor; + + /// <summary> + /// X-coordinate of the hover image + /// </summary> + private int _hoverX; + + /// <summary> + /// Y-coordinate of the hover image + /// </summary> + private int _hoverY; + + /// <summary> + /// Width of the hover image + /// </summary> + private int _hoverWidth; + + /// <summary> + /// Height of the hover image + /// </summary> + private int _hoverHeight; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public ButtonElement(GUIControl control) { + _button = control as GUIButtonControl; + _font = getFont(_button.FontName); + _focusBitmap = loadBitmap(_button.TexutureFocusName); + _noFocusBitmap = loadBitmap(_button.TexutureNoFocusName); + Type buttonType = typeof(GUIButtonControl); + FieldInfo hoverFileNameFieldInfo = buttonType.GetField("_hoverFilename", + BindingFlags.NonPublic | BindingFlags.Instance); + _hoverBitmap = loadBitmap(hoverFileNameFieldInfo.GetValue(_button).ToString()); + _textColor = GetColor(_button.TextColor); + FieldInfo textColorNoFocusFieldInfo = buttonType.GetField("_textColorNoFocus", + BindingFlags.NonPublic | BindingFlags.Instance); + _textColorNoFocus = GetColor(long.Parse(textColorNoFocusFieldInfo.GetValue(_button).ToString())); + _disabledColor = GetColor(_button.DisabledColor); + FieldInfo hoverXFieldInfo = buttonType.GetField("_hoverX", + BindingFlags.NonPublic | BindingFlags.Instance); + _hoverX = Int32.Parse(hoverXFieldInfo.GetValue(_button).ToString()); + FieldInfo hoverYFieldInfo = buttonType.GetField("_hoverY", + BindingFlags.NonPublic | BindingFlags.Instance); + _hoverY = Int32.Parse(hoverYFieldInfo.GetValue(_button).ToString()); + FieldInfo hoverWidthFieldInfo = buttonType.GetField("_hoverWidth", + BindingFlags.NonPublic | BindingFlags.Instance); + _hoverWidth = Int32.Parse(hoverWidthFieldInfo.GetValue(_button).ToString()); + FieldInfo hoverHeightFieldInfo = buttonType.GetField("_hoverHeight", + BindingFlags.NonPublic | BindingFlags.Instance); + _hoverHeight = Int32.Parse(hoverHeightFieldInfo.GetValue(_button).ToString()); + Log.Debug("VideoPlayerOSD: Found button element: " + _button.GetID); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_button.Visible) { + if (_button.Focus) { + if (_focusBitmap != null) { + graph.DrawImage(_focusBitmap, (float)_button.Location.X, (float)_button.Location.Y, (float)_button.Size.Width, (float)_button.Size.Height); + } + if (_hoverBitmap != null) { + graph.DrawImage(_hoverBitmap, _hoverX, _hoverY, _hoverWidth, _hoverHeight); + } + } else { + if (_noFocusBitmap != null) { + graph.DrawImage(_noFocusBitmap, (float)_button.Location.X, (float)_button.Location.Y, (float)_button.Size.Width, (float)_button.Size.Height); + } + } + int labelWidth = _button.Width - 2 * _button.TextOffsetX; + if (labelWidth <= 0) { + return; + } + SolidBrush brush = new SolidBrush(_button.Disabled ? _disabledColor : _button.Focus ? _textColor : _textColorNoFocus); + + // render the text on the button + int x = 0; + + switch (_button.TextAlignment) { + case GUIControl.Alignment.ALIGN_LEFT: + x = _button.TextOffsetX + _button.XPosition; + break; + + case GUIControl.Alignment.ALIGN_RIGHT: + x = _button.XPosition + _button.Width - _button.TextOffsetX; + break; + } + Rectangle rectangle = new Rectangle(x, _button.YPosition + _button.TextOffsetY, labelWidth, _button.Height); + String label = _button.Label; + graph.DrawString(GUIPropertyManager.Parse(label), _font, brush, rectangle, StringFormat.GenericTypographic); + } + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/CheckMarkElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/CheckMarkElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/CheckMarkElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,153 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Reflection; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUICheckMarkControl + /// </summary> + public class CheckMarkElement : BaseElement { + #region variables + /// <summary> + /// GUICheckMarkControl + /// </summary> + private GUICheckMarkControl _checkMark; + + /// <summary> + /// Check focus image + /// </summary> + private Bitmap _checkFocusBitmap; + + /// <summary> + /// Check non focus image + /// </summary> + private Bitmap _checkNoFocusBitmap; + + /// <summary> + /// Width of the checkMark + /// </summary> + private int _checkMarkWidth; + + /// <summary> + /// Height of the checkMark + /// </summary> + private int _checkMarkHeight; + + /// <summary> + /// Font + /// </summary> + private Font _font; + + /// <summary> + /// Disabled text color + /// </summary> + private Color _disabledColor; + + /// <summary> + /// Text color + /// </summary> + private Color _textColor; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public CheckMarkElement(GUIControl control) { + _checkMark = control as GUICheckMarkControl; + Type buttonType = typeof(GUICheckMarkControl); + FieldInfo checkFocusFieldInfo = buttonType.GetField("_checkMarkFocusTextureName", + BindingFlags.NonPublic | BindingFlags.Instance); + _checkFocusBitmap = loadBitmap(checkFocusFieldInfo.GetValue(_checkMark).ToString()); + FieldInfo checkNoFocusFieldInfo = buttonType.GetField("_checkMarkNoFocusTextureName", + BindingFlags.NonPublic | BindingFlags.Instance); + _checkNoFocusBitmap = loadBitmap(checkNoFocusFieldInfo.GetValue(_checkMark).ToString()); + FieldInfo checkMarkWidthFieldInfo = buttonType.GetField("_checkMarkWidth", + BindingFlags.NonPublic | BindingFlags.Instance); + _checkMarkWidth = Int32.Parse(checkMarkWidthFieldInfo.GetValue(_checkMark).ToString()); + FieldInfo checkMarkHeightFieldInfo = buttonType.GetField("_checkMarkHeight", + BindingFlags.NonPublic | BindingFlags.Instance); + _checkMarkHeight = Int32.Parse(checkMarkHeightFieldInfo.GetValue(_checkMark).ToString()); + _font = getFont(_checkMark.FontName); + _disabledColor = GetColor(_checkMark.DisabledColor); + _textColor = GetColor(_checkMark.TextColor); + Log.Debug("VideoPlayerOSD: Found checkMark element: " + _checkMark.GetID); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_checkMark.Visible) { + int dwTextPosX = _checkMark.XPosition; + int dwCheckMarkPosX = _checkMark.XPosition; + Rectangle _rectangle = new Rectangle() ; + _rectangle.X = _checkMark.YPosition; + _rectangle.Y = _checkMark.YPosition; + _rectangle.Height = _checkFocusBitmap.Height; + if (null != _font) { + SizeF sizeF ; + if (_checkMark.TextAlignment == GUIControl.Alignment.ALIGN_LEFT) { + sizeF = graph.MeasureString(_checkMark.Label, _font); + dwCheckMarkPosX += ((int)(sizeF.Width) + 5); + } else { + dwTextPosX = (dwCheckMarkPosX + _checkFocusBitmap.Width + 5); + sizeF = graph.MeasureString(_checkMark.Label, _font); + } + if (_checkMark.Disabled) { + SolidBrush brush = new SolidBrush(_disabledColor); + graph.DrawString(_checkMark.Label, _font, brush, dwTextPosX, _checkMark.YPosition); + } else { + if (_checkMark.Focus) { + SolidBrush brush = new SolidBrush(_textColor); + graph.DrawString(_checkMark.Label, _font, brush, dwTextPosX, _checkMark.YPosition); + } + else { + SolidBrush brush = new SolidBrush(_disabledColor); + graph.DrawString(_checkMark.Label, _font, brush, dwTextPosX, _checkMark.YPosition); + } + } + } + if (_checkMark.Selected) { + graph.DrawImage(_checkFocusBitmap, dwCheckMarkPosX, _checkMark.YPosition); + } else { + graph.DrawImage(_checkNoFocusBitmap, dwCheckMarkPosX, _checkMark.YPosition); + } + } + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/FadeLabelElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/FadeLabelElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/FadeLabelElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,89 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUIFadeLabel + /// </summary> + public class FadeLabelElement : BaseElement { + #region variables + /// <summary> + /// GUIFadeLabel + /// </summary> + private GUIFadeLabel _label; + + /// <summary> + /// Font + /// </summary> + private Font _font; + + /// <summary> + /// Brush + /// </summary> + private Brush _brush; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public FadeLabelElement(GUIControl control) { + _label = control as GUIFadeLabel; + _font = getFont(_label.FontName); + _brush = new SolidBrush(GetColor(_label.TextColor)); + Log.Debug("VideoPlayerOSD: Found label element: " + _label.Name + "/" + _font.Name); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_label.Visible) { + GUIControl.Alignment alignment = _label.TextAlignment; + RectangleF rectangle; + String text = GUIPropertyManager.Parse(_label.Label); + SizeF sizeF = graph.MeasureString(text, _font); + if (alignment == GUIControl.Alignment.ALIGN_LEFT) { + rectangle = new RectangleF((float)_label.Location.X, (float)_label.Location.Y, _label.Width, _label.Height); + } else if (alignment == GUIControl.Alignment.ALIGN_RIGHT) { + rectangle = new RectangleF((float)_label.Location.X - sizeF.Width, (float)_label.Location.Y, _label.Width, _label.Height); + } else { + rectangle = new RectangleF((float)_label.Location.X - (sizeF.Width / 2), (float)_label.Location.Y - (sizeF.Height / 2), _label.Width, _label.Height); + } + graph.DrawString(text, _font, _brush, rectangle,StringFormat.GenericTypographic); + } + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ImageElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ImageElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ImageElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,106 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUIImage + /// </summary> + public class ImageElement : BaseElement { + #region variables + /// <summary> + /// GUIImage + /// </summary> + private GUIImage _image; + + /// <summary> + /// Image of this element + /// </summary> + private Bitmap _bitmap; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public ImageElement(GUIControl control) { + _image = control as GUIImage; + _bitmap = loadBitmap(_image.FileName); + Log.Debug("VideoPlayerOSD: Found image element: " + _image.FileName); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_image.Visible &&!_image.FileName.Equals("black.bmp")) { + DrawElementAlternative(graph,GetImageRectangle()); + } + } + #endregion + + #region public methods + /// <summary> + /// Gets the rectangle of the image + /// </summary> + /// <returns>Rectangle of the image</returns> + public RectangleF GetImageRectangle() { + return new RectangleF(_image.XPosition, _image.YPosition, _image.Width, _image.Height); + } + + /// <summary> + /// Draws the element for additional osd informations + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="rectangle">Rectangle of the image</param> + public void DrawElementAlternative(Graphics graph,RectangleF rectangle) { + if (_bitmap != null) { + graph.DrawImage(_bitmap, rectangle); + } + } + #endregion + + #region public overrides methods + /// <summary> + /// Draws the element for the cache status. + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="cacheFill">Status of the cache</param> + public override void DrawCacheStatus(Graphics graph, float cacheFill) { + DrawElementAlternative(graph,GetImageRectangle()); + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/LabelElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/LabelElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/LabelElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,140 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUILabelControl + /// </summary> + public class LabelElement : BaseElement { + #region variables + /// <summary> + /// GUILabelControl + /// </summary> + private GUILabelControl _label; + + /// <summary> + /// Font + /// </summary> + private Font _font; + + /// <summary> + /// Brush + /// </summary> + private Brush _brush; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public LabelElement(GUIControl control) { + _label = control as GUILabelControl; + _font = getFont(_label.FontName); + _brush = new SolidBrush(GetColor(_label.TextColor)); + Log.Debug("VideoPlayerOSD: Found label element: " + _label.Name + "/" + _font.Name); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_label.Visible) { + DrawStandard(graph, _label.Label); + } + } + #endregion + + #region public methods + /// <summary> + /// Draws the element for additional osd informations + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="label">Label content</param> + /// <param name="strikeout">Strikeout the label, when true</param> + /// <param name="rectangle">Rectangle for the label</param> + public void DrawElementAlternative(Graphics graph, String label, bool strikeout, RectangleF rectangle) { + Font temp = _font; + if (strikeout) { + FontStyle style = _font.Style | FontStyle.Strikeout; + temp = new Font(_font.FontFamily.Name, _font.Size, style); + } + graph.DrawString(GUIPropertyManager.Parse(label), temp, _brush, rectangle, StringFormat.GenericTypographic); + } + + /// <summary> + /// Returns the rectangle for the given label + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="label">Label</param> + /// <returns>Rectangle</returns> + public RectangleF GetStringRectangle(Graphics graph, String label) { + SizeF size = graph.MeasureString(label, _font); + return new RectangleF((float)_label.Location.X, (float)_label.Location.Y, size.Width, _label.Height); + } + #endregion + + #region public overrides methods + /// <summary> + /// Draws the element for the cache status. Only implemented in some elements + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="cacheFill">Status of the cache</param> + public override void DrawCacheStatus(Graphics graph, float cacheFill) { + if(_label.Label.Contains("#currentremaining")){ + DrawStandard(graph, String.Format("{0:00.00}", cacheFill) + " %"); + } + } + #endregion + + #region private methods + /// <summary> + /// Draws the element in its standard way + /// </summary> + /// <param name="graph">Graphics</param> + /// <param name="label">Label</param> + private void DrawStandard(Graphics graph, String label) { + GUIControl.Alignment alignment = _label.TextAlignment; + RectangleF rectangle; + if (alignment == GUIControl.Alignment.ALIGN_LEFT) { + rectangle = new RectangleF((float)_label.Location.X, (float)_label.Location.Y, _label.Width, _label.Height); + } else if (alignment == GUIControl.Alignment.ALIGN_RIGHT) { + rectangle = new RectangleF((float)_label.Location.X - _label.TextWidth, (float)_label.Location.Y, _label.Width, _label.Height); + } else { + rectangle = new RectangleF((float)_label.Location.X - (_label.TextWidth / 2), (float)_label.Location.Y - (_label.TextHeight / 2), _label.Width, _label.Height); + } + DrawElementAlternative(graph, label, false, rectangle); + } + #endregion + } +} Added: trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ListElement.cs =================================================================== --- trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ListElement.cs (rev 0) +++ trunk/plugins/My MPlayer/ExternalOSDLibrary/Elements/ListElement.cs 2007-09-18 21:50:12 UTC (rev 938) @@ -0,0 +1,870 @@ +#region Copyright (C) 2006-2007 MisterD + +/* + * Copyright (C) 2006-2007 MisterD + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Reflection; +using System.Text; +using MediaPortal.GUI.Library; + +namespace ExternalOSDLibrary { + /// <summary> + /// This class represents a GUIListElement + /// </summary> + public class ListElement : BaseElement { + #region internal classes + /// <summary> + /// Internal class for ListButtons + /// </summary> + private class ListButtonElement : BaseElement { + #region variables + /// <summary> + /// Focus + /// </summary> + private bool _focus; + + /// <summary> + /// Image focus + /// </summary> + private Bitmap _imageFocus; + + /// <summary> + /// Image non focus + /// </summary> + private Bitmap _imageNonFocus; + + /// <summary> + /// X Position + /// </summary> + private int _positionX; + + /// <summary> + /// Y Position + /// </summary> + private int _positionY; + + /// <summary> + /// Width + /// </summary> + private float _width; + + /// <summary> + /// Height + /// </summary> + private float _height; + #endregion + + #region ctor + /// <summary> + /// Creates the listbutton element + /// </summary> + /// <param name="positionX">X Position</param> + /// <param name="positionY">Y Position</param> + /// <param name="width">Width</param> + /// <param name="height">Height</param> + /// <param name="buttonFocusName">FileName of the focus image</param> + /// <param name="buttonNonFocusName">FileName of the non focus image</param> + public ListButtonElement(int positionX, int positionY, float width, float height, String buttonFocusName, String buttonNonFocusName) { + _imageFocus = loadBitmap(buttonFocusName); + _imageNonFocus = loadBitmap(buttonNonFocusName); + _positionX = positionX; + _positionY = positionY; + _width = width; + _height = height; + _focus = false; + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_focus) { + if (_imageFocus != null) { + graph.DrawImage(_imageFocus, _positionX, _positionY, _width, _height); + } + } else { + if (_imageNonFocus != null) { + graph.DrawImage(_imageNonFocus, _positionX, _positionY, _width, _height); + } + } + } + #endregion + + #region properties + /// <summary> + /// Gets/Sets the focus + /// </summary> + public bool Focus { + get { return _focus; } + set { _focus = value; } + } + #endregion + + #region public methods + /// <summary> + /// Sets the position + /// </summary> + /// <param name="x">X Position</param> + /// <param name="y">Y Position</param> + public void SetPosition(int x, int y) { + _positionX = x; + _positionY = y; + } + #endregion + + } + + /// <summary> + /// Internal class for ListLabels + /// </summary> + private class ListLabelElement : BaseElement { + #region variables + /// <summary> + /// Alignment + /// </summary> + private GUIControl.Alignment _alignment; + + /// <summary> + /// X Position + /// </summary> + private float _xPosition; + + /// <summary> + /// Y Position + /// </summary> + private float _yPosition; + + /// <summary> + /// Width + /// </summary> + private float _width; + + /// <summary> + /// Height + /// </summary> + private float _height; + + /// <summary> + /// Font + /// </summary> + private Font _font; + + /// <summary> + /// Brush + /// </summary> + private SolidBrush _brush; + + /// <summary> + /// Label + /// </summary> + private String _label; + #endregion + + #region ctor + /// <summary> + /// Creates the element + /// </summary> + public ListLabelElement() { + _xPosition = 0f; + _yPosition = 0f; + _width = 0f; + _height = 0f; + _label = String.Empty; + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + RectangleF rectangle; + SizeF stringSize = graph.MeasureString(_label, _font); + if (_alignment == GUIControl.Alignment.ALIGN_LEFT) { + rectangle = new RectangleF(_xPosition, _yPosition, _width, _height); + } else if (_alignment == GUIControl.Alignment.ALIGN_RIGHT) { + rectangle = new RectangleF(_xPosition - stringSize.Width, _yPosition, _width, _height); + } else { + rectangle = new RectangleF(_xPosition - (stringSize.Width / 2), _yPosition - (stringSize.Height / 2), _width, _height); + } + graph.DrawString(GUIPropertyManager.Parse(_label), _font, _brush, rectangle, StringFormat.GenericTypographic); + } + #endregion + + #region properties + /// <summary> + /// Gets/Sets the alignment + /// </summary> + public GUIControl.Alignment Alignment { + get { return _alignment; } + set { _alignment = value; } + } + + /// <summary> + /// Gets/Sets the x position + /// </summary> + public float XPosition { + get { return _xPosition; } + set { _xPosition = value; } + } + + /// <summary> + /// Gets/Sets the y position + /// </summary> + public float YPosition { + get { return _yPosition; } + set { _yPosition = value; } + } + + /// <summary> + /// Gets/Sets the width + /// </summary> + public float Width { + get { return _width; } + set { _width = value; } + } + + /// <summary> + /// Gets/Sets the height + /// </summary> + public float Height { + get { return _height; } + set { _height = value; } + } + + /// <summary> + /// Gets/Sets the label + /// </summary> + public String Label { + get { return _label; } + set { _label = value; } + } + + /// <summary> + /// Gets/Sets the font + /// </summary> + public Font Font { + get { return _font; } + set { _font = value; } + } + + /// <summary> + /// Gets/Sets the brush + /// </summary> + public SolidBrush Brush { + get { return _brush; } + set { _brush = value; } + } + #endregion + + #region public methods + /// <summary> + /// Returns the size of the string of this listlabel element + /// </summary> + /// <param name="graph">Graphics</param> + /// <returns>Size of the label</returns> + public SizeF GetStringSize(Graphics graph) { + return graph.MeasureString(_label, _font); + } + #endregion + } + #endregion + + #region variables + /// <summary> + /// GUIListControl + /// </summary> + private GUIListControl _list; + + /// <summary> + /// Items per page + /// </summary> + private int _itemsPerPage; + + /// <summary> + /// Offset + /// </summary> + private int _offset; + + /// <summary> + /// Cursor position + /// </summary> + private int _cursorX; + + /// <summary> + /// DrawFocus + /// </summary> + private bool _drawFocus; + + /// <summary> + /// ListType + /// </summary> + private GUIListControl.ListType _listType; + + /// <summary> + /// Alignment of the elements + /// </summary> + private GUIControl.Alignment _alignment; + + /// <summary> + /// List of the buttons + /// </summary> + private List<ListButtonElement> _listButtons; + + /// <summary> + /// List of the items + /// </summary> + private List<GUIListItem> _listItems; + + /// <summary> + /// List of the Label1's + /// </summary> + private List<ListLabelElement> _labelControls1; + + /// <summary> + /// List of the Label2's + /// </summary> + private List<ListLabelElement> _labelControls2; + + /// <summary> + /// List of the Label3's + /// </summary> + private List<ListLabelElement> _labelControls3; + + /// <summary> + /// Cached Images + /// </summary> + private Dictionary<String, Bitmap> _cachedBitmaps; + + /// <summary> + /// Reflection field info for listItems + /// </summary> + private FieldInfo _listItemsFieldInfo; + + /// <summary> + /// Reflection field info for the offset + /// </summary> + private FieldInfo _offsetFieldInfo; + + /// <summary> + /// Reflection field info for the cursor position + /// </summary> + private FieldInfo _cursorXFieldInfo; + + /// <summary> + /// Played Color + /// </summary> + private long _playedColor; + + /// <summary> + /// Remote Color + /// </summary> + private long _remoteColor; + + /// <summary> + /// Download Color + /// </summary> + private long _downloadColor; + + /// <summary> + /// Text line + /// </summary> + private String _textLine; + + /// <summary> + /// VerticalScrollbarElement + /// </summary> + private VerticalScrollBarElement _verticalScrollBarElement; + #endregion + + #region ctor + /// <summary> + /// Creates the element and retrieves all information from the control + /// </summary> + /// <param name="control">GUIControl</param> + public ListElement(GUIControl control) { + _list = control as GUIListControl; + Type listType = typeof(GUIListControl); + FieldInfo alignmentFieldInfo = listType.GetField("_textAlignment", + BindingFlags.NonPublic | BindingFlags.Instance); + _alignment = (GUIControl.Alignment)alignmentFieldInfo.GetValue(_list); + + FieldInfo listTypeFieldInfo = listType.GetField("_listType", + BindingFlags.NonPublic | BindingFlags.Instance); + _listType = (GUIListControl.ListType)listTypeFieldInfo.GetValue(_list); + + FieldInfo drawFocusFieldInfo = listType.GetField("_drawFocus", + BindingFlags.NonPublic | BindingFlags.Instance); + _drawFocus = (bool)drawFocusFieldInfo.GetValue(_list); + + _cursorXFieldInfo = listType.GetField("_cursorX", + BindingFlags.NonPublic | BindingFlags.Instance); + _cursorX = (int)_cursorXFieldInfo.GetValue(_list); + + _offsetFieldInfo = listType.GetField("_offset", + BindingFlags.NonPublic | BindingFlags.Instance); + _offset = (int)_offsetFieldInfo.GetValue(_list); + + FieldInfo itemsPerPageFieldInfo = listType.GetField("_itemsPerPage", + BindingFlags.NonPublic | BindingFlags.Instance); + _itemsPerPage = (int)itemsPerPageFieldInfo.GetValue(_list); + + FieldInfo playedColorFieldInfo = listType.GetField("_playedColor", + BindingFlags.NonPublic | BindingFlags.Instance); + _playedColor = (int)itemsPerPageFieldInfo.GetValue(_list); + + FieldInfo remoteColorFieldInfo = listType.GetField("_remoteColor", + BindingFlags.NonPublic | BindingFlags.Instance); + _remoteColor = (long)remoteColorFieldInfo.GetValue(_list); + + FieldInfo downloadColorFieldInfo = listType.GetField("_downloadColor", + BindingFlags.NonPublic | BindingFlags.Instance); + _downloadColor = (long)downloadColorFieldInfo.GetValue(_list); + + FieldInfo spinControlPositionXFieldInfo = listType.GetField("_spinControlPositionX", + BindingFlags.NonPublic | BindingFlags.Instance); + int spinControlPositionX = (int)spinControlPositionXFieldInfo.GetValue(_list); + FieldInfo spinControlPositionYFieldInfo = listType.GetField("_spinControlPositionY", + BindingFlags.NonPublic | BindingFlags.Instance); + int spinControlPositionY = (int)spinControlPositionYFieldInfo.GetValue(_list); + _listButtons = new List<ListButtonElement>(); + _labelControls1 = new List<ListLabelElement>(); + _labelControls2 = new List<ListLabelElement>(); + _labelControls3 = new List<ListLabelElement>(); + _cachedBitmaps = new Dictionary<String, Bitmap>(); + AllocButtons(spinControlPositionX, spinControlPositionY); + _listItemsFieldInfo = listType.GetField("_listItems", + BindingFlags.NonPublic | BindingFlags.Instance); + initializeLabels(); + _verticalScrollBarElement = new VerticalScrollBarElement(_list.Scrollbar); + Log.Debug("VideoPlayerOSD: Found list element: "); + } + #endregion + + #region implmenented abstract method + /// <summary> + /// Draws the element on the given graphics + /// </summary> + /// <param name="graph">Graphics</param> + public override void DrawElement(Graphics graph) { + if (_list.Visible) { + _listItems = _listItemsFieldInfo.GetValue(_list) as List<GUIListItem>; + _offset = (int)_offsetFieldInfo.GetValue(_list); + _cursorX = (int)_cursorXFieldInfo.GetValue(_list); + int dwPosY = _list.YPosition; + // Render the buttons first. + for (int i = 0; i < _itemsPerPage; i++) { + if (i + _offset < _listItems.Count) { + // render item + bool gotFocus = false; + if (_drawFocus && i == _cursorX && _list.IsFocused && _listType == GUIListControl.ListType.CONTROL_LIST) + gotFocus = true; + RenderButton(graph, i, _list.XPosition, dwPosY, gotFocus); + } + dwPosY += _list.ItemHeight + _list.Space; + } + + // Render new item list + dwPosY = _list.YPosition; + for (int i = 0; i < _itemsPerPage; i++) { + int dwPosX = _list.XPosition; + if (i + _offset < _listItems.Count) { + int iconX; + int labelX; + int pinX; + + int ten = 10; + GUIGraphicsContext.ScaleHorizontal(ref ten); + switch (_alignment) { + case GUIControl.Alignm... [truncated message content] |