public void Dispose()
 {
     _zuneLibrary.Dispose();
 }
예제 #2
0
        public static int Launch(string strArgs, IntPtr hWndSplashScreen)
        {
            PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.IN_MANAGED_LAUNCH, 0U);
            Application.ErrorReport += new ErrorReportHandler(ErrorReportHandler);
            Hashtable hashtable = StandAlone.Startup(SplitCommandLineArguments(strArgs), DefaultCommandLineParameterSwitch);

            if (hashtable != null)
            {
                _unprocessedAppArgs = new List <Hashtable>();
                _unprocessedAppArgs.Add(hashtable);
            }
            DialogHelper.DialogCancel = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_CANCEL);
            DialogHelper.DialogYes    = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_YES);
            DialogHelper.DialogNo     = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_NO);
            DialogHelper.DialogOk     = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_OK);
            XmlDataProviders.Register();
            LibraryDataProvider.Register();
            SubscriptionDataProvider.Register();
            StaticLibraryDataProvider.Register();
            AggregateDataProviderQuery.Register();
            ZuneUI.Shell.InitializeInstance();
            Application.Name           = "Zune";
            Application.Window.Caption = "Zune";
            Application.Window.SetIcon("ZuneShellResources.dll", 1);
            Application.Window.AlwaysOnTop = true;
            if (!hashtable.Contains("noshadow"))
            {
                Image[]    images      = new Image[4];
                ImageInset imageInset1 = new ImageInset(26, 0, 30, 0);
                ImageInset imageInset2 = new ImageInset(0, 10, 0, 0);
                images[0] = new Image("res://ZuneShellResources.dll!activeshadowLeft.png", imageInset2);
                images[1] = new Image("res://ZuneShellResources.dll!activeshadowTop.png", imageInset1);
                images[2] = new Image("res://ZuneShellResources.dll!activeshadowRight.png", imageInset2);
                images[3] = new Image("res://ZuneShellResources.dll!activeshadowBottom.png", imageInset1);
                Application.Window.SetShadowEdgeImages(true, images);
                imageInset1 = new ImageInset(23, 0, 29, 0);
                imageInset2 = new ImageInset(0, 5, 0, 0);
                images[0]   = new Image("res://ZuneShellResources.dll!inactiveshadowLeft.png", imageInset2);
                images[1]   = new Image("res://ZuneShellResources.dll!inactiveshadowTop.png", imageInset1);
                images[2]   = new Image("res://ZuneShellResources.dll!inactiveshadowRight.png", imageInset2);
                images[3]   = new Image("res://ZuneShellResources.dll!inactiveshadowBottom.png", imageInset1);
                Application.Window.SetShadowEdgeImages(false, images);
            }
            Application.Window.CloseRequested += new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested);
            CodeDialogManager.Instance.WindowCloseNotBlocked += new EventHandler(OnWindowCloseNotBlocked);
            Application.Window.SessionConnected += new SessionConnectedHandler(OnSessionConnected);
            string source = "res://ZuneShellResources!Frame.uix#Frame";

            _hWndSplashScreen       = hWndSplashScreen;
            _initializationFailsafe = new InitializationFailsafe();
            PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD, 0U);
            Application.Window.RequestLoad(source);
            PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD_COMPLETE, 0U);
            CallbackOnUIThread callbackOnUiThread = new CallbackOnUIThread();

            _appInitializationSequencer = new AppInitializationSequencer(new CorePhase2ReadyCallback(CorePhase3Ready));
            _zuneLibrary = new ZuneLibrary();
            HRESULT num = _zuneLibrary.Initialize(null, out _dbRebuilt);

            if (num.IsSuccess)
            {
                StandAlone.Run(new DeferredInvokeHandler(Phase2Initialization));
                Application.Window.CloseRequested -= new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested);
                CodeDialogManager.Instance.WindowCloseNotBlocked -= new EventHandler(OnWindowCloseNotBlocked);
                Application.Window.SessionConnected -= new SessionConnectedHandler(OnSessionConnected);
                if (Download.IsCreated)
                {
                    Download.Instance.Dispose();
                }
                ZuneShell.DefaultInstance?.Dispose();
                ViewTimeLogger.Instance.Shutdown();
                if (PodcastCredentials.HasInstance)
                {
                    PodcastCredentials.Instance.Dispose();
                }
                if (ProxyCredentials.HasInstance)
                {
                    ProxyCredentials.Instance.Dispose();
                }
                StandAlone.Shutdown();
                HttpWebRequest.Shutdown();
                WorkerQueue.ShutdownAll();
                if (ContentRefreshTask.HasInstance)
                {
                    ContentRefreshTask.Instance.Dispose();
                }
                if (Service != null)
                {
                    Service.Dispose();
                }
                if (ShellMessagingNotifier.HasInstance)
                {
                    ShellMessagingNotifier.Instance.Dispose();
                }
                if (MessagingService.HasInstance)
                {
                    MessagingService.Instance.Dispose();
                }
                if (FeaturesChangedApi.HasInstance)
                {
                    FeaturesChangedApi.Instance.Dispose();
                }
                CDAccess.Instance.Dispose();
                PlaylistManager.Instance.Dispose();
                if (_interopNotifications != null)
                {
                    _interopNotifications.ShowErrorDialog -= new OnShowErrorDialogHandler(OnShowErrorDialog);
                    _interopNotifications.Dispose();
                    _interopNotifications = null;
                }
            }
            _zuneLibrary.Dispose();
            return(num.Int);
        }