启动参数

This commit is contained in:
lxmou666 2021-02-13 13:27:04 +08:00
parent 28cd604acc
commit df03186995
3 changed files with 53 additions and 13 deletions

View File

@ -2,6 +2,7 @@
"profiles": {
"JianGongYun": {
"commandName": "Project",
"commandLineArgs": "--classhead 测试课程1 --classsubhead 测试章节1 --teacherid 12345678 --teachername 王大锤",
"nativeDebugging": false
}
}

View File

@ -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();
}

View File

@ -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
/// </summary>
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();
}
}
}