Просмотр исходного кода

1.添加更改弹幕字号;
2.修改命令逻辑。

Yumin 6 лет назад
Родитель
Сommit
6a283a4547

+ 3 - 0
BarrageTransporter/App.config

@@ -13,6 +13,9 @@
             <setting name="startOpenBarrage" serializeAs="String">
                 <value>True</value>
             </setting>
+            <setting name="barrageFontSize" serializeAs="String">
+                <value>32</value>
+            </setting>
         </BarrageTransporter.Properties.Settings>
     </userSettings>
 </configuration>

+ 2 - 2
BarrageTransporter/BarrageHelper.cs

@@ -18,7 +18,7 @@ namespace BarrageTransporter
         public ShadowText(string text)
         {
             Text = text;
-            FontSize = 24;
+            FontSize = Properties.Settings.Default.barrageFontSize;
             Foreground = Brushes.White;
 
             Effect = new DropShadowEffect
@@ -39,7 +39,7 @@ namespace BarrageTransporter
     {
         private Grid container;
 
-        private int lineHeight = 32;
+        private int lineHeight = Properties.Settings.Default.barrageFontSize + 6;
         private int paddingTop = 4;
 
         private Boolean[] isOccupy;

+ 38 - 2
BarrageTransporter/MainWindow.xaml.cs

@@ -24,7 +24,6 @@ namespace BarrageTransporter
         private SerialTool serialTool = SerialTool.getSerialTool();
 
         SynchronizationContext synchronizationContext = null;
-        private BarrageManager barrageManager;
         private System.Timers.Timer timer;
         private bool barrageRunning = true;
         public WebSocket ws;
@@ -147,13 +146,50 @@ namespace BarrageTransporter
                 case 2:
                 case 3:
                 case 4:
+                    send = 0;
+                    break;
                 case 5:
                 case 6:
                 case 7:
+                    send = 1;
+                    break;
                 case 8:
                 case 9:
-                    send = count;
+                case 10:
+                    send = 2;
+                    break;
+                case 11:
+                case 12:
+                case 13:
+                    send = 3;
+                    break;
+                case 14:
+                case 15:
+                case 16:
+                    send = 4;
+                    break;
+                case 17:
+                case 18:
+                case 19:
+                    send = 5;
+                    break;
+                case 20:
+                case 21:
+                case 22:
+                    send = 6;
+                    break;
+                case 23:
+                case 24:
+                case 25:
+                    send = 7;
+                    break;
+                case 26:
+                case 27:
+                case 28:
+                    send = 8;
                     break;
+                case 29:
+                case 30:
                 default:
                     send = 9;
                     break;

+ 12 - 0
BarrageTransporter/Properties/Settings.Designer.cs

@@ -34,5 +34,17 @@ namespace BarrageTransporter.Properties {
                 this["startOpenBarrage"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("32")]
+        public int barrageFontSize {
+            get {
+                return ((int)(this["barrageFontSize"]));
+            }
+            set {
+                this["barrageFontSize"] = value;
+            }
+        }
     }
 }

+ 3 - 0
BarrageTransporter/Properties/Settings.settings

@@ -5,5 +5,8 @@
     <Setting Name="startOpenBarrage" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">True</Value>
     </Setting>
+    <Setting Name="barrageFontSize" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">32</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 3 - 1
BarrageTransporter/SettingsWindow.xaml

@@ -18,9 +18,11 @@
         <GroupBox x:Name="groupBox1" Header="其他设置" Margin="10,135,10,10">
             <Grid Margin="10">
                 <CheckBox x:Name="startOpenBarrage" Content="启动时显示弹幕" HorizontalAlignment="Left" VerticalAlignment="Top"/>
+                <Label Content="弹幕字号:" Margin="0,20,0,0" Height="24" Width="70" VerticalAlignment="Top" HorizontalAlignment="Left"/>
+                <ComboBox x:Name="barrageFontSize" Margin="75,20,0,0" VerticalAlignment="Top" Height="24" HorizontalAlignment="Left"/>
                 <Button x:Name="ok" Content="确定" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Height="24" Click="ok_Click"/>
             </Grid>
         </GroupBox>
-        
+
     </Grid>
 </Window>

+ 6 - 0
BarrageTransporter/SettingsWindow.xaml.cs

@@ -20,6 +20,11 @@ namespace BarrageTransporter
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
             startOpenBarrage.IsChecked = Properties.Settings.Default.startOpenBarrage;
+            for(int i = 16; i <= 72; i = i + 4)
+            {
+                barrageFontSize.Items.Add(i);
+            }
+            barrageFontSize.SelectedValue = Properties.Settings.Default.barrageFontSize;
             if (appContext.PortOpen)
             {
                 comboBox.Items.Clear();
@@ -103,6 +108,7 @@ namespace BarrageTransporter
         private void ok_Click(object sender, RoutedEventArgs e)
         {
             Properties.Settings.Default.startOpenBarrage = (bool)startOpenBarrage.IsChecked;
+            Properties.Settings.Default.barrageFontSize = (int)barrageFontSize.SelectedValue;
             Properties.Settings.Default.Save();
             Properties.Settings.Default.Reload();
             this.Close();