Example #1
0
        private void mbtnOpenProject_Click(object sender, EventArgs e)
        {
            if (myEditorTabsPanel.HasChanged)
            {
                DialogResult res = MessageBox.Show("You have unsaved changes. Do you want to save?", "Unsaved Project", MessageBoxButtons.YesNoCancel);
                if (res == DialogResult.Yes)
                {
                    myEditorTabsPanel.SaveAll();
                }
                else if (res == DialogResult.Cancel)
                {
                    return;
                }
            }

            string originalProject = myProject.FilePath;

            foreach (KeyValuePair <string, FileEditorTab> i in myEditorTabsPanel.MyListOfEditors)
            {
                myEditorTabsPanel.MyTabControl.TabPages.Remove(i.Value.MyTabPage);
            }
            myEditorTabsPanel.MyListOfEditors.Clear();
            treeFiles.Nodes.Clear();
            splitFileTreeEditorTabs.Panel2.Controls.Clear();
            myProject.Reset();

            while (true)
            {
                frmWelcome newWelcome = new frmWelcome(mySettings, myProject);
                newWelcome.ShowDialog();

                if (myProject.IsReady == false)
                {
                    if (myProject.Open(originalProject) == false)
                    {
                        MessageBox.Show("Error Reopening Original Project");
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            myEditorTabsPanel = new EditorTabsPanel(myProject, mySettings);
            splitFileTreeEditorTabs.Panel2.Controls.Add(myEditorTabsPanel);

            FillRecentProjects();

            RefreshFileTree();
        }
Example #2
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     if (listRecentFiles.SelectedIndex >= 0)
     {
         string file = Program.CleanFilePath(mySettings.FilePathFromListBoxIndex(listRecentFiles.SelectedIndex));
         if (myProject.Open(file))
         {
             mySettings.AddFileAsMostRecent(file);
             this.Close();
         }
         else
         {
             MessageBox.Show("Error, Could Not Load Project");
         }
     }
 }
Example #3
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 #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 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 #6
0
        private void recentMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveProj() == false)
            {
                return;
            }

            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            // like all good editors, ask to save first
            if (HasChanged)
            {
                DialogResult res = MessageBox.Show("You have unsaved changes. Do you want to save?", "Unsaved Project", MessageBoxButtons.YesNoCancel);
                if (res == DialogResult.Yes)
                {
                    if (SaveAll() == false)
                    {
                        return;
                    }
                }
                else if (res == DialogResult.Cancel)
                {
                    return;
                }
            }

            AVRProject newProj = new AVRProject();

            // find the actual file path by matching the menuItem's text with the list of file paths
            string recentPath = "";
            foreach (string i in SettingsManagement.RecentFileList)
            {
                if (i.EndsWith(item.Text))
                {
                    recentPath = i; // found it
                    break;
                }
            }

            if (newProj.Open(recentPath) == false)
            {
                MessageBox.Show("Error Opening Recent Project");
            }
            else if (newProj.IsReady)
            {
                HandleNewOpenProj(newProj);
            }
        }