Переглянути джерело

chore; main form use table-layout-panel to prevent desigener malfunction when dpi

Coder 7 місяців тому
батько
коміт
d1b23f578b

+ 1 - 1
Bmp.Core.Lite/Playback/Inputs/DsfAudioStream.cs

@@ -142,7 +142,7 @@ public class DsfAudioStream : DsdAudioStream,IHaveDecoderInfo
         var bytes = count / ChannelNum;
         var dstPtr = 0;
 
-        //TODO: optimization Unsafe moving ptr
+        //TODO: DsfAudioStream optimization Unsafe moving ptr
 
         for (var s = 0; s < bytes; s++)
         {

+ 1 - 1
Bmp.Core.Lite/Playback/MiddleWare/VisualizeDataMiddleWare.cs

@@ -31,7 +31,7 @@ public class VisualizeDataMiddleWare : IWaveProvider, IHaveBitPerRawSample
         {
             if (_provider.Position < _provider.Length)
             {
-                //TODO: 通知机制 流读取中断
+                //TODO: 消息机制 错误 流读取中断
             }
             return 0;
         }

+ 76 - 41
Bmp.WinForms/MainForm.Designer.cs

@@ -50,8 +50,9 @@
             MainStatusBar = new StatusStrip();
             StatusBarLabel = new ToolStripStatusLabel();
             SettingButtonToolTip = new ToolTip(components);
-            MainPanel = new Panel();
+            PlaylistModeButton = new Button();
             SeekTrackBarToolTip = new ToolTip(components);
+            MainPanel = new TableLayoutPanel();
             ((System.ComponentModel.ISupportInitialize)SeekTrackBar).BeginInit();
             MainStatusBar.SuspendLayout();
             MainPanel.SuspendLayout();
@@ -59,12 +60,12 @@
             // 
             // SeekTrackBar
             // 
-            SeekTrackBar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            SeekTrackBar.Dock = DockStyle.Fill;
             SeekTrackBar.LargeChange = 1;
-            SeekTrackBar.Location = new Point(407, 12);
+            SeekTrackBar.Location = new Point(453, 3);
             SeekTrackBar.Name = "SeekTrackBar";
-            SeekTrackBar.Size = new Size(546, 69);
-            SeekTrackBar.TabIndex = 5;
+            SeekTrackBar.Size = new Size(515, 69);
+            SeekTrackBar.TabIndex = 6;
             SeekTrackBar.TickFrequency = 0;
             SeekTrackBar.TickStyle = TickStyle.Both;
             SeekTrackBar.ValueChanged += SeekTrackBar_ValueChanged;
@@ -73,10 +74,11 @@
             // 
             // StopButton
             // 
+            StopButton.Dock = DockStyle.Fill;
             StopButton.Font = new Font("Microsoft YaHei UI", 19F);
-            StopButton.Location = new Point(12, 12);
+            StopButton.Location = new Point(3, 3);
             StopButton.Name = "StopButton";
-            StopButton.Size = new Size(73, 69);
+            StopButton.Size = new Size(69, 69);
             StopButton.TabIndex = 0;
             StopButton.Text = "⏹️";
             StopButton.UseVisualStyleBackColor = true;
@@ -84,10 +86,11 @@
             // 
             // PlayButton
             // 
+            PlayButton.Dock = DockStyle.Fill;
             PlayButton.Font = new Font("Microsoft YaHei UI", 19F);
-            PlayButton.Location = new Point(91, 12);
+            PlayButton.Location = new Point(78, 3);
             PlayButton.Name = "PlayButton";
-            PlayButton.Size = new Size(73, 69);
+            PlayButton.Size = new Size(69, 69);
             PlayButton.TabIndex = 1;
             PlayButton.Text = "▶️";
             PlayButton.UseVisualStyleBackColor = true;
@@ -95,10 +98,11 @@
             // 
             // PauseButton
             // 
+            PauseButton.Dock = DockStyle.Fill;
             PauseButton.Font = new Font("Microsoft YaHei UI", 19F);
-            PauseButton.Location = new Point(170, 12);
+            PauseButton.Location = new Point(153, 3);
             PauseButton.Name = "PauseButton";
-            PauseButton.Size = new Size(73, 69);
+            PauseButton.Size = new Size(69, 69);
             PauseButton.TabIndex = 2;
             PauseButton.Text = "⏸";
             PauseButton.UseVisualStyleBackColor = true;
@@ -106,10 +110,11 @@
             // 
             // PrevButton
             // 
+            PrevButton.Dock = DockStyle.Fill;
             PrevButton.Font = new Font("Microsoft YaHei UI", 19F);
-            PrevButton.Location = new Point(249, 12);
+            PrevButton.Location = new Point(228, 3);
             PrevButton.Name = "PrevButton";
-            PrevButton.Size = new Size(73, 69);
+            PrevButton.Size = new Size(69, 69);
             PrevButton.TabIndex = 3;
             PrevButton.Text = "⏮";
             PrevButton.UseVisualStyleBackColor = true;
@@ -117,10 +122,11 @@
             // 
             // NextButton
             // 
+            NextButton.Dock = DockStyle.Fill;
             NextButton.Font = new Font("Microsoft YaHei UI", 19F);
-            NextButton.Location = new Point(328, 12);
+            NextButton.Location = new Point(303, 3);
             NextButton.Name = "NextButton";
-            NextButton.Size = new Size(73, 69);
+            NextButton.Size = new Size(69, 69);
             NextButton.TabIndex = 4;
             NextButton.Text = "⏭";
             NextButton.UseVisualStyleBackColor = true;
@@ -131,15 +137,16 @@
             MainListView.AllowDrop = true;
             MainListView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
             MainListView.Columns.AddRange(new ColumnHeader[] { TitleColumnHeader, DurColumnHeader, StateColumnHeader });
+            MainPanel.SetColumnSpan(MainListView, 8);
             MainListView.ContextMenuStrip = MainContextMenu;
             MainListView.FullRowSelect = true;
             MainListView.GroupImageList = AlbumImageList;
             MainListView.Items.AddRange(new ListViewItem[] { listViewItem1, listViewItem2, listViewItem3, listViewItem4 });
-            MainListView.Location = new Point(12, 87);
+            MainListView.Location = new Point(3, 78);
             MainListView.Name = "MainListView";
             MainListView.ShowItemToolTips = true;
-            MainListView.Size = new Size(1020, 609);
-            MainListView.TabIndex = 7;
+            MainListView.Size = new Size(1040, 520);
+            MainListView.TabIndex = 8;
             MainListView.UseCompatibleStateImageBehavior = false;
             MainListView.View = View.Details;
             MainListView.ColumnWidthChanging += MainListView_ColumnWidthChanging;
@@ -186,12 +193,12 @@
             // 
             // SettingButton
             // 
-            SettingButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+            SettingButton.Dock = DockStyle.Fill;
             SettingButton.Font = new Font("Microsoft YaHei UI", 19F);
-            SettingButton.Location = new Point(959, 12);
+            SettingButton.Location = new Point(974, 3);
             SettingButton.Name = "SettingButton";
-            SettingButton.Size = new Size(73, 69);
-            SettingButton.TabIndex = 6;
+            SettingButton.Size = new Size(69, 69);
+            SettingButton.TabIndex = 7;
             SettingButton.Text = "🛠️";
             SettingButton.UseVisualStyleBackColor = true;
             SettingButton.Click += SettingButton_Click;
@@ -207,16 +214,16 @@
             MainStatusBar.GripStyle = ToolStripGripStyle.Visible;
             MainStatusBar.ImageScalingSize = new Size(24, 24);
             MainStatusBar.Items.AddRange(new ToolStripItem[] { StatusBarLabel });
-            MainStatusBar.Location = new Point(0, 699);
+            MainStatusBar.Location = new Point(6, 607);
             MainStatusBar.Name = "MainStatusBar";
-            MainStatusBar.Size = new Size(1044, 31);
+            MainStatusBar.Size = new Size(1046, 31);
             MainStatusBar.TabIndex = 7;
             MainStatusBar.Text = "statusStrip1";
             // 
             // StatusBarLabel
             // 
             StatusBarLabel.Name = "StatusBarLabel";
-            StatusBarLabel.Size = new Size(1029, 24);
+            StatusBarLabel.Size = new Size(1031, 24);
             StatusBarLabel.Spring = true;
             StatusBarLabel.Text = "Status Bar Label Brr Brr Brr Brr Brr Brr Brr Brr Brr";
             StatusBarLabel.TextAlign = ContentAlignment.MiddleLeft;
@@ -226,34 +233,61 @@
             SettingButtonToolTip.IsBalloon = true;
             SettingButtonToolTip.ShowAlways = true;
             // 
-            // MainPanel
+            // PlaylistModeButton
             // 
-            MainPanel.Controls.Add(StopButton);
-            MainPanel.Controls.Add(SeekTrackBar);
-            MainPanel.Controls.Add(MainListView);
-            MainPanel.Controls.Add(PlayButton);
-            MainPanel.Controls.Add(SettingButton);
-            MainPanel.Controls.Add(PauseButton);
-            MainPanel.Controls.Add(NextButton);
-            MainPanel.Controls.Add(PrevButton);
-            MainPanel.Dock = DockStyle.Fill;
-            MainPanel.Location = new Point(0, 0);
-            MainPanel.Name = "MainPanel";
-            MainPanel.Size = new Size(1044, 699);
-            MainPanel.TabIndex = 8;
+            PlaylistModeButton.Dock = DockStyle.Fill;
+            PlaylistModeButton.Font = new Font("Microsoft YaHei UI", 19F);
+            PlaylistModeButton.Location = new Point(378, 3);
+            PlaylistModeButton.Name = "PlaylistModeButton";
+            PlaylistModeButton.Size = new Size(69, 69);
+            PlaylistModeButton.TabIndex = 5;
+            PlaylistModeButton.Text = "⇶";
+            PlaylistModeButton.UseVisualStyleBackColor = true;
+            PlaylistModeButton.Click += PlaylistModeButton_Click;
+            PlaylistModeButton.Paint += PlaylistModeButton_Paint;
             // 
             // SeekTrackBarToolTip
             // 
             SeekTrackBarToolTip.ShowAlways = true;
             // 
+            // MainPanel
+            // 
+            MainPanel.ColumnCount = 8;
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
+            MainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
+            MainPanel.Controls.Add(MainListView, 0, 1);
+            MainPanel.Controls.Add(SeekTrackBar, 6, 0);
+            MainPanel.Controls.Add(SettingButton, 7, 0);
+            MainPanel.Controls.Add(StopButton, 0, 0);
+            MainPanel.Controls.Add(PlayButton, 1, 0);
+            MainPanel.Controls.Add(PauseButton, 2, 0);
+            MainPanel.Controls.Add(PlaylistModeButton, 5, 0);
+            MainPanel.Controls.Add(PrevButton, 3, 0);
+            MainPanel.Controls.Add(NextButton, 4, 0);
+            MainPanel.Dock = DockStyle.Fill;
+            MainPanel.Location = new Point(6, 6);
+            MainPanel.Name = "MainPanel";
+            MainPanel.RowCount = 2;
+            MainPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 75F));
+            MainPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
+            MainPanel.Size = new Size(1046, 601);
+            MainPanel.TabIndex = 9;
+            // 
             // MainForm
             // 
             AutoScaleDimensions = new SizeF(11F, 24F);
             AutoScaleMode = AutoScaleMode.Font;
-            ClientSize = new Size(1044, 730);
+            ClientSize = new Size(1058, 644);
             Controls.Add(MainPanel);
             Controls.Add(MainStatusBar);
             Name = "MainForm";
+            Padding = new Padding(6);
             FormClosed += MainForm_FormClosed;
             Shown += MainForm_Shown;
             ((System.ComponentModel.ISupportInitialize)SeekTrackBar).EndInit();
@@ -285,7 +319,8 @@
         private ContextMenuStrip MainContextMenu;
         private ToolTip SettingButtonToolTip;
         private Panel panel1;
-        private Panel MainPanel;
         private ToolTip SeekTrackBarToolTip;
+        private Button PlaylistModeButton;
+        private TableLayoutPanel MainPanel;
     }
 }

+ 25 - 5
Bmp.WinForms/MainForm.cs

@@ -1,4 +1,5 @@
 using System.ComponentModel;
+using System.Drawing.Drawing2D;
 using System.Text;
 using System.Threading.Channels;
 using Bmp.Core.Common.EventBus;
@@ -413,7 +414,7 @@ namespace Bmp.WinForms
             }
             else
             {
-                //TODO: 消息机制 因为发生错误而停止
+                //TODO: 消息机制 错误 因为发生错误而停止
                 _playbackState = UIPlaybackState.Error;
             }
         }
@@ -979,8 +980,6 @@ namespace Bmp.WinForms
                 }
             }
 
-
-
             //参数
             if (_inputSource != null)
             {
@@ -1044,7 +1043,7 @@ namespace Bmp.WinForms
                 sb.Append($"{_selectedOutputDevice.DisplayName}");
             }
 
-            //解码器 格式编码
+            //解码器 编码 容器
             if (_inputSource is IHaveDecoderInfo dn)
             {
                 sb.Append($" | {dn.DecoderName} {dn.FileFormat}");
@@ -1107,7 +1106,7 @@ namespace Bmp.WinForms
                 }
                 catch (Exception exception)
                 {
-                    //TODO: 异常处理
+                    //TODO: 消息机制 错误 跳转发生错误 SeekTrackBar_MouseUp
                     Console.WriteLine(exception);
                     _playbackState = UIPlaybackState.Error;
                 }
@@ -1115,6 +1114,27 @@ namespace Bmp.WinForms
             MainPanel.Enabled = true;
             _trackBarHolding = false;
         }
+
+        private void PlaylistModeButton_Paint(object sender, PaintEventArgs e)
+        {
+            // Draw the arrow glyph on the right side of the button
+            var arrowX = PlaylistModeButton.ClientRectangle.Width - 24;
+            var arrowY = PlaylistModeButton.ClientRectangle.Height / 2 + 12;
+
+            var arrowBrush = PlaylistModeButton.Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
+            var arrows = new[]
+            {
+                new PointF(arrowX, arrowY),
+                new PointF(arrowX + 18, arrowY),
+                new PointF(arrowX + 9 , arrowY + 9 )
+            };
+            e.Graphics.FillPolygon(arrowBrush, arrows);
+        }
+
+        private void PlaylistModeButton_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 
     internal enum UIPlaybackState