/// <summary>
        /// Generates the diagram.
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="package">The package.</param>
        public static void GenerateDiagram(Repository repository, Package package)
        {
            chkPackage        = package;
            pRepository       = repository;
            ProgressInfo.Info = Resources.stateGenDiagram;
            DiagramObjects dobjs = new DiagramObjects();

            Package newPackage = Manipulation.AddPackage(chkPackage, "Package Dependencies");

            object objDiagram = newPackage.Diagrams.AddNew(chkPackage.Name + " - " + appSettings.Stereotype, appSettings.Type);

            if (!Equals(objDiagram, null))
            {
                Diagram pdDiagram = (Diagram)objDiagram;
                pdDiagram.Stereotype = "generated";

                if (pdDiagram.Update())
                {
                    ProgressInfo.Info = Resources.stateSearchCurDep;

                    DependingPackageList currentDependency = CurrentDependencies(chkPackage);
                    IEnumerator          enumCurrent       = currentDependency.GetEnumerator();
                    enumCurrent.Reset();

                    ProgressInfo.Reset(Resources.stateCreateDiagram, 0, currentDependency.Count);
                    while (enumCurrent.MoveNext())
                    {
                        ProgressInfo.Next();
                        DependingPackages dp = (DependingPackages)enumCurrent.Current;

                        if (dp != null && !dobjs.IsInList(dp.Element1.ElementID))
                        {
                            object objDObj = pdDiagram.DiagramObjects.AddNew("", "");
                            if (!Equals(objDObj, null))
                            {
                                dobjs.Add(AddElementToDiagram(pdDiagram, dp.Element1));
                            }
                        }

                        if (dp != null && !dobjs.IsInList(dp.Element2.ElementID))
                        {
                            object objDObj = pdDiagram.DiagramObjects.AddNew("", "");
                            if (!Equals(objDObj, null))
                            {
                                dobjs.Add(AddElementToDiagram(pdDiagram, dp.Element2));
                            }
                        }
                    }

                    pRepository.OpenDiagram(pdDiagram.DiagramID);
                    pRepository.App.Project.LayoutDiagram(pdDiagram.DiagramGUID, 0);
                    pRepository.SaveDiagram(pdDiagram.DiagramID);

                    ProgressInfo.Info = Resources.stateFinished;
                }
            }
        }
        /// <summary>
        /// Adds the elements.
        /// </summary>
        /// <param name="dpList">The dp list.</param>
        public void AddElements(DependingPackageList dpList)
        {
            // adds a list of elements
            IEnumerator enumDPL = dpList.GetEnumerator();

            enumDPL.Reset();
            while (enumDPL.MoveNext())
            {
                DependingPackages dp = (DependingPackages)enumDPL.Current;
                // checks if the element is allready added
                if (!IsInList(dp.Element1.ElementID, dp.Element2.ElementID))
                {
                    AddNew(dp.Element1, dp.Element2, dp.Direction);
                }
            }
        }
        /// <summary>
        /// Adds a new dependency.
        /// </summary>
        /// <param name="eaElement1">The ea element1.</param>
        /// <param name="eaElement2">The ea element2.</param>
        /// <param name="sDirection">The direction of the connector.</param>
        /// <param name="eaConnector">The ea connector.</param>
        /// <returns>the added object</returns>
        public object AddNew(EA.Element eaElement1, EA.Element eaElement2, string sDirection, EA.Connector eaConnector)
        {
            // adds a new item to the list
            DependingPackages dPackages = new DependingPackages(eaElement1, eaElement2, sDirection);

            dPackages.Connector = eaConnector;

            // copies the old list to a tmp-list, generates a new list with one more item
            // and adds the new item at the end of the list
            DependingPackages[] spTmp = _dpList;
            _dpList = new DependingPackages[_dpList.Length + 1];
            for (int i = 0; i < _dpList.Length; i++)
            {
                if (i < spTmp.Length)
                {
                    _dpList[i] = spTmp[i];
                }
                else
                {
                    _dpList[i] = dPackages;
                }
            }
            return(dPackages);
        }
        /// <summary>
        /// Checks the package dependencies.
        /// (adding / deleting)
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="package">The package.</param>
        public static void CheckPackageDependencies(Repository repository, Package package)
        {
            chkPackage  = package;
            pRepository = repository;
            //ProgressInfo.Info = Resources.stateCheckStType;
            Manipulation.AddorGetStereotype(pRepository, appSettings.Stereotype, appSettings.Type);

            DependingPackageList neededDependency  = NeededDependencies(chkPackage);
            DependingPackageList currentDependency = CurrentDependencies(chkPackage);

            ProgressInfo.Info = Resources.stateUpdCurDep;
            IEnumerator enumCurrent = currentDependency.GetEnumerator();

            enumCurrent.Reset();
            ProgressInfo.Maximum = currentDependency.Count;

            while (enumCurrent.MoveNext())
            {
                ProgressInfo.Next();
                DependingPackages dp = (DependingPackages)enumCurrent.Current;
                if (dp != null)
                {
                    if (!neededDependency.IsInList(dp.Element1.ElementID, dp.Element2.ElementID))
                    {
                        DelPackageDependency(dp.Element1, dp.Element2);
                    }
                    DependingPackages needDp = neededDependency.GetItemByElements(dp.Element1.ElementID, dp.Element2.ElementID);
                    if (needDp != null)
                    {
                        if (dp.Connector != null)
                        {
                            dp.Connector.Direction = needDp.Direction;
                            dp.Connector.Update();
                        }
                    }
                }
            }
            ProgressInfo.Reset();
            ProgressInfo.Info = Resources.stateAddNewDep;
            IEnumerator enumNedded = neededDependency.GetEnumerator();

            enumNedded.Reset();
            ProgressInfo.Maximum = currentDependency.Count;
            while (enumNedded.MoveNext())
            {
                ProgressInfo.Next();
                DependingPackages dp = (DependingPackages)enumNedded.Current;
                if (dp != null && !currentDependency.IsInList(dp.Element1.ElementID, dp.Element2.ElementID))
                {
        #pragma warning disable 618
                    Manipulation.AddConnector(dp.Element1, dp.Element2, string.Empty, dp.Direction, appSettings.Type, appSettings.Stereotype);
        #pragma warning restore 618
                }
            }

            ProgressInfo.Info = Resources.stateUpdRep;
            UpdateDiagrams();

            ProgressInfo.Reset();
            ProgressInfo.Info = Resources.stateFinished;
        }