我有两个应用程序,都在 WPF 中。我的第一个应用程序是 GIS,它位于 .NET 4.0 中,而我的另一个应用程序位于 .NET 3.5 中。在我的 GIS 应用程序中,我正在加载带有图标的 GIS 数据层。我的要求是打开 exe,这是我在选定图标位置的第二个应用程序(.net 3.5)(意味着图标 lat 和 long)。
我想知道如何在图标位置加载第二个 exe。任何帮助都非常感谢。
If you are using Process.Start()
to launch your second exe, then you can pass the icon position as command line arguments in this method like:
Process.Start(@"C:\MyWPFApplication.exe", "50 60");
here assuming MyWPFApplication.exe is your second app and 50,60 are the coordinates you want to launch it on.
Now in App.xaml
of MyWPFApplication, remove the StartUpUri
and in App.xaml.cs
override OnStartup()
method as below to create the main applicatin window and set its Left and Top before showing it:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MainWindow window = new MainWindow();
if(e.Args.Length == 2)
{
window.Left = double.Parse(e.Args[0]);
window.Top = double.Parse(e.Args[1]);
}
window.Show();
}