<commit_before>﻿//-----------------------------------------------------------------------
// <copyright file="AddLayer.xaml.cs" company="CSCE 482: Aerial Mapping">
//     Copyright (c) CSCE 482 Aerial Mapping Design Team
// </copyright>
//-----------------------------------------------------------------------
namespace AerialMapping
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    /// <summary>
    /// Interaction logic for AddLayer.xaml
    /// </summary>
    public partial class AddLayer : Window
    {
        // Locations in the Locations ComboBox
        private ObservableCollection<string> comboBoxLocations;

        /// <summary>
        /// Initializes a new instance of the AddLayer class.
        /// Adds a layer to the Window
        /// </summary>
        /// <param name="locations">List of location names</param>
        public AddLayer(ObservableCollection<string> locations)
        {
            this.InitializeComponent();
            this.DatasetToAdd = new Dataset();

            // Populate locations combobox
            LocationComboBox.ItemsSource = locations;
            if (locations.Count >= 0)
            {
                LocationComboBox.SelectedIndex = 0;
            }

            this.comboBoxLocations = locations;

            this.DateTimeInput.Value = DateTime.Now;
        }

        /// <summary>
        /// Gets or sets the Dataset that we want to add
        /// </summary>
        public Dataset DatasetToAdd 
        { 
            get; 
            set; 
        }

        /// <summary>
        /// The function for the button that looks up the file path. 
        /// </summary>
        /// <param name="sender">The File Lookup button</param>
        /// <param name="e">Button press event args</param>
        private void BFilePathLookup_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter = "Map Data|*.kml;*.kmz";
            if (openFileDialog.ShowDialog() == true)
            {
                FilePathInput.Text = openFileDialog.FileName;
            }
        }

        /// <summary>
        /// The function for the button "Add"
        /// </summary>
        /// <param name="sender">The Add button</param>
        /// <param name="e">Button press event args</param>
        private void BAdd_Click(object sender, RoutedEventArgs e)
        {
            // Read the data from the boxes on screen.
            this.DatasetToAdd.Location = LocationComboBox.Text;
            
            if (DateTimeInput.Value.HasValue)
            {
                this.DatasetToAdd.Time = DateTimeInput.Value.Value;
            }<commit_msg>Fixed empty input crash on add layer<commit_after>﻿//-----------------------------------------------------------------------
// <copyright file="AddLayer.xaml.cs" company="CSCE 482: Aerial Mapping">
//     Copyright (c) CSCE 482 Aerial Mapping Design Team
// </copyright>
//-----------------------------------------------------------------------
namespace AerialMapping
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    /// <summary>
    /// Interaction logic for AddLayer.xaml
    /// </summary>
    public partial class AddLayer : Window
    {
        // Locations in the Locations ComboBox
        private ObservableCollection<string> comboBoxLocations;

        /// <summary>
        /// Initializes a new instance of the AddLayer class.
        /// Adds a layer to the Window
        /// </summary>
        /// <param name="locations">List of location names</param>
        public AddLayer(ObservableCollection<string> locations)
        {
            this.InitializeComponent();
            this.DatasetToAdd = new Dataset();

            // Populate locations combobox
            LocationComboBox.ItemsSource = locations;
            if (locations.Count >= 0)
            {
                LocationComboBox.SelectedIndex = 0;
            }

            this.comboBoxLocations = locations;

            this.DateTimeInput.Value = DateTime.Now;
        }

        /// <summary>
        /// Gets or sets the Dataset that we want to add
        /// </summary>
        public Dataset DatasetToAdd 
        { 
            get; 
            set; 
        }

        /// <summary>
        /// The function for the button that looks up the file path. 
        /// </summary>
        /// <param name="sender">The File Lookup button</param>
        /// <param name="e">Button press event args</param>
        private void BFilePathLookup_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter = "Map Data|*.kml;*.kmz";
            if (openFileDialog.ShowDialog() == true)
            {
                FilePathInput.Text = openFileDialog.FileName;
            }
        }

        /// <summary>
        /// The function for the button "Add"
        /// </summary>
        /// <param name="sender">The Add button</param>
        /// <param name="e">Button press event args</param>
        private void BAdd_Click(object sender, RoutedEventArgs e)
        {
            if (FilePathInput.Text == string.Empty)
            {
                return;
            }

            // Read the data from the boxes on screen.
            this.DatasetToAdd.Location = LocationComboBox.Text;
            
            if (DateTimeInput.Value.HasValue)
            {
                this.DatasetToAdd.Time = DateTimeInput.Value.Value;
            }
{'fraction_non_alphanumeric': 0.1432348367029549, 'fraction_numerical': 0.0037325038880248835, 'mean_word_length': 1.5879275653923541, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1351681', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1572, 'n_words': 418}