private void ExportNote()
        {
            if (SelectedNote == null)
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            if (SelectedNote.HasTagCaseInsensitive(AppSettings.TAG_MARKDOWN))
            {
                sfd.Filter   = "Markdown files (*.md)|*.md";
                sfd.FileName = SelectedNote.Title + ".md";
            }
            else
            {
                sfd.Filter   = "Text files (*.txt)|*.txt";
                sfd.FileName = SelectedNote.Title + ".txt";
            }

            if (sfd.ShowDialog() == true)
            {
                try
                {
                    File.WriteAllText(sfd.FileName, SelectedNote.Text, Encoding.UTF8);
                }
                catch (Exception e)
                {
                    App.Logger.Error("Main", "Could not write to file", e);
                    ExceptionDialog.Show(Owner, "Could not write to file", e, string.Empty);
                }
            }
        }
Beispiel #2
0
 private void SaveNotIfDirty(object sender, ElapsedEventArgs elapsedEventArgs)
 {
     if (SelectedNote != null && SelectedNote.IsDirty)
     {
         SelectedNote.SaveNote();
     }
 }
 public void ClearModel()
 {
     SelectedPart = null;
     SelectedMeasure.Clear();
     SelectedChord.Clear();
     SelectedNote.Clear();
     SelectedEffect = null;
 }
        private void LoadNote()
        {
            if (SelectedNote != null)
            {
                HoleCardsCollection.ForEach(x => x.IsChecked = !SelectedNote.Settings.ExcludedCardsList.Contains(x.Name));
            }

            noteCopy = SelectedNote?.CopyTo();

            RefreshCurrentActionSettings();
            RefreshFiltersSettings();
            RefreshCurrentHandValuesSettings();

            RaiseFilterBasedPropertyChanged();
        }
        public void Clear()
        {
            SelectedPart = null;
            SelectedMeasure.Clear();
            SelectedChord.Clear();
            SelectedNote.Clear();
            SelectedEffect = null;

            Position   = null;
            String     = null;
            Fret       = null;
            BendAmount = null;
            Returns    = null;
            Wide       = null;
            Legato     = null;

            Name       = null;
            Artist     = null;
            Album      = null;
            Instrument = null;
            StringNum  = null;
        }
Beispiel #6
0
        private void ExportNote()
        {
            if (SelectedNote == null)
            {
                return;
            }

            var selection = AllSelectedNotes.ToList();

            if (selection.Count > 1)
            {
                var dialog = new VistaFolderBrowserDialog();
                if (!(dialog.ShowDialog() ?? false))
                {
                    return;
                }

                try
                {
                    var directory = dialog.SelectedPath;
                    foreach (var note in selection)
                    {
                        var filenameRaw = ANFilenameHelper.StripStringForFilename(note.Title);
                        var filename    = filenameRaw;
                        var ext         = SelectedNote.HasTagCaseInsensitive(AppSettings.TAG_MARKDOWN) ? ".md" : ".txt";

                        int i = 1;
                        while (File.Exists(Path.Combine(directory, filename + ext)))
                        {
                            i++;
                            filename = $"{filenameRaw} ({i})";
                        }

                        File.WriteAllText(Path.Combine(directory, filename + ext), note.Text, Encoding.UTF8);
                    }
                }
                catch (Exception e)
                {
                    App.Logger.Error("Main", "Could not write to file", e);
                    ExceptionDialog.Show(Owner, "Could not write to file", e, string.Empty);
                }
            }
            else
            {
                var sfd = new SaveFileDialog();

                if (SelectedNote.HasTagCaseInsensitive(AppSettings.TAG_MARKDOWN))
                {
                    sfd.Filter   = "Markdown files (*.md)|*.md";
                    sfd.FileName = SelectedNote.Title + ".md";
                }
                else
                {
                    sfd.Filter   = "Text files (*.txt)|*.txt";
                    sfd.FileName = SelectedNote.Title + ".txt";
                }

                if (sfd.ShowDialog() != true)
                {
                    return;
                }
                try
                {
                    File.WriteAllText(sfd.FileName, SelectedNote.Text, Encoding.UTF8);
                }
                catch (Exception e)
                {
                    App.Logger.Error("Main", "Could not write to file", e);
                    ExceptionDialog.Show(Owner, "Could not write to file", e, string.Empty);
                }
            }
        }