Example #1
0
        private void OpenSelectedFileNode(string file)
        {
            //check if it is already opened
            List <CodeEditor> listeditors = this.GetCodeEditors();

            foreach (CodeEditor CE in listeditors)
            {
                if (CE.FilePath == file)
                {
                    CE.Activate();
                    return;
                }
            }
            string fileextesion = Path.GetExtension(file);

            if (fileextesion != ".mpr")
            {
                CodeEditor MCED = this.CreateEditor(file, SupportedFiles.GetType(fileextesion.Replace(".", "")));
                MCED.SetContent(FileHelper.GetContent(file));
                MCED.Show(MDockArea);
                MCED.DockState = DockState.Document;
                //add to recent
                if (MOO_APPLICATION_SETTINGS.RecentFiles.Count <= 5)
                {
                    MOO_APPLICATION_SETTINGS.RecentFiles.Add(file);
                }
            }
        }
Example #2
0
        private void OpenPrjectFile(object sender, EventArgs e)
        {
            string filter = "All files (*.*)|*.*|Moo Project (*.mpr)|*.mpr|Text file (*.txt)|*.txt|Html file ((*.html))|*.html|Xml file(*.xml)|*.xml";

            //we check if the sender was a (StartPage) or a (FProjectBrowser) to restrict for only project file
            //because those components can only send project open event
            if ((sender.GetType() == typeof(StartPage)) || (sender.GetType() == typeof(FProjectBrowser)))
            {
                filter = "Moo Project (*.mpr)|*.mpr";
            }
            string openfilepath;
            string openfilename;
            string openfilecontent  = FileHelper.GetContent(filter, out openfilepath, out openfilename);
            string openfileextesion = Path.GetExtension(openfilepath);

            if (openfilepath != String.Empty)
            {
                if (openfileextesion == ".mpr")
                {
                    //deal with project
                    Project PRJT = ProjectFactory.Open(openfilepath);
                    MOO_APPLICATION_SETTINGS.CurrentProject = PRJT;
                    //load the project into the project browser

                    MOO_PROJECT_BROWSER.BuildNodes(PRJT.Folder, PRJT.File, PRJT.Name);
                    //add to recent
                    if (MOO_APPLICATION_SETTINGS.RecentProjects.Count <= 5)
                    {
                        MOO_APPLICATION_SETTINGS.RecentProjects.Add(openfilepath);
                    }
                }
                else
                {
                    //check if it is already opened
                    List <CodeEditor> listeditors = this.GetCodeEditors();
                    foreach (CodeEditor CE in listeditors)
                    {
                        if (CE.FilePath == openfilepath)
                        {
                            CE.Activate(); return;
                        }
                    }

                    //deal with file
                    CodeEditor MCED = this.CreateEditor(openfilepath, SupportedFiles.GetType(openfileextesion.Replace(".", "")));
                    MCED.SetContent(openfilecontent);
                    MCED.Show(MDockArea);
                    MCED.DockState = DockState.Document;
                    //add to recent
                    if (MOO_APPLICATION_SETTINGS.RecentFiles.Count <= 5)
                    {
                        MOO_APPLICATION_SETTINGS.RecentFiles.Add(openfilepath);
                    }
                }
            }
        }
Example #3
0
        private void OpenRecentHandler(object sender, EventArgs e)
        {
            MenuItem mi           = (MenuItem)sender;
            string   openfilepath = mi.Tag.ToString();

            if (!new FileInfo(openfilepath).Exists)
            {
                MessageBox.Show(this, "This file has been removed", "Moo { + }", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MenuItem Parent = (MenuItem)mi.Parent;
                Parent.MenuItems.Remove(mi);
                if (Parent == MRecentFiles)
                {
                    MOO_APPLICATION_SETTINGS.RecentFiles.Remove(mi.Tag.ToString());
                }
                else
                {
                    MOO_APPLICATION_SETTINGS.RecentProjects.Remove(mi.Tag.ToString());
                }
                return;
            }

            string openfilecontent  = FileHelper.GetContent(openfilepath);
            string openfileextesion = Path.GetExtension(openfilepath);

            if (openfilepath != String.Empty)
            {
                if (openfileextesion == ".mpr")
                {
                    //deal with project
                    Project PRJT = ProjectFactory.Open(openfilepath);
                    MOO_APPLICATION_SETTINGS.CurrentProject = PRJT;
                    //load the project into the project browser
                    MOO_PROJECT_BROWSER.BuildNodes(PRJT.Folder, PRJT.File, PRJT.Name);
                }
                else
                {
                    //check if it is already opened
                    List <CodeEditor> listeditors = this.GetCodeEditors();
                    foreach (CodeEditor CE in listeditors)
                    {
                        if (CE.FilePath == openfilepath)
                        {
                            CE.Activate(); return;
                        }
                    }
                    //deal with file
                    CodeEditor MCED = this.CreateEditor(openfilepath, SupportedFiles.GetType(openfileextesion.Replace(".", "")));
                    MCED.SetContent(openfilecontent);
                    MCED.Show(MDockArea);
                    MCED.DockState = DockState.Document;
                }
            }
        }