예제 #1
0
		public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams,
		                    ref wizardResult retval)
		{
			DTE dte = (DTE) Application;

			AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
			
			string workingDir =  (string) ContextParams[3];
			string templateDir = @"C:\dev\DotNet\castle\svn\trunk\MonoRail\NewGenerator\GeneratorTemplates\";

			context = new GeneratorContext(workingDir, templateDir);

			//Using NVelocityTemplateEngine. Since we must resolve the lib dir...
			templateEngine = new NVelocityTemplateEngine(templateDir);
			((ISupportInitialize) templateEngine).BeginInit();

			NewProject generator = CreateNewProject(ContextParams);

			generator.Generate(context, this);

			dte.Solution.Open(generator.SolutionFilePath);
		}
예제 #2
0
        public void ExecuteTest()
        {
            DelphiToVisualStudio target = new DelphiToVisualStudio();

            object Application = null;                                       // TODO: Initialize to an appropriate value

            int hwndOwner = 0;                                               // TODO: Initialize to an appropriate value

            object[] ContextParams          = null;                          // TODO: Initialize to an appropriate value
            object[] ContextParams_expected = null;                          // TODO: Initialize to an appropriate value

            object[] CustomParams          = null;                           // TODO: Initialize to an appropriate value
            object[] CustomParams_expected = null;                           // TODO: Initialize to an appropriate value

            wizardResult retval          = wizardResult.wizardResultBackOut; // TODO: Initialize to an appropriate value
            wizardResult retval_expected = wizardResult.wizardResultBackOut; // TODO: Initialize to an appropriate value

            target.Execute(Application, hwndOwner, ref ContextParams, ref CustomParams, ref retval);

            CollectionAssert.AreEqual(ContextParams_expected, ContextParams, "ContextParams_Execute_expected was not set correctly.");
            CollectionAssert.AreEqual(CustomParams_expected, CustomParams, "CustomParams_Execute_expected was not set correctly.");
            Assert.AreEqual(retval_expected, retval, "retval_Execute_expected was not set correctly.");
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
예제 #3
0
		protected virtual void CancelWizard()
		{
			result = wizardResult.wizardResultCancel;

			Hide();
		}
예제 #4
0
		protected virtual void FinishWizard()
		{
			result = wizardResult.wizardResultSuccess;

			Hide();
		}
        public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref wizardResult retval)
        {
            if ((string)ContextParams[0] != "{A5B66A92-9F46-4A9D-85F6-ADC9DF03A410}")
            {
                System.Windows.Forms.MessageBox.Show("This wizard is used for conversion only.");
                retval = wizardResult.wizardResultFailure;
                return;
            }
            DTE2 lDTE = Application as DTE2;
            //lDTE.Solution.Create("C:\\", "test1");
            //Delphi.Properties.Settings.Default.ConvertProject = @"C:\Code\Custom\DelphiForVisualStudio\New Delphi Projects Sample\VCLFormApp\Project1.dpr";
            //lDTE.Solution.AddFromTemplate(@"C:\Code\Custom\DelphiForVisualStudio\Bin\Templates\Imports\Import Existing Delphi Project (dpr).vstemplate", @"C:\temp", "Project100", false);

            WizardDialog lWizardDialog = new WizardDialog();

            lWizardDialog.SolutionEnabled      = !Convert.ToBoolean(ContextParams[1]);
            lWizardDialog.DelphiProjectFilters = Resources.DelphiProjectFilters;
            lWizardDialog.OutputPaths          = Delphi.Properties.Settings.Default.WizardLocations.Split(';');
            // must use active solution path
            if (!lWizardDialog.SolutionEnabled)
            {
                lWizardDialog.OutputPath = Path.GetDirectoryName(lDTE.Solution.FileName);
            }
            else
            {
                lWizardDialog.OutputPath = Delphi.Properties.Settings.Default.WizardOutputPath;
            }
            lWizardDialog.UseSameFolder     = Delphi.Properties.Settings.Default.WizardUseSameFolder;
            lWizardDialog.CreateSolutionDir = Delphi.Properties.Settings.Default.WizardCreateSolutionDir;
            if (lWizardDialog.ShowDialog() == DialogResult.OK)
            {
                // Save settings
                if (!lWizardDialog.UseSameFolder)
                {
                    string[] lList = lWizardDialog.OutputPaths;
                    Dictionary <string, int> lLookup = new Dictionary <string, int>();
                    lLookup.Add(lWizardDialog.OutputPath, 0);
                    StringBuilder lLocations = new StringBuilder(lWizardDialog.OutputPath);
                    foreach (string s in lList)
                    {
                        if (!lLookup.ContainsKey(s))
                        {
                            lLocations.Append(";");
                            lLocations.Append(s);
                            lLookup.Add(s, 0);
                        }
                    }
                    Delphi.Properties.Settings.Default.WizardLocations = lLocations.ToString();
                }
                Delphi.Properties.Settings.Default.WizardOutputPath        = lWizardDialog.OutputPath;
                Delphi.Properties.Settings.Default.WizardUseSameFolder     = lWizardDialog.UseSameFolder;
                Delphi.Properties.Settings.Default.WizardCreateSolutionDir = lWizardDialog.CreateSolutionDir;
                Delphi.Properties.Settings.Default.Save();
                // get project name
                string lProjectName = Path.GetFileNameWithoutExtension(lWizardDialog.DelphiProjectFile);
                // if the locaiton is not the same folder then location is in the Project Name folder
                string lLocation         = lWizardDialog.OutputPath;
                string lSolutionLocation = lLocation;
                // Make new solution location if nessarry
                if (lWizardDialog.SolutionEnabled && lWizardDialog.CreateSolutionDir)
                {
                    lSolutionLocation = Path.Combine(lLocation, lWizardDialog.SolutionName);
                }
                // Make new project location if nessary
                if (!lWizardDialog.UseSameFolder)
                {
                    lLocation = Path.Combine(lSolutionLocation, lProjectName);
                }
                // Create solution if nessary
                if (lWizardDialog.SolutionEnabled)
                {
                    lDTE.Solution.Create(lSolutionLocation, lWizardDialog.SolutionName);
                }
                // if a new solution needs to be created make one in the root location
                // Save the Global Var value
                // NOTE: I do not like this i should copy the template files and add it to the
                // copied template.
                Delphi.Properties.Settings.Default.WizardConvertProject = lWizardDialog.DelphiProjectFile;
                System.Reflection.Assembly lMyAsm = System.Reflection.Assembly.GetExecutingAssembly();

                lDTE.Solution.AddFromTemplate(Path.Combine(Path.GetDirectoryName(lMyAsm.Location), Resources.ConvertTemplateFile), lLocation, lProjectName, false);
            }
        }
예제 #6
0
 public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref wizardResult retval)
 {
     LocalExecute(Application, hwndOwner, ref ContextParams, ref CustomParams, ref retval);
 }
예제 #7
0
        private void LocalExecute(object App, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref wizardResult retval)
        {
            /*ContextParams array:
             *0 WizardType
             *1 ProjectName
             *2 LocalDirectory
             *3 InstallationDirectory
             *4 FExclusive
             *5 SolutionName
             *6 Silent
             */
            _DTE DTEobj = (_DTE)App;
            MainForm Dialog = new MainForm();
            //TODO
            Dialog.DirTo = Regex.Replace(ContextParams[2].ToString(), @"\\\w*$+", @"\Плагины");
            Dialog.SolutionName = ContextParams[1].ToString();

            RegistryKey TemplatePathKey = Registry.CurrentUser.OpenSubKey("software\\ascon");
            string TemplatePath = (string)TemplatePathKey.GetValue("TemplateWizard", "D:\\projects\\Шаблон проекта");
            TemplatePathKey.Close();

            Dialog.DirFrom = TemplatePath;
            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string PathFrom = Dialog.DirFrom,
                    PathTo = Dialog.DirTo;
                SolutionName = Dialog.SolutionName;
                HasDefaultForm = Dialog.HasDefaultForm;

                try
                {
                    TemplatePathKey = Registry.CurrentUser.OpenSubKey("software\\ascon", true);
                    TemplatePathKey.SetValue("TemplateWizard", PathFrom);
                    TemplatePathKey.Close();
                }
                catch { }

                Solution MySolution = DTEobj.Solution;
                MySolution.Create(PathTo, SolutionName);
                DirectoryCopy(PathFrom, PathTo, true);

                //subst each and every string in files by
                //extensions: cs csproj cpp def vcproj
                SubstFileByExtension(PathTo);

                //add project definitions
                AddProjectsFromPath(ref MySolution, PathTo+"\\"+SolutionName);

                retval = wizardResult.wizardResultSuccess;
            }
            else
            {
                //MessageBox.Show("Отмена");
                retval = wizardResult.wizardResultFailure;
            }
            Dialog.Dispose();
            return;
        }
예제 #8
0
        void IDTWizard.Execute(object application, int hwndOwner, ref object[] contextParams, ref object[] customParams, ref wizardResult result)
        {
            // Initialisation des paramètres
            //
            DTE2   dte            = (DTE2)application;
            string wizardType     = (string)contextParams[0];
            string projectFolder  = (string)contextParams[2];
            string localDirectory = (string)contextParams[3];
            bool   fExclusive     = (bool)contextParams[4];
            string solutionName   = (string)contextParams[5];


            // Fermeture de la solution si NewprojectType
            if (wizardType.Equals("{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}", StringComparison.InvariantCultureIgnoreCase) && fExclusive)
            {
                if (dte.Solution.IsOpen && (dte.ItemOperations.PromptToSave == vsPromptResult.vsPromptResultCancelled))
                {
                    result = wizardResult.wizardResultCancel;
                    return;
                }
            }

            try
            {
                if (String.IsNullOrEmpty(solutionName))
                {
                    solutionName = (string)contextParams[1];
                }

                // On descend d'un niveau car on travaille au niveau de la solution
                int pos = projectFolder.LastIndexOf(Path.DirectorySeparatorChar);
                projectFolder = projectFolder.Substring(0, pos);

                // Création de la solution
                Directory.CreateDirectory(projectFolder);
                dte.Solution.Create(projectFolder, solutionName);

                // Chargement du package
                IVsShell   shell       = (IVsShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShell));
                Guid       packageGuid = new Guid(Constants.CandlePackageId);
                IVsPackage package     = null;
                shell.LoadPackage(ref packageGuid, out package);

                if (package == null)
                {
                    throw new Exception("Unable to load package.");
                }

                // Recherche du template passé en paramètre sous la forme
                //  modelTemplate = xxxxxxx
                //
                string template         = ExtractParam(customParams, "modelTemplate", null);
                string strategyTemplate = ExtractParam(customParams, "strategy", "default");
                string showDialog       = ExtractParam(customParams, "showDialog", "true");

                ServiceLocator.Instance.ShellHelper.AddDSLModelToSolution(template, strategyTemplate, solutionName, showDialog != null && showDialog.ToLower() == "true");
                result = wizardResult.wizardResultSuccess;
            }
            catch (Exception ex)
            {
                if (!(ex is CanceledByUser))
                {
                    MessageBox.Show(ex.Message);
                }

                result = wizardResult.wizardResultCancel;
            }
        }