Ejemplo n.º 1
0
            static void Exercise1()
            {
                StartPlan("Exercise1");
                Console.WriteLine("Dar in barname ba vared kardan tool va arz meghdar masahat va mohit mostatil ra hesab mikonim.");
                int Tool, Arz;

                Console.Write("Tool: ");
                //از این دستور برای تبدیل ورودی به عدد صحیح و همچنین کنترل نوع آن استفااده می کنیم
                if (Int32.TryParse(Console.ReadLine(), out Tool) == false)
                {
                    Console.WriteLine("Lotfan meghdar tool ra be sorat adad sahih vared namaeed...");
                }
                ;

                Console.Write("Arz: ");
                if (Int32.TryParse(Console.ReadLine(), out Arz) == false)
                {
                    Console.WriteLine("Lotfan meghdar arz ra be sorat adad sahih vared namaeed...");
                }
                ;

                int Perimeter, Area;

                Area      = Tool * Arz;
                Perimeter = (Tool + Arz) * 2;

                string PrintMsg = "\n\n\n\nTool: " + Tool.ToString() + "\nArz: " + Arz.ToString() +
                                  "\nMohit: " + Perimeter.ToString() + "\nMasahat: " + Area.ToString();

                Console.WriteLine(PrintMsg);
                ExitPlan();
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Moves all Rooms in the Story and the Story Envelope along a 3D vector calculated between the supplied Vector3 points.
 /// </summary>
 /// <param name="from">Vector3 base point of the move.</param>
 /// <param name="to">Vector3 target point of the move.</param>
 /// <returns>
 /// None.
 /// </returns>
 public void MoveFromTo(Vector3 from, Vector3 to)
 {
     if (Perimeter != null)
     {
         Perimeter = Perimeter.MoveFromTo(from, to);
     }
     foreach (var room in Corridors)
     {
         room.MoveFromTo(from, to);
     }
     foreach (var room in Exclusions)
     {
         room.MoveFromTo(from, to);
     }
     foreach (var room in Openings)
     {
         room.MoveFromTo(from, to);
     }
     foreach (var room in Rooms)
     {
         room.MoveFromTo(from, to);
     }
     foreach (var room in Services)
     {
         room.MoveFromTo(from, to);
     }
 }
Ejemplo n.º 3
0
        public MathTask Next()
        {
            _step++;

            MathTask t = null;

            do
            {
                var op = GetNextOperationType();

                switch (op)
                {
                case Operation.Add: t = new Add(op, level); break;

                case Operation.Substract: t = new Substract(op, level); break;

                case Operation.Multiply: t = new Mult(op, level); break;

                case Operation.Divide: t = new Divide(op, level); break;

                case Operation.Prime: t = new Prime(op, level); break;

                case Operation.Perimeter: t = new Perimeter(op, level); break;
                }

                t.GenerateArgs(_step, _random);
            } while (hs.Contains(t.GetHashCode()));

            _tasks.Add(t);
            hs.Add(t.GetHashCode());

            return(t);
        }
Ejemplo n.º 4
0
 public void Render(Perimeter worldSize)
 {
     skybox.Center = new TGCVector3(FastMath.Clamp(Camera.Position.X, worldSize.xMin + Radius, worldSize.xMax - Radius),
                                    skybox.Center.Y,
                                    FastMath.Clamp(Camera.Position.Z, worldSize.zMin + Radius, worldSize.zMax - Radius));
     skybox.Render();
 }
Ejemplo n.º 5
0
        public void QuadProperties()
        {
            double height = _pythagorean.ALength(D, C);

            _perimeter = () => A + B + C + D;
            _area      = () => ((B + D) / 2) * height;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a Room to the Services list.
        /// </summary>
        /// <param name="room">Room to add.</param>
        /// <param name="fit">Indicates whether the new Room should mutually fit to other Story features. Default is true.</param>
        /// <returns>
        /// True if one or more Rooms were added to the Story.
        /// </returns>
        public bool AddService(Room room, bool fit = true)
        {
            if (Perimeter == null || room.Perimeter == null || !Perimeter.Covers(perimeter))
            {
                return(false);
            }
            var newRoom =
                new Room()
            {
                Color     = room.Color,
                Elevation = Elevation,
                Height    = Height,
                Name      = room.Name,
                Perimeter = room.Perimeter
            };
            var fitRooms = new List <Room> {
                newRoom
            };

            if (fit)
            {
                var toRooms = new List <Room>(Exclusions);
                fitRooms = FitRooms(fitRooms, toRooms);
                toRooms.AddRange(fitRooms);
                Corridors = FitRooms(Corridors, toRooms);
                toRooms.AddRange(Corridors);
                Rooms = FitRooms(Rooms, toRooms);
            }
            if (fitRooms.Count == 0)
            {
                return(false);
            }
            Services.AddRange(fitRooms);
            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds a Room to the Exclusions list.
        /// </summary>
        /// <param name="room">Room to add.</param>
        /// <param name="fit">Indicates whether the new room should mutually fit to other Story features. Default is true.</param>
        /// <returns>
        /// True if one or more rooms were added to the Story.
        /// </returns>
        public bool AddExclusion(Room room, bool fit = true)
        {
            if (Perimeter == null || room.Perimeter == null || !Perimeter.Covers(perimeter))
            {
                return(false);
            }
            var newRoom =
                new Room()
            {
                Elevation = Elevation,
                Name      = room.Name,
                Perimeter = room.Perimeter
            };
            var toRooms = new List <Room> {
                newRoom
            };

            if (fit)
            {
                Services = FitRooms(Services, toRooms);
                toRooms.AddRange(Services);
                Corridors = FitRooms(Corridors, toRooms);
                toRooms.AddRange(Corridors);
                Rooms = FitRooms(Rooms, toRooms);
            }
            Exclusions.Add(newRoom);
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds a Room to the Exclusions list.
        /// </summary>
        /// <param name="room">Room to add.</param>
        /// <param name="fit">Indicates whether the new room should mutually fit to other Story features. Default is true.</param>
        /// <returns>
        /// True if one or more rooms were added to the Story.
        /// </returns>
        public bool AddExclusion(Room room, bool fit = true)
        {
            if (Perimeter == null || room.Perimeter == null)
            {
                throw new ArgumentNullException(Messages.PERIMETER_NULL_EXCEPTION);
            }
            if (!Perimeter.Covers(perimeter))
            {
                throw new ArgumentNullException(Messages.PERIMETER_PLACEMENT_EXCEPTION);
            }
            var newRoom =
                new Room()
            {
                Elevation = Elevation,
                Name      = room.Name,
                Perimeter = room.Perimeter
            };
            var toRooms = new List <Room> {
                newRoom
            };

            if (fit)
            {
                Services = FitRooms(Services, toRooms);
                toRooms.AddRange(Services);
                Corridors = FitRooms(Corridors, toRooms);
                toRooms.AddRange(Corridors);
                Rooms = FitRooms(Rooms, toRooms);
            }
            Exclusions.Add(newRoom);
            return(true);
        }
Ejemplo n.º 9
0
        public virtual int CreateNewPerimeter(Perimeter newPerimeter)
        {
            // Validate Parameters
            if (newPerimeter == null)
            {
                throw (new ArgumentNullException("newPerimeter"));
            }

            // Apply business rules
            OnPerimeterSaving(newPerimeter);
            OnPerimeterCreating(newPerimeter);

            _DatabaseContext.Perimeters.AddObject(newPerimeter);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No perimeter created!");
            }

            // Apply business workflow
            OnPerimeterCreated(newPerimeter);
            OnPerimeterSaved(newPerimeter);

            return(newPerimeter.PerimeterID);
        }
Ejemplo n.º 10
0
 public virtual void QuadProperties(double height, double _base)
 {
     _base      = B;
     height     = _pythagorean.ALength(_base, A);
     _area      = () => _base * height;
     _perimeter = () => (2 * Line1) + (2 * _base);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates Rooms by orthogonally dividing the interior of the Story perimeter by a quantity of x-axis and y-axis intervals.
        /// Adds the new Rooms to the Rooms list.
        /// New Rooms conform to Corridor and Service perimeters.
        /// </summary>
        /// <param name="xRooms">Quantity Rooms along the orthogonal x-axis.</param>
        /// <param name="yRooms">Quantity Rooms along the orthogonal y-axis.</param>
        /// <param name="height">Height of the new Rooms.</param>
        /// <param name="setback">Offset from the Story perimeter.</param>
        ///  <param name="name">String identifier applied to every new Room.</param>
        /// <param name="color">Rendering color of the Room as a Space.</param>
        /// <returns>
        /// None.
        /// </returns>
        public void RoomsByDivision(int xRooms     = 1,
                                    int yRooms     = 1,
                                    double height  = 3.0,
                                    double setback = 0.0,
                                    string name    = "",
                                    Color color    = null)
        {
            if (Perimeter == null)
            {
                throw new ArgumentNullException(Messages.PERIMETER_NULL_EXCEPTION);
            }
            if (setback < 0.0)
            {
                throw new ArgumentNullException(Messages.NONPOSITIVE_VALUE_EXCEPTION);
            }
            Rooms.Clear();
            var polygon   = Perimeter.Offset(setback * -1.0).First();
            var roomGroup = new RoomGroup(polygon, xRooms, yRooms, name);

            roomGroup.SetElevation(Elevation);
            roomGroup.SetHeight(height);
            Rooms.AddRange(roomGroup.Rooms);
            RoomsColor = color;
            FitRoomsToServices();
            FitRoomsToCorridors();
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Rotates the Story Perimeter and Rooms in the horizontal plane around the supplied pivot point.
 /// </summary>
 /// <param name="pivot">Vector3 point around which the Room Perimeter will be rotated.</param>
 /// <param name="angle">Angle in degrees to rotate the Perimeter.</param>
 /// <returns>
 /// None.
 /// </returns>
 public void Rotate(Vector3 pivot, double angle)
 {
     if (Perimeter != null)
     {
         Perimeter = Perimeter.Rotate(pivot, angle);
     }
     foreach (var room in Corridors)
     {
         room.Rotate(pivot, angle);
     }
     foreach (var room in Exclusions)
     {
         room.Rotate(pivot, angle);
     }
     foreach (var room in Openings)
     {
         room.Rotate(pivot, angle);
     }
     foreach (var room in Rooms)
     {
         room.Rotate(pivot, angle);
     }
     foreach (var room in Services)
     {
         room.Rotate(pivot, angle);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Attempts to place a Room perimeter in an open area of the RoomGroup.
        /// </summary>
        /// <param name="room">The Room from which to derive the Polygon to place.</param>
        /// <returns>
        /// True if the room was successfully placed.
        /// </returns>
        private bool AddToPerimeter(Room room, IList <Polygon> among)
        {
            var polygon = RoomPerimeter(room);

            if (polygon.Area > AvailableArea)
            {
                return(false);
            }
            if (Rooms.Count == 0)
            {
                polygon = polygon.MoveFromTo(new Vector3(), Box.SW);
                polygon = Perimeter.Intersection(polygon).First();
                if (among != null && polygon.Intersects(among))
                {
                    return(false);
                }
                room.Perimeter = polygon;
                Rooms.Add(room);
                return(true);
            }
            foreach (Polygon adjacentTo in PerimetersRooms)
            {
                var adjPolygon = Place.Adjacent(polygon, adjacentTo, Perimeter, PerimetersRooms);
                if (adjPolygon != null)
                {
                    room.Perimeter = adjPolygon;
                    Rooms.Add(room);
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 14
0
        public void DeletePerimeters(List <int> perimeterIDsToDelete)
        {
            //Validate Input
            foreach (int perimeterID in perimeterIDsToDelete)
            {
                if (perimeterID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("PerimeterID");
                }
            }

            List <Perimeter> perimetersToBeDeleted = new List <Perimeter>();

            foreach (int perimeterID in perimeterIDsToDelete)
            {
                Perimeter perimeter = new Perimeter {
                    PerimeterID = perimeterID
                };
                _DatabaseContext.Perimeters.Attach(perimeter);
                _DatabaseContext.Perimeters.DeleteObject(perimeter);
                perimetersToBeDeleted.Add(perimeter);
                OnPerimeterDeleting(perimeter);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != perimeterIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more perimeter records have not been deleted.");
            }
            foreach (Perimeter perimeterToBeDeleted in perimetersToBeDeleted)
            {
                OnPerimeterDeleted(perimeterToBeDeleted);
            }
        }
Ejemplo n.º 15
0
        public void DeletePerimeter(Perimeter perimeterToBeDeleted)
        {
            //Validate Input
            if (perimeterToBeDeleted == null)
            {
                throw (new ArgumentNullException("perimeterToBeDeleted"));
            }

            // Validate Primary key value
            if (perimeterToBeDeleted.PerimeterID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("PerimeterID");
            }

            OnPerimeterSaving(perimeterToBeDeleted);
            OnPerimeterDeleting(perimeterToBeDeleted);

            if (perimeterToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Perimeters.Attach(perimeterToBeDeleted);
            }
            _DatabaseContext.Perimeters.DeleteObject(perimeterToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Perimeter deleted!");
            }

            OnPerimeterDeleted(perimeterToBeDeleted);
            OnPerimeterSaved(perimeterToBeDeleted);
        }
Ejemplo n.º 16
0
        private double ClippedArea()
        {
            if (this.Voids == null || this.Voids.Count == 0)
            {
                return(this.Perimeter.Area());
            }

            var clipper = new ClipperLib.Clipper();
            var normal  = Perimeter.Normal();

            if (normal.IsAlmostEqualTo(Vector3.ZAxis))
            {
                clipper.AddPath(Perimeter.ToClipperPath(), ClipperLib.PolyType.ptSubject, true);
                clipper.AddPaths(this.Voids.Select(p => p.ToClipperPath()).ToList(), ClipperLib.PolyType.ptClip, true);
            }
            else
            {
                var transform = new Transform(Perimeter.Start, normal);
                transform.Invert();
                var perimeter = Perimeter.TransformedPolygon(transform);
                clipper.AddPath(perimeter.ToClipperPath(), ClipperLib.PolyType.ptSubject, true);
                clipper.AddPaths(this.Voids.Select(p => p.TransformedPolygon(transform).ToClipperPath()).ToList(), ClipperLib.PolyType.ptClip, true);
            }

            var solution = new List <List <ClipperLib.IntPoint> >();

            clipper.Execute(ClipperLib.ClipType.ctDifference, solution, ClipperLib.PolyFillType.pftEvenOdd);
            return(solution.Sum(s => ClipperLib.Clipper.Area(s)) / Math.Pow(1.0 / Vector3.EPSILON, 2));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Ensure that voids run in an opposite winding direction to the perimeter of the profile.
        /// Be sure to call this if you modify the Profile's Voids array directly.
        /// </summary>
        public void OrientVoids()
        {
            // This should only occur in the case of a parametric
            // profile which defines its own perimeter and void logic
            // during construction.
            if (Perimeter == null || Voids == null)
            {
                return;
            }

            var correctedVoids  = new List <Polygon>();
            var perimeterNormal = Perimeter.Normal();

            foreach (var voidCrv in Voids)
            {
                if (voidCrv.Normal().Dot(perimeterNormal) > 0)
                {
                    correctedVoids.Add(voidCrv.Reversed());
                }
                else
                {
                    correctedVoids.Add(voidCrv);
                }
            }
            this.Voids = correctedVoids;
        }
Ejemplo n.º 18
0
        public void UpdatePerimeter(Perimeter updatedPerimeter)
        {
            // Validate Parameters
            if (updatedPerimeter == null)
            {
                throw (new ArgumentNullException("updatedPerimeter"));
            }

            // Validate Primary key value
            if (updatedPerimeter.PerimeterID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("PerimeterID");
            }

            // Apply business rules
            OnPerimeterSaving(updatedPerimeter);
            OnPerimeterUpdating(updatedPerimeter);

            //attaching and making ready for parsistance
            if (updatedPerimeter.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Perimeters.Attach(updatedPerimeter);
            }
            _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedPerimeter, System.Data.EntityState.Modified);            //this line makes the code un-testable!
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No perimeter updated!");
            }

            //Apply business workflow
            OnPerimeterUpdated(updatedPerimeter);
            OnPerimeterSaved(updatedPerimeter);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Moves the Room along a 3D vector calculated between the supplied Vector3 points.
 /// </summary>
 /// <param name="from">Vector3 base point of the move.</param>
 /// <param name="to">Vector3 target point of the move.</param>
 /// <returns>
 /// A Polygon represeting the Room's new Perimeter.
 /// </returns>
 public Polygon MoveFromTo(Vector3 from, Vector3 to)
 {
     if (Perimeter != null)
     {
         Perimeter = Perimeter.MoveFromTo(from, to);
     }
     return(Perimeter);
 }
Ejemplo n.º 20
0
 public void CProperties(double radius)
 {
     _radius    = radius;
     _perimeter = () => (2 * _radius) * _pi;
     _area      = () => Math.Pow(_radius, 2) * _pi;
     Console.WriteLine(_perimeter);
     Console.WriteLine(_area);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Moves all Rooms, the Boundary and the Row along a 3D vector calculated between the supplied Vector3 points.
 /// </summary>
 /// <param name="from">Vector3 base point of the move.</param>
 /// <param name="to">Vector3 target point of the move.</param>
 /// <returns>
 /// None.
 /// </returns>
 public void MoveFromTo(Vector3 from, Vector3 to)
 {
     foreach (var room in Rooms)
     {
         room.MoveFromTo(from, to);
     }
     Perimeter = Perimeter.MoveFromTo(from, to);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Rotates all Rooms and the Perimeter in the horizontal plane around the supplied pivot point.
 /// </summary>
 /// <param name="pivot">Vector3 point around which the RoomRow will be rotated.</param>
 /// <param name="angle">Angle in degrees to rotate the Perimeter.</param>
 /// <returns>
 /// None.
 /// </returns>
 public void Rotate(Vector3 pivot, double angle)
 {
     foreach (Room room in Rooms)
     {
         room.Rotate(pivot, angle);
     }
     Perimeter = Perimeter.Rotate(pivot, angle);
 }
Ejemplo n.º 23
0
        public override void QuadProperties(double length, double width)
        {
            length = Line1;
            width  = Line2;

            _area      = () => length * width;
            _perimeter = () => (2 * length) + (2 * width);
        }
 public void Add(Perimeter perimeter)
 {
     var existing = (from p in Context.Perimeters
                     where p.Name == perimeter.Name && p.Scenario.Guid == perimeter.Scenario.Guid
                     select p).FirstOrDefault();
     if (existing != null) throw new DuplicateNameException(String.Format("A perimeter named {0} already exists in scenario {1}, choose another name", perimeter.Name, perimeter.Scenario.Name));
     Log(perimeter, "Added new perimeter {0} to scenario {1} in location {2}", perimeter.Name, perimeter.Scenario.Name, perimeter.Scenario.Location.Name);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Moves the Room along a 3D vector calculated between the supplied Vector3 points.
 /// </summary>
 /// <param name="from">Vector3 base point of the move.</param>
 /// <param name="to">Vector3 target point of the move.</param>
 /// <returns>
 /// A Polygon represeting the Room's new Perimeter.
 /// </returns>
 public Polygon MoveFromTo(Vector3 from, Vector3 to)
 {
     if (Perimeter != null)
     {
         Perimeter = Perimeter.MoveFromTo(from, to);
     }
     Elevation = to.Z - from.Z;
     return(Perimeter);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Rotates the Room Perimeter in the horizontal plane around the supplied pivot point.
 /// </summary>
 /// <param name="pivot">Vector3 point around which the Room Perimeter will be rotated.</param>
 /// <param name="angle">Angle in degrees to rotate the Perimeter.</param>
 /// <returns>
 /// True if the Perimeter is successfully rotated.
 /// </returns>
 public bool Rotate(Vector3 pivot, double angle)
 {
     if (Perimeter == null)
     {
         return(false);
     }
     Perimeter = Perimeter.Rotate(pivot, angle);
     return(true);
 }
Ejemplo n.º 27
0
        public void TriagProperties(double a, double b)
        {
            //for right triangles
            A = a;
            B = b;

            _area      = () => (a * b) / 2;
            _perimeter = () => A + B + C;
        }
Ejemplo n.º 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="suite"></param>
        /// <returns></returns>
        private void PlaceByAxis()
        {
            if (Rooms.Count == 0)
            {
                return;
            }
            var area = 0.0;

            foreach (var room in Rooms)
            {
                area += room.Area;
            }
            var roomRows = new List <RoomRow>();

            while (RoomsPlaced.Count < Rooms.Count)
            {
                roomRows.Clear();
                Perimeter = Shaper.RectangleByArea(area * 0.5, Ratio);
                var roomRow = new RoomRow(Perimeter);
                roomRows.Add(roomRow);
                var i = 0;
                while (i < Rooms.Count)
                {
                    if (!roomRow.AddRoomFitted(Rooms[i], false))
                    {
                        break;
                    }
                    i++;
                }
                if (i == Rooms.Count)
                {
                    return;
                }
                var compass  = Perimeter.Compass();
                var row      = new Line(compass.SE, compass.SW);
                var matchRow = new RoomRow(row, area / row.Length());
                roomRows.Add(matchRow);
                while (i < Rooms.Count)
                {
                    if (!matchRow.AddRoomFitted(Rooms[i], false))
                    {
                        break;
                    }
                    i++;
                }
                Ratio += 0.1;
            }
            Rooms.Clear();
            foreach (var roomRow in roomRows)
            {
                foreach (var room in roomRow.Rooms)
                {
                    Rooms.Add(room);
                }
            }
            Perimeter = Footprint;
        }
        public byte[] Generate(Perimeter perimeter, IEnumerable <PointQRDto> points, Dictionary <Guid, Trap> traps)
        {
            var globalSettings = new GlobalSettings
            {
                ColorMode   = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize   = PaperKind.A4,
                Margins     = new MarginSettings {
                    Top = 10
                },
                DocumentTitle = $"QR {localizer["Codes"]} - {perimeter.Facility.Name}"
            };

            var pdf = new HtmlToPdfDocument()
            {
                GlobalSettings = globalSettings
            };

            var sheetBuilder = new StringBuilder();

            sheetBuilder.Append(@"<!DOCTYPE html><html><head><meta charset=""utf-8""/></head><body>");
            sheetBuilder.Append($@"<div style=""text-align:center; font-size:28px;font-weight:bold;"">{perimeter.Facility.Name}<hr/></div>");
            sheetBuilder.Append($@"<div style=""text-align:center; font-size:20px;"">Периметр - {perimeter.PerimeterName}</div><br/>");

            foreach (var point in points)
            {
                var identifier = JsonSerializer.Serialize(new QRID(perimeter.FacilityId, perimeter.Id, point.Order, point.TrapId), new JsonSerializerOptions {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                });

                var trapName = traps[point.TrapId].TrapName;
                var qr       = encryptionService.Encrypt(identifier);
                var qrName   = $"№{point.Order}, {trapName}";

                var imgTag = $@"
                            <div style=""display:inline-block; margin-right:5px; margin-left:5px;"">
                              <div style=""text-align:center; margin-bottom:2px;"">{qrName}</div>
                              {GetImgTag(qrCodeService.Generate(qr))}
                            </div>";

                sheetBuilder.Append(imgTag);
            }

            var objectSettings = new ObjectSettings
            {
                PagesCount     = true,
                HtmlContent    = sheetBuilder.ToString(),
                WebSettings    = { DefaultEncoding = "utf-8" },
                HeaderSettings = { FontName = "Arial", FontSize = 9, Right = string.Empty, Line = false },
                FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = $"QR Коди - {perimeter.Facility.Name}" }
            };

            pdf.Objects.Add(objectSettings);

            return(converter.Convert(pdf));;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Tests if a point is contained within this profile. Returns false for points that are outside of the profile (or within voids).
        /// </summary>
        /// <param name="point">The position to test.</param>
        /// <param name="containment">Whether the point is inside, outside, at an edge, or at a vertex.</param>
        /// <returns>True if the point is within the profile.</returns>
        public bool Contains(Vector3 point, out Containment containment)
        {
            IEnumerable <Line> allLines = Perimeter.Segments();

            if (Voids != null)
            {
                allLines = allLines.Union(Voids.SelectMany(v => v.Segments()));
            }
            return(Polygon.Contains(allLines, point, out containment));
        }
        [InlineData(PerimeterType.AdministrationFinanceAndControl, ElementTypes.Classified, 718.75)]                    // classified element (absent) with perimeter not covered
        public void GetResidualRiskEstimate_DifferentFunctionalPerimeters_ReturnRREstimate(
            PerimeterType perimeter, ElementTypes classification, double expectedvci
            )
        {
            Perimeter analysis = perimeters.FindByType(perimeter);

            double estimatedVCI = analysis.GetResidualRiskEstimate(classification);

            estimatedVCI.Should().Be(expectedvci);
        }
 void Copy(Scenario scenario)
 {
     Name = scenario.Name;
     Comments = scenario.Comments;
     ShowAllAnalysisPoints = scenario.ShowAllAnalysisPoints;
     ShowAllPerimeters = scenario.ShowAllPerimeters;
     ShowAllSpecies = scenario.ShowAllSpecies;
     StartTime = new TimeSpan(scenario.StartTime.Ticks);
     Duration = new TimeSpan(scenario.Duration.Ticks);
     TimePeriod = (TimePeriod)scenario.TimePeriod;
     Location = scenario.Location;
     Wind = scenario.Wind;
     SoundSpeed = scenario.SoundSpeed;
     Sediment = scenario.Sediment;
     Bathymetry = scenario.Bathymetry;
     // Here we map the old perimeter to the new perimeter so that the copied platform gets the proper perimeter
     var perimeterMap = new Dictionary<Guid, Guid>();
     foreach (var perimeter in scenario.Perimeters)
     {
         var newPerimeter = new Perimeter(perimeter) { Scenario = this };
         perimeterMap.Add(perimeter.Guid, newPerimeter.Guid);
         Perimeters.Add(newPerimeter);
     }
     var modeMap = new Dictionary<Guid, Guid>();
     var allModes = new List<Mode>();
     foreach (var platform in scenario.Platforms)
     {
         var newPlatform = new Platform(platform) { Scenario = this };
         // Make sure the new perimeter gets the proper copied perimeter from the original scenario
         if (platform.Perimeter != null) newPlatform.Perimeter = Perimeters.Find(p => p.Guid == perimeterMap[platform.Perimeter.Guid]);
         Platforms.Add(newPlatform);
         foreach (var source in platform.Sources)
         {
             var newSource = new Source(source) { Platform = newPlatform };
             newPlatform.Sources.Add(newSource);
             foreach (var mode in source.Modes)
             {
                 var newMode = new Mode(mode) { Source = newSource };
                 modeMap.Add(mode.Guid, newMode.Guid);
                 newSource.Modes.Add(newMode);
                 allModes.Add(newMode);
             }
         }
     }
     foreach (var analysisPoint in scenario.AnalysisPoints)
     {
         var newAnalysisPoint = new AnalysisPoint(analysisPoint) { Scenario = this };
         AnalysisPoints.Add(newAnalysisPoint);
         foreach (var transmissionLoss in analysisPoint.TransmissionLosses)
         {
             var newTransmissionLoss = new TransmissionLoss { AnalysisPoint = newAnalysisPoint, LayerSettings = new LayerSettings(transmissionLoss.LayerSettings) };
             foreach (var mode in transmissionLoss.Modes) 
                 newTransmissionLoss.Modes.Add(allModes.Find(m => m.Guid == modeMap[mode.Guid]));
             newAnalysisPoint.TransmissionLosses.Add(newTransmissionLoss);
             foreach (var radial in transmissionLoss.Radials)
             {
                 var newRadial = new Radial(radial) { TransmissionLoss = newTransmissionLoss };
                 newTransmissionLoss.Radials.Add(newRadial);
                 newRadial.CopyFiles(radial);
             }
         }
     }
     foreach (var species in scenario.ScenarioSpecies)
     {
         var newSpecies = new ScenarioSpecies(species) { Scenario = this };
         ScenarioSpecies.Add(newSpecies);
         newSpecies.CopyFiles(species);
     }
 }
Ejemplo n.º 33
0
 void DeletePerimeter(Perimeter perimeter)
 {
     perimeter.Delete();
     OnPropertyChanged("IsSaveScenarioCommandEnabled");
 }
Ejemplo n.º 34
0
 void EditPerimeter(Perimeter perimeter)
 {
     try
     {
         var locationGeoRect = (GeoRect)Scenario.Location.GeoRect;
         MapViewModel.EditablePolygonOverlayViewModel.GeoArray = (GeoArray)((GeoArray)perimeter).Closed;
         MapViewModel.EditablePolygonOverlayViewModel.IsVisible = true;
         MapViewModel.EditablePolygonOverlayViewModel.LocationBounds = locationGeoRect;
         MapViewModel.EditablePolygonOverlayViewModel.AreCrossingSegmentsAllowed = false;
         perimeter.RemoveMapLayers();
         foreach (var platform in Scenario.Platforms.Where(platform => (platform.Perimeter!=null && platform.Perimeter.Guid == perimeter.Guid))) platform.RemoveMapLayers();
         Globals.VisualizerService.ShowWindow("CreateOrEditPerimeterView",
                                new CreateOrEditPerimeterViewModel { EditablePolygonOverlayViewModel = MapViewModel.EditablePolygonOverlayViewModel, PerimeterName = perimeter.Name, DialogTitle = "Edit perimeter" },
                                true,
                                (sender, args) =>
                                {
                                    MapViewModel.EditablePolygonOverlayViewModel.IsVisible = false;
                                    var vm = (CreateOrEditPerimeterViewModel)args.State;
                                    if (!vm.IsCanceled)
                                    {
                                        perimeter.SetPerimeterCoordinates(MapViewModel.EditablePolygonOverlayViewModel.GeoArray);
                                        perimeter.Name = vm.PerimeterName;
                                    }
                                    perimeter.UpdateMapLayers();
                                    foreach (var platform in Scenario.Platforms.Where(platform => (platform.Perimeter!=null && platform.Perimeter.Guid == perimeter.Guid))) platform.UpdateMapLayers();
                                });
         OnPropertyChanged("IsSaveScenarioCommandEnabled");
     }
     catch (Exception e) { Globals.MessageBoxService.ShowError(e.Message); }
 }
Ejemplo n.º 35
0
 public static float UnitToSin(this float value, Perimeter perimeter)
 {
     return sines[(int)(value * Indexer), (int)perimeter];
 }
 //void Log(Scenario scenario, string message, params object[] args) { LogBase(new LogEntry(scenario) { Location = scenario.Location, Scenario = scenario }, message, args); }
 //void Log(Scenario scenario, EnvironmentalDataSet dataSet, string message, params object[] args) { LogBase(new LogEntry(dataSet) { Location = scenario.Location, EnvironmentalDataSet = dataSet, Scenario = scenario }, message, args); }
 //void Log(Platform platform, string message, params object[] args) { LogBase(new LogEntry(platform) { Location = platform.Scenario.Location, Scenario = platform.Scenario, Platform = platform }, message, args); }
 //void Log(Source source, string message, params object[] args) { LogBase(new LogEntry(source) { Location = source.Platform.Scenario.Location, Scenario = source.Platform.Scenario, Platform = source.Platform, Source = source }, message, args); }
 //void Log(Mode mode, string message, params object[] args) { LogBase(new LogEntry(mode) { Location = mode.Source.Platform.Scenario.Location, Scenario = mode.Source.Platform.Scenario, Platform = mode.Source.Platform, Source = mode.Source, Mode = mode }, message, args); }
 void Log(Perimeter perimeter, string message, params object[] args) { LogBase(new LogEntry(perimeter) { Location = perimeter.Scenario.Location, Scenario = perimeter.Scenario, Perimeter = perimeter }, message, args); }
 internal void Log(Perimeter perimeter, string message) { LogBase(new LogEntry(perimeter), message); }