private void SingleInstanceCallback(Object sender, InstanceCallbackEventArgs args) {
if (args == null || this.Dispatcher == null) {
return;
}
var startUpLocation = Utilities.GetRegistryValue("StartUpLoc", KnownFolders.Libraries.ParsingName).ToString();
Action<Boolean> d = x => {
var win = this.MainWindow as MainWindow;
var windowsActivate = new CombinedWindowActivator();
if (!x) {
return;
}
if (win == null) {
return;
}
win.StateChanged += this.Win_StateChanged;
if (args.CommandLineArgs == null || !args.CommandLineArgs.Any()) {
return;
}
if (args.CommandLineArgs.Length == 1) {
win.Visibility = Visibility.Visible;
windowsActivate.ActivateForm(win, null, IntPtr.Zero);
} else {
if (args.CommandLineArgs[1] == "/nw") {
new MainWindow() { IsMultipleWindowsOpened = true }.Show();
} else {
IListItemEx sho;
if (args.CommandLineArgs[1] == "t") {
win.Visibility = Visibility.Visible;
windowsActivate.ActivateForm(win, null, IntPtr.Zero);
sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, startUpLocation.ToShellParsingName());
} else {
sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, args.CommandLineArgs[1].ToShellParsingName());
}
if (!IsStartMinimized || win.tcMain.Items.Count == 0) {
this.CreateInitialTab(win, sho);
} else if ((Int32)Utilities.GetRegistryValue("IsRestoreTabs", "1") == 0) {
win.tcMain.Items.Clear();
this.CreateInitialTab(win, sho);
} else if (args.CommandLineArgs.Length > 1 && args.CommandLineArgs[1] != null) {
if (args.CommandLineArgs[1] == "t") {
this.CreateInitialTab(win, sho);
} else {
var cmd = args.CommandLineArgs[1];
sho = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, cmd.ToShellParsingName());
this.CreateInitialTab(win, sho);
}
} else {
this.CreateInitialTab(win, sho);
}
}
windowsActivate.ActivateForm(win, null, IntPtr.Zero);
}
};
this.Dispatcher.BeginInvoke(d, true);
}