Esempio n. 1
0
        private void GetEdgeInformation(Polyline pline, ref Curve2dCollection plCurves, ref IntegerCollection edgeTypes)
        {
            int segCount = pline.NumberOfVertices;

            for (int cnt = 0; cnt < segCount; cnt++)
            {
                SegmentType type = pline.GetSegmentType(cnt);

                switch (type)
                {
                case SegmentType.Arc:

                    CircularArc2d arc2d = pline.GetArcSegment2dAt(cnt);

                    plCurves.Add(arc2d);

                    edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType),

                                                  HatchEdgeType.CircularArc.ToString()));

                    break;

                case SegmentType.Line:

                    LineSegment2d line2d = pline.GetLineSegment2dAt(cnt);

                    plCurves.Add(line2d);

                    edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType),

                                                  HatchEdgeType.Line.ToString()));

                    break;

                case SegmentType.Coincident:

                    break;

                case SegmentType.Empty:

                    break;

                case SegmentType.Point:

                    break;
                }
            }
        }
Esempio n. 2
0
        bool locateActiveGrips(out IntegerCollection aIndices)
        {
            ExGripDataCollection grDataCol = entPath() ? m_pOwner.GetSubentGripData(m_pOwner.GripDataDict[entityId()], subentPath).SubData :
                                             m_pOwner.GripDataDict[entityId()].DataArray;

            bool bExMethod = true;

            aIndices = new IntegerCollection();
            int i = 0;

            foreach (ExGripData dat in grDataCol)
            {
                if (null == dat.Data)
                {
                    bExMethod = false;
                }

                if (GripData.DrawType.DragImageGrip == dat.Status)
                {
                    aIndices.Add(i);
                }
                i++;
            }
            return(bExMethod);
        }
        private void AddItem()
        {
            int count = random.Next(100000);

            while (true)
            {
                globalCollection.Add(count);
                count++;
            }
        }
Esempio n. 4
0
        public static int[] GetChainStartIndices(ICoordinateList pts)
        {
            // find the startpoint (and endpoints) of all monotone chains in this edge
            int start = 0;
            IntegerCollection startIndexList = new IntegerCollection();

            startIndexList.Add(start);
            do
            {
                int last = FindChainEnd(pts, start);

                startIndexList.Add(last);
                start = last;
            }while (start < pts.Count - 1);

            // copy list to an array of ints, for efficiency
            int[] startIndex = startIndexList.ToArray();

            return(startIndex);
        }
Esempio n. 5
0
        /// <summary>
        /// Get a list of album IDs between the current instance and the specified <paramref name="topAlbumId" />. It works by
        /// analyzing the parent albums, recursively, of the current gallery object, until reaching either the root album or the specified
        /// <paramref name="topAlbumId" />. The caller is responsible for iterating through this list and calling 
        /// <see cref="Album.AssignAlbumThumbnail" /> for each album after the move operation is complete.
        /// This method should be called before the move operation takes place.
        /// </summary>
        /// <param name="topAlbumId">The ID of the album the current gallery object will be in after the move operation completes.</param>
        /// <returns>Return a list of album IDs whose thumbnail images will need updating after the move operation completes.</returns>
        protected IIntegerCollection GetAlbumHierarchy(int topAlbumId)
        {
            IIntegerCollection albumsInHierarchy = new IntegerCollection();
            IGalleryObject album = this.Parent;

            while (!(album is NullObjects.NullGalleryObject))
            {
                // If we're at the same level as the destination album, don't go any further.
                if (album.Id == topAlbumId)
                    break;

                albumsInHierarchy.Add(album.Id);

                album = album.Parent;
            }

            return albumsInHierarchy;
        }
Esempio n. 6
0
        /// <summary>
        /// Extract information from the query string and assign to our class level variables. Return false if something goes wrong
        /// and the variables cannot be set. This will happen when the query string is in an unexpected format.
        /// </summary>
        /// <param name="queryString">The query string for the current request. Can be populated with HttpContext.Request.Url.Query.</param>
        /// <returns>Returns true if all relevant variables were assigned from the query string; returns false if there was a problem.</returns>
        private bool ExtractQueryStringParms(string queryString)
        {
            if (String.IsNullOrEmpty(queryString))
            {
                return(false);
            }

            if (queryString.StartsWith("?", StringComparison.Ordinal))
            {
                queryString = queryString.Remove(0, 1);
            }

            // id=0&gid=all&secaction=6&sc=false&navurl=&levels=2&includealbum=true&idtoselect%5B%5D=220&idtoselect%5B%5D=99
            foreach (string nameValuePair in queryString.Split(new char[] { '&' }))
            {
                string[] nameOrValue = nameValuePair.Split(new char[] { '=' });

                if (nameOrValue.Length < 2)
                {
                    return(false);
                }

                switch (Utils.UrlDecode(nameOrValue[0]))
                {
                case "id":
                {
                    int aid;
                    if (Int32.TryParse(nameOrValue[1], out aid))
                    {
                        _albumId = aid;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case "gid":
                {
                    int gid;
                    if (Int32.TryParse(nameOrValue[1], out gid))
                    {
                        _galleries = new GalleryCollection()
                        {
                            Factory.LoadGallery(gid)
                        };
                    }
                    else if (Utils.UrlDecode(nameOrValue[1]).Trim() == "all")
                    {
                        _galleries = UserController.GetGalleriesCurrentUserCanAdminister();
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case "secaction":
                {
                    int secActionInt;
                    if (Int32.TryParse(nameOrValue[1], out secActionInt))
                    {
                        if (SecurityActionEnumHelper.IsValidSecurityAction((SecurityActions)secActionInt))
                        {
                            _securityAction = (SecurityActions)secActionInt; break;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }

                case "sc":
                {
                    bool showCheckbox;
                    if (Boolean.TryParse(nameOrValue[1], out showCheckbox))
                    {
                        _showCheckbox = showCheckbox;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case "navurl":
                {
                    _navigateUrl = Utils.UrlDecode(nameOrValue[1]).Trim();
                    break;
                }

                case "levels":
                {
                    int numLevels;
                    if (Int32.TryParse(nameOrValue[1], out numLevels))
                    {
                        _numberOfLevels = numLevels;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case "includealbum":
                {
                    bool includeAlbum;
                    if (Boolean.TryParse(nameOrValue[1], out includeAlbum))
                    {
                        _includeAlbum = includeAlbum;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                case "idtoselect":
                case "idtoselect[]":
                {
                    int idToSelect;
                    if (Int32.TryParse(nameOrValue[1], out idToSelect))
                    {
                        _albumIdsToSelect.Add(idToSelect);
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }

                default: return(false); // Unexpected query string parm. Return false so execution is aborted.
                }
            }

            return(true);
        }
Esempio n. 7
0
        void updateInvisibleGrips()
        {
            ExGripDataCollection aOverall = new ExGripDataCollection();

            foreach (KeyValuePair <ObjectId, ExGripDataExt> grDataDc in m_gripDataDict)
            {
                foreach (ExGripData grData in grDataDc.Value.DataArray)
                {
                    aOverall.Add(grData);
                }
                foreach (ExGripDataSubent grDataSub in grDataDc.Value.DataSub)
                {
                    foreach (ExGripData grData in grDataSub.SubData)
                    {
                        aOverall.Add(grData);
                    }
                }
            }

            int iSize = aOverall.Count;

            for (int i = 0; i < iSize; i++)
            {
                ExGripData grData = aOverall[i];
                grData.Invisible = false;
                grData.Shared    = false;

                IntegerCollection aEq = new IntegerCollection();
                aEq.Add(i);

                Point3d ptIni = grData.Point;

                int       iNext = i + 1;
                Tolerance tc    = new Tolerance(1E-6, 1E-6);
                while (iNext < iSize)
                {
                    Point3d ptCur = aOverall[iNext].Point;
                    if (ptIni.IsEqualTo(ptCur, tc))
                    {
                        aEq.Add(iNext);
                        iNext++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (aEq.Count >= 2)
                {
                    int iVisible = 0;
                    int jSize    = aEq.Count;
                    for (int j = 0; j < iSize; j++)
                    {
                        ExGripData pGrip = aOverall[aEq[j]];

                        bool bOk = true;
                        if (pGrip.Data != null)
                        {
                            if (pGrip.Data.SkipWhenShared)
                            {
                                bOk = false;
                            }
                        }

                        if (bOk)
                        {
                            iVisible = j;
                            break;
                        }
                    }

                    for (int j = 0; j < iSize; j++)
                    {
                        ExGripData pGrip = aOverall[aEq[j]];
                        pGrip.Shared    = true;
                        pGrip.Invisible = (j != iVisible);
                    }
                }
            }
        }
        private static void InsertSampleUsersAndRoles()
        {
            // Get list of all album IDs
            List<int> albumIds = new List<int>();
            foreach (IGalleryServerRole role in RoleController.GetGalleryServerRoles())
            {
                if (role.RoleName == "System Administrator")
                {
                    albumIds.AddRange(role.AllAlbumIds);
                    albumIds.Sort();
                }
            }

            //// Create roles and assign each one to a random album
            Random rdm = new Random();
            const int numRoles = 100;
            for (int i = 0; i < numRoles; i++)
            {
                int albumId;
                do
                {
                    albumId = rdm.Next(albumIds[0], albumIds[albumIds.Count - 1]);
                } while (!albumIds.Contains(albumId));

                IIntegerCollection roleAlbums = new IntegerCollection();
                roleAlbums.Add(albumId);
                RoleController.CreateRole("Role " + i, true, false, true, false, true, false, true, false, true, false, false, false, roleAlbums);
            }

            // Create users and assign to random number of roles.
            const int numUsers = 100;
            for (int i = 0; i < numUsers; i++)
            {
                int numRolesToAssignToUser = rdm.Next(0, 5); // Add up to 5 roles to user
                List<String> roleNames = new List<string>(numRolesToAssignToUser);
                for (int j = 0; j < numRolesToAssignToUser; j++)
                {
                    // Pick a random role
                    string roleName = "Role " + rdm.Next(0, numRoles - 1);
                    if (!roleNames.Contains(roleName))
                        roleNames.Add(roleName);
                }

                string userName = "******" + i;
                if (UserController.GetUser(userName, false) == null)
                {
                    UserController.CreateUser(userName, "111", String.Empty, roleNames.ToArray(), false, 1);
                }
            }
        }