Click here to Skip to main content
13,832,258 members
Click here to Skip to main content

Stats

730.8K views
29.9K downloads
281 bookmarked
Posted 14 Sep 2010
Licenced CPOL

PVS.AVPlayer - MCI Audio and Video Library

, 7 Aug 2018
Windows Media Control Interface (MCI) library with many added features
PVS.AVPlayer
PVS.AVPlayer .NET 2.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 3.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 3.5
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.5
PVS.AVPlayer .NET 4.5.1
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.5.2
PVS.AVPlayer.XML
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6.1
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6.2
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.7
PVS.AVPlayer .NET 4.7.1
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.7.2
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer All Source Code
AVPlayerExample
AVPlayerExample
AVPlayerExample.csproj.user
bin
Debug
PVS.AVPlayer.XML
Release
Dialogs
Display Overlays
obj
Debug
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
WingDings3a.ttf
Voice Recorder
FolderView
FolderView
bin
Debug
PVS.AVPlayer.XML
Release
FolderView.csproj.user
obj
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
PVS.AVPlayer
AVPlayerExample.csproj.user
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Custom Items
Native Methods
Bob.png
Crystal Italic1.ttf
Dial Green 2.png
Dial Green 4.png
Dial Green.png
Dial Red 2.png
Dial Red.png
media7.ico
media7a.ico
Media8.ico
Media8a.ico
VU Meter.png
WingDings3a.ttf
Sound Recorder
Various
About Dialog
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Custom Items
FolderView.csproj.user
Debug
Bob.png
Crystal Italic1.ttf
media7a.ico
media7b.ico
Media8a.ico
Media8b.ico
Subtitles Overlay
Various
How To (C#)
PVSAVPlayerHowTo
bin
Debug
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Release
obj
Debug
Release
Properties
How To (VB.NET)
PVSAVPlayerHowToVB
bin
Debug
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Release
My Project
Application.myapp
obj
Debug
Release
PVSAVPlayerHowTo.vbproj.user
PVS.AVPlayer Examples
AVPlayerExample.ex_
FolderView.ex_
AVPlayerExample.exe
FolderView.exe
PVS.AVPlayer.dll
#region Usings

using PVS.AVPlayer;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

#endregion

namespace AVPlayerExample
{
    // Clone Window
    // A Form used as a display clone of the main player.

    #region Clone Shapes Enum

    internal enum CloneShape
    {
        None,
        Columns,
        Heart,
        Oval,
        Rectangular,
        Rounded,
        Rows,
        Spiral,
        Star
    }

    #endregion

    public partial class CloneWindow : Form
    {
        #region Fields

        private MainWindow      _baseWindow;
        private Player          _basePlayer;
        internal string         CloneTitle;

        private bool            _fullScreen;
        private FormWindowState _oldWindowState;

        private bool            _stretchMode;

        private bool            _hasSizeEvent;
        private bool            _hasShapeEvents;
        private CloneShape      _cloneShape = CloneShape.None;

        private Timer           _timer; 

        #endregion

        // ******************************** Main / Eventhandlers

        #region Main / Eventhandlers

        public CloneWindow(MainWindow mainWindow, Player player, string title)
        {
            InitializeComponent();

            _baseWindow     = mainWindow;
            _basePlayer     = player;
            CloneTitle      = title;

            _basePlayer.CursorHide.Add(this);

            _timer          = new Timer();
            _timer.Interval = 100;
            _timer.Tick     += Timer_Tick;

            KeyPreview      = true;
            KeyDown         += CloneWindow_KeyDown;

            ((ToolStripDropDownMenu)hideMainWindowMenuItem.DropDown).ShowImageMargin = false;

        }

        private void SetShapeEvents()
        {
            if (!_hasShapeEvents && !_stretchMode)
            {
                _basePlayer.Events.MediaStarted += BasePlayer_MediaStarted;
                _basePlayer.Events.MediaDisplayModeChanged += BasePlayer_MediaDisplayModeChanged;
                _hasShapeEvents = true;
            }

            if (!_hasSizeEvent)
            {
                ClientSizeChanged += CloneWindow_ClientSizeChanged;
                _hasSizeEvent = true;
            }
        }

        private void RemoveShapeEvents()
        {
            if (_hasShapeEvents)
            {
                _basePlayer.Events.MediaStarted -= BasePlayer_MediaStarted;
                _basePlayer.Events.MediaDisplayModeChanged -= BasePlayer_MediaDisplayModeChanged;
                _hasShapeEvents = false;
            }

            if (_hasSizeEvent && _cloneShape == CloneShape.None)
            {
                ClientSizeChanged -= CloneWindow_ClientSizeChanged;
                _hasSizeEvent = false;
            }
        }

        private void BasePlayer_MediaStarted(object sender, EventArgs e)
        {
            if (_cloneShape != CloneShape.None) UpdateDisplayShape();
        }

        private void BasePlayer_MediaDisplayModeChanged(object sender, EventArgs e)
        {
            if (_cloneShape != CloneShape.None) UpdateDisplayShape();
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            // used with rotating shapes

            Region region = Region.Clone();
            Matrix transformMatrix = new Matrix();
            transformMatrix.RotateAt(10, new Point(Width / 2, Height / 2));
            region.Transform(transformMatrix);
            Region = region;
        }

        private void CloneWindow_ClientSizeChanged(object sender, EventArgs e)
        {
            if (_cloneShape != CloneShape.None) UpdateDisplayShape();
        }

        private void CloneWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (_fullScreen && e.KeyCode == Keys.Escape)
            {
                e.Handled = true;
                fullScreenMenuItem.PerformClick();
            }
        }

        private void CloneWindow_FormClosed(object sender, FormClosedEventArgs e)
        {
            _timer.Dispose();

            _baseWindow.CloneWindows_Remove(this);
            if (_hasShapeEvents || _hasSizeEvent) RemoveShapeEvents();

            if (_baseWindow.Opacity == 0 && _basePlayer.DisplayClones.Count == 0)
            {
                _baseWindow.Opacity = 1;
                if (_basePlayer.HasOverlay) _basePlayer.Overlay.Window.Opacity = 1;
            }
        }

        #endregion

        // ******************************** Drag Borderless Form

        #region Drag Borderless Form

        private const int WM_NCLBUTTONDOWN = 0xA1;
        private const int HT_CAPTION = 0x2;
        private void Control_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && WindowState != FormWindowState.Maximized)
            {
                this.Cursor = Cursors.SizeAll;
                ((Control)sender).Capture = false;
                Message msg = Message.Create(Handle, WM_NCLBUTTONDOWN, (IntPtr)HT_CAPTION, IntPtr.Zero);
                base.WndProc(ref msg);
                this.Cursor = Cursors.Default;
            }
        }

        #endregion

        // ******************************** Context Menu Handling

        #region Context Menu Handling

        #region Display Mode

        private void ZoomMenuItem_Click(object sender, System.EventArgs e)
        {
            if (_stretchMode)
            {
                zoomMenuItem.Checked = true;
                stretchMenuItem.Checked = false;
                displayModeMenuItem.Checked = false;
                _basePlayer.DisplayClones.SetLayout(this, CloneLayout.Zoom);

                _stretchMode = false;
                if (_cloneShape != CloneShape.None)
                {
                    UpdateDisplayShape();
                    SetShapeEvents();
                }
            }
        }

        private void StretchMenuItem_Click(object sender, System.EventArgs e)
        {
            if (!_stretchMode)
            {
                zoomMenuItem.Checked = false;
                stretchMenuItem.Checked = true;
                displayModeMenuItem.Checked = true;
                _basePlayer.DisplayClones.SetLayout(this, CloneLayout.Stretch);

                _stretchMode = true;
                if (_cloneShape != CloneShape.None) UpdateDisplayShape();
                RemoveShapeEvents();
            }
        }

        #endregion

        #region Display Shapes

        private void ColumnsShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Columns);
        }

        private void HeartShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Heart);
        }

        private void OvalShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Oval);
        }

        private void RectangularShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Rectangular);
        }

        private void RoundedShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Rounded);
        }

        private void RowsShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Rows);
        }

        private void SpiralShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Spiral);
        }

        private void StarShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.Star);
        }

        private void RotatingShapeMenuItem_Click(object sender, EventArgs e)
        {
            rotatingShapeMenuItem.Checked = !rotatingShapeMenuItem.Checked;
            if (rotatingShapeMenuItem.Checked)
            {
                if (_cloneShape != CloneShape.None) _timer.Start();
            }
            else
            {
                _timer.Stop();
            }
        }

        private void NormalShapeMenuItem_Click(object sender, EventArgs e)
        {
            SetDisplayShape(CloneShape.None);
        }

        #endregion

        #region Flip Mode

        private void FlipXMenuItem_Click(object sender, EventArgs e)
        {
            _basePlayer.DisplayClones.SetFlip(this, CloneFlip.FlipX);
            SetFlipMode(flipXMenuItem);
        }

        private void FlipXYMenuItem_Click(object sender, EventArgs e)
        {
            _basePlayer.DisplayClones.SetFlip(this, CloneFlip.FlipXY);
            SetFlipMode(flipXYMenuItem);
        }

        private void FlipYMenuItem_Click(object sender, EventArgs e)
        {
            _basePlayer.DisplayClones.SetFlip(this, CloneFlip.FlipY);
            SetFlipMode(flipYMenuItem);
        }

        private void FlipNoneMenuItem_Click(object sender, EventArgs e)
        {
            _basePlayer.DisplayClones.SetFlip(this, CloneFlip.FlipNone);
            SetFlipMode(flipNoneMenuItem);
        }

        private void SetFlipMode(ToolStripMenuItem setItem)
        {
            flipXMenuItem.Checked = false;
            flipXYMenuItem.Checked = false;
            flipYMenuItem.Checked = false;
            flipNoneMenuItem.Checked = false;

            setItem.Checked = true;
            flipModeMenuItem.Checked = setItem != flipNoneMenuItem;
        }

        #endregion

        #region Quality Mode

        private void NormalQualityMenuItem_Click(object sender, System.EventArgs e)
        {
            normalQualityMenuItem.Checked = true;
            highQualityMenuItem.Checked = false;
            cloneQualityMenuItem.Checked = false;
            _basePlayer.DisplayClones.SetQuality(this, CloneQuality.Auto);
        }

        private void HighQualityMenuItem_Click(object sender, System.EventArgs e)
        {
            normalQualityMenuItem.Checked = false;
            highQualityMenuItem.Checked = true;
            cloneQualityMenuItem.Checked = true;
            _basePlayer.DisplayClones.SetQuality(this, CloneQuality.High);
        }

        #endregion

        #region Opacity

        private void Opacity25MenuItem_Click(object sender, EventArgs e)
        {
            Opacity = 0.25;
            SetOpacityMenu(sender);
        }

        private void Opacity50MenuItem_Click(object sender, EventArgs e)
        {
            Opacity = 0.5;
            SetOpacityMenu(sender);
        }

        private void Opacity75MenuItem_Click(object sender, EventArgs e)
        {
            Opacity = 0.75;
            SetOpacityMenu(sender);
        }

        private void Opacity100MenuItem_Click(object sender, EventArgs e)
        {
            Opacity = 1;
            SetOpacityMenu(sender);
        }

        // Checks the selected Opacity menu item and removes the check marks from the others
        private void SetOpacityMenu(object sender)
        {
            foreach (ToolStripItem item in (((ToolStripMenuItem)sender).GetCurrentParent().Items))
            {
                if (item.GetType() == typeof(ToolStripMenuItem))
                {
                    ((ToolStripMenuItem)item).Checked = item == sender;
                }
            }
            opacityMenuItem.Checked = (Opacity != 1);
        }

        #endregion

        #region FullScreen

        private void FullScreenMenuItem_Click(object sender, EventArgs e)
        {
            _fullScreen = !_fullScreen;
            fullScreenMenuItem.Checked = _fullScreen;

            if (_fullScreen)
            {
                _oldWindowState = WindowState;
                if (WindowState == FormWindowState.Maximized) WindowState = FormWindowState.Normal;

                if (_cloneShape == CloneShape.None) FormBorderStyle = FormBorderStyle.None;
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                if (_cloneShape == CloneShape.None) FormBorderStyle = FormBorderStyle.Sizable;
                WindowState = _oldWindowState;
            }

            if (_cloneShape != CloneShape.None) UpdateDisplayShape();
        }

        #endregion

        #region Show In Taskbar / Always On Top

        private void ShowInTaskbarMenuItem_Click(object sender, System.EventArgs e)
        {
            showInTaskbarMenuItem.Checked = !showInTaskbarMenuItem.Checked;
            ShowInTaskbar = showInTaskbarMenuItem.Checked;
        }

        private void AlwaysOnTopMenuItem_Click(object sender, System.EventArgs e)
        {
            alwaysOnTopMenuItem.Checked = !alwaysOnTopMenuItem.Checked;
            TopMost = alwaysOnTopMenuItem.Checked;
        }

        #endregion

        #region Main Window

        private void HideMainWindowMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            if (_baseWindow.Opacity > 0)
            {
                hideWindowMenuItem.Enabled = true;
                showWindowMenuItem.Enabled = false;
            }
            else
            {
                hideWindowMenuItem.Enabled = false;
                showWindowMenuItem.Enabled = true;
            }
        }

        private void HideWindowMenuItem_Click(object sender, EventArgs e)
        {
            _baseWindow.Opacity = 0;
            if (_basePlayer.HasOverlay) _basePlayer.Overlay.Window.Opacity = 0;
        }

        private void ShowWindowMenuItem_Click(object sender, EventArgs e)
        {
            _baseWindow.Opacity = 1;
            _baseWindow.Activate();
            if (_basePlayer.HasOverlay) _basePlayer.Overlay.Window.Opacity = 1;
        }

        #endregion

        #region Close

        private void CloseMenuItem_Click(object sender, System.EventArgs e)
        {
            Close();
        }

        #endregion

        #endregion

        // ******************************** Set Display Shapes

        #region Set Display Shapes

        private void SetDisplayShape(CloneShape shape)
        {
            if (shape != _cloneShape)
            {
                // set form border
                if (shape == CloneShape.None)
                {
                    if (_cloneShape != CloneShape.None)
                    {
                        _timer.Stop();

                        BackColor = Color.FromArgb(18, 18, 18);
                        TransparencyKey = Color.Empty;
                        if (!_fullScreen) FormBorderStyle = FormBorderStyle.Sizable;
                        if (Region != null)
                        {
                            Region.Dispose();
                            Region = null;
                        }
                        RemoveShapeEvents();
                    }
                }
                else
                {
                    if (_cloneShape == CloneShape.None)
                    {
                        TransparencyKey = Color.RosyBrown;
                        BackColor = Color.RosyBrown;
                        if (!_fullScreen) FormBorderStyle = FormBorderStyle.None;

                        if (rotatingShapeMenuItem.Checked) _timer.Start();
                    }
                }

                // uncheck menu items
                int count = displayShapeMenuItem.DropDown.Items.Count;
                for (int i = 0; i < count; i++)
                {
                    // untill the first separator
                    if (displayShapeMenuItem.DropDown.Items[i].GetType() == typeof(ToolStripSeparator)) break;
                    ((ToolStripMenuItem)displayShapeMenuItem.DropDown.Items[i]).Checked = false;
                }
                if (shape != CloneShape.None) normalShapeMenuItem.Checked = false;

                // check menu item
                switch (shape)
                {
                    case CloneShape.Columns:
                        columnsShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Heart:
                        heartShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Oval:
                        ovalShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Rectangular:
                        rectangularShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Rounded:
                        roundedShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Rows:
                        rowsShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Spiral:
                        spiralShapeMenuItem.Checked = true;
                        break;

                    case CloneShape.Star:
                        starShapeMenuItem.Checked = true;
                        break;

                    // No shape
                    default:
                        normalShapeMenuItem.Checked = true;
                        break;
                }

                // parent border menu item
                displayShapeMenuItem.Checked = !normalShapeMenuItem.Checked;

                // set form shape
                _cloneShape = shape;
                if (_cloneShape != CloneShape.None)
                {
                    UpdateDisplayShape();
                    SetShapeEvents();
                }
            }
        }

        private void UpdateDisplayShape()
        {
            switch (_cloneShape)
            {
                case CloneShape.Columns:
                    SetColumnsShape();
                    break;

                case CloneShape.Heart:
                    SetHeartShape();
                    break;

                case CloneShape.Oval:
                    SetOvalShape();
                    break;

                case CloneShape.Rectangular:
                    SetRectangularShape();
                    break;

                case CloneShape.Rounded:
                    SetRoundedShape();
                    break;

                case CloneShape.Rows:
                    SetRowsShape();
                    break;

                case CloneShape.Spiral:
                    SetSpiralShape();
                    break;

                case CloneShape.Star:
                    SetStarShape();
                    break;

                // No shape
                default:
                    break;
            }
        }

        private void SetColumnsShape()
        {
            //float VBLINDS = (2 * _baseWindow._random.Next(7, 24)) + 1; // use odd number
            const float VBLINDS = 47; // use odd number

            Rectangle r1 = _basePlayer.DisplayClones.GetVideoBounds(this);
            RectangleF r2 = r1;

            GraphicsPath path = new GraphicsPath();

            r2.Width = r1.Width / VBLINDS;
            r2.Height = r1.Height;

            for (int i = 0; i < VBLINDS; i += 2)
            {
                r2.X = r1.X + (i * r2.Width);
                path.AddRectangle(r2);
            }

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetHeartShape()
        {
            Rectangle r = _basePlayer.DisplayClones.GetVideoBounds(this);

            // x and y units
            float x = r.Width / 6f;
            float y = r.Height / 6f;

            GraphicsPath path = new GraphicsPath();
            path.FillMode = FillMode.Winding;

            path.AddEllipse(new RectangleF(r.X, r.Y, 3.1f * x, 3 * y));
            path.AddEllipse(new RectangleF(r.X + (2.9f * x), r.Y, 3.1f * x, 3 * y));

            PointF[] points = new PointF[4];

            //points[0].X = r.X + (0.1f * x);
            //points[0].Y = r.Y + (2f * y);

            //points[1].X = r.X + (5.9f * x);
            //points[1].Y = r.Y + (2f * y);

            //points[2].X = r.X + (3 * x);
            //points[2].Y = r.Y + (6 * y);

            //points[3].X = r.X + (0.1f * x);
            //points[3].Y = r.Y + (2f * y);

            //path.AddPolygon(points);


            points[0].X = r.X + (0.085f * x);
            points[0].Y = r.Y + (2f * y);

            points[1].X = r.X + (5.78f * x);
            points[1].Y = r.Y + (2f * y);

            points[2].X = r.X + (3 * x);
            points[2].Y = r.Y + (6 * y);

            points[3].X = r.X + (0.085f * x);
            points[3].Y = r.Y + (2f * y);

            path.AddCurve(points, 0.2f);

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetOvalShape()
        {
            GraphicsPath path = new GraphicsPath();
            path.AddEllipse(_basePlayer.DisplayClones.GetVideoBounds(this));

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetRectangularShape()
        {
            Rectangle r = _basePlayer.DisplayClones.GetVideoBounds(this);
            //r.Width++;
            //r.Height++;

            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(r);

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetRoundedShape()
        {
            Rectangle r = _basePlayer.DisplayClones.GetVideoBounds(this);
            r.Width += r.Left + 1;
            r.Height += r.Top + 1;

            IntPtr handle = SafeNativeMethods.CreateRoundRectRgn(
                r.Left,
                r.Top,
                r.Width,
                r.Height,
                48,
                48);
            Region = Region.FromHrgn(handle);
            SafeNativeMethods.DeleteObject(handle);
        }

        private void SetRowsShape()
        {
            // float HBLINDS = (2 * _baseWindow._random.Next(11, 24)) + 1; // use odd number
            const float HBLINDS = 47; // use odd number

            Rectangle r1 = _basePlayer.DisplayClones.GetVideoBounds(this);
            RectangleF r2 = r1;

            GraphicsPath path = new GraphicsPath();

            r2.Width = r1.Width;
            r2.Height = r1.Height / HBLINDS;

            for (int i = 0; i < HBLINDS; i += 2)
            {
                r2.Y = r1.Y + (i * r2.Height);
                path.AddRectangle(r2);
            }

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetSpiralShape()
        {
            Rectangle r1 = _basePlayer.DisplayClones.GetVideoBounds(this);
            RectangleF r2 = r1;
            GraphicsPath path = new GraphicsPath();

            // x and y units
            float x = r1.Width / 14f;
            float y = r1.Height / 14f;

            // 1
            //r2.X = r1.X;
            //r2.Y = r1.Y;
            r2.Width = 14 * x;
            r2.Height = 2 * y;
            path.AddRectangle(r2);

            // 2
            r2.X = r1.X;
            r2.Y = r1.Y + (2 * y);
            r2.Width = 2 * x;
            r2.Height = 12 * y;
            path.AddRectangle(r2);

            // 3
            r2.X = r1.X + (2 * x);
            r2.Y = r1.Y + (12 * y);
            r2.Width = 12 * x;
            r2.Height = 2 * y;
            path.AddRectangle(r2);

            // 4 - open
            r2.X = r1.X + (12 * x);
            r2.Y = r1.Y + (3 * y);
            r2.Width = 2 * x;
            r2.Height = 9 * y;
            path.AddRectangle(r2);

            //// 4 - closed
            //r.X = r1.X + (12 * x);
            //r.Y = r1.Y + (2 * y);
            //r.Width = 2 * x;
            //r.Height = 10 * y;
            //path.AddRectangle(r);

            // 5
            r2.X = r1.X + (3 * x);
            r2.Y = r1.Y + (3 * y);
            r2.Width = 9 * x;
            r2.Height = 2 * y;
            path.AddRectangle(r2);

            // 6
            r2.X = r1.X + (3 * x);
            r2.Y = r1.Y + (5 * y);
            r2.Width = 2 * x;
            r2.Height = 6 * y;
            path.AddRectangle(r2);

            // 7
            r2.X = r1.X + (5 * x);
            r2.Y = r1.Y + (9 * y);
            r2.Width = 6 * x;
            r2.Height = 2 * y;
            path.AddRectangle(r2);

            // 8
            r2.X = r1.X + (9 * x);
            r2.Y = r1.Y + (6 * y);
            r2.Width = 2 * x;
            r2.Height = 3 * y;
            path.AddRectangle(r2);

            // 9
            r2.X = r1.X + (6 * x);
            r2.Y = r1.Y + (6 * y);
            r2.Width = 3 * x;
            r2.Height = 2 * y;
            path.AddRectangle(r2);

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        private void SetStarShape()
        {
            Rectangle r = _basePlayer.DisplayClones.GetVideoBounds(this);

            // x and y units
            float x = r.Width / 6f;
            float y = r.Height / 6f;

            PointF[] points = new PointF[17];

            points[0].X = r.X;
            points[0].Y = r.Y;

            points[1].X = r.X + (2.5f * x);
            points[1].Y = r.Y + (1.5f * y);

            points[2].X = r.X + (3 * x);
            points[2].Y = r.Y;

            points[3].X = r.X + (3.5f * x);
            points[3].Y = r.Y + (1.5f * y);

            points[4].X = r.X + (6 * x);
            points[4].Y = r.Y;

            points[5].X = r.X + (4.5f * x);
            points[5].Y = r.Y + (2.5f * y);

            points[6].X = r.X + (6 * x);
            points[6].Y = r.Y + (3 * y);

            points[7].X = r.X + (4.5f * x);
            points[7].Y = r.Y + (3.5f * y);

            points[8].X = r.X + (6 * x);
            points[8].Y = r.Y + (6 * y);

            points[9].X = r.X + (3.5f * x);
            points[9].Y = r.Y + (4.5f * y);

            points[10].X = r.X + (3 * x);
            points[10].Y = r.Y + (6 * y);

            points[11].X = r.X + (2.5f * x);
            points[11].Y = r.Y + (4.5f * y);

            points[12].X = r.X;
            points[12].Y = r.Y + (6 * y);

            points[13].X = r.X + (1.5f * x);
            points[13].Y = r.Y + (3.5f * y);

            points[14].X = r.X;
            points[14].Y = r.Y + (3 * y);

            points[15].X = r.X + (1.5f * x);
            points[15].Y = r.Y + (2.5f * y);

            points[16].X = r.X;
            points[16].Y = r.Y;

            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(points);

            if (Region != null) Region.Dispose();
            Region = new Region(path);
            path.Dispose();
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Peter Vegter
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190114.1 | Last Updated 7 Aug 2018
Article Copyright 2010 by Peter Vegter
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid