예제 #1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            // Treat all files to be opened. We'll have to do the same
            // as when initial loading with a list of filenames.
            FileSelector fs = (FileSelector)lstProjects.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateMain.Instance().InitializeApplication(new string[] { file });
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                lstProjects.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Open project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void btnDefinition_Click(object sender, EventArgs e)
        {
            FileSelector fs = (FileSelector)lstProjects.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            // Laad het project bestand.
            // Zoek de solution op die erbij hoort
            // Pluis uit waar de solution gedefinieerd is
            // En open dat project
            XmlDocument d = new XmlDocument();

            try
            {
                d.Load(file);
                string  solution_file = "";
                string  solution      = d.SelectSingleNode("project/solution").InnerText;
                XmlNode location      = d.SelectSingleNode("project/solutionfilename");
                if (location != null)
                {
                    solution_file = location.InnerText;
                }
                else
                {
                    solution_file = solution;
                }

                solution_file = Generator.Utility.TemplateUtil.Instance().CombineAndCompact(file, solution_file);
                d.Load(solution_file);
                XmlNode sourceproject = d.SelectSingleNode("solution/sourceproject");
                if (sourceproject == null)
                {
                    throw new ApplicationException("Could not find sourceproject for solution '" + solution + "'");
                }

                file = sourceproject.InnerText;
                file = Generator.Utility.TemplateUtil.Instance().CombineAndCompact(solution_file, file);

                TemplateCache.Instance().Clear(true);
                TemplateMain.Instance().InitializeApplication(new string[] { file });
                Close();
            }
            catch (ApplicationException aex)
            {
                MessageBox.Show(aex.Message, "Open definition project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        private void btnTemplates_Click(object sender, EventArgs e)
        {
            FileSelector fs   = (FileSelector)lstProjects.SelectedItem;
            string       file = fs.CompletePath;

            // Laad het project bestand.
            // Zoek de solution op die erbij hoort
            // Instrueer de cache dat we een project hebben dat een solution 'na doet'
            // Zodat als er wat gevraagd wordt, (lijst met types e.d.) dit juist
            // geinterpreteerd wordt.
            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateCache.Instance().LoadProjectFile(file, true);
                TemplateMain.Instance().InitializeApplication(null);
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                lstProjects.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Open template project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            FileSelector fs = (FileSelector)lstSolutions.SelectedItem;

            if (fs == null)
            {
                return;
            }

            string file = fs.CompletePath;

            TemplateCache.Instance().Clear(true);
            try
            {
                TemplateCache.Instance().LoadSolutionFile(file, false);
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedSolution(file);
                lstSolutions.Items.Remove(fs);
                MessageBox.Show(aex.Message, "Load solution error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            openFileDialog.Multiselect      = false;
            openFileDialog.CheckFileExists  = false;
            openFileDialog.Title            = "Create projectfile";
            openFileDialog.DefaultExt       = ".xmp";
            openFileDialog.Filter           = "NextGen projects (*.xmp)|*.xmp";
            openFileDialog.RestoreDirectory = false;
            openFileDialog.FileName         = "";
            if (openFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // Treat all files to be opened. We'll have to do the same
            // as when initial loading with a list of filenames.
            file = openFileDialog.FileName;
            XmlDocument d = new XmlDocument();

            d.AppendChild(d.CreateElement("project"));
            XmlElement elm = d.CreateElement("solution");

            elm.AppendChild(d.CreateTextNode(TemplateCache.Instance().Solution));
            d.DocumentElement.AppendChild(elm);
            elm = d.CreateElement("solutionfilename");
            elm.AppendChild(d.CreateTextNode(TemplateCache.Instance().SolutionFilename));
            d.DocumentElement.AppendChild(elm);
            d.Save(file);

            string[] args = new string[] { file };

            try
            {
                TemplateMain.Instance().InitializeApplication(args);
                Close();
            }
            catch (ApplicationException aex)
            {
                OptionsSettings.Instance().UnRegisterLastUsedProject(file);
                MessageBox.Show(aex.Message, "New project error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }