浏览代码

音频播放添加

章政 6 年之前
父节点
当前提交
d2632cd957

+ 21 - 1
UAS-出货标签管理(吉利通)/PublicMethod/BaseUtil.cs

@@ -10,6 +10,7 @@ using static System.Windows.Forms.Control;
 using System.Text.RegularExpressions;
 using UAS_LabelMachine.CustomControl.RichText;
 using System.IO;
+using System.Media;
 
 namespace UAS_LabelMachine
 {
@@ -35,7 +36,26 @@ namespace UAS_LabelMachine
             }
         }
 
-    
+        public static void PlaySound(string FileName)
+        {
+            //要加载COM组件:Microsoft speech object Library    
+            if (!System.IO.File.Exists(FileName))
+            {
+                return;
+            }
+            try
+            {
+                SoundPlayer player = new SoundPlayer();
+                player.SoundLocation = FileName;
+                player.Load();
+                player.Play();
+            }
+            catch (Exception e)
+            {
+                MessageBox.Show(e.Message);
+            }
+        }
+
         public static string SysDisc1
         {
             get

+ 4 - 0
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -240,6 +240,7 @@ namespace UAS_LabelMachine
                         if (!FrontCheckFunction(msg, out ErrorMsg))
                         {
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataDelete);
+                            BaseUtil.PlaySound("Scan.Error.wav");
                             MessageLog.AppendText(">>" + ErrorMsg + "\n", Color.Red);
                         }
                         else
@@ -258,6 +259,7 @@ namespace UAS_LabelMachine
                                 }
                             }
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
+                            BaseUtil.PlaySound("Scan.Finish.wav");
                             //勾选了中盒自动打印
                             if (MidLabelAutoPrint.Checked)
                                 AutoPrintMidLabel();
@@ -270,10 +272,12 @@ namespace UAS_LabelMachine
                         if (BackendCheckFunction(msg, pib_id, out ErrorMsg))
                         {
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataPass);
+                            BaseUtil.PlaySound("Confirm.Finish.wav");
                         }
                         else
                         {
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataDelete);
+                            BaseUtil.PlaySound("Confirm.Error.wav");
                             MessageLog.AppendText(">>" + ErrorMsg + "\n", Color.Red);
                         }
                         break;

二进制
UAS-出货标签管理(吉利通)/bin/Debug/Confirm.Error.wav


二进制
UAS-出货标签管理(吉利通)/bin/Debug/Confirm.Finish.wav


二进制
UAS-出货标签管理(吉利通)/bin/Debug/Scan.Error.wav


二进制
UAS-出货标签管理(吉利通)/bin/Debug/Scan.Finish.wav