Ejemplo n.º 1
0
 /// <summary>
 /// Save as event handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SaveChildAs(object sender, EventArgs e)
 {
     if (ActiveMdiChild != null)
     {
         SongEditorChild window = ((SongEditorChild)ActiveMdiChild);
         Song            sng    = window.Song;
         window.ValidateChildren();
         string fileName = SaveAs(sng, null);
         if (fileName != null)
         {
             int hashCode = sng.GetHashCode();
             ((EditorChildMetaData)window.Tag).HashCode = hashCode;
             ((EditorChildMetaData)window.Tag).Filename = fileName;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles saving of changed data when closing a song window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void childForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            SongEditorChild window = ((SongEditorChild)sender);

            String filename = ((EditorChildMetaData)window.Tag).Filename;
            Song   sng      = window.Song;

            int storedHashCode = ((EditorChildMetaData)window.Tag).HashCode;
            int songHashCode   = sng.GetHashCode();

            if (storedHashCode != songHashCode)
            {
                DialogResult dlg = MessageBox.Show(
                    string.Format(StringResources.SaveChangesMadeToTheSong, sng.Title),
                    StringResources.SongEditor,
                    MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (dlg == DialogResult.Yes)
                {
                    Save(sng, ((EditorChildMetaData)window.Tag).Filename);
                }
                else if (dlg == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            else if (filename != null && !File.Exists(filename))
            {
                DialogResult dlg = MessageBox.Show(string.Format(StringResources.SaveChangesMadeToTheSong, sng.Title),
                                                   StringResources.SongEditor,
                                                   MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (dlg == DialogResult.Yes)
                {
                    SaveAs(sng, ((EditorChildMetaData)window.Tag).Filename);
                }
                else if (dlg == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a song editor child form with the given song and file name
        /// </summary>
        /// <param name="sng">Song</param>
        /// <param name="fileName">File name, may be null</param>
        /// <param name="forceSaveCheck">Force check for save file</param>
        /// <returns></returns>
        private void CreateSongEditorChildForm(Song sng, String fileName, bool forceSaveCheck)
        {
            int             hashCode  = forceSaveCheck ? 0 : sng.GetHashCode();
            SongEditorChild childForm = new SongEditorChild(_settings, _imgManager, sng)
            {
                Tag       = new EditorChildMetaData(fileName, hashCode),
                MdiParent = this
            };

            childForm.FormClosing += childForm_FormClosing;
            childForm.Show();
            RegisterChild(childForm);

            // Se status
            SetStatus(string.Format(StringResources.LoadedSong, sng.Title));

            // Set window title if new song
            if (fileName == null)
            {
                childForm.SetWindowTitle(sng.Title + @" " + ++_childFormNumber);
            }
        }