Exemplo n.º 1
0
        /// <summary>
        /// Adds music from the explorer to the timeline on clicking on it
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void OnMusicClick(object sender, MouseButtonEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            if (sender.GetType() != typeof(MusicExplorerElementControl))
            {
                return;
            }

            int index = Music_Holder.Children.IndexOf((MusicExplorerElementControl)sender);

            _timeline.AddMusicElement(MusicPaths[index]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses a loadable Datastore xml-schemed file. And sets its value to the current Datastore
        /// </summary>
        /// <param name="fileName">The path of the xml-schmed file</param>
        public void LoadFrom(string fileName)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.AppStarting;
                DataContractSerializer serializer = new DataContractSerializer(typeof(DataStore));
                DataStore ds;
                using (Stream s = File.OpenRead(fileName))
                {
                    ds = (DataStore)serializer.ReadObject(s);
                }

                if (ds.ExportData != null)
                {
                    ExportData            = new ExportData(_timeline, _statusBar, ds.ExportData.Resolution, ds.ExportData.FPS);
                    ExportData.Bitrate    = ds.ExportData.Bitrate;
                    ExportData.ExportPath = ds.ExportData.ExportPath;
                }

                _pictureExplorer.Reset();
                _musicExplorer.Reset();
                _timeline.PictureElements.Clear();
                _timeline.MusicElements.Clear();

                //Remove Music End Elements
                List <UIElement> toRemove = new List <UIElement>();
                foreach (UIElement child in _timeline.MainCanvas.Children)
                {
                    if (child.GetType() == typeof(TlMusikElementEnde))
                    {
                        toRemove.Add(child);
                    }
                }
                foreach (UIElement element in toRemove)
                {
                    _timeline.MainCanvas.Children.Remove(element);
                }
                _timeline.EndElements.Clear();

                _timeline.MainScrollbar.ScrollToRightEnd();

                foreach (string musicPath in ds._musicPaths)
                {
                    _musicExplorer.AddMusic(musicPath);
                }

                foreach (TimelinePictureElementData elData in ds._timelinePictureData)
                {
                    _timeline.AddPictureElement(elData.StartTime, elData.EndTime, elData.Thumbnail, elData.TransitionID, elData.TransitionExecutionTime, -1);
                }

                foreach (TimelineMusicElementData elData in ds._timelineMusicData)
                {
                    _timeline.AddMusicElement(elData.MusicPath);
                }

                Canvas.SetLeft(_timeline.tlMarker, ds._tlMarkerPos);

                _pictureExplorer.AddImages(ds._picturePaths.ToArray());
            } catch (Exception)
            {
                MessageBox.Show("Error while loading file " + fileName + ". File could not be loaded!", "Error opening project", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            Mouse.OverrideCursor = null;
        }