Beispiel #1
0
 /// <summary>
 ///   Import a Visual Studio Project.
 /// </summary>
 private void ImportVisualStudioProject(Diagram diagram, ImportSettings settings, string fileName)
 {
     // TO DO
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new ImportSettingsForm2.
        /// </summary>
        /// <param name="settings">The <see cref="ImportSettings"/> which will be used for import. </param>
        public ImportSettingsForm(ImportSettings settings)
        {
            InitializeComponent();

            // Add the icons to the realisation check boxes.
            chkCreateRealizations.Image    = DiagramEditor.Properties.Resources.Realization;
            chkCreateNesting.Image         = DiagramEditor.Properties.Resources.Nesting;
            chkCreateGeneralizations.Image = DiagramEditor.Properties.Resources.Generalization;
            chkCreateAssociations.Image    = DiagramEditor.Properties.Resources.Association;

            //Localization goes here...
            colFilterElement.Items.Clear();
            colFilterElement.ImageSize = new Size(16, 16);
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Elements, null, FilterElements.AllElements));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Class, DiagramEditor.Properties.Resources.Class, FilterElements.Class));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Struct, DiagramEditor.Properties.Resources.Structure, FilterElements.Struct));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Interface, DiagramEditor.Properties.Resources.Interface32, FilterElements.Interface));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Delegate, DiagramEditor.Properties.Resources.Delegate, FilterElements.Delegate));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Enum, DiagramEditor.Properties.Resources.Enum, FilterElements.Enum));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_EnumValue, DiagramEditor.Properties.Resources.EnumItem, FilterElements.EnumValue));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Constructor, DiagramEditor.Properties.Resources.Constructor, FilterElements.Constructor));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Field, DiagramEditor.Properties.Resources.Field, FilterElements.Field));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Constant, DiagramEditor.Properties.Resources.PublicConst, FilterElements.Constant));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Property, DiagramEditor.Properties.Resources.Property, FilterElements.Property));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Method, DiagramEditor.Properties.Resources.Method, FilterElements.Method));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Operator, DiagramEditor.Properties.Resources.PublicOperator, FilterElements.Operator));
            colFilterElement.Items.Add(new ImageComboBoxItem(Strings.Element_Event, DiagramEditor.Properties.Resources.Event, FilterElements.Event));

            colFilterModifier.Items.Clear();
            colFilterModifier.ImageSize = new Size(16, 16);
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_All, null, FilterModifiers.AllModifiers));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Instance, null, FilterModifiers.Instance));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Static, DiagramEditor.Properties.Resources.Static, FilterModifiers.Static));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Default, Resources.ModifierDefault, FilterModifiers.Default));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Public, null, FilterModifiers.Public));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Private, Resources.ModifierPrivate, FilterModifiers.Private));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Internal, Resources.ModifierInternal, FilterModifiers.Internal));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_Protected, Resources.ModifierProtected, FilterModifiers.Protected));
            colFilterModifier.Items.Add(new ImageComboBoxItem(Strings.Modifier_ProtectedInternal, Resources.ModifierProtectedInternal, FilterModifiers.ProtectedInternal));

            //Build reverse maps for easy access while loading a template.
            reverseElementNameMap.Clear();
            foreach (ImageComboBoxItem comboBoxItem in colFilterElement.Items)
            {
                reverseElementNameMap.Add((FilterElements)comboBoxItem.Tag, comboBoxItem);
            }
            reverseModifierNameMap.Clear();
            foreach (ImageComboBoxItem comboBoxItem in colFilterModifier.Items)
            {
                reverseModifierNameMap.Add((FilterModifiers)comboBoxItem.Tag, comboBoxItem);
            }

            importSettings = settings;

            //Templates
            cboTemplate.Items.Clear();
            if (Settings.Default.ImportSettingsTemplates == null)
            {
                Settings.Default.ImportSettingsTemplates = new TemplateList();
                ImportSettings newSettings = new ImportSettings
                {
                    Name = Strings.Settings_Template_LastUsed,
                    CreateAssociations    = true,
                    CreateGeneralizations = true,
                    CreateNestings        = true,
                    CreateRealizations    = true,
                    CreateRelationships   = true,
                    LabelAggregations     = true
                };
                Settings.Default.ImportSettingsTemplates.Add(newSettings);
            }
            foreach (object xTemplate in Settings.Default.ImportSettingsTemplates)
            {
                cboTemplate.Items.Add(xTemplate);
            }
            cboTemplate.SelectedItem = cboTemplate.Items[0];
            DisplaySettings((ImportSettings)cboTemplate.Items[0]);

            LocalizeComponents();
        }
Beispiel #3
0
        // ========================================================================
        // Methods

        #region === Methods

        /// <summary>
        ///   Starts the functionality of the plugin.
        /// </summary>
        protected void Launch()
        {
            if (Workspace.HasActiveProject)
            {
                ImportSettings settings = new ImportSettings();
                using (ImportSettingsForm settingsForm = new ImportSettingsForm(settings))
                {
                    if (settingsForm.ShowDialog() == DialogResult.OK)
                    {
                        Diagram diagram = new Diagram(CSharpLanguage.Instance);

                        // Is it a file or a folder?
                        foreach (string item in settings.Items)
                        {
                            // Analyse items to know if it is :
                            // a C# source file
                            // a folder
                            // a .NET assembly
                            if (Path.HasExtension(item) == true)
                            {
                                switch (Path.GetExtension(item))
                                {
                                case ".cs":
                                    if (File.Exists(item) == true)
                                    {
                                        if (settings.NewDiagram == true)
                                        {
                                            diagram = new Diagram(CSharpLanguage.Instance);
                                        }

                                        ImportCSharpFile(diagram, settings, item);
                                    }
                                    break;

                                case ".dll":
                                case ".exe":
                                    if (File.Exists(item) == true)
                                    {
                                        if (settings.NewDiagram == true)
                                        {
                                            diagram = new Diagram(CSharpLanguage.Instance);
                                        }

                                        ImportAssembly(diagram, settings, item);
                                    }
                                    break;

                                case ".sln":
                                    if (File.Exists(item) == true)
                                    {
                                        if (settings.NewDiagram == true)
                                        {
                                            diagram = new Diagram(CSharpLanguage.Instance);
                                        }

                                        ImportVisualStudioSolution(diagram, settings, item);
                                    }
                                    break;

                                case ".csproj":
                                    if (File.Exists(item) == true)
                                    {
                                        if (settings.NewDiagram == true)
                                        {
                                            diagram = new Diagram(CSharpLanguage.Instance);
                                        }

                                        ImportVisualStudioProject(diagram, settings, item);
                                    }
                                    break;

                                default:
                                    // unknow extension
                                    break;
                                }
                            }
                            else
                            {
                                if (Directory.Exists(item) == true)
                                {
                                    ImportFolder(diagram, settings, item);
                                }
                            }
                        }
                    }
                }
            }
        }