Prechádzať zdrojové kódy

track bar seeking tooltip

Coder 8 mesiacov pred
rodič
commit
bfedc913fd

+ 13 - 7
Bmp.WinForms/MainForm.Designer.cs

@@ -29,10 +29,10 @@
         private void InitializeComponent()
         {
             components = new System.ComponentModel.Container();
-            ListViewItem listViewItem5 = new ListViewItem(new string[] { "1", "12:34:56" }, -1);
-            ListViewItem listViewItem6 = new ListViewItem(new string[] { "2", "", "▶" }, -1);
-            ListViewItem listViewItem7 = new ListViewItem("3");
-            ListViewItem listViewItem8 = new ListViewItem("4");
+            ListViewItem listViewItem1 = new ListViewItem(new string[] { "1", "12:34:56" }, -1);
+            ListViewItem listViewItem2 = new ListViewItem(new string[] { "2", "", "▶" }, -1);
+            ListViewItem listViewItem3 = new ListViewItem("3");
+            ListViewItem listViewItem4 = new ListViewItem("4");
             SeekTrackBar = new TrackBar();
             StopButton = new Button();
             PlayButton = new Button();
@@ -51,6 +51,7 @@
             StatusBarLabel = new ToolStripStatusLabel();
             SettingButtonToolTip = new ToolTip(components);
             MainPanel = new Panel();
+            TrackBarToolTip = new ToolTip(components);
             ((System.ComponentModel.ISupportInitialize)SeekTrackBar).BeginInit();
             MainStatusBar.SuspendLayout();
             MainPanel.SuspendLayout();
@@ -62,11 +63,11 @@
             SeekTrackBar.LargeChange = 1;
             SeekTrackBar.Location = new Point(407, 12);
             SeekTrackBar.Name = "SeekTrackBar";
-            SeekTrackBar.Size = new Size(513, 69);
-            SeekTrackBar.SmallChange = 1;
+            SeekTrackBar.Size = new Size(508, 69);
             SeekTrackBar.TabIndex = 5;
             SeekTrackBar.TickFrequency = 0;
             SeekTrackBar.TickStyle = TickStyle.Both;
+            SeekTrackBar.ValueChanged += SeekTrackBar_ValueChanged;
             SeekTrackBar.MouseDown += SeekTrackBar_MouseDown;
             SeekTrackBar.MouseUp += SeekTrackBar_MouseUp;
             // 
@@ -133,7 +134,7 @@
             MainListView.ContextMenuStrip = MainContextMenu;
             MainListView.FullRowSelect = true;
             MainListView.GroupImageList = AlbumImageList;
-            MainListView.Items.AddRange(new ListViewItem[] { listViewItem5, listViewItem6, listViewItem7, listViewItem8 });
+            MainListView.Items.AddRange(new ListViewItem[] { listViewItem1, listViewItem2, listViewItem3, listViewItem4 });
             MainListView.Location = new Point(12, 87);
             MainListView.Name = "MainListView";
             MainListView.ShowItemToolTips = true;
@@ -237,6 +238,10 @@
             MainPanel.Size = new Size(1006, 518);
             MainPanel.TabIndex = 8;
             // 
+            // TrackBarToolTip
+            // 
+            TrackBarToolTip.ShowAlways = true;
+            // 
             // MainForm
             // 
             AutoScaleDimensions = new SizeF(11F, 24F);
@@ -277,5 +282,6 @@
         private ToolTip SettingButtonToolTip;
         private Panel panel1;
         private Panel MainPanel;
+        private ToolTip TrackBarToolTip;
     }
 }

+ 12 - 2
Bmp.WinForms/MainForm.cs

@@ -108,7 +108,7 @@ namespace Bmp.WinForms
 
                     item.SubItems[DurColumnHeader.Index].Text = meta.Duration.ToString("hh\\:mm\\:ss");
 
-                    var localVarPath = Uri.UnescapeDataString( item.Name);
+                    var localVarPath = Uri.UnescapeDataString(item.Name);
 
                     item.ToolTipText = localVarPath;
 
@@ -477,7 +477,7 @@ namespace Bmp.WinForms
 
                     var localVarPath = path;
                     if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var uri) && uri.IsFile == false) localVarPath = uri.ToString();
-                    
+
                     item.Text = Path.GetFileName(localVarPath);
                     if (string.IsNullOrWhiteSpace(item.Text)) item.Text = localVarPath;
 
@@ -1089,8 +1089,16 @@ namespace Bmp.WinForms
             _trackBarHolding = true;
         }
 
+        private void SeekTrackBar_ValueChanged(object sender, EventArgs e)
+        {
+            if (_trackBarHolding == false) return;
+            TrackBarToolTip.Show(TimeSpan.FromMilliseconds(SeekTrackBar.Value).ToString(), SeekTrackBar,0,-32);
+        }
+
         private async void SeekTrackBar_MouseUp(object sender, MouseEventArgs e)
         {
+            TrackBarToolTip.Hide(SeekTrackBar);
+
             MainPanel.Enabled = false;
             if (_inputSource != null)
             {
@@ -1135,6 +1143,8 @@ namespace Bmp.WinForms
             MainPanel.Enabled = true;
             _trackBarHolding = false;
         }
+
+
     }
 
     internal enum UIPlaybackState

+ 4 - 1
Bmp.WinForms/MainForm.resx

@@ -130,7 +130,10 @@
     <value>401, 17</value>
   </metadata>
   <metadata name="SettingButtonToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>817, 17</value>
+    <value>818, 19</value>
+  </metadata>
+  <metadata name="TrackBarToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>1067, 19</value>
   </metadata>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>470</value>