private static void imageSourcePropertyChange(DependencyObject source, DependencyPropertyChangedEventArgs e) { ArtistPictureControl ctr = (ArtistPictureControl)source; DataList<TrackImage> pics = null; if (e.NewValue is DataList<TrackImage>) pics = (DataList<TrackImage>)e.NewValue; else if (e.NewValue is TrackImage) pics = new DataList<TrackImage>((TrackImage)e.NewValue); ctr.pictureBox.Children.Clear(); if (pics == null || pics.Count == 0) { Image myImage3 = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); MemoryStream stream = new MemoryStream(Static.DefaultImage); bi3.StreamSource = stream; bi3.EndInit(); myImage3.Stretch = Stretch.Fill; myImage3.Source = bi3; myImage3.Width = 100; myImage3.Height = 100; ctr.pictureBox.Children.Clear(); ctr.pictureBox.Children.Add(myImage3); } else { foreach (TrackImage arr in pics) { Image myImage3 = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); MemoryStream stream = new MemoryStream(arr.Image); bi3.StreamSource = stream; bi3.EndInit(); myImage3.Stretch = Stretch.Fill; myImage3.Source = bi3; myImage3.Width = 100; myImage3.Height = 100; UIElement[] currentcol = new UIElement[ctr.pictureBox.Children.Count]; ctr.pictureBox.Children.CopyTo(currentcol, 0); ctr.pictureBox.Children.Clear(); ctr.pictureBox.Children.Add(myImage3); foreach (UIElement ui in currentcol) ctr.pictureBox.Children.Add(ui); if (ctr.pictureBox.Children.Count > 1 && ctr.pictureBox.Children.Count < 18) { myImage3.RenderTransform = new RotateTransform() { Angle = 10 * ctr.pictureBox.Children.Count }; myImage3.RenderTransformOrigin = new Point(0.5, 0.5); } } } }
private void trackList_Drop(object sender, DragEventArgs e) { try { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { String[] droppedObjects = (String[])e.Data.GetData(DataFormats.FileDrop); BackgroundWorker backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.DoWork += new DoWorkEventHandler(fileImportDoWorkHandler); backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(fileImportProgressEventHandler); backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(fileImportTaskComplete); backgroundWorker.RunWorkerAsync(droppedObjects); return; } if (e.Data.GetDataPresent(DataFormats.Dif)) { Artist artist = e.Data.GetData(DataFormats.Dif) as Artist; DataList<Track> tracks = new DataList<Track>(); foreach (Album alb in artist.Albums) tracks.Import(alb.Tracks); this.files.Import(tracks.Map<PlayListWrapperFile>(row => new PlayListWrapperFile(row))); } MediaFile dropObj = e.Data.GetData(typeof(MediaFile)) as MediaFile; if (dropObj != null) { } } catch (Exception ex) { Logging.Error(typeof(PlayList), ex); } }
private void fileImportDoWorkHandler(Object sender, DoWorkEventArgs e) { ((BackgroundWorker)sender).ReportProgress(0, new ReportProgress{ Message = "Adding files to playlist.", vardata= null}); DataList<String> filesToImport = new DataList<string>((String[])e.Argument); filesToImport = Static.GetFiles(filesToImport); ((BackgroundWorker)sender).ReportProgress(0, new ReportProgress { Message = String.Format("Adding files to playlist.0/{0}", filesToImport.Count), vardata = null }); Int64 progressCounter = 0; DataList<PlayListWrapperFile> importList = new DataList<PlayListWrapperFile>(); foreach (String fileName in filesToImport) { if (progressCounter == 10) { ((BackgroundWorker)sender).ReportProgress(0, new ReportProgress { Message = String.Format("Adding files to playlist.{1}/{0}", filesToImport.Count, filesToImport.IndexOf(fileName)+1), vardata = importList }); importList = new DataList<PlayListWrapperFile>(); progressCounter = 0; } if (Static.knownFileExtensions.Contains(Static.GetFileExtension(fileName))) { MediaFile mf = MediaFile.Create(fileName); importList.Add(new PlayListWrapperFile(mf)); progressCounter++; } } ((BackgroundWorker)sender).ReportProgress(100, new ReportProgress {vardata = importList }); }
public DataRange(DataList owner, int pageIndex, int pageSize) { _owner = owner; _startIndex = pageIndex * pageSize; _endIndex = _startIndex + pageSize; _version = owner._version; _index = -1; }