예제 #1
0
        /// <summary>
        /// Shows the add layer window.
        /// </summary>
        /// <param name="sender">Sender that raised the event.</param>
        /// <param name="e">The event args.</param>
        public void ButtonClick(object sender, EventArgs e)
        {
            // check if it's a valid SpatiaLite layer
            using (OpenFileDialog fd = new OpenFileDialog
            {
                Title = Resources.OpenSpatialiteDatabase,
                Filter = Resources.SpatialiteDatabaseFilter
            })
            {
                if (fd.ShowDialog() == DialogResult.OK)
                {
                    string cs = SqLiteHelper.GetSqLiteConnectionString(fd.FileName);
                    string error;
                    var    slh = SpatiaLiteHelper.Open(cs, out error);
                    if (slh == null)
                    {
                        MessageBox.Show(string.Format(Resources.DatabaseNotValid, fd.FileName, error));
                        return;
                    }

                    using (FrmAddLayer frm = new FrmAddLayer(slh, App.Map))
                    {
                        frm.ShowDialog();
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// This static method is only meant to be used by the deserializer.
        /// </summary>
        /// <param name="filePath">Path of the file that contains the layer that gets loaded.</param>
        /// <param name="layerName">Name of the layer that should be loaded.</param>
        /// <returns>The opened layer.</returns>
        public static IFeatureSet OpenLayer(string filePath, string layerName)
        {
            var connectionString = SqLiteHelper.GetSqLiteConnectionString(filePath);

            var file = SpatiaLiteHelper.Open(connectionString, out string error);

            if (file == null)
            {
                throw new FileLoadException(string.Format(Resources.DatabaseNotValid, filePath, error));
            }

            var fs = file.ReadFeatureSet(layerName);

            return(fs);
        }
예제 #3
0
 private void BQueryClick(object sender, EventArgs e)
 {
     // check if it's a valid SpatiaLite layer
     using (OpenFileDialog fd = new OpenFileDialog
     {
         Title = Resources.OpenSpatialiteDatabase,
         Filter = Resources.SpatialiteDatabaseFilter
     })
     {
         if (fd.ShowDialog() == DialogResult.OK)
         {
             string cs  = SqLiteHelper.GetSqLiteConnectionString(fd.FileName);
             var    frm = new FrmQuery(cs, App.Map);
             frm.Show();
         }
     }
 }
예제 #4
0
        private void BQueryClick(object sender, EventArgs e)
        {
            // check if it's a valid SpatiaLite layer
            using OpenFileDialog fd = new()
                  {
                      Title  = Resources.OpenSpatialiteDatabase,
                      Filter = Resources.SpatialiteDatabaseFilter
                  };
            if (fd.ShowDialog() == DialogResult.OK)
            {
                string cs  = SqLiteHelper.GetSqLiteConnectionString(fd.FileName);
                var    slh = SpatiaLiteHelper.Open(cs, out string error);

                if (slh == null)
                {
                    MessageBox.Show(string.Format(Resources.DatabaseNotValid, fd.FileName, error));
                    return;
                }

                using var frm = new FrmQuery(slh, App.Map);
                frm.ShowDialog();
            }
        }