1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-08 11:34:05 +02:00

Add close/download/fullscreen buttons to video player

This commit is contained in:
chylex 2017-08-28 13:31:19 +02:00
parent 6d779f17b3
commit 0d71a33b28
9 changed files with 336 additions and 13 deletions

View File

@ -83,6 +83,10 @@ private void currentPipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e){
break;
case "download":
TwitterUtils.DownloadVideo(lastUrl);
break;
case "rip":
currentPipe.Dispose();
currentPipe = null;

View File

@ -31,8 +31,14 @@ private void InitializeComponent() {
this.labelTime = new System.Windows.Forms.Label();
this.timerData = new System.Windows.Forms.Timer(this.components);
this.labelTooltip = new TweetDuck.Video.Controls.LabelTooltip();
this.imageResize = new System.Windows.Forms.PictureBox();
this.imageDownload = new System.Windows.Forms.PictureBox();
this.imageClose = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.trackBarVolume)).BeginInit();
this.tablePanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.imageResize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.imageDownload)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.imageClose)).BeginInit();
this.SuspendLayout();
//
// timerSync
@ -45,7 +51,7 @@ private void InitializeComponent() {
this.trackBarVolume.AutoSize = false;
this.trackBarVolume.BackColor = System.Drawing.SystemColors.Control;
this.trackBarVolume.Dock = System.Windows.Forms.DockStyle.Fill;
this.trackBarVolume.Location = new System.Drawing.Point(158, 5);
this.trackBarVolume.Location = new System.Drawing.Point(245, 5);
this.trackBarVolume.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.trackBarVolume.Maximum = 100;
this.trackBarVolume.Name = "trackBarVolume";
@ -62,19 +68,26 @@ private void InitializeComponent() {
// tablePanel
//
this.tablePanel.BackColor = System.Drawing.SystemColors.Control;
this.tablePanel.ColumnCount = 3;
this.tablePanel.ColumnCount = 6;
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 28F));
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F));
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 74F));
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tablePanel.Controls.Add(this.trackBarVolume, 2, 0);
this.tablePanel.Controls.Add(this.progressSeek, 0, 0);
this.tablePanel.Controls.Add(this.labelTime, 1, 0);
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 28F));
this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 28F));
this.tablePanel.Controls.Add(this.trackBarVolume, 3, 0);
this.tablePanel.Controls.Add(this.progressSeek, 1, 0);
this.tablePanel.Controls.Add(this.labelTime, 2, 0);
this.tablePanel.Controls.Add(this.imageResize, 5, 0);
this.tablePanel.Controls.Add(this.imageDownload, 4, 0);
this.tablePanel.Controls.Add(this.imageClose, 0, 0);
this.tablePanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tablePanel.Location = new System.Drawing.Point(0, 86);
this.tablePanel.Name = "tablePanel";
this.tablePanel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.tablePanel.RowCount = 1;
this.tablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tablePanel.Size = new System.Drawing.Size(255, 34);
this.tablePanel.Size = new System.Drawing.Size(400, 34);
this.tablePanel.TabIndex = 1;
//
// progressSeek
@ -82,11 +95,11 @@ private void InitializeComponent() {
this.progressSeek.BackColor = System.Drawing.Color.White;
this.progressSeek.Dock = System.Windows.Forms.DockStyle.Fill;
this.progressSeek.ForeColor = System.Drawing.Color.LimeGreen;
this.progressSeek.Location = new System.Drawing.Point(9, 10);
this.progressSeek.Location = new System.Drawing.Point(39, 10);
this.progressSeek.Margin = new System.Windows.Forms.Padding(9, 10, 8, 10);
this.progressSeek.Maximum = 5000;
this.progressSeek.Name = "progressSeek";
this.progressSeek.Size = new System.Drawing.Size(63, 14);
this.progressSeek.Size = new System.Drawing.Size(121, 14);
this.progressSeek.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.progressSeek.TabIndex = 0;
this.progressSeek.MouseDown += new System.Windows.Forms.MouseEventHandler(this.progressSeek_MouseDown);
@ -94,10 +107,10 @@ private void InitializeComponent() {
// labelTime
//
this.labelTime.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelTime.Location = new System.Drawing.Point(80, 2);
this.labelTime.Location = new System.Drawing.Point(168, 2);
this.labelTime.Margin = new System.Windows.Forms.Padding(0, 2, 0, 5);
this.labelTime.Name = "labelTime";
this.labelTime.Size = new System.Drawing.Size(75, 27);
this.labelTime.Size = new System.Drawing.Size(74, 27);
this.labelTime.TabIndex = 1;
this.labelTime.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@ -112,19 +125,65 @@ private void InitializeComponent() {
this.labelTooltip.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.labelTooltip.ForeColor = System.Drawing.Color.White;
this.labelTooltip.Location = new System.Drawing.Point(0, 0);
this.labelTooltip.Margin = new System.Windows.Forms.Padding(0, 4, 0, 0);
this.labelTooltip.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0);
this.labelTooltip.Name = "labelTooltip";
this.labelTooltip.Padding = new System.Windows.Forms.Padding(4, 2, 2, 2);
this.labelTooltip.Size = new System.Drawing.Size(6, 20);
this.labelTooltip.TabIndex = 2;
this.labelTooltip.Visible = false;
//
// imageResize
//
this.imageResize.Cursor = System.Windows.Forms.Cursors.Hand;
this.imageResize.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageResize.Image = global::TweetDuck.Video.Properties.Resources.btnResize;
this.imageResize.Location = new System.Drawing.Point(373, 5);
this.imageResize.Margin = new System.Windows.Forms.Padding(3, 5, 3, 7);
this.imageResize.Name = "imageResize";
this.imageResize.Size = new System.Drawing.Size(22, 22);
this.imageResize.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.imageResize.TabIndex = 3;
this.imageResize.TabStop = false;
this.imageResize.WaitOnLoad = true;
this.imageResize.Click += new System.EventHandler(this.imageResize_Click);
//
// imageDownload
//
this.imageDownload.Cursor = System.Windows.Forms.Cursors.Hand;
this.imageDownload.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageDownload.Image = global::TweetDuck.Video.Properties.Resources.btnDownload;
this.imageDownload.Location = new System.Drawing.Point(345, 5);
this.imageDownload.Margin = new System.Windows.Forms.Padding(3, 5, 3, 7);
this.imageDownload.Name = "imageDownload";
this.imageDownload.Size = new System.Drawing.Size(22, 22);
this.imageDownload.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.imageDownload.TabIndex = 4;
this.imageDownload.TabStop = false;
this.imageDownload.WaitOnLoad = true;
this.imageDownload.Click += new System.EventHandler(this.imageDownload_Click);
//
// imageClose
//
this.imageClose.BackColor = System.Drawing.SystemColors.Control;
this.imageClose.Cursor = System.Windows.Forms.Cursors.Hand;
this.imageClose.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageClose.Image = global::TweetDuck.Video.Properties.Resources.btnClose;
this.imageClose.Location = new System.Drawing.Point(5, 5);
this.imageClose.Margin = new System.Windows.Forms.Padding(3, 5, 3, 7);
this.imageClose.Name = "imageClose";
this.imageClose.Size = new System.Drawing.Size(22, 22);
this.imageClose.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.imageClose.TabIndex = 5;
this.imageClose.TabStop = false;
this.imageClose.WaitOnLoad = true;
this.imageClose.Click += new System.EventHandler(this.imageClose_Click);
//
// FormPlayer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(255, 120);
this.ClientSize = new System.Drawing.Size(400, 120);
this.ControlBox = false;
this.Controls.Add(this.labelTooltip);
this.Controls.Add(this.tablePanel);
@ -132,6 +191,7 @@ private void InitializeComponent() {
this.Location = new System.Drawing.Point(-32000, -32000);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 120);
this.Name = "FormPlayer";
this.ShowIcon = false;
this.ShowInTaskbar = false;
@ -140,6 +200,9 @@ private void InitializeComponent() {
this.Load += new System.EventHandler(this.FormPlayer_Load);
((System.ComponentModel.ISupportInitialize)(this.trackBarVolume)).EndInit();
this.tablePanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.imageResize)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.imageDownload)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.imageClose)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -154,6 +217,9 @@ private void InitializeComponent() {
private System.Windows.Forms.Label labelTime;
private System.Windows.Forms.Timer timerData;
private Controls.LabelTooltip labelTooltip;
private System.Windows.Forms.PictureBox imageResize;
private System.Windows.Forms.PictureBox imageDownload;
private System.Windows.Forms.PictureBox imageClose;
}
}

View File

@ -57,6 +57,10 @@ public FormPlayer(IntPtr handle, int volume, string url, string token){
return $"{(progress/60).ToString("00")}:{(progress%60).ToString("00")}";
});
labelTooltip.AttachTooltip(imageClose, false, "Close");
labelTooltip.AttachTooltip(imageDownload, false, "Download");
labelTooltip.AttachTooltip(imageResize, false, "Fullscreen");
Application.AddMessageFilter(new MessageFilter(this));
}
@ -194,6 +198,18 @@ private void trackBarVolume_MouseUp(object sender, MouseEventArgs e){
isDragging = false;
}
private void imageClose_Click(object sender, EventArgs e){
StopVideo();
}
private void imageDownload_Click(object sender, EventArgs e){
pipe.Write("download");
}
private void imageResize_Click(object sender, EventArgs e){
Player.fullScreen = true;
}
// Controls & messages
private bool HandleKey(Keys key){

93
video/Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TweetDuck.Video.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TweetDuck.Video.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap btnClose {
get {
object obj = ResourceManager.GetObject("btnClose", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap btnDownload {
get {
object obj = ResourceManager.GetObject("btnDownload", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap btnResize {
get {
object obj = ResourceManager.GetObject("btnResize", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnResize" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btnResize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btnDownload" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btnDownload.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btnClose" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btnClose.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

(image error) Size: 998 B

Binary file not shown.

After

(image error) Size: 882 B

Binary file not shown.

After

(image error) Size: 828 B

View File

@ -62,6 +62,11 @@
<Compile Include="NativeMethods.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<COMReference Include="WMPLib">
@ -75,6 +80,9 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\btnResize.png" />
<None Include="Resources\btnDownload.png" />
<None Include="Resources\btnClose.png" />
<Content Include="Resources\icon.ico" />
</ItemGroup>
<ItemGroup>
@ -83,5 +91,11 @@
<Name>TweetLib.Windows</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>