/// <summary>
        /// Command handler for Save As Command
        /// </summary>
        private void SaveFamilyAs(object sender, RoutedEventArgs e)
        {
            if (family.IsOldVersion && !appSettings.DontShowOldVersionMessage)
            {
                //Show message that the file will be saved in the new format
                ShowOldVersionMessage();
            }
            else
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyV3Extension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title            = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);

                    if (familyCollection.FullyQualifiedFilename.EndsWith(Properties.Resources.DefaultFamilyExtension))
                    {
                        // Remove the file from its current position and add it back to the top/most recent position.
                        App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                        App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                        BuildOpenMenu();
                    }
                }
            }
        }
        /// <summary>
        /// Command handler for Open Command
        /// </summary>
        private void OpenFamily(object sender, RoutedEventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtensions));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV3Files, Properties.Resources.FamilyV3Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV2Files, Properties.Resources.FamilyV2Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                LoadFamily(dialog.FileName);

                ShowDetailsPane();

                // This will tell other views using this data to update themselves using the new data
                family.OnContentChanged();

                if (familyCollection.FullyQualifiedFilename.EndsWith(Properties.Resources.DefaultFamilyExtension))
                {
                    // Remove the file from its current position and add it back to the top/most recent position.
                    App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                    App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                    BuildOpenMenu();
                    family.IsDirty = false;
                }
            }
        }
        /// <summary>
        /// Command handler for ExportXPSCommand
        /// </summary>
        private void ExportXps(object sender, EventArgs e)
        {
            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.XpsFiles, Properties.Resources.XpsExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title            = Properties.Resources.Export;
            dialog.DefaultExtension = Properties.Resources.DefaultXpsExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                // Create the XPS document from the window's main container (in this case, a grid)
                Package           package   = Package.Open(dialog.FileName, FileMode.Create);
                XpsDocument       xpsDoc    = new XpsDocument(package);
                XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

                // Hide the zoom control before the diagram is saved
                DiagramControl.ZoomSliderPanel.Visibility = Visibility.Hidden;

                // Since DiagramBorder derives from FrameworkElement, the XpsDocument writer knows
                // how to output it's contents. The border is used instead of the DiagramControl
                // so that the diagram background is output as well as the digram control itself.
                xpsWriter.Write(DiagramBorder);
                xpsDoc.Close();
                package.Close();

                // Show the zoom control again
                DiagramControl.ZoomSliderPanel.Visibility = Visibility.Visible;
            }
        }
        private void ImportGedcom(object sender, EventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.GedcomFiles, Properties.Resources.GedcomExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Import;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                try
                {
                    GedcomImport ged = new GedcomImport();
                    ged.Import(family, dialog.FileName);
                    familyCollection.FullyQualifiedFilename = string.Empty;

                    ShowDetailsPane();
                    family.IsDirty = false;
                }
                catch
                {
                    // Could not import the GEDCOM for some reason. Handle
                    // all exceptions the same, display message and continue
                    /// without importing the GEDCOM file.
                    MessageBox.Show(this, Properties.Resources.GedcomFailedMessage,
                                    Properties.Resources.GedcomFailed, MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Command handler for Save Command
        /// </summary>
        private void SaveFamily(object sender, RoutedEventArgs e)
        {
            // Prompt to save if the file has not been saved before, otherwise just save to the existing file.
            if (string.IsNullOrEmpty(familyCollection.FullyQualifiedFilename))
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title            = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);

                    // Remove the file from its current position and add it back to the top/most recent position.
                    App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                    App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                    BuildOpenMenu();
                }
            }
            else
            {
                familyCollection.Save();

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                BuildOpenMenu();
            }
        }
        /// <summary>
        /// Command handler for Open Command in the menu.
        /// </summary>
        private void OpenFamily(object sender, RoutedEventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                // Load the selected family file
                familyCollection.Load(dialog.FileName);

                ShowDetailsPane();

                // This will tell the diagram to redraw and the details panel to update.
                family.OnContentChanged();

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                BuildOpenMenu();
                family.IsDirty = false;
            }
        }
Exemple #7
0
        private void Export()
        {
            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.htmlFiles, Properties.Resources.htmlExtension));
            dialog.Title            = Properties.Resources.Export;
            dialog.DefaultExtension = Properties.Resources.DefaulthtmlExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                SourcesExport sources = new SourcesExport();
                sources.ExportSources(dialog.FileName, Path.GetFileName(this.familyCollection.FullyQualifiedFilename), source);
            }

            if (File.Exists(dialog.FileName))
            {
                MessageBoxResult result = MessageBox.Show(Properties.Resources.SourcesExportMessage,
                                                          Properties.Resources.ExportResult, MessageBoxButton.YesNo, MessageBoxImage.Question);

                try
                {
                    if (result == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(dialog.FileName);
                    }
                }
                catch { }
            }
        }
        /// <summary>
        /// Prompts the user to save the current family if it has been changed
        /// </summary>
        private void PromptToSave()
        {
            if (!family.IsDirty)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show(Properties.Resources.NotSavedMessage,
                                                      Properties.Resources.NotSaved, MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyV3Extension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title            = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);

                    if (!App.RecentFiles.Contains(familyCollection.FullyQualifiedFilename))
                    {
                        App.RecentFiles.Add(familyCollection.FullyQualifiedFilename);
                        BuildOpenMenu();
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Handles selecting the avatar photo
        /// </summary>
        private void AvatarGrid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString();
            dialog.Filter.Add(new FilterEntry(Properties.Resources.JpegFiles, Properties.Resources.JpegExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.PngFiles, Properties.Resources.PngExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                avatarPhotoPath    = dialog.FileName;
                AvatarPhoto.Source = new BitmapImage(new Uri(avatarPhotoPath));
            }
        }
Exemple #10
0
        /// <summary>
        /// Command handler for Open Command
        /// </summary>
        private void OpenFamily(object sender, RoutedEventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtensions));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV3Files, Properties.Resources.FamilyV3Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV2Files, Properties.Resources.FamilyV2Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            OpenFamilyFromFile(dialog.FileName);
        }
        /// <summary>
        /// Command handler for ExportGedcomCommand
        /// </summary>
        private void ExportGedcom(object sender, EventArgs e)
        {
            CommonDialog dialog = new CommonDialog();

            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.GedcomFiles, Properties.Resources.GedcomExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title            = Properties.Resources.Export;
            dialog.DefaultExtension = Properties.Resources.DefaultGedcomExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                GedcomExport ged = new GedcomExport();
                ged.Export(family, dialog.FileName);
            }
        }
Exemple #12
0
        /// <summary>
        /// Add a photo.
        /// If the photo name exists, append (#) to the file name.
        /// If the file is not supported inform the user.
        /// </summary>
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            Person person = (Person)this.DataContext;

            string appLocation = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            appLocation = Path.Combine(appLocation, App.AppDataFolderName);

            // Absolute path to the photos folder
            string       photoLocation = Path.Combine(appLocation, Photo.PhotosFolderName);
            CommonDialog dialog        = new CommonDialog();

            dialog.Filter.Add(new FilterEntry(Properties.Resources.ImageFiles, Properties.Resources.ImageExtension));
            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            dialog.Title            = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                if (App.IsPhotoFileSupported(Path.GetFileName(dialog.FileName)))
                {
                    Photo photo = new Photo(dialog.FileName);
                    photo.RelativePath = Path.Combine(Photo.PhotosFolderName, Path.GetFileName(dialog.FileName));

                    // Associate the photo with the person.
                    person.Photos.Add(photo);

                    if (person.Photos.Count == 0)
                    {
                        PhotosListBox.SelectedIndex = 0;
                    }

                    // Setter for property change notification
                    person.Avatar = "";
                }
            }

            person.OnPropertyChanged("HasPhoto");
        }
        /// <summary>
        /// Command handler for ExportGedcomCommand
        /// </summary>
        private void ExportGedcom(object sender, EventArgs e)
        {
            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.GedcomFiles, Properties.Resources.GedcomExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Export;
            dialog.DefaultExtension = Properties.Resources.DefaultGedcomExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                GedcomExport ged = new GedcomExport();
                ged.Export(family, dialog.FileName);
            }
        }
        /// <summary>
        /// Handles selecting the avatar photo
        /// </summary>
        private void AvatarGrid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString();
            dialog.Filter.Add(new FilterEntry(Properties.Resources.JpegFiles, Properties.Resources.JpegExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.PngFiles, Properties.Resources.PngExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                avatarPhotoPath = dialog.FileName;
                AvatarPhoto.Source = new BitmapImage(new Uri(avatarPhotoPath));
            }
        }
Exemple #15
0
        /// <summary>
        /// Link an existing photo.
        /// If not existing photo or photo is not in "Family Data\Images" then return warning.
        /// If file not supported, return warning.
        /// </summary>
        private void Link_Click(object sender, RoutedEventArgs e)
        {
            Person person = (Person)this.DataContext;

            string appLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                              App.ApplicationFolderName);

            appLocation = Path.Combine(appLocation, App.AppDataFolderName);

            // Absolute path to the photos folder
            string photoLocation = Path.Combine(appLocation, Photo.PhotosFolderName);

            int photoCount = 0;

            if (Directory.Exists(photoLocation))
            {
                photoCount = Directory.GetFiles(photoLocation).Length;
            }

            if (photoCount > 0)
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = photoLocation;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.ImageFiles, Properties.Resources.ImageExtension));
                dialog.Title = Properties.Resources.Link;
                dialog.ShowOpen();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    if (File.Exists(Path.Combine(photoLocation, Path.GetFileName(dialog.FileName))))  //only link files which are in the temp directory
                    {
                        if (App.IsPhotoFileSupported(Path.GetFileName(dialog.FileName)))
                        {
                            int i = 0;

                            foreach (Photo p in person.Photos)
                            {
                                if (p.RelativePath.ToString() == Path.Combine(Photo.PhotosFolderName, Path.GetFileName(dialog.FileName)))
                                {
                                    i++;
                                }
                            }

                            if (i == 0)
                            {
                                Photo photo = new Photo();
                                photo.RelativePath = Path.Combine(Photo.PhotosFolderName, Path.GetFileName(dialog.FileName));
                                // Associate the photo with the person.
                                person.Photos.Add(photo);

                                if (person.Photos.Count == 0)
                                {
                                    PhotosListBox.SelectedIndex = 0;
                                }

                                // Setter for property change notification
                                person.Avatar = "";
                            }
                            else
                            {
                                MessageBox.Show(Properties.Resources.PhotoExistsMessage,
                                                Properties.Resources.LinkFailed, MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.LinkAddMessage,
                                        Properties.Resources.LinkFailed, MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                person.OnPropertyChanged("HasPhoto");
            }
            else
            {
                MessageBox.Show(Properties.Resources.NoExistingPhotos,
                                Properties.Resources.LinkFailed, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #16
0
        /// <summary>
        /// Command handler for Open Command in the menu.
        /// </summary>
        private void OpenFamily(object sender, RoutedEventArgs e)
        {
            PromptToSave();
        
            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                // Load the selected family file
                familyCollection.Load(dialog.FileName);

                ShowDetailsPane();

                // This will tell the diagram to redraw and the details panel to update.
                family.OnContentChanged();

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                BuildOpenMenu();
                family.IsDirty = false;
            }
        }
        /// <summary>
        /// Prompts the user to save the current family if it has been changed
        /// </summary>
        private void PromptToSave()
        {
            if (!family.IsDirty)
                return;

            MessageBoxResult result = MessageBox.Show(Properties.Resources.NotSavedMessage,
                Properties.Resources.NotSaved, MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyV3Extension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);

                    if (!App.RecentFiles.Contains(familyCollection.FullyQualifiedFilename))
                    {
                        App.RecentFiles.Add(familyCollection.FullyQualifiedFilename);
                        BuildOpenMenu();
                    }
                }
            }
        }
        /// <summary>
        /// Command handler for Save As Command
        /// </summary>
        private void SaveFamilyAs(object sender, RoutedEventArgs e)
        {
            if (family.IsOldVersion && !appSettings.DontShowOldVersionMessage)
            {
                //Show message that the file will be saved in the new format
                ShowOldVersionMessage();
            }
            else
            {

                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyV3Extension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);

                    if (familyCollection.FullyQualifiedFilename.EndsWith(Properties.Resources.DefaultFamilyExtension))
                    {
                        // Remove the file from its current position and add it back to the top/most recent position.
                        App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                        App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                        BuildOpenMenu();
                    }
                }
            }
        }
        private void OldVersionMessageControl_ContinueButtonClick(object sender, RoutedEventArgs e)
        {
            HideOldVersionMessage();

            // Prompt to save if the file has not been saved before, otherwise just save to the existing file.
            if (string.IsNullOrEmpty(familyCollection.FullyQualifiedFilename) || family.IsOldVersion)
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV3Files, Properties.Resources.FamilyV3Extension));
                dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
                dialog.Title = Properties.Resources.SaveAs;
                dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
                dialog.ShowSave();

                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    familyCollection.Save(dialog.FileName);
                    family.IsOldVersion = false;

                    // Remove the file from its current position and add it back to the top/most recent position.
                    App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                    App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                    BuildOpenMenu();
                }
            }
            else
            {
                familyCollection.Save();

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                BuildOpenMenu();
            }
        }
        /// <summary>
        /// Command handler for Open Command
        /// </summary>
        private void OpenFamily(object sender, RoutedEventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtensions));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV3Files, Properties.Resources.FamilyV3Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyV2Files, Properties.Resources.FamilyV2Extension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Open;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                LoadFamily(dialog.FileName);

                ShowDetailsPane();

                // This will tell other views using this data to update themselves using the new data
                family.OnContentChanged();

                if (familyCollection.FullyQualifiedFilename.EndsWith(Properties.Resources.DefaultFamilyExtension))
                {
                    // Remove the file from its current position and add it back to the top/most recent position.
                    App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                    App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                    BuildOpenMenu();
                    family.IsDirty = false;
                }
            }
        }
        private void ImportGedcom(object sender, EventArgs e)
        {
            PromptToSave();

            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.GedcomFiles, Properties.Resources.GedcomExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Import;
            dialog.ShowOpen();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                try
                {
                    GedcomImport ged = new GedcomImport();
                    ged.Import(family, dialog.FileName);
                    familyCollection.FullyQualifiedFilename = string.Empty;

                    ShowDetailsPane();
                    family.IsDirty = false;
                }
                catch
                {
                    // Could not import the GEDCOM for some reason. Handle
                    // all exceptions the same, display message and continue
                    /// without importing the GEDCOM file.
                    MessageBox.Show(this, Properties.Resources.GedcomFailedMessage,
                        Properties.Resources.GedcomFailed, MessageBoxButton.OK,
                        MessageBoxImage.Information);
                }
            }
        }
        /// <summary>
        /// Command handler for ExportXPSCommand
        /// </summary>
        private void ExportXps(object sender, EventArgs e)
        {
            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.XpsFiles, Properties.Resources.XpsExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.Export;
            dialog.DefaultExtension = Properties.Resources.DefaultXpsExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                // Create the XPS document from the window's main container (in this case, a grid)
                Package package = Package.Open(dialog.FileName, FileMode.Create);
                XpsDocument xpsDoc = new XpsDocument(package);
                XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

                // Hide the zoom control before the diagram is saved
                DiagramControl.ZoomSliderPanel.Visibility = Visibility.Hidden;

                // Since DiagramBorder derives from FrameworkElement, the XpsDocument writer knows
                // how to output it's contents. The border is used instead of the DiagramControl
                // so that the diagram background is output as well as the digram control itself.
                xpsWriter.Write(DiagramBorder);
                xpsDoc.Close();
                package.Close();

                // Show the zoom control again
                DiagramControl.ZoomSliderPanel.Visibility = Visibility.Visible;
            }
        }
Exemple #23
0
        private void Export()
        {
            if (Options() != "0") //only run if cancel not clicked
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.htmlFiles, Properties.Resources.htmlExtension));
                dialog.Title            = Properties.Resources.Export;
                dialog.DefaultExtension = Properties.Resources.DefaulthtmlExtension;
                dialog.ShowSave();

                if (string.IsNullOrEmpty(dialog.FileName))
                {
                    //return without doing anything if no file name is input
                }
                else
                {
                    if (!string.IsNullOrEmpty(dialog.FileName))
                    {
                        HtmlExport html = new HtmlExport();

                        int start = minYear;
                        int end   = DateTime.Now.Year;

                        string filename = dialog.FileName;
                        if (Options() == "1")
                        {
                            html.ExportAll(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());  //Export the all individuals
                        }
                        if (Options() == "2")
                        {
                            html.ExportCurrent(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "3")
                        {
                            html.ExportDirect(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());     //Export current person and immediate family relatives
                        }
                        if (Options() == "4")
                        {
                            html.ExportGenerations(family, source, repository, Ancestors(), Descendants(), dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "5")
                        {
                            html.ExportFilter(family, source, repository, searchtextvalue(), searchfieldvalue(), searchfieldindex(), dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "6")
                        {
                            html.ExportEventsByDecade(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), start, end);
                        }

                        MessageBoxResult result = MessageBox.Show(Properties.Resources.SourcesExportMessage, Properties.Resources.ExportResult, MessageBoxButton.YesNo, MessageBoxImage.Question);

                        try
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(filename);
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Exemple #24
0
        private void Export()
        {
            if (Options() != "0") //only run if cancel not clicked
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.htmlFiles, Properties.Resources.kmlExtension));
                dialog.Title            = Properties.Resources.Export;
                dialog.DefaultExtension = Properties.Resources.DefaultkmlExtension;
                dialog.ShowSave();

                if (string.IsNullOrEmpty(dialog.FileName))
                {
                    //return without doing anything if no file name is input
                }
                else
                {
                    if (!string.IsNullOrEmpty(dialog.FileName))
                    {
                        PlacesExport places = new PlacesExport();

                        string filename = dialog.FileName;

                        string[] summary = null;

                        if (Options() == "1")
                        {
                            summary = places.ExportPlaces(family, filename, Privacy(), false, false, true, Burials(), Deaths(), Cremations(), Births(), Marriages());
                        }
                        if (Options() == "2")
                        {
                            summary = places.ExportPlaces(family, filename, Privacy(), true, false, false, Burials(), Deaths(), Cremations(), Births(), Marriages());
                        }
                        if (Options() == "3")
                        {
                            summary = places.ExportPlaces(family, filename, Privacy(), false, true, false, Burials(), Deaths(), Cremations(), Births(), Marriages());
                        }


                        if (summary[1] == "No file")
                        {
                            MessageBoxResult result = MessageBox.Show(summary[0],
                                                                      Properties.Resources.ExportResult, MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            MessageBoxResult result = MessageBox.Show(summary[0] + "\n\n" + Properties.Resources.PlacesMessage,
                                                                      Properties.Resources.ExportResult, MessageBoxButton.YesNo, MessageBoxImage.Information);

                            if (result == MessageBoxResult.Yes)
                            {
                                try
                                {
                                    System.Diagnostics.Process.Start(summary[1]);
                                }
                                catch
                                {
                                    //no viewer or other error
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #25
0
        /// <summary>
        /// Command handler for Save As Command
        /// </summary>
        private void SaveFamilyAs(object sender, RoutedEventArgs e)
        {
            CommonDialog dialog = new CommonDialog();
            dialog.InitialDirectory = People.ApplicationFolderPath;
            dialog.Filter.Add(new FilterEntry(Properties.Resources.FamilyFiles, Properties.Resources.FamilyExtension));
            dialog.Filter.Add(new FilterEntry(Properties.Resources.AllFiles, Properties.Resources.AllExtension));
            dialog.Title = Properties.Resources.SaveAs;
            dialog.DefaultExtension = Properties.Resources.DefaultFamilyExtension;
            dialog.ShowSave();

            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                familyCollection.Save(dialog.FileName);

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(familyCollection.FullyQualifiedFilename);
                App.RecentFiles.Insert(0, familyCollection.FullyQualifiedFilename);
                BuildOpenMenu();
            }
        }