Ejemplo n.º 1
0
        public bool Open()
        {
            string filename;

            if (_fileService.Open(ProjectFilter, out filename, ProjectFilterIndex))
            {
                Open(filename);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void view_OpenClicked()
        {
            string filename;

            if (!_dialogService.Open(OpenDialogFilter, out filename, 4))
            {
                return;
            }

            if (Model.OpenDatasource(filename))
            {
                View.SetDatasource();
            }
        }
Ejemplo n.º 3
0
        public void ImportTms()
        {
            string filename;

            if (_dialogService.Open("*.xml|*.xml", out filename))
            {
                try
                {
                    string xml = File.ReadAllText(filename);

                    var imagery = xml.DeserializeFromXml <imagery>();

                    AddProviders(imagery);
                }
                catch (Exception ex)
                {
                    Logger.Current.Info("Failed to import TMS providers from XML file.", ex);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Import field definitions.
        /// </summary>
        public static bool ImportFieldsFromDbf(IFileDialogService service, IAttributeTable table)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            if (!table.EditMode)
            {
                return(false);
            }

            string filename;

            service.Title = @"Please choose the DBF file whose field definitions you would like to import...";

            if (!service.Open(@"DBF Files (*.dbf)|*.dbf", out filename))
            {
                return(false);
            }

            using (var impTable = new AttributeTable())
            {
                if (!impTable.Open(filename))
                {
                    const string err = "Failed to open table.";
                    Logger.Current.Info(err + " Filename: " + impTable.LastError);
                    MessageService.Current.Info(err);
                    return(false);
                }

                string msg = "About to import fields: " + impTable.Fields.Count + "." + Environment.NewLine
                             + " Do you want to continue?";

                if (!MessageService.Current.Ask(msg))
                {
                    return(false);
                }

                var skipped = new List <string>();
                int count   = 0;

                var fields = table.Fields;
                foreach (var fld in impTable.Fields)
                {
                    count++;

                    if (fields.IndexByName(fld.Name) == -1)
                    {
                        table.Fields.Add(fld.Name, fld.Type, fld.Precision, fld.Width);
                    }
                    else
                    {
                        skipped.Add(fld.Name);
                    }
                }

                msg = "Field definitions imported: " + count + ".";

                if (skipped.Any())
                {
                    msg += Environment.NewLine + Environment.NewLine;
                    msg += "The following fields were skipped because of the name conflict: ";
                    msg += Environment.NewLine + StringHelper.Join(skipped, ",");
                }

                MessageService.Current.Info(msg);
            }

            return(true);
        }