mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-10 08:34:06 +02:00
Add a custom tooltip to be used for video player controls
This commit is contained in:
parent
7ea7366a43
commit
8e162fe031
37
video/Controls/LabelTooltip.cs
Normal file
37
video/Controls/LabelTooltip.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Video.Controls{
|
||||
sealed class LabelTooltip : Label{
|
||||
public LabelTooltip(){
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
public void AttachTooltip(Control control, bool followCursor, string tooltip){
|
||||
AttachTooltip(control, followCursor, args => tooltip);
|
||||
}
|
||||
|
||||
public void AttachTooltip(Control control, bool followCursor, Func<MouseEventArgs, string> tooltipFunc){
|
||||
control.MouseEnter += control_MouseEnter;
|
||||
control.MouseLeave += control_MouseLeave;
|
||||
|
||||
control.MouseMove += (sender, args) => {
|
||||
Form form = control.FindForm();
|
||||
Debug.Assert(form != null);
|
||||
|
||||
Text = tooltipFunc(args);
|
||||
Location = form.PointToClient(control.Parent.PointToScreen(new Point(control.Location.X-Width/2+(followCursor ? args.X : control.Width/2), -Height+Margin.Top-Margin.Bottom)));;
|
||||
};
|
||||
}
|
||||
|
||||
private void control_MouseEnter(object sender, EventArgs e){
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
private void control_MouseLeave(object sender, EventArgs e){
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
17
video/FormPlayer.Designer.cs
generated
17
video/FormPlayer.Designer.cs
generated
@ -30,6 +30,7 @@ private void InitializeComponent() {
|
||||
this.progressSeek = new TweetDuck.Video.Controls.SeekBar();
|
||||
this.labelTime = new System.Windows.Forms.Label();
|
||||
this.timerData = new System.Windows.Forms.Timer(this.components);
|
||||
this.labelTooltip = new TweetDuck.Video.Controls.LabelTooltip();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarVolume)).BeginInit();
|
||||
this.tablePanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -105,6 +106,19 @@ private void InitializeComponent() {
|
||||
this.timerData.Interval = 500;
|
||||
this.timerData.Tick += new System.EventHandler(this.timerData_Tick);
|
||||
//
|
||||
// labelTooltip
|
||||
//
|
||||
this.labelTooltip.AutoSize = true;
|
||||
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.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;
|
||||
//
|
||||
// FormPlayer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -112,6 +126,7 @@ private void InitializeComponent() {
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(255, 120);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.labelTooltip);
|
||||
this.Controls.Add(this.tablePanel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Location = new System.Drawing.Point(-32000, -32000);
|
||||
@ -126,6 +141,7 @@ private void InitializeComponent() {
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarVolume)).EndInit();
|
||||
this.tablePanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -137,6 +153,7 @@ private void InitializeComponent() {
|
||||
private Controls.SeekBar progressSeek;
|
||||
private System.Windows.Forms.Label labelTime;
|
||||
private System.Windows.Forms.Timer timerData;
|
||||
private Controls.LabelTooltip labelTooltip;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,9 @@
|
||||
<Compile Include="Controls\ControlWMP.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\LabelTooltip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\SeekBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
Loading…
Reference in New Issue
Block a user