private void LoadStack(bool aCreatedNew) { iWindowLoaded.WaitOne(); Linn.Kinsky.Model model = new Linn.Kinsky.Model(iViewMaster, iPlaySupport); iMediator = new Mediator(iHelper, model); Dispatcher.Invoke((Action) delegate() { iSystrayForm = new SystrayForm(this); iSystrayForm.EventClosed += window_Closed; iSystrayForm.Text = this.Title; }); // create the drop converter for the browser views DropConverter browseDropConverter = new DropConverter(); browseDropConverter.Add(new DropConverterInternal()); browseDropConverter.Add(new DropConverterUri()); browseDropConverter.Add(new DropConverterFileDrop(iHttpServer, false)); browseDropConverter.Add(new DropConverterText()); // create the drop converter for the other views DropConverter viewDropConverter = new DropConverter(); viewDropConverter.Add(new DropConverterInternal()); viewDropConverter.Add(new DropConverterUri()); viewDropConverter.Add(new DropConverterFileDrop(iHttpServer, true)); viewDropConverter.Add(new DropConverterText()); Dispatcher.Invoke((Action) delegate() { if (!aCreatedNew) { double newX = iUIOptions.WindowLocation.X + 10; double newY = iUIOptions.WindowLocation.Y + 10; Point midpoint = new Point(newX + (Width / 2), newY + (Height / 2)); if (PointToScreen(midpoint).X >= SystemParameters.VirtualScreenWidth) { newX = 0; } if (PointToScreen(midpoint).Y >= SystemParameters.VirtualScreenHeight) { newY = 0; } Left = newX; Top = newY; //iUIOptions.WindowLocation = new Point(Left, Top); } iSystrayForm.Initialise(iViewMaster); viewKinsky.Initialise(this, iHelper, iLocator, iViewSaveSupport, iPlaySupport, browseDropConverter, viewDropConverter, iViewMaster, iUIOptions, iGroupPlaylistOption, iHelper.Senders); SetThemeOverrides(); kompactMenuItem.IsChecked = iUIOptions.MiniMode; mainWindowChrome.MiniModeActiveChanged += new EventHandler(mainWindowChrome_MiniModeActiveChanged); }); EReleaseQuality currentBuildType = EReleaseQuality.Stable; if (iHelper.Title.ToLowerInvariant().Contains("nightly")) { currentBuildType = EReleaseQuality.Nightly; } else if (iHelper.Title.ToLowerInvariant().Contains("beta")) { currentBuildType = EReleaseQuality.Beta; } else if (iHelper.Title.ToLowerInvariant().Contains("development")) { currentBuildType = EReleaseQuality.Development; } else if (iHelper.Title.ToLowerInvariant().Contains("developer")) { currentBuildType = EReleaseQuality.Developer; } var appName = iHelper.Product; iAutoUpdate = new AutoUpdate(iHelper, AutoUpdate.DefaultFeedLocation(appName, "Windows"), 1000 * 60 * 60, iAutoUpdateType, appName, kApplicationTarget, kUpdateVersion, currentBuildType); iAutoUpdate.EventUpdateFound += iAutoUpdate_EventUpdateFound; iHelper.SetStackExtender(this); iHelper.Stack.SetStatusHandler(new StackStatusHandlerWpf(iHelper.Title, iSystrayForm.NotifyIcon)); Dispatcher.BeginInvoke((Action) delegate() { HwndSource source = PresentationSource.FromVisual(this) as HwndSource; source.AddHook(HandleSessionEvents); if (!WTSRegisterSessionNotification((new WindowInteropHelper(this)).Handle, NOTIFY_FOR_THIS_SESSION)) { UserLog.WriteLine("Could not register for user session changes."); } iInitialSessionId = System.Diagnostics.Process.GetCurrentProcess().SessionId; iSessionConnected = true; iSessionHookAdded = true; StartStack(); }); // show the options dialog if specified by the user if (iHelper.Stack.StatusHandler.ShowOptions) { Dispatcher.BeginInvoke((Action) delegate() { ShowOptionsDialog(true); }); } }