diff --git a/YoutubeEnchanted.Installer/API/APICore.cs b/YoutubeEnchanted.Installer/API/APICore.cs new file mode 100644 index 0000000..8e9d730 --- /dev/null +++ b/YoutubeEnchanted.Installer/API/APICore.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YoutubeEnchanted.Installer.API +{ + internal class APICore + { + public static void Install() + { + } + public static void CheckInstall() + { + } + public static void Update() + { + } + public static void Uninstall() + { + } + } +} diff --git a/YoutubeEnchanted.Installer/YoutubeEnchanted.Installer.csproj b/YoutubeEnchanted.Installer/YoutubeEnchanted.Installer.csproj index cc5be48..41ce56e 100644 --- a/YoutubeEnchanted.Installer/YoutubeEnchanted.Installer.csproj +++ b/YoutubeEnchanted.Installer/YoutubeEnchanted.Installer.csproj @@ -66,6 +66,7 @@ + Form diff --git a/YoutubeEnchanted/API/APICore.cs b/YoutubeEnchanted/API/APICore.cs index 2469869..1a81e5b 100644 --- a/YoutubeEnchanted/API/APICore.cs +++ b/YoutubeEnchanted/API/APICore.cs @@ -13,6 +13,8 @@ using YoutubeExplode.Videos.Streams; using System.Windows.Forms; using Vlc.DotNet.Forms; +using System.Net.Http; +using System.Data.Common; namespace YoutubeEnchanted.API { @@ -31,9 +33,16 @@ public class APICore public static bool ShowPlayControlMenu = false; //public static void ResetCore() //{ - //videoPlayCore.Dispose(); - //videoPlayCore=new VlcControl() { Dock = DockStyle.Fill, VlcLibDirectory = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "VLCLIBx64") }; + //videoPlayCore.Dispose(); + //videoPlayCore=new VlcControl() { Dock = DockStyle.Fill, VlcLibDirectory = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "VLCLIBx64") }; //} + public static HttpClient HttpClient() + { + HttpClientHandler handler = new HttpClientHandler(); + handler.UseCookies= true; + handler.CookieContainer=new System.Net.CookieContainer(); + return new System.Net.Http.HttpClient(handler); + } public static void UpdateURL() { try { NOW_URL = UPDATED_LIST[VideoINDEX]; } catch { } @@ -64,7 +73,7 @@ public static async void Play(string url,string Topic) try { - var youtube = new YoutubeClient(); + var youtube = new YoutubeExplode.YoutubeClient(APICore.HttpClient()); var video = await youtube.Videos.GetAsync(url); var streamManifest = await youtube.Videos.Streams.GetManifestAsync(url); var streamInfo = streamManifest.GetMuxedStreams().GetWithHighestBitrate(); @@ -112,10 +121,12 @@ public static async void ParseUrl(string url) try { - var youtube = new YoutubeClient(); + var youtube = new YoutubeExplode.YoutubeClient(APICore.HttpClient()); var streamManifest = await youtube.Videos.Streams.GetManifestAsync(url); - var streamInfo = streamManifest.GetMuxedStreams().GetWithHighestVideoQuality(); + IVideoStreamInfo streamInfo; + try { streamInfo = streamManifest.GetMuxedStreams().GetWithHighestVideoQuality(); } catch(Exception ex) { Program.errorForm = new ErrorUI.Common.UnknowError(ex);Program.error = true; return; } PARSE_URL = streamInfo.Url; + } catch (YoutubeExplode.Exceptions.RequestLimitExceededException ex) { diff --git a/YoutubeEnchanted/ErrorUI/Common/IOError.Designer.cs b/YoutubeEnchanted/ErrorUI/Common/IOError.Designer.cs new file mode 100644 index 0000000..fd7aef3 --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/IOError.Designer.cs @@ -0,0 +1,176 @@ +namespace YoutubeEnchanted.ErrorUI.Common +{ + partial class IOError + { + /// + /// 設計工具所需的變數。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清除任何使用中的資源。 + /// + /// 如果應該處置受控資源則為 true,否則為 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 元件設計工具產生的程式碼 + + /// + /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 + /// 這個方法的內容。 + /// + private void InitializeComponent() + { + this.button2 = new System.Windows.Forms.Button(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.button3 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button2.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button2.Location = new System.Drawing.Point(338, 679); + this.button2.Margin = new System.Windows.Forms.Padding(4); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(239, 67); + this.button2.TabIndex = 16; + this.button2.Text = "Open Log"; + this.button2.UseVisualStyleBackColor = false; + // + // pictureBox1 + // + this.pictureBox1.BackgroundImage = global::YoutubeEnchanted.Properties.Resources.error; + this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pictureBox1.Location = new System.Drawing.Point(33, -7); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(4); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(179, 195); + this.pictureBox1.TabIndex = 14; + this.pictureBox1.TabStop = false; + // + // pictureBox2 + // + this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.pictureBox2.BackColor = System.Drawing.SystemColors.ActiveCaptionText; + this.pictureBox2.Location = new System.Drawing.Point(27, 196); + this.pictureBox2.Margin = new System.Windows.Forms.Padding(4); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(14, 462); + this.pictureBox2.TabIndex = 15; + this.pictureBox2.TabStop = false; + // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button3.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button3.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button3.Location = new System.Drawing.Point(586, 679); + this.button3.Margin = new System.Windows.Forms.Padding(4); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(239, 67); + this.button3.TabIndex = 12; + this.button3.Text = "Retry (Restart)"; + this.button3.UseVisualStyleBackColor = false; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button1.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(855, 679); + this.button1.Margin = new System.Windows.Forms.Padding(4); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(154, 67); + this.button1.TabIndex = 10; + this.button1.Text = "Exit"; + this.button1.UseVisualStyleBackColor = false; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(220, -7); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(789, 200); + this.label1.TabIndex = 11; + this.label1.Text = "Error,File not found"; + // + // panel1 + // + this.panel1.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.panel1.AutoScroll = true; + this.panel1.Controls.Add(this.label2); + this.panel1.Location = new System.Drawing.Point(49, 196); + this.panel1.Margin = new System.Windows.Forms.Padding(4); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(953, 462); + this.panel1.TabIndex = 13; + // + // label2 + // + this.label2.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.label2.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(4, 0); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(916, 475); + this.label2.TabIndex = 5; + this.label2.Text = "Why this happen? \r\nFile is Missing\r\nreslove method:\r\n1.Try Reinstall This Applica" + + "tion"; + // + // IOError + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.button2); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.pictureBox2); + this.Controls.Add(this.button3); + this.Controls.Add(this.button1); + this.Controls.Add(this.label1); + this.Controls.Add(this.panel1); + this.Name = "IOError"; + this.Size = new System.Drawing.Size(1036, 739); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button2; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label2; + } +} diff --git a/YoutubeEnchanted/ErrorUI/Common/IOError.cs b/YoutubeEnchanted/ErrorUI/Common/IOError.cs new file mode 100644 index 0000000..d473b48 --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/IOError.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace YoutubeEnchanted.ErrorUI.Common +{ + public partial class IOError : UserControl + { + public IOError() + { + InitializeComponent(); + } + } +} diff --git a/YoutubeEnchanted/ErrorUI/Common/IOError.resx b/YoutubeEnchanted/ErrorUI/Common/IOError.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/IOError.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 diff --git a/YoutubeEnchanted/ErrorUI/Common/UnknowError.Designer.cs b/YoutubeEnchanted/ErrorUI/Common/UnknowError.Designer.cs new file mode 100644 index 0000000..cca803b --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/UnknowError.Designer.cs @@ -0,0 +1,152 @@ +namespace YoutubeEnchanted.ErrorUI.Common +{ + partial class UnknowError + { + /// + /// 設計工具所需的變數。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清除任何使用中的資源。 + /// + /// 如果應該處置受控資源則為 true,否則為 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 元件設計工具產生的程式碼 + + /// + /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 + /// 這個方法的內容。 + /// + private void InitializeComponent() + { + this.button2 = new System.Windows.Forms.Button(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button3 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button2.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button2.Location = new System.Drawing.Point(302, 512); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(174, 48); + this.button2.TabIndex = 22; + this.button2.Text = "Open Log"; + this.button2.UseVisualStyleBackColor = false; + // + // pictureBox1 + // + this.pictureBox1.BackgroundImage = global::YoutubeEnchanted.Properties.Resources.error; + this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pictureBox1.Location = new System.Drawing.Point(80, 22); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(130, 139); + this.pictureBox1.TabIndex = 21; + this.pictureBox1.TabStop = false; + // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button3.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button3.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button3.Location = new System.Drawing.Point(482, 512); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(174, 48); + this.button3.TabIndex = 19; + this.button3.Text = "Retry (Restart)"; + this.button3.UseVisualStyleBackColor = false; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.button1.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(678, 512); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(112, 48); + this.button1.TabIndex = 17; + this.button1.Text = "Exit"; + this.button1.UseVisualStyleBackColor = false; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(216, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(574, 143); + this.label1.TabIndex = 18; + this.label1.Text = "Error,"; + // + // panel1 + // + this.panel1.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.panel1.AutoScroll = true; + this.panel1.Controls.Add(this.label2); + this.panel1.Location = new System.Drawing.Point(92, 167); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(693, 330); + this.panel1.TabIndex = 20; + // + // label2 + // + this.label2.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.label2.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(3, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(666, 339); + this.label2.TabIndex = 5; + this.label2.Text = "Error Info:\r\n"; + // + // UnknowError + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.button2); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.button3); + this.Controls.Add(this.button1); + this.Controls.Add(this.label1); + this.Controls.Add(this.panel1); + this.Name = "UnknowError"; + this.Size = new System.Drawing.Size(871, 582); + this.Load += new System.EventHandler(this.UnknowError_Load); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button2; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label2; + } +} diff --git a/YoutubeEnchanted/ErrorUI/Common/UnknowError.cs b/YoutubeEnchanted/ErrorUI/Common/UnknowError.cs new file mode 100644 index 0000000..fe44724 --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/UnknowError.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace YoutubeEnchanted.ErrorUI.Common +{ + public partial class UnknowError : UserControl + { + public UnknowError(Exception exception) + { + InitializeComponent(); + label2.Text = "Why this happen? \nUnknow error Found in " + exception.Source + "\n More info:\n"+exception.StackTrace+""; + label1.Text ="Error, "+ exception.Message; + + } + + private void UnknowError_Load(object sender, EventArgs e) + { + + } + } +} diff --git a/YoutubeEnchanted/ErrorUI/Common/UnknowError.resx b/YoutubeEnchanted/ErrorUI/Common/UnknowError.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/YoutubeEnchanted/ErrorUI/Common/UnknowError.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 diff --git a/YoutubeEnchanted/Properties/AssemblyInfo.cs b/YoutubeEnchanted/Properties/AssemblyInfo.cs index 5f0a014..aeb2e8c 100644 --- a/YoutubeEnchanted/Properties/AssemblyInfo.cs +++ b/YoutubeEnchanted/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 // 設為預設,如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.1.0")] -[assembly: AssemblyFileVersion("0.0.1.0")] +[assembly: AssemblyVersion("0.0.2.0")] +[assembly: AssemblyFileVersion("0.0.2.0")] diff --git a/YoutubeEnchanted/Properties/Resources.Designer.cs b/YoutubeEnchanted/Properties/Resources.Designer.cs index b03944a..db44e69 100644 --- a/YoutubeEnchanted/Properties/Resources.Designer.cs +++ b/YoutubeEnchanted/Properties/Resources.Designer.cs @@ -100,6 +100,16 @@ internal static System.Drawing.Bitmap PlayIcon { } } + /// + /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 + /// + internal static System.Drawing.Bitmap Search_Icon { + get { + object obj = ResourceManager.GetObject("Search_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 /// diff --git a/YoutubeEnchanted/Properties/Resources.resx b/YoutubeEnchanted/Properties/Resources.resx index 8e23015..1eb7e94 100644 --- a/YoutubeEnchanted/Properties/Resources.resx +++ b/YoutubeEnchanted/Properties/Resources.resx @@ -121,6 +121,9 @@ ..\Resources\obedtwLAPI.oUI.oVideoViewControl.PauseIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\obedtwLAPI.oUI.oVideoViewControl.StopIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -130,7 +133,7 @@ ..\Resources\home.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Search_Icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/YoutubeEnchanted/Resources/Search_Icon.png b/YoutubeEnchanted/Resources/Search_Icon.png new file mode 100644 index 0000000..a089d1a Binary files /dev/null and b/YoutubeEnchanted/Resources/Search_Icon.png differ diff --git a/YoutubeEnchanted/UI/BGN_VIDEO.Designer.cs b/YoutubeEnchanted/UI/BGN_VIDEO.Designer.cs index 3fa1472..ad35495 100644 --- a/YoutubeEnchanted/UI/BGN_VIDEO.Designer.cs +++ b/YoutubeEnchanted/UI/BGN_VIDEO.Designer.cs @@ -33,7 +33,9 @@ private void InitializeComponent() this.panel1 = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.colorSlider2 = new ColorSlider.ColorSlider(); + this.colorSlider1 = new ColorSlider.ColorSlider(); + this.flowLayoutPanel1 = new System.Windows.Forms.Panel(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -41,15 +43,15 @@ private void InitializeComponent() this.label6 = new System.Windows.Forms.Label(); this.pictureBox4 = new System.Windows.Forms.PictureBox(); this.pictureBox3 = new System.Windows.Forms.PictureBox(); - this.panel3 = new System.Windows.Forms.Panel(); - this.colorSlider2 = new ColorSlider.ColorSlider(); - this.colorSlider1 = new ColorSlider.ColorSlider(); + this.pictureBox5 = new System.Windows.Forms.PictureBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); this.SuspendLayout(); // // panel2 @@ -110,107 +112,6 @@ private void InitializeComponent() this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click_1); // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.flowLayoutPanel1.Location = new System.Drawing.Point(874, 74); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(380, 592); - this.flowLayoutPanel1.TabIndex = 7; - this.flowLayoutPanel1.Visible = false; - this.flowLayoutPanel1.WrapContents = false; - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label2.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(867, 31); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(383, 40); - this.label2.TabIndex = 8; - this.label2.Text = "More like this:"; - this.label2.Visible = false; - this.label2.Click += new System.EventHandler(this.label2_Click); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(12, 452); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(193, 40); - this.label3.TabIndex = 9; - this.label3.Visible = false; - // - // label4 - // - this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label4.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(12, 452); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(823, 40); - this.label4.TabIndex = 10; - this.label4.Visible = false; - // - // label5 - // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label5.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(15, 541); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(823, 1011); - this.label5.TabIndex = 11; - this.label5.Visible = false; - // - // label6 - // - this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label6.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(68, 488); - this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(767, 40); - this.label6.TabIndex = 12; - this.label6.Visible = false; - // - // pictureBox4 - // - this.pictureBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.pictureBox4.Location = new System.Drawing.Point(12, 488); - this.pictureBox4.Margin = new System.Windows.Forms.Padding(4); - this.pictureBox4.Name = "pictureBox4"; - this.pictureBox4.Size = new System.Drawing.Size(48, 49); - this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox4.TabIndex = 13; - this.pictureBox4.TabStop = false; - this.pictureBox4.Visible = false; - // - // pictureBox3 - // - this.pictureBox3.BackgroundImage = global::YoutubeEnchanted.Properties.Resources.home; - this.pictureBox3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.pictureBox3.Location = new System.Drawing.Point(19, -1); - this.pictureBox3.Margin = new System.Windows.Forms.Padding(2); - this.pictureBox3.Name = "pictureBox3"; - this.pictureBox3.Size = new System.Drawing.Size(119, 70); - this.pictureBox3.TabIndex = 6; - this.pictureBox3.TabStop = false; - this.pictureBox3.Click += new System.EventHandler(this.pictureBox3_Click); - // - // panel3 - // - this.panel3.Anchor = System.Windows.Forms.AnchorStyles.None; - this.panel3.AutoScroll = true; - this.panel3.BackColor = System.Drawing.SystemColors.ActiveCaptionText; - this.panel3.Location = new System.Drawing.Point(143, 31); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(945, 627); - this.panel3.TabIndex = 14; - this.panel3.Visible = false; - this.panel3.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.panel3_ControlAdded); - this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint); - // // colorSlider2 // this.colorSlider2.BackColor = System.Drawing.Color.Transparent; @@ -339,34 +240,154 @@ private void InitializeComponent() 0}); this.colorSlider1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.colorSlider1_Scroll); // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Location = new System.Drawing.Point(874, 74); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(380, 592); + this.flowLayoutPanel1.TabIndex = 7; + this.flowLayoutPanel1.Visible = false; + this.flowLayoutPanel1.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanel1_ControlAdded); + this.flowLayoutPanel1.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanel1_ControlRemoved); + this.flowLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.flowLayoutPanel1_Paint); + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label2.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(867, 31); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(383, 40); + this.label2.TabIndex = 8; + this.label2.Text = "More like this:"; + this.label2.Visible = false; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label3.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(12, 452); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(193, 40); + this.label3.TabIndex = 9; + this.label3.Visible = false; + // + // label4 + // + this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label4.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(12, 452); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(823, 40); + this.label4.TabIndex = 10; + this.label4.Visible = false; + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label5.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(15, 541); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(823, 1011); + this.label5.TabIndex = 11; + this.label5.Visible = false; + // + // label6 + // + this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label6.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(68, 488); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(767, 40); + this.label6.TabIndex = 12; + this.label6.Visible = false; + // + // pictureBox4 + // + this.pictureBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pictureBox4.Location = new System.Drawing.Point(12, 488); + this.pictureBox4.Margin = new System.Windows.Forms.Padding(4); + this.pictureBox4.Name = "pictureBox4"; + this.pictureBox4.Size = new System.Drawing.Size(48, 49); + this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox4.TabIndex = 13; + this.pictureBox4.TabStop = false; + this.pictureBox4.Visible = false; + // + // pictureBox3 + // + this.pictureBox3.BackgroundImage = global::YoutubeEnchanted.Properties.Resources.home; + this.pictureBox3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pictureBox3.Location = new System.Drawing.Point(19, -1); + this.pictureBox3.Margin = new System.Windows.Forms.Padding(2); + this.pictureBox3.Name = "pictureBox3"; + this.pictureBox3.Size = new System.Drawing.Size(119, 70); + this.pictureBox3.TabIndex = 6; + this.pictureBox3.TabStop = false; + this.pictureBox3.Click += new System.EventHandler(this.pictureBox3_Click); + // + // pictureBox5 + // + this.pictureBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox5.BackgroundImage = global::YoutubeEnchanted.Properties.Resources.Search_Icon; + this.pictureBox5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.pictureBox5.Location = new System.Drawing.Point(774, 16); + this.pictureBox5.Name = "pictureBox5"; + this.pictureBox5.Size = new System.Drawing.Size(46, 32); + this.pictureBox5.TabIndex = 16; + this.pictureBox5.TabStop = false; + this.pictureBox5.Click += new System.EventHandler(this.pictureBox5_Click); + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox1.Location = new System.Drawing.Point(143, 12); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(625, 36); + this.textBox1.TabIndex = 15; + this.textBox1.WordWrap = false; + // // BGN_VIDEO // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1262, 673); - this.Controls.Add(this.panel3); + this.Controls.Add(this.pictureBox5); this.Controls.Add(this.pictureBox4); this.Controls.Add(this.label6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label2); + this.Controls.Add(this.textBox1); this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.pictureBox3); this.Controls.Add(this.panel2); + this.KeyPreview = true; this.Name = "BGN_VIDEO"; this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "BGN_VIDEO"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.BGN_VIDEO_Load); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.BGN_VIDEO_KeyUp); this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -380,7 +401,7 @@ private void InitializeComponent() private ColorSlider.ColorSlider colorSlider2; private ColorSlider.ColorSlider colorSlider1; private System.Windows.Forms.PictureBox pictureBox3; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Panel flowLayoutPanel1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; @@ -388,5 +409,7 @@ private void InitializeComponent() private System.Windows.Forms.PictureBox pictureBox4; private System.Windows.Forms.Label label6; private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.TextBox textBox1; + public System.Windows.Forms.PictureBox pictureBox5; } } \ No newline at end of file diff --git a/YoutubeEnchanted/UI/BGN_VIDEO.cs b/YoutubeEnchanted/UI/BGN_VIDEO.cs index 7ce3816..f14e6f6 100644 --- a/YoutubeEnchanted/UI/BGN_VIDEO.cs +++ b/YoutubeEnchanted/UI/BGN_VIDEO.cs @@ -34,7 +34,7 @@ private void VideoPlayCore_Log(object sender, Vlc.DotNet.Core.VlcMediaPlayerLogE string nowurl=""; private async void UpdateVideo(string id, string top) { - var youtube = new YoutubeClient(); + var youtube = new YoutubeExplode.YoutubeClient(APICore.HttpClient()); flowLayoutPanel1.Controls.Clear(); foreach (var result in await youtube.Search.GetVideosAsync(id).CollectAsync(20)) { @@ -47,10 +47,11 @@ private async void UpdateVideo(string id, string top) } } + private MainPage MainSec; private async void Tick() { await Task.Delay(1000); - this.Controls.Add(new UI.MainPage() { Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom, Size = this.Size }); + this.Controls.Add(MainSec= new UI.MainPage() { Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom, Size = this.Size }); do { try @@ -103,6 +104,7 @@ private async void Tick() label5.Visible = true; label3.Visible = true; label2.Visible = true; + flowLayoutPanel1.Visible = true; nowurl = APICore._PARSE_URL; panel2.Visible = true; @@ -159,6 +161,21 @@ private async void Tick() } if (Program.error) { + this.panel3 = new System.Windows.Forms.Panel(); + // + // panel3 + // + this.panel3.Anchor = System.Windows.Forms.AnchorStyles.None; + this.panel3.AutoScroll = true; + this.panel3.BackColor = System.Drawing.SystemColors.ActiveCaptionText; + + this.panel3.Location = new System.Drawing.Point(143, 31); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(945, 627); + this.panel3.TabIndex = 14; + this.panel3.Visible = false; + this.panel3.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.panel3_ControlAdded); + this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint); panel3.Controls.Add(Program.errorForm); return; } @@ -173,7 +190,7 @@ private async void UpdateVideoAuthor(string vidUrl) { try { - YoutubeExplode.YoutubeClient yt = new YoutubeExplode.YoutubeClient(); + YoutubeExplode.YoutubeClient yt = new YoutubeExplode.YoutubeClient(new System.Net.Http.HttpClient()); try { var vid = await yt.Videos.GetAsync(vidUrl); @@ -262,5 +279,45 @@ private void panel3_Paint(object sender, PaintEventArgs e) { } + + private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void BGN_VIDEO_KeyUp(object sender, KeyEventArgs e) + { + switch(e.KeyCode) + { + case Keys.Enter: + MainSec.StartSerch(textBox1.Text); + textBox1.Text = ""; + break; + case Keys.Space: + try { videoPlayCore.Pause(); } catch(Exception ex) { APICore.Log("User Press Space but "+ex.Message); APICore.Log(ex.StackTrace); } + break; + + + } + } + + private void pictureBox5_Click(object sender, EventArgs e) + { + MainSec.StartSerch(textBox1.Text); + APICore.ShowPlayControlMenu = false; + textBox1.Text = ""; + } + int createsize = 10; + private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e) + { + createsize = e.Control.Size.Height + createsize; + e.Control.Location = new Point(10, createsize); + } + + private void flowLayoutPanel1_ControlRemoved(object sender, ControlEventArgs e) + { + try { flowLayoutPanel1.Controls[-1].Location = e.Control.Location; } catch(Exception ex) { APICore.Log(ex.Message);APICore.Log(ex.StackTrace); } + + } } } diff --git a/YoutubeEnchanted/UI/MainPage.Designer.cs b/YoutubeEnchanted/UI/MainPage.Designer.cs index 92997e1..143c87b 100644 --- a/YoutubeEnchanted/UI/MainPage.Designer.cs +++ b/YoutubeEnchanted/UI/MainPage.Designer.cs @@ -43,6 +43,7 @@ private void InitializeComponent() this.TopicShower.Name = "TopicShower"; this.TopicShower.Size = new System.Drawing.Size(1325, 811); this.TopicShower.TabIndex = 0; + this.TopicShower.Paint += new System.Windows.Forms.PaintEventHandler(this.TopicShower_Paint); // // MainPage // diff --git a/YoutubeEnchanted/UI/MainPage.cs b/YoutubeEnchanted/UI/MainPage.cs index ea4e6c4..45a7dbd 100644 --- a/YoutubeEnchanted/UI/MainPage.cs +++ b/YoutubeEnchanted/UI/MainPage.cs @@ -63,5 +63,18 @@ private void panel2_Paint(object sender, PaintEventArgs e) { } + + public void StartSerch(string topic) + { + TopicShower.Controls.Clear(); + createtmp = 0; + AddTopic(topic); + + } + + private void TopicShower_Paint(object sender, PaintEventArgs e) + { + + } } } diff --git a/YoutubeEnchanted/UI/TopicVideoSelecter.Designer.cs b/YoutubeEnchanted/UI/TopicVideoSelecter.Designer.cs index 0c9cca9..3d86f14 100644 --- a/YoutubeEnchanted/UI/TopicVideoSelecter.Designer.cs +++ b/YoutubeEnchanted/UI/TopicVideoSelecter.Designer.cs @@ -28,7 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.flowLayoutPanel1 = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.SuspendLayout(); @@ -39,23 +39,27 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.flowLayoutPanel1.AutoScroll = true; this.flowLayoutPanel1.BackColor = System.Drawing.SystemColors.Control; - this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 58); + this.flowLayoutPanel1.Location = new System.Drawing.Point(4, 56); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(1057, 259); + this.flowLayoutPanel1.Size = new System.Drawing.Size(1409, 340); this.flowLayoutPanel1.TabIndex = 0; - this.flowLayoutPanel1.WrapContents = false; + this.flowLayoutPanel1.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanel1_ControlAdded); + this.flowLayoutPanel1.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanel1_ControlRemoved); this.flowLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.flowLayoutPanel1_Paint); // // label1 // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label1.Font = new System.Drawing.Font("Segoe UI", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(3, 0); + this.label1.Font = new System.Drawing.Font("Segoe UI", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(4, 0); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(1057, 55); + this.label1.Size = new System.Drawing.Size(1409, 52); this.label1.TabIndex = 1; this.label1.Text = "label1"; + this.label1.Click += new System.EventHandler(this.label1_Click); // // backgroundWorker1 // @@ -63,22 +67,22 @@ private void InitializeComponent() // // TopicVideoSelecter // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; this.Controls.Add(this.label1); this.Controls.Add(this.flowLayoutPanel1); + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "TopicVideoSelecter"; - this.Size = new System.Drawing.Size(1063, 321); + this.Size = new System.Drawing.Size(1417, 401); this.Load += new System.EventHandler(this.TopicVideoSelecter_Load); this.ResumeLayout(false); } #endregion - - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Label label1; private System.ComponentModel.BackgroundWorker backgroundWorker1; + public System.Windows.Forms.Panel flowLayoutPanel1; } } diff --git a/YoutubeEnchanted/UI/TopicVideoSelecter.cs b/YoutubeEnchanted/UI/TopicVideoSelecter.cs index 4a0f97d..80824c7 100644 --- a/YoutubeEnchanted/UI/TopicVideoSelecter.cs +++ b/YoutubeEnchanted/UI/TopicVideoSelecter.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using YoutubeEnchanted.API; using YoutubeExplode; using YoutubeExplode.Common; using YoutubeExplode.Search; @@ -20,6 +21,7 @@ public TopicVideoSelecter(string topid) { InitializeComponent(); label1.Text= topid; + API.APICore.Log("Serching "+topid); UpdateVideo(topid,topid); } @@ -34,7 +36,7 @@ private void TopicVideoSelecter_Load(object sender, EventArgs e) } private async void UpdateVideo(string id,string top) { - var youtube = new YoutubeClient(); + var youtube = new YoutubeExplode.YoutubeClient(new System.Net.Http.HttpClient()); foreach (var result in await youtube.Search.GetVideosAsync(id).CollectAsync(20) ) { if (flowLayoutPanel1.Controls.Count == 20) @@ -50,5 +52,22 @@ private async void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { } + + private void label1_Click(object sender, EventArgs e) + { + + } + int createsize=10; + private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e) + { + createsize = e.Control.Size.Width + createsize; + e.Control.Location = new Point(createsize, 10); + } + + private void flowLayoutPanel1_ControlRemoved(object sender, ControlEventArgs e) + { + + try { flowLayoutPanel1.Controls[-1].Location = e.Control.Location; } catch (Exception ex) { APICore.Log(ex.Message); APICore.Log(ex.StackTrace); } + } } } diff --git a/YoutubeEnchanted/UI/VideoControl.Designer.cs b/YoutubeEnchanted/UI/VideoControl.Designer.cs index ac405b9..cc7464d 100644 --- a/YoutubeEnchanted/UI/VideoControl.Designer.cs +++ b/YoutubeEnchanted/UI/VideoControl.Designer.cs @@ -42,6 +42,7 @@ private void InitializeComponent() // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.label1.BackColor = System.Drawing.Color.White; this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(4, 188); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -49,11 +50,14 @@ private void InitializeComponent() this.label1.Size = new System.Drawing.Size(256, 41); this.label1.TabIndex = 1; this.label1.Click += new System.EventHandler(this.pictureBox2_Click); + this.label1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.label1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); // // label2 // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.label2.BackColor = System.Drawing.Color.White; this.label2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(64, 229); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -61,6 +65,8 @@ private void InitializeComponent() this.label2.Size = new System.Drawing.Size(199, 40); this.label2.TabIndex = 2; this.label2.Click += new System.EventHandler(this.pictureBox2_Click); + this.label2.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.label2.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); // // backgroundWorker1 // @@ -81,6 +87,7 @@ private void InitializeComponent() // this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox2.BackColor = System.Drawing.Color.White; this.pictureBox2.ErrorImage = global::YoutubeEnchanted.Properties.Resources.error; this.pictureBox2.Location = new System.Drawing.Point(8, 229); this.pictureBox2.Margin = new System.Windows.Forms.Padding(4); @@ -90,11 +97,14 @@ private void InitializeComponent() this.pictureBox2.TabIndex = 4; this.pictureBox2.TabStop = false; this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click); + this.pictureBox2.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.pictureBox2.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); // // pictureBox1 // this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.BackColor = System.Drawing.Color.White; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.pictureBox1.ErrorImage = global::YoutubeEnchanted.Properties.Resources.error; this.pictureBox1.Location = new System.Drawing.Point(4, 4); @@ -105,11 +115,14 @@ private void InitializeComponent() this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox2_Click); + this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); // // VideoControl // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; this.Controls.Add(this.pictureBox2); this.Controls.Add(this.label3); this.Controls.Add(this.label2); @@ -120,6 +133,8 @@ private void InitializeComponent() this.Size = new System.Drawing.Size(267, 288); this.Load += new System.EventHandler(this.VideoControl_Load); this.Click += new System.EventHandler(this.pictureBox2_Click); + this.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); diff --git a/YoutubeEnchanted/UI/VideoControl.cs b/YoutubeEnchanted/UI/VideoControl.cs index fe762c1..e5140d7 100644 --- a/YoutubeEnchanted/UI/VideoControl.cs +++ b/YoutubeEnchanted/UI/VideoControl.cs @@ -41,7 +41,8 @@ private async void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) private async void UpdateVideo() { try { - YoutubeExplode.YoutubeClient yt = new YoutubeExplode.YoutubeClient(); + YoutubeExplode.YoutubeClient yt = new YoutubeExplode.YoutubeClient(APICore.HttpClient()); + APICore.Log("Getting metadata from "+videoURL); try { var vid = await yt.Videos.GetAsync(videoURL); @@ -50,10 +51,13 @@ private async void UpdateVideo() pictureBox1.LoadAsync(vid.Thumbnails.GetWithHighestResolution().Url); var us = await yt.Channels.GetAsync(vid.Author.ChannelUrl); pictureBox2.LoadAsync(us.Thumbnails[0].Url); + APICore.Log("Metadata Geted ("+videoURL+")"); } catch (YoutubeExplode.Exceptions.RequestLimitExceededException ex) { + APICore.Log(ex.Message); + APICore.Log(ex.StackTrace); Program.errorForm = new ErrorUI.Common.YoutubeLimted(); Program.error = true; @@ -75,5 +79,32 @@ private void pictureBox2_Click(object sender, EventArgs e) //API.APICore.Log("Playing "+videoURL); Play(videoURL,Topics); } + + private void pictureBox1_MouseEnter(object sender, EventArgs e) + { + foreach (Control control in this.Controls) + { + control.BackColor = Color.Black; + control.ForeColor = Color.White; + } + this.BackColor= Color.Black; + this.Location = new Point(this.Location.X - 10, this.Location.Y -10); + this.Size = new Size(this.Width+20,this.Height+20); + try {this.BringToFront(); } catch (Exception ex) { APICore.Log(ex.Message); APICore.Log(ex.StackTrace); } + } + + private void pictureBox1_MouseLeave(object sender, EventArgs e) + { + foreach (Control control in this.Controls) + { + control.BackColor = Color.White; + control.ForeColor = Color.Black; + } + this.BackColor = Color.White; + this.Location = new Point(this.Location.X+10,this.Location.Y+10); + this.Size = new Size(this.Width - 20, this.Height- 20); + try { this.SendToBack(); } catch(Exception ex) { APICore.Log(ex.Message);APICore.Log(ex.StackTrace); } + + } } } diff --git a/YoutubeEnchanted/YoutubeEnchanted.csproj b/YoutubeEnchanted/YoutubeEnchanted.csproj index 6e87407..e1033d2 100644 --- a/YoutubeEnchanted/YoutubeEnchanted.csproj +++ b/YoutubeEnchanted/YoutubeEnchanted.csproj @@ -108,6 +108,18 @@ + + UserControl + + + IOError.cs + + + UserControl + + + UnknowError.cs + UserControl @@ -158,6 +170,12 @@ VideoPlayerPage.cs + + IOError.cs + + + UnknowError.cs + YoutubeLimted.cs @@ -228,6 +246,9 @@ + + +