// ========================================================================
        // Methods

        #region === Methods

        /// <summary>
        ///   Starts the functionality of the plugin.
        /// </summary>
        protected void Launch()
        {
            if (Workspace.HasActiveProject)
            {
                string fileName;
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.Filter = Strings.OpenFileDialog_Filter;
                    if (dialog.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    fileName = dialog.FileName;
                }

                ImportSettings settings = new ImportSettings();
                using (ImportSettingsForm settingsForm = new ImportSettingsForm(settings))
                {
                    if (settingsForm.ShowDialog() == DialogResult.OK)
                    {
                        Diagram   diagram  = new Diagram(CSharpLanguage.Instance);
                        NETImport importer = new NETImport(diagram, settings);

                        if (importer.ImportAssembly(fileName))
                        {
                            Workspace.ActiveProject.Add(diagram);
                        }
                    }
                }
            }
        }
예제 #2
0
        public void Launch(ProjectCore project)
        {
            if (project == null)
            {
                return;
            }

            if (project.Language.Name != "C#")
            {
                MessageBox.Show("The " + project.Language.Name + " language is not supported.",
                                "Assembly Importer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string fileName;

            using (OpenFileDialog dialog = new OpenFileDialog()) {
                dialog.Filter = "Assemblies (*.exe, *.dll)|*.exe;*.dll";
                if (dialog.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            ImportSettings settings = new ImportSettings();

            using (ImportSettingsForm settingsForm = new ImportSettingsForm(settings)) {
                if (settingsForm.ShowDialog() == DialogResult.OK && project.NewProject())
                {
                    NETImport importer = new NETImport(project, settings);
                    importer.ImportAssembly(fileName);
                }
            }
        }
예제 #3
0
        private bool ImportAssembly(string fileName, ClassDiagram diagram, ImportSettings settings)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                MessageBox.Show(Strings.Error_NoAssembly, Strings.Error_MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            try
            {
                NETImport importer = new NETImport(diagram, settings);
                return(importer.ImportAssembly(fileName));
            }
            catch (UnsafeTypesPresentException)
            {
                MessageBox.Show(null, Strings.UnsafeTypesPresent, Strings.WarningTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }
            catch (ReflectionTypeLoadException)
            {
                MessageBox.Show(Strings.Error_MissingReferencedAssemblies, Strings.Error_MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (FileLoadException)
            {
                MessageBox.Show(Strings.Error_MissingReferencedAssemblies, Strings.Error_MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (BadImageFormatException)
            {
                MessageBox.Show(Strings.Error_BadImageFormat, Strings.Error_MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            catch (Exception ex)
            {
                DetailsErrorDialog.Show(Strings.Error_MessageBoxTitle, Strings.Error_GeneralException, ex.ToString(), MessageBoxIcon.Error);
                return(false);
            }
        }
예제 #4
0
    // ========================================================================
    // Methods

    #region === Methods

    /// <summary>
    ///   Starts the functionality of the plugin.
    /// </summary>
    protected void Launch()
    {
      if(Workspace.HasActiveProject)
      {
        string fileName;
        using (OpenFileDialog dialog = new OpenFileDialog())
        {
          dialog.Filter = Strings.OpenFileDialog_Filter;
          if (dialog.ShowDialog() == DialogResult.Cancel)
            return;
          fileName = dialog.FileName;
        }

        ImportSettings settings = new ImportSettings();
        using(ImportSettingsForm settingsForm = new ImportSettingsForm(settings))
        {
          if(settingsForm.ShowDialog() == DialogResult.OK)
          {
            ClassDiagram diagram = new ClassDiagram(CSharpLanguage.Instance);
            NETImport importer = new NETImport(diagram, settings);

            if(importer.ImportAssembly(fileName))
            {
              Workspace.ActiveProject.Add(diagram);
            }
          }
        }
      }
    }