I want to make program name Cyan Pembuat Soal(Cyan Question Maker) I add the startup event to this Code:
using System;
using System.Windows;
namespace Cyan_Pembuat_Soal {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
private void Application_Startup(object sender, StartupEventArgs e){
if (FindPlace(e.Args) != null) {
Cyan_Pembuat_Soal.MainWindow a = new Cyan_Pembuat_Soal.MainWindow();
a.Activate();
} else {
Cyan_Pembuat_Soal.MainWindow a = new Cyan_Pembuat_Soal.MainWindow();
a.Activate();
a.Closed += delegate(object senders, EventArgs es) {this.Shutdown();};
}
}
private static string FindPlace(string[] a) {
if (a.Length == 0) {
return null;
}
int b = 0;
System.Uri c;
for (b = 0; b < a.Length; b++) {
if(Uri.TryCreate(a[b], UriKind.RelativeOrAbsolute, out c)){
break;
}
}
c = null;
return a[b];
}
}
}
But that code did not work properly. What’s wrong in this program?
I would try to add
a.ShowDialog();ora.Show();in addition toa.Activate();.Not sure why you are using
Activate(), but make sure that it does what you want it do to.http://msdn.microsoft.com/en-us/library/system.windows.window.activate.aspx