Exemplo n.º 1
0
        public Wizard(AVRProject project)
        {
            this.project = project;

            InitializeComponent();

            this.DialogResult = DialogResult.Cancel;

            string[] templateList = ProjTemplate.GetTemplateNames();
            foreach (string tempName in templateList)
            {
                dropTemplates.Items.Add(tempName);
            }
            if (dropTemplates.Items.Count == 0)
            {
                dropTemplates.Items.Add("No Templates Available");
            }

            string lastTemp = SettingsManagement.LastTemplate;

            if (lastTemp == null)
            {
                lastTemp = "";
            }
            if (dropTemplates.Items.Contains(lastTemp))
            {
                dropTemplates.SelectedIndex = dropTemplates.Items.IndexOf(lastTemp);
            }
            else
            {
                dropTemplates.SelectedIndex = 0;
            }

            // warning, hack
            string lastFileType = SettingsManagement.LastInitialFileType;

            if (lastFileType == null)
            {
                lastFileType = "";
            }
            if (dropFileType.Items.Contains(lastFileType))
            {
                dropFileType.SelectedIndex = dropFileType.Items.IndexOf(lastFileType);
            }
            else
            {
                dropFileType.SelectedIndex = 0;
            }

            if (dropFileType.SelectedIndex < 0)
            {
                dropFileType.SelectedIndex = 0;
            }
            if (dropTemplates.SelectedIndex < 0)
            {
                dropTemplates.SelectedIndex = 0;
            }


            if (string.IsNullOrEmpty(SettingsManagement.FavFolder))
            {
                string mydocs = Program.CleanFilePath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) + Path.DirectorySeparatorChar + "Projects";
                SettingsManagement.FavFolder = mydocs;
            }

            txtFolderPath.Text = SettingsManagement.FavFolder + Path.DirectorySeparatorChar;

            string newFileName = DateTime.Now.ToString("MM_dd_yyyy").Replace(' ', '_').Replace('-', '_').Replace(Path.AltDirectorySeparatorChar, '_').Replace(Path.DirectorySeparatorChar, '_');;

            char[] illegalChars = Path.GetInvalidFileNameChars();
            foreach (char c in illegalChars)
            {
                newFileName.Replace(c, '_');
            }

            Random r = new Random();

            txtProjName.Text = "Sketch_" + newFileName + "_" + r.Next(15).ToString("X");
        }
Exemplo n.º 2
0
        public ConfigWindow(AVRProject project)
        {
            InitializeComponent();

            if (orderedDevices == null)
            {
                orderedDevices = new List <string>();
            }

            if (orderedDevices.Count == 0)
            {
                foreach (string s in dropDevices.Items)
                {
                    if (orderedDevices.Contains(s.ToLowerInvariant()) == false)
                    {
                        orderedDevices.Add(s.ToLowerInvariant());
                    }
                }

                string pathToXmls = SettingsManagement.AppInstallPath + "chip_xml" + Path.DirectorySeparatorChar;
                if (Directory.Exists(pathToXmls))
                {
                    foreach (FileInfo fi in new DirectoryInfo(pathToXmls).GetFiles())
                    {
                        if (fi.Name.ToLowerInvariant() != "interruptvectors.xml")
                        {
                            if (fi.Name.ToLowerInvariant().EndsWith(".xml"))
                            {
                                string name = Path.GetFileNameWithoutExtension(fi.Name).ToLowerInvariant().Trim();
                                if (orderedDevices.Contains(name) == false)
                                {
                                    orderedDevices.Add(name);
                                }
                            }
                        }
                    }
                }

                orderedDevices.Sort((x, y) => string.Compare(x, y));
            }

            dropDevices.Items.Clear();
            foreach (string s in orderedDevices)
            {
                dropDevices.Items.Add(s);
            }

            this.originalProject = project;
            this.project         = project.Clone();

            burnerPanel = new BurnerPanel(this.project);
            grpBoxBurnerPanel.Controls.Add(burnerPanel);
            burnerPanel.Dock = DockStyle.Fill;

            this.originalProject.HasBeenConfigged = true;
            this.project.HasBeenConfigged         = true;

            string[] templateList = ProjTemplate.GetTemplateNames();
            foreach (string tempName in templateList)
            {
                dropTemplates.Items.Add(tempName);
            }
            if (dropTemplates.Items.Count == 0)
            {
                dropTemplates.Items.Add("No Templates Available");
            }
            dropTemplates.SelectedIndex = 0;

            PopulateForm();
        }