private void ShowGenerationWindow()
        {
            GenerateCommandPackage generateCommandPackage = package as GenerateCommandPackage;
            var generationControl = new SolutionGenerationWindow(generateCommandPackage.Output_path_);

            generationControl.ShowModal();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GenerateCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private GenerateCommand(AsyncPackage package, OleMenuCommandService commandService)
        {
            this.package   = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(this.GenerateAll, menuCommandID);

            commandService.AddCommand(menuItem);

            var menuCommandID2 = new CommandID(CommandSet, CommandId2);
            var menuItem2      = new MenuCommand(this.Generate2, menuCommandID2);

            commandService.AddCommand(menuItem2);

            var menuCommandID3 = new CommandID(CommandSet, CommandId3);
            var menuItem3      = new MenuCommand(this.Generate3, menuCommandID3);

            commandService.AddCommand(menuItem3);

            GenerateCommandPackage generateCommandPackage = package as GenerateCommandPackage;

            dict_implementation.Add(ElementConstants.BusinessObject, generateCommandPackage.BusinessObjectImplementation);
            dict_implementation.Add(ElementConstants.Contract, generateCommandPackage.Contract_implementation_);
            dict_implementation.Add(ElementConstants.ApplicationEvent, generateCommandPackage.ApplicationEvent_implementation_);
            dict_implementation.Add(ElementConstants.ApplicationComponent, generateCommandPackage.ApplicationComponent_implementation_);
            dict_implementation.Add(ElementConstants.DataObject, generateCommandPackage.DataObject_implementation_);
            dict_implementation.Add(ElementConstants.ApplicationProcess, generateCommandPackage.ApplicationProcess_implementation_);
            dict_implementation.Add(ElementConstants.ApplicationService, generateCommandPackage.ApplicationService_implementation_);
        }
        private void ShowGenerationWindow()
        {
            GenerateCommandPackage generateCommandPackage = package as GenerateCommandPackage;
            var generationControl = new GenerationWindow(GetSourceFilePath(), dict_implementation, generateCommandPackage.Output_path_ + "\\FileGenerated.cs", generateCommandPackage.Name_space_, GetProjects(), current_solution_path, current_solution_name, GetDTE().Solution);

            generationControl.ShowModal();
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void GenerateAll(object sender, EventArgs e)
        {
            EnvDTE80.DTE2 current_DTE2 = GetDTE2();
            current_solution_path = System.IO.Path.GetDirectoryName(current_DTE2.Solution.FullName);
            current_solution_name = current_DTE2.Solution.FileName;
            string path_in = GetSourceFilePath();

            UserSettings.Default.SourceFile = path_in;
            UserSettings.Default.Save();
            ThreadHelper.ThrowIfNotOnUIThread();
            //string message = string.Format(CultureInfo.CurrentCulture, "inside {0}.menuitemcallback()", GetType().FullName);
            string message;

            if (isCorrectFileType(path_in))
            {
                message = "File generated";
            }
            else
            {
                message = "error: File type not correct";
            }
            string title = "ArchimateGenerateExtension";

            FileGenerator          fileGenerator          = new FileGenerator(path_in, dict_implementation, current_solution_name, current_solution_path, current_DTE2.Solution);
            GenerateCommandPackage generateCommandPackage = package as GenerateCommandPackage;

            fileGenerator.Generate(fileGenerator.getAllType(), fileGenerator.getAllElements(), "Maidis.Vnext.", current_DTE2.Solution);

            // show a message box to prove we were here
            VsShellUtilities.ShowMessageBox(
                this.package,
                message,
                title,
                OLEMSGICON.OLEMSGICON_INFO,
                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
        }
        private void Generate3(object sender, EventArgs e)
        {
            EnvDTE80.DTE2 current_DTE2 = GetDTE2();
            string        path_in      = GetSourceFilePath();

            ThreadHelper.ThrowIfNotOnUIThread();
            //string message = string.Format(CultureInfo.CurrentCulture, "inside {0}.menuitemcallback()", GetType().FullName);
            string message;

            if (Path.GetExtension(path_in).Equals(".xml"))
            {
                string                 path_out;
                FileGenerator          fileGenerator          = new FileGenerator(path_in, dict_implementation, current_solution_name, current_solution_path, current_DTE2.Solution);
                GenerateCommandPackage generateCommandPackage = package as GenerateCommandPackage;
                if (generateCommandPackage.Output_path_.Equals("") || generateCommandPackage.Output_path_ == null)
                {
                    path_out = path_in.Replace(path_in.Substring(path_in.LastIndexOf("\\") + 1), "") + "FileGenerated.cs";
                }
                else
                {
                    path_out = generateCommandPackage.Output_path_ + "\\FileGenerated.cs";
                }

                string str_types    = UserSettings.Default.ElementType;
                string str_groups   = UserSettings.Default.Groups;
                string str_views    = UserSettings.Default.Views;
                string str_elements = UserSettings.Default.Elements;
                //string str_projects_paths = UserSettings.Default.Projects_paths;
                string name_space = UserSettings.Default.Name_space;

                string[] element_types = str_types.Length > 0 ? str_types.Split(',').ToList().ToArray() : null;
                string[] groups        = str_groups.Length > 0 ? str_groups.Split(',').ToList().ToArray() : null;
                string[] views         = str_views.Length > 0 ? str_views.Split(',').ToList().ToArray() : null;
                string[] elements      = str_elements.Length > 0 ? str_elements.Split(',').ToList().ToArray() : null;
                //string[] projects_paths = str_projects_paths.Length > 0 ? str_projects_paths.Split(',').ToList().ToArray() : null;

                var projects = GetProjects();
                Dictionary <string, Project> dict_path_project = new Dictionary <string, Project>();
                foreach (var p in projects)
                {
                    var fullName     = p.FullName;
                    var project_path = fullName.Replace(fullName.Substring(fullName.LastIndexOf("\\") + 1), "");
                    dict_path_project.Add(project_path, p);
                }

                fileGenerator.Generate(fileGenerator.getAllType(), elements, name_space, GetDTE().Solution);

                message = "File generated with the former setting";
            }
            else if (Path.GetExtension(path_in).Equals(".cs"))
            {
                if (UserSettings.Default.SourceFile.Length > 0)
                {
                    path_in = path_in.Replace(".generated", "");
                    string        source_file   = UserSettings.Default.SourceFile;
                    FileGenerator fileGenerator = new FileGenerator(source_file, dict_implementation, current_solution_name, current_solution_path, current_DTE2.Solution);
                    Element       element       = fileGenerator.Dict_element.FirstOrDefault(x => StringHelper.UpperString(x.Value.Class_name_).Equals(Path.GetFileNameWithoutExtension(path_in))).Value;
                    string        element_name  = element.Name_;
                    if (element_name != null)
                    {
                        fileGenerator.Generate(new[] { element.Type_ }, new[] { element_name }, UserSettings.Default.Name_space, GetDTE().Solution);
                        message = "Element \"" + element_name + "\" regenerated successfully";
                    }
                    else
                    {
                        message = "Element \"" + element_name + "\" doesn't exist in model";
                    }
                }
                else
                {
                    message = "You have never generated before";
                }
            }
            else
            {
                message = "error: File type not correct";
            }
            string title = "ArchimateGenerateExtension";

            // show a message box to prove we were here
            VsShellUtilities.ShowMessageBox(
                this.package,
                message,
                title,
                OLEMSGICON.OLEMSGICON_INFO,
                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
        }