Example #1
0
        private void btnApplyTemplate_Click(object sender, EventArgs e)
        {
            FormToProj();

            if (ProjTemplate.ApplyTemplate((string)dropTemplates.Items[dropTemplates.SelectedIndex], project) == false)
            {
                MessageBox.Show("Template was not applied successfully");
            }
            else
            {
                MessageBox.Show("Template \"" + (string)dropTemplates.Items[dropTemplates.SelectedIndex] + "\" was applied");
            }

            PopulateForm();
        }
Example #2
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            splash = new SplashScreen();
            splash.Show();

            try
            {
                SettingsManagement.Load();
                FileTemplate.Unpack();
                ProjTemplate.Load();

                if (SettingsManagement.AutocompleteEnable)
                {
                    KeywordImageGen.GenerateKeywordImages();
                }
            }
            catch (Exception ex)
            {
                ErrorReportWindow.Show(ex, "Initialization Error");
            }

            try
            {
                UpdateMech.CheckForUpdates();
            }
            catch (Exception ex)
            {
                ErrorReportWindow.Show(ex, "Error Checking Updates");
            }

            try
            {
                AVRProject newProject = new AVRProject();

                if (args.Length > 0)
                {
                    string fname = args[0];

                    if (newProject.Open(fname) == true)
                    {
                        SettingsManagement.AddFileAsMostRecent(fname);
                    }
                    else
                    {
                        MessageBox.Show("Error, failed to open file");
                    }
                }
                else if (SettingsManagement.OpenLastProject)
                {
                    if (string.IsNullOrEmpty(SettingsManagement.LastProjectPath) == false)
                    {
                        if (newProject.Open(SettingsManagement.LastProjectPath) == true)
                        {
                            SettingsManagement.AddFileAsMostRecent(SettingsManagement.LastProjectPath);
                        }
                        else
                        {
                            MessageBox.Show("Error, failed to open file");
                        }
                    }
                }

                KeywordScanner.Initialize();

                Application.Run(new IDEWindow(newProject));

                if (newProject.IsReady)
                {
                    if (SettingsManagement.SaveRecentList() == false)
                    {
                        MessageBox.Show("Error, Could Not Save Recent File List");
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorReportWindow.Show(ex, "Main IDE Error");
            }

            try
            {
                if (UpdateMech.HasFinishedChecking)
                {
                    if (UpdateMech.UpdateAvailable)
                    {
                        try
                        {
                            if (MessageBox.Show("An Updated Version of AVR Project IDE is Available (" + SettingsManagement.Version + " to " + UpdateMech.NewBuildID + "). Would you like to download it?", "Update Available", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                System.Diagnostics.Process.Start(Properties.Resources.WebsiteURL);
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorReportWindow.Show(ex, "Updater Error");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorReportWindow.Show(ex, "Error Checking Updates");
            }

            try
            {
                if (SettingsManagement.LastRunVersion != SettingsManagement.Version)
                {
                    NotifyOfUserAction();
                }

                SettingsManagement.LastRunVersion = SettingsManagement.Version;
            }
            catch { }
        }
Example #3
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");
        }
Example #4
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string iniFilename = txtInitialFilename.Text.Trim();
            bool   hasIniFile  = !string.IsNullOrEmpty(iniFilename);

            hasIniFile = false;
            string projFilename = txtProjName.Text.Trim();

            if (string.IsNullOrEmpty(projFilename))
            {
                MessageBox.Show("The project name can't be blank");
                return;
            }

            char[] forbidChars = Path.GetInvalidFileNameChars();
            foreach (char c in forbidChars)
            {
                if (hasIniFile && iniFilename.Contains(c))
                {
                    MessageBox.Show("Illegal Character in Initial File Name");
                    return;
                }

                if (projFilename.Contains(c))
                {
                    MessageBox.Show("Illegal Character in Project File Name");
                    return;
                }
            }

            if (hasIniFile)
            {
                if (iniFilename.Contains('/') || iniFilename.Contains('\\') || iniFilename.Contains(Path.DirectorySeparatorChar) || iniFilename.Contains(Path.AltDirectorySeparatorChar))
                {
                    MessageBox.Show("Illegal Character in Initial File Name");
                    return;
                }

                if (iniFilename.Contains('.') || iniFilename.Contains(' ') || iniFilename.Contains('\t'))
                {
                    MessageBox.Show("No Spaces or Dots are Allowed in Initial File Name");
                    return;
                }
            }

            if (projFilename.Contains('/') || projFilename.Contains('\\') || projFilename.Contains(Path.DirectorySeparatorChar) || projFilename.Contains(Path.AltDirectorySeparatorChar))
            {
                MessageBox.Show("Illegal Character in Project File Name");
                return;
            }

            if (projFilename.Contains('.'))
            {
                MessageBox.Show("No Dots are Allowed in Project File Name");
                return;
            }

            string folderPath = Program.CleanFilePath(txtFolderPath.Text);

            if (Program.MakeSurePathExists(folderPath) == false)
            //if (Directory.Exists(folderPath))
            {
                MessageBox.Show("Error Creating Folder");
                //MessageBox.Show("Error: Folder Invalid");
                return;
            }

            string projFilePath = folderPath + Path.DirectorySeparatorChar + projFilename + ".avrproj";

            project.FilePath = projFilePath;

            string ext = "c";

            if (((string)dropFileType.Items[dropFileType.SelectedIndex]).Contains("C++"))
            {
                ext = "cpp";
            }
            else if (((string)dropFileType.Items[dropFileType.SelectedIndex]).Contains("C"))
            {
                ext = "c";
            }
            else if (((string)dropFileType.Items[dropFileType.SelectedIndex]).Contains("Arduino"))
            {
                ext = "pde";
            }

            string iniFilePath = folderPath + Path.DirectorySeparatorChar + iniFilename + "." + ext;

            if (File.Exists(projFilePath))
            {
                if (MessageBox.Show("Project File Already Exists at the Location, Overwrite it?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            bool merge = false;

            if (hasIniFile && File.Exists(iniFilePath))
            {
                if (MessageBox.Show("Initial File Already Exists at the Location, Merge it with your project?", "Merge File?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    merge = true;
                }
                else if (MessageBox.Show("Maybe you'd rather overwrite it with a blank file?", "Overwrite File?", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            if (hasIniFile)
            {
                if (merge == false)
                {
                    try
                    {
                        StreamWriter writer = new StreamWriter(iniFilePath);
                        if (ext == "pde")
                        {
                            writer.Write(FileTemplate.CreateFile(iniFilename + "." + ext, projFilename, "initialpde.txt"));
                        }
                        else
                        {
                            writer.Write(FileTemplate.CreateFile(iniFilename + "." + ext, projFilename, "initialmain.txt"));
                        }
                        writer.WriteLine();
                        writer.Close();
                    }
                    catch (Exception ex)
                    {
                        ErrorReportWindow.Show(ex, "Error while creating initial file");
                    }
                }

                ProjectFile newFile = new ProjectFile(iniFilePath, project);
                newFile.IsOpen = true;
                project.FileList.Add(newFile.FileName.ToLowerInvariant(), newFile);
            }

            ProjTemplate.ApplyTemplate((string)dropTemplates.Items[dropTemplates.SelectedIndex], project);

            project.FilePath = projFilePath;

            FileAddWizard faw = new FileAddWizard(project);

            faw.ShowDialog();

            if (project.Save(projFilePath) == false)
            {
                MessageBox.Show("Error While Saving Project");
            }
            else
            {
                if (project.Open(projFilePath) == false)
                {
                    MessageBox.Show("Error While Opening Project");
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #5
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();
        }