Example #1
0
        public EditorGrid(Song song, EditorWindow parent)
        {
            InitializeComponent();

            if (song == null)
                throw new ArgumentNullException("song");

            this.parent = parent;

            this.song = song;

            var tnp = (Nodes.TreeNodeProvider)FindResource("treeNodeProvider");
            tnp.Song = song;

            if (song.CheckSingleFontSize())
            {
                SingleFontSize = true;
            }

            song.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Formatting")
                    OnPropertyChanged("SingleFontSize");
            };

            this.StructureTree.IsEnabled = false;
            this.OrderListBox.IsEnabled = false;

            this.PreviewControl.FinishedLoading += (sender, args) => InitSelection();
        }
        public EditChordsWindow(Song song)
        {
            InitializeComponent();

            this.song = song;

            DataContext = this;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SongPartReference"/> class.
        /// </summary>
        /// <param name="part">The referenced part.</param>
        public SongPartReference(SongPart part)
        {
            if (part == null)
                throw new ArgumentNullException("part");

            this.root = part.Root;
            this.part = part;
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SourceNode"/> class.
 /// </summary>
 /// <param name="song">The song.</param>
 public SourceNode(Song song)
     : base(song)
 {
     song.PropertyChanged += (sender, args) =>
     {
         if (args.PropertyName == "Formatting")
             OnPropertyChanged("Size");
     };
 }
        public EditorDocument(Song song, EditorWindow parent)
        {
            Song = song;

            Grid = new EditorGrid(song, parent);
            Grid.PreviewControl.ShowChords = parent.ShowChords;

            Song.IsUndoEnabled = true;
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SongSlide"/> class.
 /// </summary>
 /// <param name="root">The song this slide belongs to.</param>
 public SongSlide(Song root)
 {
     this.Root = root;
     this.text = "";
     this.TextWithoutChords = "";
     this.translation = "";
     this.TranslationWithoutChords = "";
     this.size = Root.Formatting.MainText.Size;
 }
 public RenamePartWindow(Song song, SongPart part)
 {
     InitializeComponent();
     this.song = song;
     this.part = part;
     this.DataContext = this;
     if (this.part != null)
     {
         this.PartName = this.part.Name;
     }
 }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SongPart"/> class.
        /// </summary>
        /// <param name="root">The song this part belongs to.</param>
        /// <param name="name">The part's name.</param>
        public SongPart(Song root, string name)
        {
            this.Root = root;

            if (Root.Parts != null && Root.FindPartByName(name) != null)
            {
                throw new InvalidOperationException("part with that name already exists");
            }

            this.name = name;
            this.Slides = new ReadOnlyObservableCollection<SongSlide>(slides);
        }
Example #9
0
        public void Load(Song song, bool update = false)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            this.song = song;

            base.Load(false, true);

            DoubleAnimation ani = new DoubleAnimation { From = 0.0, To = 1.0 };
            storyboard = new Storyboard();
            storyboard.Children.Add(ani);
            Storyboard.SetTarget(ani, Control.ForegroundGrid);
            Storyboard.SetTargetProperty(ani, new PropertyPath(Image.OpacityProperty));

            if (song.VideoBackground == null)
            {
                frontImage = new ImageGrid { Background = Brushes.Black, Stretch = Stretch.UniformToFill };
                backImage = new ImageGrid { Background = Brushes.Black, Stretch = Stretch.UniformToFill };

                this.Control.BackgroundGrid.Children.Add(backImage);
                this.Control.ForegroundGrid.Children.Add(frontImage);
            }
            else
            {
                videoBackground = new AudioVideo.VlcWrapper(); // TODO: use configurable wrapper (does WPF work?)

                videoBackground.Autoplay = true;
                videoBackground.Loop = true;
                try
                {
                    videoBackground.Load(DataManager.Backgrounds.GetFile(song.VideoBackground).Uri);
                }
                catch (FileNotFoundException)
                {
                    throw new NotImplementedException("Video background file not found: Doesn't know what to do.");
                }

                var brush = new System.Windows.Media.VisualBrush(videoBackground);
                videoBackgroundClone = new System.Windows.Shapes.Rectangle();
                videoBackgroundClone.Fill = brush;

                this.Control.ForegroundGrid.Children.Add(videoBackground);
                this.Control.BackgroundGrid.Children.Add(videoBackgroundClone);
            }

            this.Control.Web.IsTransparent = true;
            this.Control.Web.ProcessCreated += Web_ProcessCreated;
            currentSlideIndex = -1;
        }
        private void ExportSong(Song song)
        {
            // TODO: localize
            var dlg = new Microsoft.Win32.SaveFileDialog();
            string[] exts = { ".ppl", ".xml", ".html" };
            dlg.DefaultExt = exts[0];
            dlg.Filter = "Powerpraise-Lied|*.ppl|OpenLyrics-Lied|*.xml|HTML-Dokument|*.html"; // must be same order as exts
            dlg.Title = Resource.eMenuExportSong;
            dlg.InitialDirectory = Properties.Settings.Default.LastSongDirectory;

            if (song.Uri == null)
            {
                dlg.FileName = song.Title;
            }
            else
            {
                dlg.FileName = Path.GetFileNameWithoutExtension(Uri.UnescapeDataString(song.Uri.Segments.Last()));
            }

            if (dlg.ShowDialog() == true)
            {
                Properties.Settings.Default.LastSongDirectory = Path.GetDirectoryName(dlg.FileName);

                string path = dlg.FileName;
                string ext = Path.GetExtension(path).ToLower();

                if (!exts.Contains(ext))
                {
                    ext = exts[dlg.FilterIndex - 1];
                    path = path + ext;
                }

                if (ext == ".html")
                {
                    song.Export(new Uri(path), new HtmlSongWriter());
                }
                else if (ext == ".xml")
                {
                    song.Export(new Uri(path), new OpenLyricsSongWriter());
                }
                else if (ext == ".ppl")
                {
                    song.Export(new Uri(path), new PowerpraiseSongWriter());
                }
                else
                {
                    // TODO: add more formats
                    throw new InvalidOperationException("Invalid extension " + ext + ". This should not happen.");
                }

            }
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SongSource"/> class.
 /// </summary>
 /// <param name="root">The song this source belongs to.</param>
 public SongSource(Song root)
 {
     this.Root = root;
 }
Example #12
0
 /// <summary>
 /// Loads the media object from the file specified in the <see cref="File"/> field into memory.
 /// This is always called before the control panel and/or presentation is shown.
 /// Use <see cref="MediaManager.LoadMedia"/> to call this safely.
 /// </summary>
 public override void Load()
 {
     Song = new Song(this.Uri);
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CcliNumberNode"/> class.
 /// </summary>
 /// <param name="song">The song.</param>
 public CcliNumberNode(Song song)
     : base(song)
 {
 }
 public EditorDocument CheckSongOpened(Song song)
 {
     foreach (var doc in openDocuments)
     {
         if (doc.Song.Uri != null && doc.Song.Uri == song.Uri)
             return doc;
     }
     return null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SongPartReference"/> class.
 /// </summary>
 /// <param name="name">The name of the referenced <see cref="SongPart"/>.</param>
 public SongPartReference(Song root, string name)
     : this(root.FindPartByName(name))
 {
 }
        private void SaveSongAs(Song song)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            SaveFilenameDialog dlg = new SaveFilenameDialog(song.Title);
            dlg.Owner = this;

            if (dlg.ShowDialog() == true)
            {
                song.Save(new Uri("song:///" + dlg.Filename));
            }
        }
        private void SaveSong(Song song)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            if (song.Uri == null || song.IsImported)
            {
                SaveSongAs(song);
            }
            else
            {
                song.Save();
            }
        }
        private void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e)
        {
            EditorDocument doc;

            if (e.Parameter != null && e.Parameter is EditorDocument)
                doc = e.Parameter as EditorDocument;
            else
                doc = Tabs != null ? (Tabs.SelectedItem as EditorDocument) : null;

            if (e.Command == ApplicationCommands.New)
            {
                NewSong();
            }
            else if (e.Command == ApplicationCommands.Open)
            {
                OpenSong();
            }
            else if (e.Command == ApplicationCommands.Save)
            {
                SaveSong(doc.Song);
            }
            else if (e.Command == ApplicationCommands.SaveAs)
            {
                SaveSongAs(doc.Song);
            }
            else if (e.Command == CustomCommands.Export)
            {
                ExportSong(doc.Song);
            }
            else if (e.Command == CustomCommands.ImportFromClipboard)
            {
                try
                {
                    var song = new Song(null, new ClipboardUriResolver(), new CcliTxtSongReader());
                    Load(song);
                }
                catch
                {
                    MessageBox.Show(Resource.eMsgCouldNotImportFromClipboard);
                }
            }
            else if (e.Command == ApplicationCommands.Close)
            {
                CloseSong(doc);
            }
            else if (e.Command == CustomCommands.ViewCurrent)
            {
                SaveSong(doc.Song);
                Controller.ReloadActiveMedia();
                Controller.FocusMainWindow(true);
            }
            else if (e.Command == CustomCommands.SwitchWindow)
            {
                if (openDocuments.Count == 0)
                    this.Close();

                Controller.FocusMainWindow(true);
            }
            else if (e.Command == CustomCommands.SongSettings)
            {
                var win = new SongSettingsWindow(doc.Song.Formatting.Clone() as SongFormatting);
                win.Owner = this;
                if (win.ShowDialog() == true)
                {
                    if (win.Formatting.SingleFontSize && !doc.Song.CheckSingleFontSize())
                    {
                        var res = MessageBox.Show(Resource.eMsgSingleFontSize, Resource.eMsgSingleFontSizeTitle, MessageBoxButton.YesNo);
                        if (res == MessageBoxResult.No)
                        {
                            win.Formatting.SingleFontSize = false;
                        }
                    }
                    doc.Song.Formatting = win.Formatting;
                }
            }
            else if (e.Command == CustomCommands.EditChords)
            {
                var win = new EditChordsWindow(doc.Song);
                win.Owner = this;
                win.ShowDialog();
            }
            else if (e.Command == CustomCommands.AddMedia)
            {
                Controller.AddToPortfolio(doc.Song.Uri);
            }
            else if (e.Command == ApplicationCommands.Find)
            {
                Controller.ShowSongList();
            }
            else if (e.Command == CustomCommands.SearchSongSelect)
            {
                string searchString = null;
                if (e.Parameter is string)
                {
                    searchString = (string)e.Parameter;
                }
                else
                {
                    int? searchNum = e.Parameter as int?;
                    if (searchNum.HasValue)
                        searchString = searchNum.ToString();
                }

                if (!String.IsNullOrWhiteSpace(searchString))
                    new Uri(String.Format(Resource.eSongSelectSearchString, searchString)).OpenInBrowser();
            }
        }
        private void Load(Song song)
        {
            var opened = CheckSongOpened(song);
            if (opened == null)
            {
                opened = new EditorDocument(song, this);
                openDocuments.Add(opened);
            }

            opened.Grid.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedElement")
                    OnPropertyChanged("FontSizeEnabled");
            };

            Tabs.SelectedItem = opened;
        }
        void ApplySongTemplateMaster(Song song, MasterOverrideOptions options)
        {
            SongFormatting master = Song.CreateFromTemplate().Formatting;
            var changed = song.Formatting;

            if (options.TextFormatting)
            {
                changed.MainText = master.MainText;
                changed.TranslationText = master.TranslationText;
            }
            if (options.TextPosition)
            {
                changed.HorizontalOrientation = master.HorizontalOrientation;
                changed.VerticalOrientation = master.VerticalOrientation;
                changed.TextLineSpacing = master.TextLineSpacing;
                changed.TranslationPosition = master.TranslationPosition;
                changed.TranslationLineSpacing = master.TranslationLineSpacing;
            }
            if (options.SourceFormatting)
            {
                changed.SourceText = master.SourceText;
            }
            if (options.SourcePosition)
            {
                changed.SourceDisplayPosition = master.SourceDisplayPosition;
                changed.SourceBorderRight = master.SourceBorderRight;
                changed.SourceBorderTop = master.SourceBorderTop;
            }
            if (options.CopyrightFormatting)
            {
                changed.CopyrightText = master.CopyrightText;
            }
            if (options.CopyrightPosition)
            {
                changed.CopyrightDisplayPosition = master.CopyrightDisplayPosition;
                changed.CopyrightBorderBottom = master.CopyrightBorderBottom;
            }
            if (options.OutlineShadow)
            {
                changed.IsOutlineEnabled = master.IsOutlineEnabled;
                changed.IsShadowEnabled = master.IsShadowEnabled;
                changed.OutlineColor = master.OutlineColor;
                changed.ShadowColor = master.ShadowColor;
                changed.ShadowDirection = master.ShadowDirection;
            }

            song.Formatting = changed;
        }
Example #21
0
        /// <summary>
        /// Shows a window to prompt for a new name for the song.
        /// </summary>
        /// <param name="song">The song.</param>
        /// <returns>The window.</returns>
        private RenameSongWindow ShowRenameSongDialog(Song song)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            RenameSongWindow win = new RenameSongWindow(song.Title);
            win.Owner = parent;
            win.ShowDialog();
            return win;
        }
Example #22
0
		public static async Task<Song> LoadAsync(Uri uri, SongUriResolver resolver, ISongReader reader, CancellationToken cancellation = default(CancellationToken))
		{
			var song = new Song();
			song.Uri = uri;
			song.uriResolver = resolver;

			if (reader.NeedsTemplate)
			{
				song.LoadClearTemplate();
			}

			using (Stream stream = await song.uriResolver.GetAsync(uri, cancellation))
			{
				cancellation.ThrowIfCancellationRequested();
				reader.Read(song, stream);
			}

			if (!(reader is PowerpraiseSongReader))
			{
				song.IsImported = true;
			}

			return song;
		}
        public void Load(Song song)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            if (features != FeatureLevel.None)
            {
                var backgrounds = new List<JSValue>(song.Backgrounds.Count);

                foreach (var bg in song.Backgrounds.Where(bg => bg.Type == SongBackgroundType.Image))
                {
                    try
                    {
                        backgrounds.Add(new JSValue(bg.FilePath.Replace('\\', '/')));
                    }
                    catch (FileNotFoundException)
                    {
                        // ignore -> just show black background
                    }
                }

                bridge["preloadImages"] = new JSValue(backgrounds.ToArray());
                bridge["backgroundPrefix"] = new JSValue("asset://backgrounds/");
            }
            bridge["songString"] = new JSValue(JsonConvert.SerializeObject(song));
            bridge["showChords"] = new JSValue(ShowChords);

            this.control.Source = new Uri("asset://WordsLive/song.html");
        }
Example #24
0
 public virtual void Init()
 {
     song = new Song(@"TestData\SimpleSong.ppl");
     song.IsUndoEnabled = true;
 }
Example #25
0
        /// <summary>
        /// Generated a <see cref="SongSource"/> by parsing a string.
        /// A variety of formats is supported, e.g. '[Book] / [Nr]' or '[Book], Nr. [Nr]'.
        /// </summary>
        /// <param name="source">The string to parse.</param>
        /// <returns>The parsed source object.</returns>
        public static SongSource Parse(string source, Song root)
        {
            SongSource result = new SongSource(root);

            if(String.IsNullOrWhiteSpace(source))
                return result;

            bool success = false;
            int n;

            if (source.Contains("/"))
            {
                var parts = source.Split('/');
                result.songbook = parts[0].Trim();
                if (int.TryParse(parts[1].Trim(), out n))
                {
                    result.number = n;
                    success = true;
                }
            }

            if (!success)
            {
                int index = source.LastIndexOfAny(new char[] {' ','.',','});
                if (index >= 0 && int.TryParse(source.Substring(index+1).Trim(), out n))
                {
                    result.Number = n;
                    string book = source.Substring(0, index+1).Trim();
                    if (book.EndsWith("Nr."))
                        book = book.Substring(0, book.Length - 3).Trim();
                    if (book.EndsWith(","))
                        book = book.Substring(0, book.Length - 1).Trim();
                    result.songbook = book;
                }
                else
                {
                    result.songbook = source;
                }
            }

            return result;
        }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataNode"/> class.
 /// </summary>
 /// <param name="song">The song.</param>
 public MetadataNode(Song song)
 {
     this.Root = song;
 }
Example #27
0
		/// <summary>
		/// Creates a new song from a template.
		/// </summary>
		/// <returns></returns>
		public static Song CreateFromTemplate()
		{
			Song song = new Song();
			song.LoadTemplate();
			return song;
		}
        public void LoadOrImport(Uri uri)
        {
            if (uri == null)
                throw new ArgumentNullException("uri");

            uri = DataManager.Songs.TryRewriteUri(uri);

            string ext = uri.GetExtension();

            Song song = null;

            try
            {
                if (ext == ".ppl")
                {
                    song = new Song(uri, new PowerpraiseSongReader());
                }
                else if (ext == ".sng")
                {
                    song = new Song(uri, new SongBeamerSongReader());
                }
                else if (ext == ".chopro" || ext == ".cho" || ext == ".pro")
                {
                    song = new Song(uri, new ChordProSongReader());
                }
                else if (ext == ".usr")
                {
                    song = new Song(uri, new CcliUsrSongReader());
                }
                else if (ext == ".txt")
                {
                    song = new Song(uri, new CcliTxtSongReader());
                }
                else if (ext == ".xml")
                {
                    song = new Song(uri, new OpenLyricsSongReader());
                }
                else if (ext == "") // OpenSong songs have no file extension
                {
                    song = new Song(uri, new OpenSongSongReader());
                }
                else
                {
                    throw new NotSupportedException("Song format is not supported.");
                }
            }
            catch(Exception e)
            {
                Controller.ShowEditorWindow();
                MessageBox.Show(String.Format(Resource.eMsgCouldNotOpenSong, uri.FormatLocal(), e.Message), Resource.dialogError, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (song != null)
            {
                Load(song);
            }
        }
Example #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryNode"/> class.
 /// </summary>
 /// <param name="song">The song.</param>
 public CategoryNode(Song song)
     : base(song)
 {
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LanguageNode"/> class.
 /// </summary>
 /// <param name="song">The song.</param>
 public LanguageNode(Song song)
     : base(song)
 {
 }