图标 参数

This commit is contained in:
lxmou666 2021-02-22 17:17:02 +08:00
parent 2d3c116a32
commit 5cac0bf044
7 changed files with 107 additions and 65 deletions

View File

@ -5,6 +5,7 @@ using System.Data;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Media.Imaging;
namespace JianGongYun namespace JianGongYun
{ {
@ -13,5 +14,19 @@ namespace JianGongYun
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
public static BitmapImage icon
{
get
{
BitmapImage bitmapImage = new BitmapImage();
string name = "JianGongYun.lg.ico";
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream stream = assembly.GetManifestResourceStream(name);
bitmapImage.BeginInit();
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();
return bitmapImage;
}
}
} }
} }

View File

@ -12,6 +12,10 @@
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
<AssemblyName>sznykt</AssemblyName> <AssemblyName>sznykt</AssemblyName>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="lg.ico" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AduSkin" Version="1.1.1.8" /> <PackageReference Include="AduSkin" Version="1.1.1.8" />
<PackageReference Include="CommonServiceLocator" Version="2.0.5" /> <PackageReference Include="CommonServiceLocator" Version="2.0.5" />
@ -48,6 +52,11 @@
<Version>4.5.1.20201229</Version> <Version>4.5.1.20201229</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="lg.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="set Platform=Win64&#xD;&#xA;SETLOCAL ENABLEDELAYEDEXPANSION&#xD;&#xA;if $(PlatformName)==x86 ( &#xD;&#xA;set Platform=Win32&#xD;&#xA;)&#xD;&#xA;copy /Y &quot;$(ProjectDir)TRTC_SDK\!Platform!\lib\*.*&quot; &quot;$(ProjectDir)$(OutDir)&quot;&#xD;&#xA;ENDLOCAL" /> <Exec Command="set Platform=Win64&#xD;&#xA;SETLOCAL ENABLEDELAYEDEXPANSION&#xD;&#xA;if $(PlatformName)==x86 ( &#xD;&#xA;set Platform=Win32&#xD;&#xA;)&#xD;&#xA;copy /Y &quot;$(ProjectDir)TRTC_SDK\!Platform!\lib\*.*&quot; &quot;$(ProjectDir)$(OutDir)&quot;&#xD;&#xA;ENDLOCAL" />
</Target> </Target>

View File

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"JianGongYun": { "JianGongYun": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "sznykt://--classhead|测试课程1|--classsubhead|测试章节1|--teacherid|1234_5678|--teachername|王大锤|endtime|MjAyMS0wMy0xOCAyMTo1MDowMA==", "commandLineArgs": "sznykt://--classhead|测试课程1|--classsubhead|测试章节1|--teacherid|1234_5678|--teachername|王大锤|endtime|2022-02-25 11:11:11",
"nativeDebugging": false "nativeDebugging": false
} }
} }

View File

@ -35,7 +35,8 @@ namespace JianGongYun.TRTC.Windows
public LiveWindow() public LiveWindow()
{ {
InitializeComponent(); InitializeComponent();
this.Icon = new BitmapImage(new Uri("logo.ico", UriKind.RelativeOrAbsolute)); this.Icon = App.icon;
//this.Icon = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "logo.ico"), UriKind.Absolute));
NoticeManager.Initialize(); NoticeManager.Initialize();
AttachConsole(-1);//把进程挂在控制台,通过命令行启动程序可以看到控制台输出 AttachConsole(-1);//把进程挂在控制台,通过命令行启动程序可以看到控制台输出
LiveWindowViewModel = new ViewModels.LiveWindowViewModel(); LiveWindowViewModel = new ViewModels.LiveWindowViewModel();

View File

@ -29,7 +29,8 @@ namespace JianGongYun.TRTC.Windows
{ {
_Instance = new SettingWindow(); _Instance = new SettingWindow();
} }
_Instance.Icon= new BitmapImage(new Uri("logo.ico", UriKind.Relative)); _Instance.Icon = App.icon;
//_Instance.Icon = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "logo.ico"), UriKind.Absolute));
return _Instance; return _Instance;
} }

View File

@ -31,77 +31,93 @@ namespace JianGongYun.Views
public Login() public Login()
{ {
InitializeComponent(); InitializeComponent();
this.Icon = new BitmapImage(new Uri("logo.ico", UriKind.Relative)); try
string errMsg = "", classHead = default, classSubHead = default, teacherId = default, teacherName = default, endtime = default;
var urltemps = Environment.GetCommandLineArgs();
if (urltemps.Length < 2)
{ {
errMsg = $"Startup Parameter Null"; //this.Icon = new BitmapImage(new Uri("lg.ico", UriKind.Relative));
goto Skip; this.Icon = App.icon;
} //this.Icon = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "logo.ico"), UriKind.Absolute));
var first = urltemps[1]; string errMsg = "", classHead = default, classSubHead = default, teacherId = default, teacherName = default, endtime = default;
if (!first.StartsWith("sznykt")) var urltemps = Environment.GetCommandLineArgs();
{ if (urltemps.Length < 2)
errMsg = "Startup Parameter Error"; {
goto Skip; errMsg = $"Startup Parameter Null";
} goto Skip;
var args = HttpUtility.UrlDecode(first, Encoding.UTF8).Replace("://", "|").Split("|"); }
int indexTemp = Array.IndexOf(args, CLASS_HEAD); var first = urltemps[1];
if (indexTemp < 0) if (!first.StartsWith("sznykt"))
{ {
errMsg = $"{nameof(classHead)} NULL"; errMsg = "Startup Parameter Error";
goto Skip; goto Skip;
} }
classHead = args[indexTemp + 1];
indexTemp = Array.IndexOf(args, CLASS_SUB_HEAD); var u = HttpUtility.UrlDecode(first, Encoding.UTF8);
if (indexTemp < 0) if (u.EndsWith('/'))
{ {
errMsg = $"{nameof(CLASS_SUB_HEAD)} NULL"; u = u.Substring(0, u.Length - 1);
goto Skip; }
} var args = u.Replace("://", "|").Split("|");
classSubHead = args[indexTemp + 1]; int indexTemp = Array.IndexOf(args, CLASS_HEAD);
if (indexTemp < 0)
{
errMsg = $"{nameof(classHead)} NULL";
goto Skip;
}
classHead = args[indexTemp + 1];
indexTemp = Array.IndexOf(args, TEACHER_ID); indexTemp = Array.IndexOf(args, CLASS_SUB_HEAD);
if (indexTemp < 0) if (indexTemp < 0)
{ {
errMsg = $"{nameof(TEACHER_ID)} NULL"; errMsg = $"{nameof(CLASS_SUB_HEAD)} NULL";
goto Skip; goto Skip;
} }
teacherId = args[indexTemp + 1]; classSubHead = args[indexTemp + 1];
indexTemp = Array.IndexOf(args, TEACHER_NAME); indexTemp = Array.IndexOf(args, TEACHER_ID);
if (indexTemp < 0) if (indexTemp < 0)
{ {
errMsg = $"{nameof(TEACHER_NAME)} NULL"; errMsg = $"{nameof(TEACHER_ID)} NULL";
goto Skip; goto Skip;
} }
teacherName = args[indexTemp + 1]; teacherId = args[indexTemp + 1];
indexTemp = Array.IndexOf(args, END_TIME); indexTemp = Array.IndexOf(args, TEACHER_NAME);
if (indexTemp < 0) if (indexTemp < 0)
{ {
errMsg = $"{nameof(END_TIME)} NULL"; errMsg = $"{nameof(TEACHER_NAME)} NULL";
goto Skip; goto Skip;
} }
endtime = args[indexTemp + 1]; teacherName = args[indexTemp + 1];
Skip: indexTemp = Array.IndexOf(args, END_TIME);
if (!string.IsNullOrWhiteSpace(errMsg)) if (indexTemp < 0)
{
errMsg = $"{nameof(END_TIME)} NULL";
goto Skip;
}
endtime = args[indexTemp + 1];
Skip:
if (!string.IsNullOrWhiteSpace(errMsg))
{
MessageBox.Show(errMsg, "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
Environment.Exit(0);
return;
}
LiveClassroom.EnterTheClassroom(Window.GetWindow(this),
new TRTC.Models.ClassroomEntity
{
ClassHead = classHead,
ClassSubHead = classSubHead,
TeacherId = teacherId,
TeacherName = teacherName,
EndTime = string.IsNullOrEmpty(endtime) ? null : new DateTime?(DateTime.Parse(endtime))
});
}
catch (Exception ex)
{ {
MessageBox.Show(errMsg, "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error); MessageBox.Show(ex.Message, "错误", MessageBoxButton.OKCancel, MessageBoxImage.Error);
Environment.Exit(0); Environment.Exit(0);
return;
} }
LiveClassroom.EnterTheClassroom(Window.GetWindow(this),
new TRTC.Models.ClassroomEntity
{
ClassHead = classHead,
ClassSubHead = classSubHead,
TeacherId = teacherId,
TeacherName = teacherName,
EndTime = string.IsNullOrEmpty(endtime) ? null : new DateTime?(DateTime.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(endtime))))
});
} }
} }
} }

BIN
JianGongYun/lg.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB