コード例 #1
0
        public bool Initialize()
        {
            if (!File.Exists("ZuneDBApi.dll"))
            {
                throw new FileNotFoundException(
                          "Could not find ZuneDBApi.dll. Are you sure Zune Social Tagger is installed in the Zune application folder?");
            }

            //Just copying what the zune software does internally here to initialize the database
            _zuneLibrary = new ZuneLibrary();

            bool dbRebult;

            //anything other than 0 means an error occured reading the database
            int num = _zuneLibrary.Initialize(null, out dbRebult);

            if (num > -1)
            {
                int phase2;
                _zuneLibrary.Phase2Initialization(out phase2);
                _zuneLibrary.CleanupTransientMedia();
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues = new object[15]
            {
                string.Empty,
                TimeSpan.Zero,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                0,
                0,
                string.Empty,
                0L,
                string.Empty,
                0,
                0,
                Guid.Empty
            };
            ZuneLibrary.GetFieldValues(libraryId, EListType.eVideoList, ColumnIndexes.Length, ColumnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndexes.Length; ++index)
            {
                if (ColumnIndexes[index] == 177)
                {
                    dataProviderObject.SetProperty("MediaType", MediaDescriptions.Map((MediaType)fieldValues[index]));
                }
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
コード例 #3
0
 private static T SetFieldValue <T>(int mediaId, EListType listType, int atom, T newValue)
 {
     int[]    columnIndexes = new int[] { atom };
     object[] fieldValues   = new object[] { newValue };
     ZuneLibrary.SetFieldValues(mediaId, listType, 1, columnIndexes, fieldValues, new QueryPropertyBag());
     return((T)fieldValues[0]);
 }
コード例 #4
0
 internal static bool AddTransientMedia(
     string filename,
     MediaType mediaType,
     out int libraryID,
     out bool fFileAlreadyExists)
 {
     _transientTableCleanupComplete.WaitOne();
     return(ZuneLibrary.AddTransientMedia(filename, (EMediaTypes)mediaType, out libraryID, out fFileAlreadyExists));
 }
コード例 #5
0
 private void CommitLastStoredBookmark()
 {
     if (this.MediaType != MediaType.PodcastEpisode && this.MediaType != MediaType.Video)
     {
         return;
     }
     int[]    columnIndexes = new int[1];
     object[] fieldValues   = new object[1];
     columnIndexes[0] = 35;
     fieldValues[0]   = _lastStoredBookmark;
     ZuneLibrary.SetFieldValues(this.MediaId, this.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
 }
コード例 #6
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues   = (object[])DefaultFieldValues.Clone();
            bool[]   isEmptyValues = new bool[fieldValues.Length];
            ZuneLibrary.GetFieldValues(libraryId, EListType.eAppList, ColumnIndices.Length, ColumnIndices, fieldValues, isEmptyValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndices.Length; ++index)
            {
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
コード例 #7
0
 private static HRESULT Split(int libraryId)
 {
     try
     {
         ZuneLibrary.SplitAudioTrack(libraryId);
     }
     catch (COMException ex)
     {
         return(ex.ErrorCode);
     }
     return(HRESULT._S_OK);
 }
コード例 #8
0
        private static void Phase2InitializationWorker(object arg)
        {
            Win32Window.Close(_hWndSplashScreen);
            bool flag = _zuneLibrary.Phase2Initialization(out int hr);

            Application.DeferredInvoke(new DeferredInvokeHandler(Phase2InitializationUIStage), new object[2]
            {
                hr, flag
            });
            ZuneLibrary.CleanupTransientMedia();
            _transientTableCleanupComplete.Set();
            SQMLog.Log(SQMDataId.GdiMode, Application.RenderingType == RenderingType.GDI ? 1 : 0);
        }
コード例 #9
0
 private static bool CanAddMedia(string filename, MediaType mediaType, CanAddMediaArgs args)
 {
     try
     {
         return(Directory.Exists(filename) ? ZuneLibrary.CanAddFromFolder(filename) && (CanAddMedia(Directory.GetFiles(filename), mediaType, args) || CanAddMedia(Directory.GetDirectories(filename), mediaType, args)) : ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType));
     }
     catch (UnauthorizedAccessException ex)
     {
         return(false);
     }
     catch (IOException ex)
     {
         return(false);
     }
 }
コード例 #10
0
        public override HRESULT GetURI(out string uri)
        {
            string  uriOut  = null;
            HRESULT hresult = HRESULT._S_OK;

            Microsoft.Zune.Service.EContentType eContentType;
            if (PlaylistManager.GetFieldValue(this._mediaId, this._listType, 177, -1) == 43)
            {
                eContentType = Microsoft.Zune.Service.EContentType.Video;
            }
            else
            {
                eContentType = Microsoft.Zune.Service.EContentType.MusicTrack;
                uriOut       = PlaylistManager.GetFieldValue(this._mediaId, this._listType, 317, (string)null);
                if (!string.IsNullOrEmpty(uriOut))
                {
                    try
                    {
                        if (new Uri(uriOut).Scheme == Uri.UriSchemeFile)
                        {
                            if (!ZuneLibrary.DoesFileExist(uriOut))
                            {
                                uriOut = null;
                            }
                        }
                    }
                    catch (UriFormatException ex)
                    {
                    }
                }
            }
            if (string.IsNullOrEmpty(uriOut) && this.ZuneMediaId != Guid.Empty)
            {
                hresult = ZuneApplication.Service.GetContentUri(this.ZuneMediaId, eContentType, Microsoft.Zune.Service.EContentUriFlags.None, out uriOut, out this._zuneMediaInstanceId);
            }
            uri = uriOut;
            return(hresult);
        }
コード例 #11
0
 private static void Phase2InitializationUIStage(object arg)
 {
     _initializationFailsafe.Initialize(delegate
     {
         _appInitializationSequencer.UIReady();
     });
     ProcessAppArgs();
     Download.Instance.Phase2Init();
     if (!ZuneShell.DefaultInstance.NavigationsPending && ZuneShell.DefaultInstance.CurrentPage is StartupPage)
     {
         ZuneUI.Shell.NavigateToHomePage();
     }
     if (_dbRebuilt)
     {
         string caption = ZuneLibrary.LoadStringFromResource(109U);
         string text    = ZuneLibrary.LoadStringFromResource(110U);
         if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(text))
         {
             Win32MessageBox.Show(text, caption, Win32MessageBoxType.MB_ICONHAND, null);
         }
     }
     _phase2InitComplete = true;
 }
コード例 #12
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues = new object[19]
            {
                string.Empty,
                TimeSpan.Zero,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                new ArrayList(),
                string.Empty,
                string.Empty,
                DateTime.MinValue,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                0L,
                string.Empty
            };
            bool[] isEmptyValues = new bool[fieldValues.Length];
            ZuneLibrary.GetFieldValues(libraryId, EListType.eTrackList, ColumnIndexes.Length, ColumnIndexes, fieldValues, isEmptyValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndexes.Length; ++index)
            {
                if (ColumnIndexes[index] == 177)
                {
                    fieldValues[index] = MediaDescriptions.Map((MediaType)fieldValues[index]);
                }
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
コード例 #13
0
        private static bool AddMedia(string filename, MediaType mediaType)
        {
            bool flag = false;

            try
            {
                if (Directory.Exists(filename))
                {
                    flag  = AddMedia(Directory.GetFiles(filename), mediaType);
                    flag |= AddMedia(Directory.GetDirectories(filename), mediaType);
                }
                else if (ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType))
                {
                    flag = ZuneLibrary.AddMedia(filename) != -1;
                }
            }
            catch (UnauthorizedAccessException ex)
            {
            }
            catch (IOException ex)
            {
            }
            return(flag);
        }
コード例 #14
0
        private static void UpdatePlayedStatesWorker(object o)
        {
            if (!(o is UpdatePlayedStatesTask playedStatesTask))
            {
                return;
            }
            int num1 = 0;
            int num2 = 0;
            int num3 = 0;

            int[]    columnIndexes = new int[7];
            object[] fieldValues   = new object[7];
            if (playedStatesTask.IncrementPlayCount)
            {
                columnIndexes[0] = 367;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num2             = (int)fieldValues[0];
                columnIndexes[0] = 366;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num1 = (int)fieldValues[0];
            }
            if (playedStatesTask.IncrementSkipCount)
            {
                columnIndexes[0] = 374;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num3 = (int)fieldValues[0];
            }
            int cValues = 0;

            if (playedStatesTask.MarkPlayed)
            {
                columnIndexes[cValues] = 262;
                fieldValues[cValues]   = 1;
                ++cValues;
            }
            if (playedStatesTask.IncrementPlayCount)
            {
                int num4 = num2 + 1;
                columnIndexes[cValues] = 367;
                fieldValues[cValues]   = num4;
                int index1 = cValues + 1;
                int num5   = num1 + 1;
                columnIndexes[index1] = 366;
                fieldValues[index1]   = num5;
                int index2 = index1 + 1;
                columnIndexes[index2] = 363;
                fieldValues[index2]   = DateTime.UtcNow;
                cValues = index2 + 1;
            }
            if (playedStatesTask.IncrementSkipCount)
            {
                int num4 = num3 + 1;
                columnIndexes[cValues] = 374;
                fieldValues[cValues]   = num4;
                int index = cValues + 1;
                columnIndexes[index] = 365;
                fieldValues[index]   = DateTime.UtcNow;
                cValues = index + 1;
            }
            if (cValues > 0)
            {
                ZuneLibrary.SetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, cValues, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
            }
            if (!playedStatesTask.IncrementPlayCount || playedStatesTask.ContainerPlayMarker == null)
            {
                return;
            }
            bool flag = false;

            lock (playedStatesTask.ContainerPlayMarker)
            {
                if (!playedStatesTask.ContainerPlayMarker.Marked)
                {
                    playedStatesTask.ContainerPlayMarker.Marked = true;
                    flag = true;
                }
            }
            if (!flag)
            {
                return;
            }
            if (playedStatesTask.ContainerPlayMarker.LibraryId == -1 && playedStatesTask.ListType == EListType.eTrackList)
            {
                fieldValues[0] = -1;
                if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Album)
                {
                    columnIndexes[0] = 11;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
                else if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Genre)
                {
                    columnIndexes[0] = 399;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
                else if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Artist)
                {
                    columnIndexes[0] = 11;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    int iMediaId = (int)fieldValues[0];
                    fieldValues[0]   = -1;
                    columnIndexes[0] = 78;
                    ZuneLibrary.GetFieldValues(iMediaId, EListType.eAlbumList, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
            }
            if (playedStatesTask.ContainerPlayMarker.LibraryId == -1)
            {
                return;
            }
            columnIndexes[0] = 363;
            fieldValues[0]   = DateTime.UtcNow;
            EListType listType = PlaylistManager.MediaTypeToListType(playedStatesTask.ContainerPlayMarker.MediaType);

            ZuneLibrary.SetFieldValues(playedStatesTask.ContainerPlayMarker.LibraryId, listType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
        }
コード例 #15
0
 public LibraryAlbumInfo(
     LibraryPlaybackTrack track,
     int thumbnailMaxWidth,
     int thumbnailMaxHeight,
     ICommand onAsyncUpdateAlbumArtUrlCompleted)
 {
     this._onAsyncUpdateAlbumArtUrlCompleted = onAsyncUpdateAlbumArtUrlCompleted == null ? new Command(this) : onAsyncUpdateAlbumArtUrlCompleted;
     if (track.MediaType == MediaType.Track)
     {
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes1 = new int[2] {
             11, 78
         };
         object[] fieldValues1 = new object[2]
         {
             -1,
             -1
         };
         ZuneLibrary.GetFieldValues(this._trackId, EListType.eTrackList, columnIndexes1.Length, columnIndexes1, fieldValues1, PlaylistManager.Instance.QueryContext);
         int albumId  = (int)fieldValues1[0];
         int iMediaId = (int)fieldValues1[1];
         if (albumId >= 0)
         {
             int[] columnIndexes2 = new int[2] {
                 382, 451
             };
             object[] fieldValues2 = new object[2];
             ZuneLibrary.GetFieldValues(albumId, EListType.eAlbumList, columnIndexes2.Length, columnIndexes2, fieldValues2, PlaylistManager.Instance.QueryContext);
             this._albumTitle  = (string)fieldValues2[0];
             this._zuneMediaId = GuidHelper.CreateFromString((string)fieldValues2[1]);
             ThreadPool.QueueUserWorkItem(args =>
             {
                 string str = LibraryDataProviderItemBase.GetArtUrl(albumId, "Album", false);
                 if (!string.IsNullOrEmpty(str))
                 {
                     str = "file://" + str;
                 }
                 Application.DeferredInvoke(new DeferredInvokeHandler(this.AsyncUpdateAlbumArtUrl), str);
             }, null);
         }
         if (iMediaId < 0)
         {
             return;
         }
         int[] columnIndexes3 = new int[1] {
             138
         };
         object[] fieldValues3 = new object[1];
         ZuneLibrary.GetFieldValues(iMediaId, EListType.eArtistList, columnIndexes3.Length, columnIndexes3, fieldValues3, PlaylistManager.Instance.QueryContext);
         this._artistName = (string)fieldValues3[0];
     }
     else if (track.MediaType == MediaType.PodcastEpisode)
     {
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes1 = new int[2] {
             311, 24
         };
         object[] fieldValues1 = new object[2]
         {
             -1,
             null
         };
         ZuneLibrary.GetFieldValues(this._trackId, EListType.ePodcastEpisodeList, columnIndexes1.Length, columnIndexes1, fieldValues1, PlaylistManager.Instance.QueryContext);
         int iMediaId = (int)fieldValues1[0];
         this._artistName = (string)fieldValues1[1];
         if (iMediaId < 0)
         {
             return;
         }
         int[] columnIndexes2 = new int[2] {
             344, 17
         };
         object[] fieldValues2 = new object[2];
         ZuneLibrary.GetFieldValues(iMediaId, EListType.ePodcastList, columnIndexes2.Length, columnIndexes2, fieldValues2, PlaylistManager.Instance.QueryContext);
         this._albumTitle  = (string)fieldValues2[0];
         this._albumArtUrl = (string)fieldValues2[1];
     }
     else
     {
         if (track.MediaType != MediaType.Video)
         {
             return;
         }
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes = new int[3] {
             380, 382, 312
         };
         object[] fieldValues = new object[3];
         ZuneLibrary.GetFieldValues(this._trackId, EListType.eVideoList, columnIndexes.Length, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
         this._artistName = (string)fieldValues[0];
         this._albumTitle = (string)fieldValues[1];
         if (string.IsNullOrEmpty(this._albumTitle))
         {
             this._albumTitle = (string)fieldValues[2];
         }
         if (Application.RenderingType != RenderingType.GDI)
         {
             return;
         }
         ThreadPool.QueueUserWorkItem(args =>
         {
             string artUrl = LibraryDataProviderItemBase.GetArtUrl(this._trackId, "Video", false);
             if (string.IsNullOrEmpty(artUrl))
             {
                 return;
             }
             Application.DeferredInvoke(new DeferredInvokeHandler(this.AsyncUpdateThumbnailUrl), "file://" + artUrl);
         }, null);
     }
 }
コード例 #16
0
 private static void ProcessAppArgs(Hashtable args)
 {
     if (args["device"] is string str && !_phase2InitComplete)
     {
         char[] chArray = new char[1] {
             '"'
         };
         SyncControls.Instance.SetCurrentDeviceByCanonicalName(str.Trim(chArray));
     }
     if (args["link"] is string link && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         ZuneUI.Shell.ProcessExternalLink(link);
     }
     if (args["ripcd"] is string playCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         CDAccess.HandleDiskFromAutoplay(playCdPath, CDAction.Rip);
     }
     if (args["playcd"] is string ripCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         CDAccess.HandleDiskFromAutoplay(ripCdPath, CDAction.Play);
     }
     if (args["playmedia"] is string initialUrl && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         RegisterNewFileEnumeration(new LaunchFromShellHelper("play", initialUrl));
     }
     if (args["shellhlp_v2"] is string taskName && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         string marshalledDataObject = args["dataobject"] as string;
         string eventName            = args["event"] as string;
         if (marshalledDataObject != null && eventName != null)
         {
             RegisterNewFileEnumeration(new LaunchFromShellHelper(taskName, marshalledDataObject, eventName));
         }
     }
     if (args.Contains("refreshlicenses"))
     {
         ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh();
     }
     if (args.Contains("update"))
     {
         SoftwareUpdates.Instance.InstallUpdates();
     }
     if (args.Contains("shuffleall") && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         SingletonModelItem <TransportControls> .Instance.ShuffleAllRequested = true;
     }
     if (args.Contains("resumenowplaying") && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         SingletonModelItem <TransportControls> .Instance.ResumeLastNowPlayingHandler();
     }
     if (args.Contains("refreshcontentandexit"))
     {
         if (!_phase2InitComplete)
         {
             HRESULT sOk = HRESULT._S_OK;
             HRESULT hr  = ContentRefreshTask.Instance.StartContentRefresh(new AsyncCompleteHandler(OnContentRefreshTaskComplete));
             if (hr.IsError)
             {
                 OnContentRefreshTaskComplete(hr);
             }
         }
         else
         {
             ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh();
         }
     }
     if (!(args["playpin"] is string pinString) || ZuneUI.Shell.IgnoreAppNavigationsArgs)
     {
         return;
     }
     JumpListManager.PlayPin(JumpListPin.Parse(pinString));
 }
コード例 #17
0
ファイル: ZuneApi.cs プロジェクト: quad341/zpd
        // Using http://blog.ctaggart.com/2010/08/query-zune-music-collection-with-f.html#!/2010/08/query-zune-music-collection-with-f.html as a base
        // Also found some help at http://averagedeveloper.blogspot.com/2012/04/querying-zunedbapidll.html
        /// <summary>
        /// Reindexes the music by iterating through all music in the Zune Library and saving it in the local Lucene database. Required for search to work correctly
        /// </summary>
        /// <seealso cref="Search"/>
        public void ReIndexMusic()
        {
            var library = new ZuneLibrary();
            var dbReloaded = false;
            int returnValue = library.Initialize(null, out dbReloaded);
            if (returnValue >= 0)
            {
                library.Phase2Initialization(out returnValue);
                if (returnValue >= 0)
                {
                    library.CleanupTransientMedia();

                    ZuneQueryList searchResult = library.QueryDatabase(EQueryType.eQueryTypeAllTracks, 0, EQuerySortType.eQuerySortOrderNone, 0, null);
                    if (null != searchResult)
                    {
                        // we have results, index them
                        var writer = new IndexWriter(new SimpleFSDirectory(new DirectoryInfo(LUCENE_INDEX_DIRECTORY)), new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), true, IndexWriter.MaxFieldLength.UNLIMITED);
                        for (uint i = 0; i < searchResult.Count; i++)
                        {
                            // add a document for each song. We will only store the mediaId and mediaTypeId and store+index the title, artist, and album
                            var doc = new Document();

                            var mediaId = (UInt32)searchResult.GetFieldValue(i, typeof(UInt32), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_MediaID);
                            var mediaTypeId = (UInt32)searchResult.GetFieldValue(i, typeof(UInt32), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_MediaType);
                            var duration = (UInt32)searchResult.GetFieldValue(i, typeof(UInt32), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_Duration);
                            var artist = (String)searchResult.GetFieldValue(i, typeof(String), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_DisplayArtist);
                            var title = (String)searchResult.GetFieldValue(i, typeof(String), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_Title);
                            var album = (String)searchResult.GetFieldValue(i, typeof(String), (uint)MicrosoftZuneLibrary.SchemaMap.kiIndex_WMAlbumTitle);

                            doc.Add(new Field("mediaId", mediaId.ToString(), Field.Store.YES, Field.Index.NO));
                            doc.Add(new Field("mediaTypeId", mediaTypeId.ToString(), Field.Store.YES, Field.Index.NO));
                            doc.Add(new Field("duration", duration.ToString(), Field.Store.YES, Field.Index.NO));
                            doc.Add(new Field("artist", artist, Field.Store.YES, Field.Index.ANALYZED));
                            doc.Add(new Field("title", title, Field.Store.YES, Field.Index.ANALYZED));
                            doc.Add(new Field("album", album, Field.Store.YES, Field.Index.ANALYZED));

                            writer.AddDocument(doc);
                        }
                        writer.Commit();
                        writer.Close();
                    }
                }
            }
        }
コード例 #18
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);
        }