diff --git a/KaraokePlayer/KaraokePlayer.csproj b/KaraokePlayer/KaraokePlayer.csproj index e60fd3c..a8bf55d 100644 --- a/KaraokePlayer/KaraokePlayer.csproj +++ b/KaraokePlayer/KaraokePlayer.csproj @@ -83,6 +83,9 @@ Form + + OverlayForm.cs + @@ -91,6 +94,9 @@ MainForm.cs + + OverlayForm.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -101,592 +107,6 @@ Resources.resx True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -710,7 +130,6 @@ - @@ -1011,6 +430,9 @@ + + + XCOPY "$(ProjectDir)lib" "$(TargetDir)lib\" /S /y /c diff --git a/KaraokePlayer/KaraokeVideoPlayer.Designer.cs b/KaraokePlayer/KaraokeVideoPlayer.Designer.cs index f57a212..f5cfffa 100644 --- a/KaraokePlayer/KaraokeVideoPlayer.Designer.cs +++ b/KaraokePlayer/KaraokeVideoPlayer.Designer.cs @@ -44,18 +44,14 @@ this.vlcPlayer.Text = "vlcControl1"; this.vlcPlayer.VlcLibDirectory = null; this.vlcPlayer.VlcMediaplayerOptions = new string[] { - "--projectm-preset-path=Presets", - "--projectm-width=1680", - "--projectm-height=1050", + "--projectm-preset-path=lib\\presets", "--audio-visual=projectm", "--effect-list=scope", "--no-video", - "--extraintf=logger", "--verbose=2"}; this.vlcPlayer.VlcLibDirectoryNeeded += new System.EventHandler(this.vlcPlayer_VlcLibDirectoryNeeded); this.vlcPlayer.Playing += new System.EventHandler(this.vlcPlayer_Playing); this.vlcPlayer.TimeChanged += new System.EventHandler(this.vlcPlayer_TimeChanged); - this.vlcPlayer.Stopped += new System.EventHandler(this.vlcPlayer_Stopped); // // KaraokeVideoPlayer // diff --git a/KaraokePlayer/KaraokeVideoPlayer.cs b/KaraokePlayer/KaraokeVideoPlayer.cs index 8e482c5..fc6843d 100644 --- a/KaraokePlayer/KaraokeVideoPlayer.cs +++ b/KaraokePlayer/KaraokeVideoPlayer.cs @@ -15,26 +15,22 @@ namespace KaraokePlayer { public partial class KaraokeVideoPlayer : UserControl { - private readonly PictureBox _lyrics = new PictureBox {Dock = DockStyle.Fill}; private GraphicsFile _cdgFile; - private Image _lyricImage; private OverlayForm _overlayForm; private DateTime _startTime; private readonly System.Timers.Timer _lyricTimer = new System.Timers.Timer(); - private Stopwatch _stopwatch = new Stopwatch(); public KaraokeVideoPlayer() { InitializeComponent(); - _lyricTimer.Interval = 30; + _lyricTimer.Interval = 50; _lyricTimer.Elapsed += LyricTimerOnElapsed; } private void LyricTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) { var picture = _cdgFile.RenderAtTime((long)(DateTime.Now - _startTime).TotalMilliseconds); - _lyrics.Image = picture; - + _overlayForm.Graphic.Image = picture; } public async void Play(Uri file) @@ -48,11 +44,6 @@ namespace KaraokePlayer { _startTime = DateTime.Now; _lyricTimer.Start(); - - - - - } private void vlcPlayer_TimeChanged(object sender, VlcMediaPlayerTimeChangedEventArgs e) @@ -60,17 +51,11 @@ namespace KaraokePlayer _startTime = DateTime.Now.AddMilliseconds(-e.NewTime); } - private void vlcPlayer_Stopped(object sender, VlcMediaPlayerStoppedEventArgs e) - { - _overlayForm.Hide(); - } - private void KaraokeVideoPlayer_ParentChanged(object sender, EventArgs e) { if (ParentForm != null) { _overlayForm = new OverlayForm(this); - _overlayForm.Controls.Add(_lyrics); } } diff --git a/KaraokePlayer/MainForm.Designer.cs b/KaraokePlayer/MainForm.Designer.cs index 862900a..345aca9 100644 --- a/KaraokePlayer/MainForm.Designer.cs +++ b/KaraokePlayer/MainForm.Designer.cs @@ -34,6 +34,7 @@ // // materialRaisedButton1 // + this.materialRaisedButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.materialRaisedButton1.Depth = 0; this.materialRaisedButton1.Location = new System.Drawing.Point(385, 358); this.materialRaisedButton1.MouseState = MaterialSkin.MouseState.HOVER; @@ -46,9 +47,12 @@ // // karaokeVideoPlayer1 // - this.karaokeVideoPlayer1.Location = new System.Drawing.Point(100, 140); + this.karaokeVideoPlayer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.karaokeVideoPlayer1.Location = new System.Drawing.Point(12, 72); this.karaokeVideoPlayer1.Name = "karaokeVideoPlayer1"; - this.karaokeVideoPlayer1.Size = new System.Drawing.Size(249, 146); + this.karaokeVideoPlayer1.Size = new System.Drawing.Size(454, 280); this.karaokeVideoPlayer1.TabIndex = 0; // // MainForm diff --git a/KaraokePlayer/OverlayForm.Designer.cs b/KaraokePlayer/OverlayForm.Designer.cs new file mode 100644 index 0000000..a1183c3 --- /dev/null +++ b/KaraokePlayer/OverlayForm.Designer.cs @@ -0,0 +1,62 @@ +namespace KaraokePlayer +{ + partial class OverlayForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Graphic = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.Graphic)).BeginInit(); + this.SuspendLayout(); + // + // Graphic + // + this.Graphic.Dock = System.Windows.Forms.DockStyle.Fill; + this.Graphic.Location = new System.Drawing.Point(0, 0); + this.Graphic.Name = "Graphic"; + this.Graphic.Size = new System.Drawing.Size(284, 261); + this.Graphic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.Graphic.TabIndex = 0; + this.Graphic.TabStop = false; + // + // OverlayForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 261); + this.Controls.Add(this.Graphic); + this.Name = "OverlayForm"; + this.Text = "OverlayForm"; + ((System.ComponentModel.ISupportInitialize)(this.Graphic)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + public System.Windows.Forms.PictureBox Graphic; + } +} \ No newline at end of file diff --git a/KaraokePlayer/OverlayForm.cs b/KaraokePlayer/OverlayForm.cs index b9320a3..8b3d1b0 100644 --- a/KaraokePlayer/OverlayForm.cs +++ b/KaraokePlayer/OverlayForm.cs @@ -5,12 +5,15 @@ using System.Windows.Forms; namespace KaraokePlayer { - internal class OverlayForm : Form + public partial class OverlayForm : Form { private const int DwmwaTransitionsForcedisabled = 3; + ContainerControl _parent; public OverlayForm(ContainerControl parent) { + InitializeComponent(); + _parent = parent; BackColor = Color.FromArgb(1, 1, 1); TransparencyKey = Color.FromArgb(1, 1, 1); FormBorderStyle = FormBorderStyle.None; @@ -20,10 +23,9 @@ namespace KaraokePlayer AutoScaleMode = AutoScaleMode.None; Location = parent.PointToScreen(Point.Empty); ClientSize = parent.ClientSize; + Show(parent); parent.ParentForm.LocationChanged += Cover_LocationChanged; - parent.ParentForm.ClientSizeChanged += Cover_ClientSizeChanged; - Show(parent.ParentForm); - parent.ParentForm.Focus(); + parent.ClientSizeChanged += Cover_ClientSizeChanged; // Disable Aero transitions, the plexiglass gets too visible if (Environment.OSVersion.Version.Major >= 6) { @@ -40,12 +42,12 @@ namespace KaraokePlayer private void Cover_LocationChanged(object sender, EventArgs e) { - // Location = Owner.PointToScreen(Point.Empty); + Location = _parent.PointToScreen(Point.Empty); } private void Cover_ClientSizeChanged(object sender, EventArgs e) { - //ClientSize = Owner.ClientSize; + ClientSize = _parent.ClientSize; } protected override void OnFormClosing(FormClosingEventArgs e) @@ -64,10 +66,10 @@ 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); } -} \ No newline at end of file +} diff --git a/KaraokePlayer/OverlayForm.resx b/KaraokePlayer/OverlayForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/KaraokePlayer/OverlayForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file