예제 #1
0
파일: Eggs.cs 프로젝트: jschementi/eggs
 private static void DownloadTestXap_Complete(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null) {
         var sri = new StreamResourceInfo(e.Result, null);
         if (_onDownloadComplete != null) {
             _onDownloadComplete.Invoke(sri);
         }
     } else {
         System.Windows.Browser.HtmlPage.Window.Alert("Tests failed to download");
     }
 }
예제 #2
0
 private void WebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() => {
         try {
             ActionFacebookGetAvatarArgs arg = _waiting[(WebClient)sender];
             var streamResourceInfo          = new StreamResourceInfo(e.Result, null);
             var bitmapImage = new BitmapImage();
             bitmapImage.SetSource(streamResourceInfo.Stream);
             arg.Avatar = bitmapImage;
             Done(arg);
         } catch (Exception ex) {
         }
     });
 }
 private void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     try
     {
         XmlReader       reader = XmlReader.Create(e.Result);
         SyndicationFeed feed   = SyndicationFeed.Load(reader);
         gridFeed.ItemsSource = feed.Items;
         reader.Close();
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
예제 #4
0
파일: FileUtils.cs 프로젝트: tsebalj1/rawr
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                StreamResourceInfo zipStream = new StreamResourceInfo(e.Result as Stream, null);
                foreach (string file in FilesToDownload)
                {
                    UpdateProgress(0, "Decompressing " + file + "...");
                    Uri part = new Uri(file, UriKind.Relative);
#if !SILVERLIGHT
                    System.IO.Packaging.Package     zipFile = System.IO.Packaging.ZipPackage.Open(zipStream.Stream, FileMode.Open);
                    System.IO.Packaging.PackagePart thePart = zipFile.GetPart(part);
                    StreamReader sr           = new StreamReader(thePart.GetStream());
                    string       unzippedFile = sr.ReadToEnd();
                    StreamWriter writer       = new StreamWriter(file);
                    writer.Write(unzippedFile);
                    writer.Close();
#else
                    // This reading method only works in Silverlight due to the GetResourceStream not existing with 2 arguments in
                    // regular .Net-land
                    StreamResourceInfo fileStream   = Application.GetResourceStream(zipStream, part);
                    StreamReader       sr           = new StreamReader(fileStream.Stream);
                    string             unzippedFile = sr.ReadToEnd();
                    //Write it in a special way when using IsolatedStorage, due to IsolatedStorage
                    //having a huge performance issue when writing small chunks
                    IsolatedStorageFileStream isfs = GetFileStream(file, true);

                    char[] charBuffer = unzippedFile.ToCharArray();
                    int    fileSize   = charBuffer.Length;
                    byte[] byteBuffer = new byte[fileSize];
                    for (int i = 0; i < fileSize; i++)
                    {
                        byteBuffer[i] = (byte)charBuffer[i];
                    }
                    isfs.Write(byteBuffer, 0, fileSize);
                    isfs.Close();
#endif

                    UpdateProgress(0, "Finished " + file + "...");
                }
            }
            else
            {
                (App.Current as App).WriteLoadProgress(e.Error.Message);
            }
            if (StreamReady != null)
            {
                StreamReady.Invoke(this, EventArgs.Empty);
            }
        }
예제 #5
0
        /// <summary>
        /// Place images received from the REST service in the proper place in the active tile cube, and save them to
        /// the cache.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void TileServerRequestCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            pendingRequestCount--;

            TileInformation requestInformation = (TileInformation)e.UserState;

            // Do not handle the event if the request was cancelled
            if (requestInformation.IsRequestCancelled)
            {
                requestInformation.MarkImageRequestCancelled();

                if (pendingRequestCount == 0)
                {
                    MoveToNextPhase();
                }

                return;
            }

            bool imageAvailable = e.Error == null ? true : false;

            // Clean the old image, if any
            requestInformation.Dispose(true);

            try
            {
                if (imageAvailable == true)
                {
                    SetTileImage(e, requestInformation);
                }
            }
            catch (Exception)
            {
                imageAvailable = false;
            }

            if (imageAvailable == false)
            {
                requestInformation.Image = unavailableImage;
            }

            requestInformation.MarkImageRequestCompleted();

            // If all asynchronous calls returned, we can move to the next phase
            if (pendingRequestCount == 0)
            {
                MoveToNextPhase();
            }
        }
예제 #6
0
        static void OpenReadCompletedHandler(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                // need to handle the error
                return;
            }

            StreamResourceInfo info = Application.GetResourceStream(
                new StreamResourceInfo(e.Result, null),
                new Uri("AppManifest.xaml", UriKind.Relative));

            string    appManifest = new StreamReader(info.Stream).ReadToEnd();
            XmlReader xReader     = XmlReader.Create(new StringReader(appManifest));
            Type      objType     = null;

            while (xReader.Read())
            {
                if (xReader.IsStartElement("AssemblyPart"))
                {
                    xReader.MoveToAttribute("Source");
                    if (xReader.ReadAttributeValue())
                    {
                        StreamResourceInfo asmInfo   = new StreamResourceInfo(e.Result, "application/binary");
                        StreamResourceInfo asmStream = Application.GetResourceStream(asmInfo, new Uri(xReader.Value, UriKind.Relative));
                        AssemblyPart       part      = new AssemblyPart();
                        Assembly           asm       = part.Load(asmStream.Stream);

                        foreach (Type t in asm.GetTypes())
                        {
                            if (t.IsDefined(typeof(CharacterHostAttribute), false))
                            {
                                objType = t;
                            }
                        }
                    }
                }
            }

            if (objType != null)
            {
                _temp.Add(typeof(CharacterHostAttribute), Activator.CreateInstance(objType));
            }

            if (LoadCompleted != null)
            {
                LoadCompleted(null, EventArgs.Empty);
            }
        }
예제 #7
0
        void request_DownloadConcertInfo(object sender,
                                         OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                XmlReader eventsReader = XmlReader.Create(e.Result);
                this.events = this.parseEvents(eventsReader);
                this.artists.Clear();
                this.venues.Clear();
                foreach (Event tempEvent in this.events)
                {
                    foreach (Artist tempArtist in tempEvent.Artists)
                    {
                        if (!this.artists.Contains <Artist>(tempArtist))
                        {
                            this.artists.Add(tempArtist);
                        }
                    }

                    if (!this.venues.Contains <Venue>(tempEvent.Venue))
                    {
                        this.venues.Add(tempEvent.Venue);
                    }
                }

                System.Diagnostics.Debug.WriteLine("Already contains " + this.events.Count);

                if (this.events.Count <= 0)
                {
                    this.events  = this.eventsStorageHelper.LoadAll();
                    this.artists = this.artistsStorageHelper.LoadAll();
                    this.venues  = this.venuesStorageHelper.LoadAll();
                }
                else
                {
                    this.eventsStorageHelper.SaveAll(this.events);
                    this.artistsStorageHelper.SaveAll(this.artists);
                    this.venuesStorageHelper.SaveAll(this.venues);
                }
            }
            else
            {
                this.events  = this.eventsStorageHelper.LoadAll();
                this.artists = this.artistsStorageHelper.LoadAll();
                this.venues  = this.venuesStorageHelper.LoadAll();
            }

            this.updateUi();
        }
예제 #8
0
        private void LoadFromServer_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            var userState = e.UserState as string;

            try
            {
                if (e.Error is object)
                {
                    throw e.Error;
                }
                if (e.Result is null)
                {
                    throw new ConfigurationNotLoadedException(ExceptionStrings.MapConfiguration_WebService_InvalidResult);
                }
                var byteList = new List <byte>();
                var buffer   = new byte[1000];
                for (var index1 = e.Result.Read(buffer, 0, 1000); 0 < index1; index1 = e.Result.Read(buffer, 0, 1000))
                {
                    if (index1 == 1000)
                    {
                        byteList.AddRange(buffer);
                    }
                    else
                    {
                        for (var index2 = 0; index2 < index1; ++index2)
                        {
                            byteList.Add(buffer[index2]);
                        }
                    }
                }
                var array = byteList.ToArray();
                using (var memoryStream = new MemoryStream(array))
                {
                    var sectionReader = XmlReader.Create(memoryStream);
                    using (var storageFileStream = GetIsolatedStorageFileStream(userState, FileMode.Create))
                        new BinaryWriter(storageFileStream).Write(array);
                    ConfigLoaded(userState, ParseConfiguration(sectionReader));
                }
            }
            catch (Exception ex)
            {
                if (Loaded is object)
                {
                    Loaded(this, new MapConfigurationLoadedEventArgs(ex));
                }
            }
            lock (configLock)
                requestQueue.Remove(userState);
        }
예제 #9
0
        void WClient_Download_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e1)
        {
            string Path;

            if (e1.Error == null)
            {
                try
                {
                    string filename         = "MyFile545.mp3";
                    bool   isSpaceAvailable = IsSpaceIsAvailable(e1.Result.Length);

                    if (isSpaceAvailable)
                    {
                        // Save mp3 to Isolated Storage
                        try
                        {
                            using (var isfs = new IsolatedStorageFileStream(filename,
                                                                            FileMode.CreateNew,
                                                                            IsolatedStorageFile.GetUserStoreForApplication()))
                            {
                                long   fileLen = 100 * 1024;
                                byte[] b       = new byte[fileLen];
                                e1.Result.Position = 300 * 1024;
                                e1.Result.Read(b, 0, b.Length);
                                isfs.Write(b, 0, b.Length);
                                isfs.Flush();
                                Path = isfs.Name;

                                //var client = new DropNetClient("8o22eryy1qg3m1z", "2timqmgbvjg1qjj");
                                //var uploaded =  client.UploadFileTask("/", "music.mp3", b);
                            }
                        }
                        catch (Exception ex) { }
                    }
                    else
                    {
                        MessageBox.Show("Not enough to save space available to download mp3.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show(e1.Error.Message);
            }
        }
예제 #10
0
 /// <summary>
 /// Read the diagram
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Result != null)
     {
         StreamReader sr = new StreamReader(e.Result);
         try
         {
             m_controlSource = sr.ReadToEnd();
         }
         finally
         {
             sr.Dispose();
         }
     }
 }
예제 #11
0
 void forecastClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         forecastClient.OpenReadCompleted -= forecastClient_OpenReadCompleted;
         Stream      stream          = e.Result;
         CityWeather cityWeatherInfo = (CityWeather)e.UserState;
         Task.Factory.StartNew(() => {
             lock (forecastLocker) {
                 ForecastInfo forecast = ReadForecast(stream);
                 cityWeatherInfo.SetForecast(forecast);
             }
         });
     }
 }
예제 #12
0
        void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            var jsonSerializer = new DataContractJsonSerializer(typeof(List <string>));

            videoList = (List <string>)jsonSerializer.ReadObject(e.Result);
            if (videoList != null && videoList.Count > 0)
            {
                player.Source = new Uri(videoList[0]);
                player.Play();
            }
            else
            {
                System.Threading.Tasks.Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(15000); GetVideos(); });
            }
        }
예제 #13
0
 void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     log("wc_OpenReadCompleted, get service response, parse...");
     if (e.Error != null)
     {
         log(String.Format("wc_OpenReadCompleted, error in reading answer, msg [{0}], trace [{1}]", e.Error.Message, e.Error.StackTrace));
         return;
     }
     try {
         fillLyrList(e.Result);
     }
     catch (Exception ex) {
         log(String.Format("wc_OpenReadCompleted, Ошибка разбора списка [{0}]", ex.Message));
     }
 }         // void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) {
        private static void SaveFile(OpenReadCompletedEventArgs e, String filename)
        {
            var file = IsolatedStorageFile.GetUserStoreForApplication();

            e.Result.Position = 0;
            using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filename, FileMode.Create, FileAccess.Write, file))
            {
                byte[] buffer    = new byte[1024];
                int    bytesRead = 0;
                while ((bytesRead = e.Result.Read(buffer, 0, buffer.Length)) > 0)
                {
                    stream.Write(buffer, 0, bytesRead);
                }
            }
        }
예제 #15
0
파일: FileUtils.cs 프로젝트: rakot/rawr
 void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         ExtractXmlFiles(e.Result);
     }
     else
     {
         (App.Current as App).WriteLoadProgress(e.Error.Message);
     }
     if (StreamReady != null)
     {
         StreamReady.Invoke(this, EventArgs.Empty);
     }
 }
예제 #16
0
파일: Bound.cs 프로젝트: BioNoob/tink_oblig
 private void Wx_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     try
     {
         Img_exct = Image.FromStream(e.Result);
     }
     catch (Exception ex)
     {
         if (ex.InnerException.Message.Contains("404"))
         {
             Img_path = "";
         }
         DrawImg();
     }
 }
예제 #17
0
 void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         using (Stream sf = (Stream)saveFileDialog.OpenFile())
         {
             e.Result.CopyTo(sf);
             sf.Flush();
             sf.Close();
             DownLoading = Visibility.Collapsed;
             NotifyWindow notifyWindow = new NotifyWindow("下载完成", "下载完成!");
             notifyWindow.Show();
         }
     }
 }
예제 #18
0
 private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         MainViewModel.Instance.GameMode = GameModes.GameSelect;
         Stream zipPackageStream = (Stream)e.Result;
         MainViewModel.Instance.LoadDeckFromZip(zipPackageStream);
         SaveStreamToIsolatedStorage(MainViewModel.Instance.Decks.SelectedDeck.Title, zipPackageStream);
         IsBusy = false;
     }
     else
     {
         ReportStatus(ServerErrorString);
     }
 }
예제 #19
0
 /// <summary>
 /// 非同期ダウンロード完了通知イベント
 /// </summary>
 void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         using (Stream fs = _AsyncSaveDialog.OpenFile())
         {
             int    length     = Convert.ToInt32(e.Result.Length);
             byte[] byteResult = new byte[length];
             e.Result.Read(byteResult, 0, length);
             fs.Write(byteResult, 0, byteResult.Length);
             fs.Close();
         }
     }
     MessageBox.Show("今のところSilverlightのロゴ(Jpeg)を非同期にダウンロードするだけです。");
 }
예제 #20
0
 void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     completed = true;
     try {
         // Accessing e.Result causes a security exception in SL which makes the harness stop working
         // if we don't handle the exception
         Console.WriteLine("client_OpenRead: e.Result: {0}, e.ex: {1}", e.Result, e.Error);
         if (e.Result != null)
         {
             media.SetSource(new SlowStream(e.Result));
         }
     } catch (Exception ex) {
         Console.WriteLine(ex.Message);
     }
 }
예제 #21
0
        void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            Stream stream       = e.Result;
            var    reader       = new StreamReader(stream);
            var    shortenedUrl = reader.ReadToEnd();


            loadingBar.Visibility = Visibility.Collapsed;

            ShareStatusTask shareStatusTask = new ShareStatusTask();

            shareStatusTask.Status = String.Format("Check out this perk: {0}. More at {1}", Helper.venues[_currentVenueControlId].message, shortenedUrl);

            shareStatusTask.Show();
        }
        ///
        /// <summary>
        /// Occures every time next xml data file is available or error</summary>
        ///
        private void OnDataReadCompleted(
            object sender,
            OpenReadCompletedEventArgs args
            )
        {
            Utilities.Trace(this);

            ++m_dataLoadCount;

            if (!args.Cancelled && args.Error == null)
            {
                m_streams.Add(args.Result);
            }
            CheckCompleted();
        }
예제 #23
0
        /// <summary>
        /// Gets the response, and parses as a feed.
        /// </summary>
        /// <param name="sender">The web client.</param>
        /// <param name="e">Open Read Completed Event Args</param>
        private void Client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (this.refreshingContentPresenter != null)
            {
                this.refreshingContentPresenter.Visibility = Visibility.Collapsed;
            }

            if (e.Error == null && e.Result != null)
            {
                try
                {
                    XmlReader       xmlReader = XmlReader.Create(e.Result);
                    SyndicationFeed feed      = SyndicationFeed.Load(xmlReader);
                    this.ItemsSource = feed.Items;

                    if (this.feedErrorContentPresenter != null)
                    {
                        this.feedErrorContentPresenter.Visibility = Visibility.Collapsed;
                    }
                }
                catch (XmlException exception)
                {
                    StringBuilder errorMessage = new StringBuilder();
                    errorMessage.AppendLine("An error occured:");
                    errorMessage.AppendLine("   " + exception.Message);
                    errorMessage.AppendLine("       " + exception.StackTrace);
                    this.FeedErrorContent = errorMessage.ToString();

                    if (this.feedErrorContentPresenter != null)
                    {
                        this.feedErrorContentPresenter.Visibility = Visibility.Visible;
                    }
                }
            }
            else if (e.Error != null)
            {
                StringBuilder errorMessage = new StringBuilder();
                errorMessage.AppendLine("An error occured:");
                errorMessage.AppendLine("   " + e.Error.Message);
                errorMessage.AppendLine("       " + e.Error.StackTrace);
                this.FeedErrorContent = errorMessage.ToString();

                if (this.feedErrorContentPresenter != null)
                {
                    this.feedErrorContentPresenter.Visibility = Visibility.Visible;
                }
            }
        }
예제 #24
0
        private void OnStreamOpened(object sender, OpenReadCompletedEventArgs args)
        {
            var stream = args.Result;

            if (!args.Cancelled && stream != null && stream.CanRead)
            {
                try
                {
                    byte[] data = new byte[1024];

                    using (MemoryStream ms = new MemoryStream())
                    {
                        while (true)
                        {
                            int read = stream.Read(data, 0, data.Length);

                            if (read > 0)
                            {
                                ms.Write(data, 0, read);
                            }
                            else
                            {
                                data = ms.ToArray();
                                break;
                            }
                        }
                    }

                    OnImageHandlerEvent(true, data);
                }
                catch
                {
                    OnImageHandlerEvent(false, null);
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Flush();
                        stream.Close();
                    }
                }
            }
            else
            {
                OnImageHandlerEvent(false, null);
            }
        }
예제 #25
0
 void esClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error != null)
     {
     }
     else
     {
         Stream       data      = e.Result as Stream;
         StreamReader reader    = new StreamReader(data);
         HtmlDocument sudsTimes = new HtmlDocument();
         sudsTimes.Load(reader);
         data.Close();
         reader.Close();
         DisplayStates(sudsTimes);
     }
 }
예제 #26
0
파일: Downloader.cs 프로젝트: publicwmh/eas
 void OnOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         if (this.ErrorAccured != null)
         {
             FileDownloadErrorAccured accured = new FileDownloadErrorAccured();
             accured.Exception = e.Error;
             this.ErrorAccured(this, accured);
         }
     }
     else if (this.DownloadCompleted != null)
     {
         this.DownloadCompleted(this, new FileDownloadCompleteEventArgs(e.Result));
     }
 }
예제 #27
0
        private void OnOpenLandCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                //with the serializer we can create a Land object
                var stream = e.Result;
                var sr     = new StreamReader(stream);
                _land = Deserialize <List <DonationsLand> >(sr.ReadToEnd());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            OnLandReceived(EventArgs.Empty);
        }
예제 #28
0
 void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error != null)
     {
     }
     else
     {
         Stream       data           = e.Result as Stream;
         StreamReader reader         = new StreamReader(data);
         HtmlDocument busPredictions = new HtmlDocument();
         busPredictions.Load(reader);
         data.Close();
         reader.Close();
         ParseHtml(busPredictions);
     }
 }
예제 #29
0
파일: Updater.cs 프로젝트: nicengi/Updater
 private void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.UserState.ToString() != nameof(CheckForUpdateAsync) || e.Error != null)
     {
         return;
     }
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(UpdateInfo));
         UpdateInfo = (UpdateInfo)serializer.Deserialize(e.Result);
     }
     catch (Exception ex)
     {
         UpdateDialog.ShowException(ex, () => UpdateDialog.CheckForUpdate());
     }
 }
예제 #30
0
 // Picture Completed Download
 void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     using (var userStore = IsolatedStorageFile.GetUserStoreForApplication())
     {
         var fileNames = userStore.GetFileNames("*.jpg");
         var fileCount = fileNames.Count();
         using (var stream = new IsolatedStorageFileStream((fileCount++) + ".jpg", System.IO.FileMode.Create, userStore))
         {
             byte[] buffer = new byte[1024];
             while (e.Result.Read(buffer, 0, buffer.Length) > 0)
             {
                 stream.Write(buffer, 0, buffer.Length);
             }
         }
     }
 }
예제 #31
0
        /// <summary>
        /// Opens the read completed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Net.OpenReadCompletedEventArgs"/> instance containing the event data.</param>
        private static void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            IEnumerable <FlickrData> result = null;

            if (!e.Cancelled && e.Error == null)
            {
                using (Stream stream = e.Result)
                {
                    result = ProcessResult(stream);
                }
            }

            var callback = (Action <IEnumerable <FlickrData> >)e.UserState;

            SynchronizationContext.Current.Post(x => callback((IEnumerable <FlickrData>)x), result);
        }
예제 #32
0
 void _clientByImage_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     
     if (e.Error == null && !e.Cancelled)
     {
         try
         {
             BitmapImage image = new BitmapImage();
             image.SetSource(e.Result);
             _bitmapImages[_webClients[sender as HttpWebClient]] = image;
             _markCount++;
             if (_markCount == _count)
             {
                 //下载完成
                 if (CoverImagesDownloadCompleted != null)
                     CoverImagesDownloadCompleted(sender);
                 InitElement();
             }
         }
         catch { }
     }
 }
		protected virtual void OnOpenReadCompleted (
			OpenReadCompletedEventArgs args)
		{
			if (OpenReadCompleted != null)
				OpenReadCompleted (this, args);
		}
예제 #34
0
    void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        this.webClient = null;
        if (e.Cancelled || e.Error != null)
            return;
        byte[] module = new byte[e.Result.Length];
        int module_len = e.Result.Read(module, 0, module.Length);

        ASAP asap = new ASAP();
        asap.Load(this.filename, module, module_len);
        ASAP_ModuleInfo module_info = asap.GetModuleInfo();
        if (this.song < 0)
            this.song = module_info.default_song;
        int duration = module_info.durations[this.song];
        if (duration < 0)
            duration = this.defaultPlaybackTime;
        else if (module_info.loops[this.song] && this.loopPlaybackTime != Once)
            duration = this.loopPlaybackTime;
        asap.PlaySong(this.song, duration);

        Stop();
        this.mediaElement = new MediaElement();
        this.mediaElement.Volume = 1;
        this.mediaElement.AutoPlay = true;
        this.mediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
    }
예제 #35
0
파일: SilverASAP.cs 프로젝트: epi/asap
    void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        WebClient = null;
        if (e.Cancelled || e.Error != null)
            return;
        byte[] module = new byte[e.Result.Length];
        int moduleLen = e.Result.Read(module, 0, module.Length);

        ASAP asap = new ASAP();
        asap.Load(Filename, module, moduleLen);
        ASAPInfo info = asap.GetInfo();
        if (Song < 0)
            Song = info.GetDefaultSong();
        int duration = info.GetLoop(Song) ? -1 : info.GetDuration(Song);
        asap.PlaySong(Song, duration);

        Stop();
        MediaElement = new MediaElement();
        MediaElement.Volume = 1;
        MediaElement.AutoPlay = true;
        MediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
    }
예제 #36
0
 public virtual void OnOpenReadCompleted(Stream stream, object state)
 {
     if (OpenReadCompleted == null)
     {
         return;
     }
     var args = new OpenReadCompletedEventArgs(stream, state);
     OpenReadCompleted(this, args);
 }
예제 #37
0
	void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
	{
		this.WebClient = null;
		if (e.Cancelled || e.Error != null)
			return;
		byte[] module = new byte[e.Result.Length];
		int moduleLen = e.Result.Read(module, 0, module.Length);

		ASAP asap = new ASAP();
		asap.Load(this.Filename, module, moduleLen);
		this.Info = asap.GetInfo();
		if (this.Song < 0)
			this.Song = this.Info.GetDefaultSong();
		int duration = this.Info.GetLoop(this.Song) ? -1 : this.Info.GetDuration(this.Song);
		asap.PlaySong(this.Song, duration);

		Stop();
		CallJS("onLoad");
		this.MediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
	}