Пример #1
0
 private void Exit()
 {
     if (iProcessedOptions)
     {
         iHideCursorOption.EventValueChanged            -= OnOptionChanged;
         iRotaryControlsOption.EventValueChanged        -= OnOptionChanged;
         iShowToolTipsOption.EventValueChanged          -= OnOptionChanged;
         iShowExtendedTrackInfoOption.EventValueChanged -= OnOptionChanged;
         iFontsOption.EventValueChanged -= OnOptionChanged;
     }
     if (iSystrayForm != null && !iSystrayForm.IsDisposed)
     {
         iSystrayForm.Invoke((Action) delegate()
         {
             iSystrayForm.Close();
             iSystrayForm.Dispose();
             iSystrayForm = null;
         });
     }
     StopStack();
     if (iNamedMutex != null)
     {
         iNamedMutex.Close();
         iNamedMutex = null;
     }
     if (iUpdateOnExit)
     {
         // allow updater to spawn its process before shutting down
         using (EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, kUpdateReadySignal))
         {
             using (EventWaitHandle waitHandle2 = new EventWaitHandle(false, EventResetMode.AutoReset, kUpdateStartedSignal))
             {
                 waitHandle.Set();
                 waitHandle2.WaitOne();
             }
         }
     }
     if (iSessionHookAdded)
     {
         try
         {
             // try to clean up session notifications, but don't worry if this fails as it should be cleaned up by OS anyway.
             WTSUnRegisterSessionNotification((new WindowInteropHelper(this)).Handle);
             HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
             if (source != null)
             {
                 source.RemoveHook(HandleSessionEvents);
             }
         }
         catch { }
     }
     CefSharp.Cef.Shutdown();
 }
Пример #2
0
        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);
                });
            }
        }