Ejemplo n.º 1
0
        private void btnImportEagle_Click(object sender, EventArgs e)
        {
            //
            // GenTestData.GenerateData();

            //
            AppSettings.SourceFilename = textBoxSource.Text;
            AppSettings.DestFolder     = textBoxDest.Text;
            SaveAppSettings();

            if (Directory.Exists(AppSettings.DestFolder))
            {
                bool is_empty = false;

                string[] Files = Directory.GetFiles(AppSettings.DestFolder);

                if (Files.Length == 0)
                {
                    string[] folders = Directory.GetDirectories(AppSettings.DestFolder);
                    if (folders.Length == 0)
                    {
                        is_empty = true;
                    }
                }

                if (!is_empty)
                {
                    DialogResult res = MessageBox.Show("Warning - Destination folder is not empty, files will be overwritten!" + Environment.NewLine + Environment.NewLine +
                                                       "Continue ?",
                                                       "Overwrite check",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation
                                                       );

                    if (res != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            else
            {
                AppSettingsBase.CreateDirectory(AppSettings.DestFolder);
            }

            ProjectConverter converter = new ProjectConverter();
            //if (converter.CheckValid(textBoxSource.Text))
            {
                converter.OnTrace += Trace;
                converter.ConvertProject(textBoxSource.Text, textBoxDest.Text);
            }
        }
Ejemplo n.º 2
0
        private static bool ConvertToKicad()
        {
            AppSettings.SourceFilename = SourceFilename;
            AppSettings.DestFolder     = DestFolder;

            if (Directory.Exists(AppSettings.DestFolder))
            {
                if (!overwrite)
                {
                    bool is_empty = false;

                    string[] Files = Directory.GetFiles(AppSettings.DestFolder);

                    if (Files.Length == 0)
                    {
                        string[] folders = Directory.GetDirectories(AppSettings.DestFolder);
                        if (folders.Length == 0)
                        {
                            is_empty = true;
                        }
                    }

                    if (!is_empty)
                    {
                        Trace("error: Destination folder is not empty, specify -overwrite option");
                        Usage();
                        return(false);
                    }
                }
            }
            else
            {
                AppSettingsBase.CreateDirectory(AppSettings.DestFolder);
            }

            ProjectConverter converter = new ProjectConverter();

            //if (converter.CheckValid(textBoxSource.Text))
            {
                converter.OnTrace += Trace;
                converter.ConvertProject(SourceFilename, DestFolder);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public bool SaveToXmlFile(string FileName)
        {
            bool          result     = false;
            XmlSerializer serializer = new XmlSerializer(typeof(AppSettings));
            TextWriter    Writer     = null;

            AppSettingsBase.CreateDirectory(Path.GetDirectoryName(FileName));
            try
            {
                Writer = new StreamWriter(FileName, false, Encoding.UTF8);
                serializer.Serialize(Writer, this);
                result = true;
            }
            finally
            {
                if (Writer != null)
                {
                    Writer.Close();
                }
            }
            return(result);
        }