/// <summary>
        /// Drag and drop or double click image to add it to timeline
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnImgClick(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1)
            {
                //Drag img
                int        index   = Picture_Holder.Children.IndexOf((Image)sender);
                DataObject dataObj = new DataObject(ImgPaths[index]);
                DragDrop.DoDragDrop(sender as Image, dataObj, DragDropEffects.Copy);
            }
            else
            {
                //Double click img
                if (sender == null)
                {
                    return;
                }

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

                int index = Picture_Holder.Children.IndexOf((Image)sender);
                _timeline.AddPictureElement(ImgPaths[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;
        }