stuff working

This commit is contained in:
Brett Sanderson 2016-03-08 00:19:33 -05:00
parent 8ba905e256
commit 385954f90f
7 changed files with 99 additions and 7 deletions

View File

@ -88,6 +88,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TransparentPanel.cs">
<SubType>Component</SubType>
</Compile>
<EmbeddedResource Include="KaraokeVideoPlayer.resx">
<DependentUpon>KaraokeVideoPlayer.cs</DependentUpon>
</EmbeddedResource>

View File

@ -29,7 +29,9 @@
private void InitializeComponent()
{
this.vlcPlayer = new Vlc.DotNet.Forms.VlcControl();
this.panelVideo = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.vlcPlayer)).BeginInit();
this.panelVideo.SuspendLayout();
this.SuspendLayout();
//
// vlcPlayer
@ -52,16 +54,28 @@
this.vlcPlayer.VlcLibDirectoryNeeded += new System.EventHandler<Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs>(this.vlcPlayer_VlcLibDirectoryNeeded);
this.vlcPlayer.Playing += new System.EventHandler<Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs>(this.vlcPlayer_Playing);
this.vlcPlayer.TimeChanged += new System.EventHandler<Vlc.DotNet.Core.VlcMediaPlayerTimeChangedEventArgs>(this.vlcPlayer_TimeChanged);
this.vlcPlayer.DoubleClick += new System.EventHandler(this.vlcPlayer_DoubleClick);
//
// panelVideo
//
this.panelVideo.Controls.Add(this.vlcPlayer);
this.panelVideo.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelVideo.Location = new System.Drawing.Point(0, 0);
this.panelVideo.Name = "panelVideo";
this.panelVideo.Size = new System.Drawing.Size(428, 330);
this.panelVideo.TabIndex = 2;
//
// KaraokeVideoPlayer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.vlcPlayer);
this.Controls.Add(this.panelVideo);
this.Name = "KaraokeVideoPlayer";
this.Size = new System.Drawing.Size(428, 330);
this.DoubleClick += new System.EventHandler(this.KaraokeVideoPlayer_DoubleClick);
this.ParentChanged += new System.EventHandler(this.KaraokeVideoPlayer_ParentChanged);
((System.ComponentModel.ISupportInitialize)(this.vlcPlayer)).EndInit();
this.panelVideo.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -69,5 +83,6 @@
#endregion
private Vlc.DotNet.Forms.VlcControl vlcPlayer;
private System.Windows.Forms.Panel panelVideo;
}
}

View File

@ -55,7 +55,7 @@ namespace KaraokePlayer
{
if (ParentForm != null)
{
_overlayForm = new OverlayForm(this);
_overlayForm = new OverlayForm(this);
}
}
@ -63,5 +63,20 @@ namespace KaraokePlayer
{
e.VlcLibDirectory = new DirectoryInfo(@"lib\vlc\");
}
private void vlcPlayer_DoubleClick(object sender, EventArgs e)
{
}
private void KaraokeVideoPlayer_DoubleClick(object sender, EventArgs e)
{
}
private void panel1_DoubleClick(object sender, EventArgs e)
{
}
}
}

View File

@ -21,5 +21,7 @@ namespace KaraokePlayer
{
karaokeVideoPlayer1.Play(new Uri(@"D:\Karaoke\SF360 February 2016\SF360-01 - Charlie Puth - One Call Away\SF360-01 - Charlie Puth - One Call Away.mp3"));
}
}
}

View File

@ -41,6 +41,7 @@
this.Graphic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.Graphic.TabIndex = 0;
this.Graphic.TabStop = false;
this.Graphic.DoubleClick += new System.EventHandler(this.Graphic_DoubleClick);
//
// OverlayForm
//
@ -50,6 +51,7 @@
this.Controls.Add(this.Graphic);
this.Name = "OverlayForm";
this.Text = "OverlayForm";
this.DoubleClick += new System.EventHandler(this.OverlayForm_DoubleClick);
((System.ComponentModel.ISupportInitialize)(this.Graphic)).EndInit();
this.ResumeLayout(false);

View File

@ -12,7 +12,9 @@ namespace KaraokePlayer
public OverlayForm(ContainerControl parent)
{
InitializeComponent();
Graphic.BackColor = Color.Transparent;
_parent = parent;
BackColor = Color.FromArgb(1, 1, 1);
TransparencyKey = Color.FromArgb(1, 1, 1);
@ -21,17 +23,19 @@ namespace KaraokePlayer
ShowInTaskbar = false;
StartPosition = FormStartPosition.Manual;
AutoScaleMode = AutoScaleMode.None;
Location = parent.PointToScreen(Point.Empty);
ClientSize = parent.ClientSize;
Show(parent);
parent.ParentForm.LocationChanged += Cover_LocationChanged;
parent.ClientSizeChanged += Cover_ClientSizeChanged;
parent.LocationChanged += Cover_LocationChanged;
parent.VisibleChanged += Cover_LocationChanged;
parent.ClientSizeChanged += Cover_ClientSizeChanged;
// Disable Aero transitions, the plexiglass gets too visible
if (Environment.OSVersion.Version.Major >= 6)
{
var value = 1;
DwmSetWindowAttribute(parent.ParentForm.Handle, DwmwaTransitionsForcedisabled, ref value, 4);
}
Location = parent.PointToScreen(Point.Empty);
ClientSize = parent.ClientSize;
}
public sealed override Color BackColor
@ -42,7 +46,7 @@ namespace KaraokePlayer
private void Cover_LocationChanged(object sender, EventArgs e)
{
Location = _parent.PointToScreen(Point.Empty);
Location = _parent.PointToScreen(Point.Empty);
}
private void Cover_ClientSizeChanged(object sender, EventArgs e)
@ -66,10 +70,22 @@ namespace KaraokePlayer
protected override void OnActivated(EventArgs e)
{
// Always keep the owner activated instead
// BeginInvoke(new Action(() => Owner.Activate()));
BeginInvoke(new Action(() => Owner.Activate()));
}
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hWnd, int attr, ref int value, int attrLen);
private void Graphic_DoubleClick(object sender, EventArgs e)
{
}
private void OverlayForm_DoubleClick(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KaraokePlayer
{
class TransparentPanel : PictureBox
{
public TransparentPanel()
{
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.Opaque, true);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
e.Graphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
//base.OnPaintBackground(e);
}
protected override void OnPaint(PaintEventArgs e)
{
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
e.Graphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
//base.OnPaintBackground(e);
}
}
}