图标 参数

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.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace JianGongYun
{
@ -13,5 +14,19 @@ namespace JianGongYun
/// </summary>
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>
<AssemblyName>sznykt</AssemblyName>
</PropertyGroup>
<ItemGroup>
<None Remove="lg.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AduSkin" Version="1.1.1.8" />
<PackageReference Include="CommonServiceLocator" Version="2.0.5" />
@ -48,6 +52,11 @@
<Version>4.5.1.20201229</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="lg.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<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" />
</Target>

View File

@ -2,7 +2,7 @@
"profiles": {
"JianGongYun": {
"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
}
}

View File

@ -35,7 +35,8 @@ namespace JianGongYun.TRTC.Windows
public LiveWindow()
{
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();
AttachConsole(-1);//把进程挂在控制台,通过命令行启动程序可以看到控制台输出
LiveWindowViewModel = new ViewModels.LiveWindowViewModel();

View File

@ -29,7 +29,8 @@ namespace JianGongYun.TRTC.Windows
{
_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;
}

View File

@ -31,77 +31,93 @@ namespace JianGongYun.Views
public Login()
{
InitializeComponent();
this.Icon = new BitmapImage(new Uri("logo.ico", UriKind.Relative));
string errMsg = "", classHead = default, classSubHead = default, teacherId = default, teacherName = default, endtime = default;
var urltemps = Environment.GetCommandLineArgs();
if (urltemps.Length < 2)
try
{
errMsg = $"Startup Parameter Null";
goto Skip;
}
var first = urltemps[1];
if (!first.StartsWith("sznykt"))
{
errMsg = "Startup Parameter Error";
goto Skip;
}
var args = HttpUtility.UrlDecode(first, Encoding.UTF8).Replace("://", "|").Split("|");
int indexTemp = Array.IndexOf(args, CLASS_HEAD);
if (indexTemp < 0)
{
errMsg = $"{nameof(classHead)} NULL";
goto Skip;
}
classHead = args[indexTemp + 1];
//this.Icon = new BitmapImage(new Uri("lg.ico", UriKind.Relative));
this.Icon = App.icon;
//this.Icon = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "logo.ico"), UriKind.Absolute));
string errMsg = "", classHead = default, classSubHead = default, teacherId = default, teacherName = default, endtime = default;
var urltemps = Environment.GetCommandLineArgs();
if (urltemps.Length < 2)
{
errMsg = $"Startup Parameter Null";
goto Skip;
}
var first = urltemps[1];
if (!first.StartsWith("sznykt"))
{
errMsg = "Startup Parameter Error";
goto Skip;
}
indexTemp = Array.IndexOf(args, CLASS_SUB_HEAD);
if (indexTemp < 0)
{
errMsg = $"{nameof(CLASS_SUB_HEAD)} NULL";
goto Skip;
}
classSubHead = args[indexTemp + 1];
var u = HttpUtility.UrlDecode(first, Encoding.UTF8);
if (u.EndsWith('/'))
{
u = u.Substring(0, u.Length - 1);
}
var args = u.Replace("://", "|").Split("|");
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);
if (indexTemp < 0)
{
errMsg = $"{nameof(TEACHER_ID)} NULL";
goto Skip;
}
teacherId = 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_NAME);
if (indexTemp < 0)
{
errMsg = $"{nameof(TEACHER_NAME)} NULL";
goto Skip;
}
teacherName = 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, END_TIME);
if (indexTemp < 0)
{
errMsg = $"{nameof(END_TIME)} NULL";
goto Skip;
}
endtime = 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))
indexTemp = Array.IndexOf(args, END_TIME);
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);
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