Ejemplo n.º 1
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();

            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;
                }
            }
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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));
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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 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);
                }
            }
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
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);
            }
        }
        /// <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));
            }
        }