diff --git a/JianGongYun/Properties/launchSettings.json b/JianGongYun/Properties/launchSettings.json index 81e5d4b..0b73c15 100644 --- a/JianGongYun/Properties/launchSettings.json +++ b/JianGongYun/Properties/launchSettings.json @@ -2,6 +2,7 @@ "profiles": { "JianGongYun": { "commandName": "Project", + "commandLineArgs": "--classhead 测试课程1 --classsubhead 测试章节1 --teacherid 12345678 --teachername 王大锤", "nativeDebugging": false } } diff --git a/JianGongYun/TRTC/LiveClassroom.cs b/JianGongYun/TRTC/LiveClassroom.cs index d5d9007..f6cb088 100644 --- a/JianGongYun/TRTC/LiveClassroom.cs +++ b/JianGongYun/TRTC/LiveClassroom.cs @@ -592,7 +592,6 @@ namespace JianGongYun.TRTC prc.WaitForExit(); CurrentLiveWindow.Dispatcher.Invoke(new Action(() => { - CurrentLiveWindow.Close(); NoticeManager.NotifiactionShow.AddNotifiaction(new NotifiactionModel() { Title = "提醒", @@ -620,6 +619,7 @@ namespace JianGongYun.TRTC File.Delete(AudioTempPath); } } + CurrentLiveWindow.Close(); })); Debug.Print("结束写入视频线程"); }, TaskCreationOptions.LongRunning); @@ -727,7 +727,8 @@ namespace JianGongYun.TRTC Application.Current.Shutdown(); return; } - CallerWindow.Show();//还原调用者窗口 + CallerWindow.Close();//直接关闭 + Application.Current.Shutdown(); } diff --git a/JianGongYun/Views/Login.xaml.cs b/JianGongYun/Views/Login.xaml.cs index f885528..6f67f2c 100644 --- a/JianGongYun/Views/Login.xaml.cs +++ b/JianGongYun/Views/Login.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using System.Linq; namespace JianGongYun.Views { @@ -21,25 +22,62 @@ namespace JianGongYun.Views /// public partial class Login : MetroWindow { + const string CLASS_HEAD = "--classhead"; + const string CLASS_SUB_HEAD = "--classsubhead"; + const string TEACHER_ID = "--teacherid"; + const string TEACHER_NAME = "--teachername"; public Login() { InitializeComponent(); - BorderBrush = new SolidColorBrush(color: Color.FromRgb(42, 43, 48)); - var roomId = ConfigurationManager.AppSettings["RoomId"]; - if (string.IsNullOrWhiteSpace(roomId)) + var args = Environment.GetCommandLineArgs(); + string errMsg = "", classHead = default, classSubHead = default, teacherId = default, teacherName = default; + int indexTemp = Array.IndexOf(args, CLASS_HEAD); + if (indexTemp < 0) { - MessageBox.Show("未配置房间号!","警告", MessageBoxButton.OKCancel,MessageBoxImage.Error); - Application.Current.Shutdown(); + errMsg = $"{nameof(classHead)} NULL"; + goto Skip; } - LiveClassroom.EnterTheClassroom(null, + classHead = args[indexTemp + 1]; + + indexTemp = Array.IndexOf(args, CLASS_SUB_HEAD); + if (indexTemp < 0) + { + errMsg = $"{nameof(CLASS_SUB_HEAD)} NULL"; + goto Skip; + } + classSubHead = args[indexTemp + 1]; + + indexTemp = Array.IndexOf(args, TEACHER_ID); + if (indexTemp < 0) + { + errMsg = $"{nameof(TEACHER_ID)} NULL"; + goto Skip; + } + teacherId = args[indexTemp + 1]; + + indexTemp = Array.IndexOf(args, TEACHER_NAME); + if (indexTemp < 0) + { + errMsg = $"{nameof(TEACHER_NAME)} NULL"; + goto Skip; + } + teacherName = args[indexTemp + 1]; + + Skip: + if (!string.IsNullOrWhiteSpace(errMsg)) + { + MessageBox.Show(errMsg, "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error); + Application.Current.Shutdown(); + return; + } + LiveClassroom.EnterTheClassroom(Window.GetWindow(this), new TRTC.Models.ClassroomEntity { - ClassHead = "课程1", - ClassSubHead = "章节1", - TeacherId = roomId, - TeacherName = "王大锤" + ClassHead = classHead, + ClassSubHead = classSubHead, + TeacherId = teacherId, + TeacherName = teacherName }); - this.Close(); } } }