Inheritance: MonoBehaviour
Example #1
0
        private string m_name = "Opening"; //name of opening

        #endregion Fields

        #region Constructors

        /// <summary>
        /// The default constructor
        /// </summary>
        /// <param name="opening">Opening in Revit</param>
        public OpeningProperty(Opening opening)
        {
            if (null == opening)
            {
                throw new ArgumentNullException();
            }

            //get parameters which need to show
            m_name = opening.Name;
            m_elementId = opening.Id.IntegerValue.ToString();

            if (null != opening.Host)
            {
                if (null != opening.Host.Category)
                    m_hostName = opening.Host.Category.Name;

                m_hostElementId = opening.Host.Id.IntegerValue.ToString();
            }

            if (null != opening.Category)
            {
                if ("Shaft Openings" == opening.Category.Name)
                    m_isShaft = true;
            }
        }
Example #2
0
                /// <summary>
                /// Performs the <see cref="TopHat"/> operator on the given
                /// <see cref="Matrix"/>.
                /// </summary>
                /// <remarks>
                /// Performs morphological top-hat filtering on a grayscale or 
                /// binary input image using the applied structuring element.
                /// </remarks>
                /// <param name="src">
                /// The <see cref="Matrix"/> which should be used by the
                /// operator.
                /// </param>
                /// <returns> The filtered <see cref="Matrix"/>. </returns>
                public Matrix Execute (Matrix src)
                {
                        Opening opening = new Opening (this.se);

                        Matrix opened = opening.Execute (src);

                        return ((src.isLogical()) ? 
                                (src & (!opened)) : (src - opened));
                }
Example #3
0
        private void AddOpening(Company v)
        {
            var randomJob           = JobService.GetAllJobs()[random.Next(100)];
            var randomQualification = QualificationsService.GetAllQualifications()[random.Next(10)];
            var newOpening          = new Opening()
            {
                Company = v,
                Job     = randomJob,
                RequiredQualification = randomQualification
            };

            OpeningService.AddOpening(newOpening);
        }
Example #4
0
        public static Opening Transform(this Opening opening, TransformMatrix transform, double tolerance = Tolerance.Distance)
        {
            if (!transform.IsRigidTransformation(tolerance))
            {
                BH.Engine.Reflection.Compute.RecordError("Transformation failed: only rigid body transformations are currently supported.");
                return(null);
            }

            Opening result = opening.ShallowClone();

            result.CoordinateSystem = result.CoordinateSystem.Transform(transform);
            return(result);
        }
        public static List <Opening> SplitOpeningByGeometry(this Opening opening, List <Polyline> polylines)
        {
            List <Opening> openings = new List <Opening>();

            foreach (Polyline p in polylines)
            {
                Opening pan = opening.GetShallowClone(true) as Opening;
                pan.Edges = p.ToEdges();
                openings.Add(pan);
            }

            return(openings);
        }
        public void InsertOpening(Opening aOpening)
        {
            CheckPermission(Permission.EDIT_BLUEPRINT);

            blueprint.InsertOpening(aOpening);

            if (!templates.Exists(aOpening.getTemplate()))
            {
                templates.Add(aOpening.getTemplate());
            }
            repository.Modify(blueprint);
            HasBeenModify = true;
        }
Example #7
0
        public static MaterialComposition MaterialComposition(this Opening opening)
        {
            if (opening == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the material composition of a null opening.");
                return(null);
            }

            if (opening.OpeningConstruction == null && opening.Edges == null)
            {
                Engine.Reflection.Compute.RecordError("The Opening does not have any constructions assigned");
                return(null);
            }

            List <MaterialComposition> comps = new List <MaterialComposition>();
            List <double> ratios             = new List <double>();

            double glazedVolume = 0;

            if (opening.OpeningConstruction != null && opening.OpeningConstruction.IThickness() > oM.Geometry.Tolerance.Distance)
            {
                if (opening.Edges != null && opening.Edges.Count != 0)
                {
                    double glazedArea = opening.ComponentAreas().Item1;
                    glazedVolume = glazedArea * opening.OpeningConstruction.IThickness();
                }
                else
                {
                    glazedVolume = opening.Area() * opening.OpeningConstruction.IThickness();
                }
                comps.Add(opening.OpeningConstruction.IMaterialComposition());
                ratios.Add(glazedVolume);
            }

            foreach (FrameEdge edge in opening.Edges)
            {
                if (edge.FrameEdgeProperty != null)
                {
                    comps.Add(edge.MaterialComposition());
                    ratios.Add(edge.SolidVolume());
                }
            }

            if (comps.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordError("The Opening does not have any constructions assigned to get an aggregated material composition from");
                return(null);
            }

            return(BH.Engine.Matter.Compute.AggregateMaterialComposition(comps, ratios));
        }
Example #8
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
                                                ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "External Tool");

            try
            {
                transaction.Start();
                Application app         = commandData.Application.Application;
                bool        haveOpening = false;

                //search Opening in Revit
                List <OpeningInfo>      openingInfos = new List <OpeningInfo>();
                FilteredElementIterator iter         = (new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document)).OfClass(typeof(Opening)).GetElementIterator();
                iter.Reset();
                while (iter.MoveNext())
                {
                    Object obj = iter.Current;
                    if (obj is Opening)
                    {
                        haveOpening = true;
                        Opening     opening     = obj as Opening;
                        OpeningInfo openingInfo = new OpeningInfo(opening, commandData.Application);
                        openingInfos.Add(openingInfo);
                    }
                }

                if (!haveOpening)
                {
                    message = "don't have opening in the project";
                    return(Autodesk.Revit.UI.Result.Cancelled);
                }

                //show dialogue
                using (OpeningForm openingForm = new OpeningForm(openingInfos))
                {
                    openingForm.ShowDialog();
                }
            }
            catch (Exception e)
            {
                message = e.ToString();
                return(Autodesk.Revit.UI.Result.Failed);
            }
            finally
            {
                transaction.Commit();
            }

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Example #9
0
        /// <summary>
        /// Handle the display of the notification based on the current StackMode
        /// </summary>
        /// <param name="notificationOptions">Information about the notification to display</param>
        private void Show(NotificationOptions notificationOptions)
        {
            var eventArgs = new InAppNotificationOpeningEventArgs();

            Opening?.Invoke(this, eventArgs);

            if (eventArgs.Cancel)
            {
                return;
            }

            var shouldDisplayImmediately = true;

            switch (StackMode)
            {
            case StackMode.Replace:
                _stackedNotificationOptions.Clear();
                _stackedNotificationOptions.Add(notificationOptions);
                break;

            case StackMode.StackInFront:
                _stackedNotificationOptions.Insert(0, notificationOptions);
                break;

            case StackMode.QueueBehind:
                _stackedNotificationOptions.Add(notificationOptions);
                shouldDisplayImmediately = _stackedNotificationOptions.Count == 1;
                break;

            default:
                break;
            }

            if (shouldDisplayImmediately)
            {
                Visibility = Visibility.Visible;
                VisualStateManager.GoToState(this, StateContentVisible, true);

                UpdateContent(notificationOptions);

                if (notificationOptions.Duration > 0)
                {
                    _dismissTimer.Interval = TimeSpan.FromMilliseconds(notificationOptions.Duration);
                    _dismissTimer.Start();
                }
                else
                {
                    _dismissTimer.Stop();
                }
            }
        }
Example #10
0
        public async Task <IActionResult> CreateRole(RoleViewModel roleViewModel)
        {
            var     userId           = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var     viewOpening      = roleViewModel.Opening;
            Opening newOpening       = new Opening();
            var     currentProjectId = roleViewModel.Project.Id;

            newOpening           = viewOpening;
            newOpening.ProjectId = currentProjectId;
            _context.Openings.Add(newOpening);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(ProjectIndex)));
        }
Example #11
0
        private void fillHoleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GrayscaleBT709 greyscale = new GrayscaleBT709();
            Bitmap         grey      = greyscale.Apply(skin);
            Threshold      filter    = new Threshold(100);

            filter.ApplyInPlace(grey);
            Closing close = new Closing();
            Bitmap  j     = close.Apply(grey);
            Opening open  = new Opening();

            k = open.Apply(j);
            pictureBox3.Image = k;
        }
Example #12
0
        public static Opening TogbXML(this Aperture aperture, int cADObjectIdSufix = -1, double tolerance = Core.Tolerance.MicroDistance)
        {
            if (aperture == null)
            {
                return(null);
            }

            PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D;

            if (planarBoundary3D == null)
            {
                return(null);
            }

            ApertureConstruction apertureConstruction = aperture.ApertureConstruction;

            if (apertureConstruction == null)
            {
                return(null);
            }

            string name = aperture.Name;

            if (string.IsNullOrWhiteSpace(name))
            {
                name = aperture.ApertureConstruction.Name;
            }

            Opening opening = new Opening();

            //opening.constructionIdRef = Core.gbXML.Query.Id(aperture.ApertureConstruction, typeof(gbXMLSerializer.Construction));
            opening.Description = name;
            opening.id          = Core.gbXML.Query.Id(aperture, typeof(Opening));

            if (cADObjectIdSufix == -1)
            {
                opening.Name = string.Format("{0} [{1}]", name, aperture.Guid);
            }
            else
            {
                opening.Name = string.Format("{0} [{1}]", name, cADObjectIdSufix);
            }

            opening.openingType = Query.OpeningTypeEnum(aperture.ApertureConstruction.ApertureType);
            opening.pg          = planarBoundary3D.TogbXML(tolerance);
            opening.rg          = planarBoundary3D.TogbXML_RectangularGeometry(tolerance);
            opening.CADObjectId = Query.CADObjectId(aperture, cADObjectIdSufix);

            return(opening);
        }
Example #13
0
    private City FindMatching(Opening opening, List <City> allCities)
    {
        int startCoordinate = Random.Range(0, allCities.Count);

        for (int i = 0; i < allCities.Count; i++)
        {
            City city = allCities[(i + startCoordinate) % allCities.Count];
            if (Matches(opening, city))
            {
                return(city);
            }
        }
        return(null);
    }
Example #14
0
        public ActionResult AddOpening(Opening opening)
        {
            OpeningTestRepo repo = new OpeningTestRepo();

            repo.AddOpening(opening);
            if (ModelState.IsValid)
            {
                return(RedirectToAction("Openings"));
            }
            else
            {
                return(View(opening));
            }
        }
 private void PaintWindow(Opening opening)
 {
     using (Graphics graphics = Graphics.FromImage(openingLayer)) {
         System.Drawing.Point   center = LogicPointIntoDrawablePoint(opening.GetPosition());
         System.Drawing.Point[] points =
         {
             new System.Drawing.Point(center.X + 5, center.Y + 5),
             new System.Drawing.Point(center.X - 5, center.Y + 5),
             new System.Drawing.Point(center.X + 5, center.Y - 5),
             new System.Drawing.Point(center.X - 5, center.Y - 5)
         };
         graphics.DrawPolygon(windowPen, points);
     }
 }
        private void InsertAndDrawOpening(Opening newOpening)
        {
            try
            {
                editor.InsertOpening(newOpening);
            }
            catch (Exception)
            {
                //error message
            }

            PaintOpenings();
            calulateCostsAndPrices();
        }
        private static IfcOpeningElement ToIfc(this Opening opening, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape)
        {
            var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(id),
                                                   null,
                                                   null,
                                                   null,
                                                   null,
                                                   localPlacement,
                                                   shape,
                                                   null,
                                                   IfcOpeningElementTypeEnum.OPENING);

            return(ifcOpening);
        }
        public static Opening AssignGenericConstructions(this Opening opening)
        {
            if (opening == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot assign the generic constructions to a null opening.");
                return(null);
            }

            Opening cloned = opening.DeepClone <Opening>();

            List <Construction> constructions = BH.Engine.Library.Query.Library("GenericConstructions").Select(x => x as Construction).ToList();

            if (constructions.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordError("The dataset for generic Environment constructions did not exist within your datasets. Generic Constructions cannot be assigned.");
                return(cloned);
            }

            if (cloned.OpeningConstruction != null)
            {
                BH.Engine.Reflection.Compute.RecordWarning(string.Format("The construction for the opening with GUID {0} was not null and will be replaced with a generic construction", cloned.BHoM_Guid));
            }
            else
            {
                BH.Engine.Reflection.Compute.RecordNote(string.Format("The construction for the opening with GUID {0} was automatically assigned a generic construction", cloned.BHoM_Guid));
            }

            switch (cloned.Type)
            {
            case OpeningType.CurtainWall:
            case OpeningType.Door:
            case OpeningType.Frame:
            case OpeningType.Glazing:
            case OpeningType.Hole:
            case OpeningType.Rooflight:
            case OpeningType.RooflightWithFrame:
            case OpeningType.Undefined:
            case OpeningType.VehicleDoor:
            case OpeningType.Window:
            case OpeningType.WindowWithFrame:
                cloned.OpeningConstruction = constructions.Where(x => x.Name == "generic_window").FirstOrDefault();
                break;

            default:
                cloned.OpeningConstruction = constructions.Where(x => x.Name == "generic_window").FirstOrDefault();
                break;
            }

            return(cloned);
        }
Example #19
0
        public static int InsertNewOpening(Opening open, string inputContent)
        {
            //insert general information
            new OpeningDAL().Insert(open);

            //insert open move
            ArrayList stepOpening = CommonService.OpeningStep(inputContent);

            foreach (string step in stepOpening)
            {
                new OpeningSequenceDAL().Insert(step);
            }
            return(0);
        }
Example #20
0
    public static Opening getInstance()
    {
        if (opening == null)
        {
            opening = FindObjectOfType <Opening> ();

            if (opening == null)
            {
                GameObject container = new GameObject("Opening");

                opening = container.AddComponent <Opening> ();
            }
        }
        return(opening);
    }
        protected void CreateOpeningGeometries(Opening opening)
        {
            CreateBeamElementGeometry(new BuildingStructuralElements.BeamElement() { BeamType = new Beam(),SNode = new Point( 0,0,0),ENode = new Point( 10,0,0)});
            //CreateBeamElementGeometry(new BuildingStructuralElements.BeamElement() { BeamType = new Column(), SNode = new Point(0, 0, 0) });
            //opening.Edges.ForEach(e =>
            //{

            //    if (e.IsVertical())
            //        geometries.Add(
            //            CreateBeamElementGeometry(new NErgy.Silverlight.BeamElement(e) { BeamType = new Column() }));
            //    if (e.IsHorizontal())
            //        geometries.Add(
            //                CreateBeamElementGeometry(new NErgy.Silverlight.BeamElement(e) { BeamType = new Beam() }));
            //});
        }
Example #22
0
        public void Area()
        {
            // A floor with two holes punched in it.
            var p1        = Polygon.Rectangle(1, 1);
            var p2        = Polygon.Rectangle(1, 1);
            var o1        = new Opening(p1, 1, 1);
            var o2        = new Opening(p2, 3, 3);
            var floorType = new FloorType("test", 0.2);
            var floor     = new Floor(Polygon.Rectangle(10, 10), floorType, 0.0, null, new List <Opening>()
            {
                o1, o2
            });

            Assert.Equal(100.0, floor.Area());
        }
Example #23
0
        async Task InternalOpenAsync(TimeSpan timeout)
        {
            State = CommunicationState.Opening;
            if (Opening != null)
            {
                Opening.Invoke(this, EventArgs.Empty);
            }
            await OpenAsync(timeout);

            State = CommunicationState.Opened;
            if (Opened != null)
            {
                Opened.Invoke(this, EventArgs.Empty);
            }
        }
Example #24
0
        public static IDictionary <DayOfWeek, OpeningDay> GetOpening(Opening opening)
        {
            Dictionary <DayOfWeek, OpeningDay> Opening = new Dictionary <DayOfWeek, OpeningDay>
            {
                { DayOfWeek.Monday, opening.Monday },
                { DayOfWeek.Tuesday, opening.Tuesday },
                { DayOfWeek.Wednesday, opening.Wednesday },
                { DayOfWeek.Thursday, opening.Thursday },
                { DayOfWeek.Friday, opening.Friday },
                { DayOfWeek.Saturday, opening.Saturday },
                { DayOfWeek.Sunday, opening.Sunday }
            };

            return(Opening);
        }
Example #25
0
        public static double FrameFactor(this Opening opening)
        {
            if (opening.InnerEdges == null || opening.InnerEdges.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordWarning($"This opening with ID {opening.BHoM_Guid} does not contain any inner edges for the calculation. Assuming a 0% frame factor");
                return(0);
            }

            double outerArea = opening.Polyline().Area();
            double innerArea = opening.InnerEdges.Polyline().Area();

            double frameArea = outerArea - innerArea;

            return(frameArea / outerArea);
        }
Example #26
0
        public static Opening SetGeometry(this Opening opening, Cartesian coordinateSystem)
        {
            if (opening == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot set the geometry of a null opening.");
                return(null);
            }

            Opening clone = opening.ShallowClone();

            clone.CoordinateSystem = coordinateSystem;

            BH.Engine.Reflection.Compute.RecordWarning("Only the coordinate system of the opening has been updated - to update its dimension, please modify relevant properties of the Profile.");
            return(clone);
        }
Example #27
0
        private bool OnIsCoerceValue(bool baseValue)
        {
            var ev = new CancelEventArgs(false);

            if (baseValue)
            {
                Opening?.Invoke(this, ev);
                return(!ev.Cancel);
            }
            else
            {
                Closing?.Invoke(this, ev);
                return(ev.Cancel);
            }
        }         // proc OnIsCoerceValue
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static double MaxDiagonal(this Opening opening)
        {
            if (opening.Profile is CircleProfile)
            {
                return(((CircleProfile)opening.Profile).Diameter);
            }
            else if (opening.Profile is RectangleProfile)
            {
                return(Math.Sqrt(Math.Pow(((RectangleProfile)opening.Profile).Height, 2) + Math.Pow(((RectangleProfile)opening.Profile).Width, 2)));
            }
            else
            {
                return(double.NaN);
            }
        }
Example #29
0
        public void Init()
        {
            if (m_CurrentPetIndex == account.petsList.Count)//MainForm.ActualMainForm.MainRunning.CurrentBot.PetsList.Count)
            {
                //MainForm.ActualMainForm.MainRunning.NextBot();
                account.SetNextMeal();
                return;
            }

            if ((CheckTime(account.petsList[m_CurrentPetIndex])) ||
                ((m_Feeding != null) && (m_Feeding.SecondFeeding)))
            {
                if (
                    account.petsList[m_CurrentPetIndex].Informations.Position == 8)
                {
                    Console.WriteLine();
                }

                if (account.petsList[m_CurrentPetIndex].FoodList.Count == 0)
                {
                    if (account.Safe == null)
                    {
                        NoFood();
                        return;
                    }

                    if (!m_OnSafe)
                    {
                        m_OnSafe   = true;
                        m_Openning = new Opening();
                        m_Openning.Init(account);
                        return;
                    }

                    LeavingFoodToSafe();
                    return;
                }

                m_Feeding = new Feeding(account);
                m_Feeding.Init(account.petsList[m_CurrentPetIndex]);
                account.Wait(500, 1000);
                m_CurrentPetIndex++;
                return;
            }

            m_CurrentPetIndex++;
            Init();
        }
Example #30
0
        /// <summary>
        ///     Returns true if PriceBase instances are equal
        /// </summary>
        /// <param name="other">Instance of PriceBase to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PriceBase other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Opening == other.Opening ||
                     Opening != null &&
                     Opening.Equals(other.Opening)
                 ) &&
                 (
                     Closing == other.Closing ||
                     Closing != null &&
                     Closing.Equals(other.Closing)
                 ) &&
                 (
                     Highest == other.Highest ||
                     Highest != null &&
                     Highest.Equals(other.Highest)
                 ) &&
                 (
                     Lowest == other.Lowest ||
                     Lowest != null &&
                     Lowest.Equals(other.Lowest)
                 ) &&
                 (
                     Volume == other.Volume ||
                     Volume != null &&
                     Volume.Equals(other.Volume)
                 ) &&
                 (
                     Turnover == other.Turnover ||
                     Turnover != null &&
                     Turnover.Equals(other.Turnover)
                 ));
        }
Example #31
0
        public void Open(Point mousePos, int showDelayPeriod, object sender, MouseEventArgs e)
        {
            if (!MenuPopup.IsOpen)
            {
                if (!OpenMenuList.Contains(this))
                {
                    OpenMenuList.Add(this);
                }
                UIElement LayoutRoot = GetRootLayoutElement((FrameworkElement)sender);
                ClickedElements       = VisualTreeHelper.FindElementsInHostCoordinates(mousePos, LayoutRoot);
                RootGrid.Margin       = new Thickness(mousePos.X - 200 + OffsetX, mousePos.Y + OffsetY, 0, 0);
                ListBox.SelectedIndex = -1; // Reset selected item

                // Invoking the event via a dispatcher to make sure the visual tree for our listbox is created before the event handler is called
                if (Opening != null)
                {
                    ListBox.Dispatcher.BeginInvoke(() => Opening.Invoke(sender, e));
                }

                RootGrid.Width = 0;

                _timerOpen          = new DispatcherTimer();
                _timerOpen.Interval = TimeSpan.FromMilliseconds(showDelayPeriod);
                _timerOpen.Tick    += delegate
                {
                    _timerOpen.Stop();
                    // If menu has not already been closed by hovering on the outergrid
                    if (MenuPopup.IsOpen)
                    {
                        // Remove Width = 0 constraint set originally
                        RootGrid.Width = double.NaN;
                        if (Showing != null)
                        {
                            Showing.Invoke(sender, e);
                        }
                        Animate(RootGrid, "UIElement.Opacity", 0, 1, TimeSpan.FromMilliseconds(HoverShowDelay));
                        //Animate(ListBox, "(UIElement.Projection).(PlaneProjection.RotationY)", 90, 0, TimeSpan.FromMilliseconds(200));
                        if (Shown != null)
                        {
                            Shown.Invoke(sender, e);
                        }
                    }
                };
                _timerOpen.Start();

                MenuPopup.IsOpen = true;
            }
        }
        public static Bitmap ProcessImage(string imagePath)
        {
            var img = AForge.Imaging.Image.FromFile(imagePath);

            ContrastStretch filterContrastStretch = new ContrastStretch();

            filterContrastStretch.ApplyInPlace(img);

            try
            {
                img = Grayscale.CommonAlgorithms.BT709.Apply(img);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("The image should not be grayscale");
            }

            Opening filterOpening = new Opening();

            filterOpening.ApplyInPlace(img);

            SobelEdgeDetector sobel = new SobelEdgeDetector();

            sobel.ApplyInPlace(img);

            Closing filterClosing = new Closing();

            filterClosing.ApplyInPlace(img);

            Threshold threshold = new Threshold(100);

            threshold.ApplyInPlace(img);

            FillHoles fillHoles = new FillHoles();

            fillHoles.MaxHoleWidth         = img.Width;
            fillHoles.MaxHoleHeight        = img.Height;
            fillHoles.CoupledSizeFiltering = false;
            fillHoles.ApplyInPlace(img);

            filterOpening.ApplyInPlace(img);

            Erosion filterErosion = new Erosion();

            filterErosion.ApplyInPlace(img);

            return(img);
        }
Example #33
0
        //Accept Pending Application
        public async Task <IActionResult> AcceptPendingApplication(int Id)
        {
            var pendingApplication = await _context.PendingApplications.FirstOrDefaultAsync(m => m.Id == Id);

            var     userId  = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Opening opening = await _context.Openings.FirstOrDefaultAsync(m => m.Id == pendingApplication.OpeningId);

            var developer = await _context.Developers.FirstOrDefaultAsync(a => a.Id == pendingApplication.DeveloperId);

            var project = await _context.Projects.FirstOrDefaultAsync(m => m.Id == opening.ProjectId);

            var projectName = _context.Projects.Where(m => m.Id == opening.ProjectId).Select(m => m.Name).FirstOrDefault();

            var           currentUser   = _context.Users.FirstOrDefault(m => m.Id == userId);
            ProjectMember projectMember = new ProjectMember();

            projectMember.DeveloperId = pendingApplication.DeveloperId;
            projectMember.JoinDate    = DateTime.Now;
            projectMember.Email       = pendingApplication.Email;
            projectMember.RoleId      = developer.RoleId;
            projectMember.ProjectId   = opening.ProjectId;
            opening.IsFilled          = true;
            await _context.ProjectMembers.AddAsync(projectMember);


            //SendGrid API
            var apiKey           = API_KEYS.SendGridAPI;
            var client           = new SendGridClient(apiKey);
            var from             = new EmailAddress(currentUser.Email);
            var to               = new EmailAddress(pendingApplication.Email, developer.UserName);
            var subject          = "Your application has been accepted for project: " + projectName;
            var plainTextContent = "Here is your link to joing the githubt repository! Link: " + project.GithubUrl;
            var htmlContent      = "<strong>Get your CodeSquad on!!! </strong>" + plainTextContent;
            var msg              = MailHelper.CreateSingleEmail(
                from,
                to,
                subject,
                plainTextContent,
                htmlContent
                );

            var response = await client.SendEmailAsync(msg);

            _context.PendingApplications.Remove(pendingApplication);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(ProjectIndex)));
        }
Example #34
0
        private WireFrame m_sketch; //Profile information of opening

        #endregion Fields

        #region Constructors

        /// <summary>
        /// The default constructor, 
        /// get the information we want from Opening
        /// get OpeningProperty, BoundingBox and Profile
        /// </summary>
        /// <param name="opening">an opening in revit</param>
        /// <param name="app">application object</param>
        public OpeningInfo(Opening opening, UIApplication app)
        {
            m_opening = opening;
            m_revit = app;

            //get OpeningProperty which can use in PropertyGrid control
            OpeningProperty openingProperty = new OpeningProperty(m_opening);
            m_property = openingProperty;

            //get BoundingBox of Opening
            BoundingBoxXYZ boxXYZ = m_opening.get_BoundingBox(m_revit.ActiveUIDocument.Document.ActiveView);
            BoundingBox boundingBox = new BoundingBox(boxXYZ);
            m_boundingBox = boundingBox;

            //get profile
            GetProfile();
        }
 public void AddOpeningToView(Opening opening)
 {
     CreateOpeningGeometries(opening);
     geometries.ForEach(((ControllerBase<object,Geometry>) this).AddGeometryToView);
 }
Example #36
0
        private void Stream( ArrayList data, Opening opn )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( Opening ) ) );

              data.Add( new Snoop.Data.Enumerable( "Boundary curves", opn.BoundaryCurves ) );
              data.Add( new Snoop.Data.Bool( "Is boundary rect", opn.IsRectBoundary ) );
              data.Add( new Snoop.Data.Enumerable( "Boundary rect", opn.BoundaryRect ) );
              data.Add( new Snoop.Data.Object( "Host", opn.Host ) );
        }
    private GameObject FindBridgeAnchor(GameObject island, Opening opening)
    {
        BridgeOpening[] islandAnchors;
        islandAnchors = island.GetComponentsInChildren<BridgeOpening>();

        foreach (BridgeOpening anchor in islandAnchors) {
            if (anchor.opening == opening)
                return anchor.gameObject;
        }
        Debug.LogError("Couldn't find bridge anchor for island: " + island.name);
        return null;
    }
Example #38
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="app"></param>
 /// <param name="opening"></param>
 /// <returns></returns>
 private static Revit.Element CloneElement( Autodesk.Revit.UI.UIApplication app, Opening opening )
 {
     Opening openingClone = app.ActiveUIDocument.Document.Create.NewOpening( opening.Host, opening.BoundaryCurves, true );
       Utils.ParamUtil.SetParameters( openingClone.Parameters, opening.Parameters );
       return openingClone;
 }
            private void OnGameLoaded(object o,
						   GameLoadedEventArgs args)
            {
                PGNChessGame game = args.Game;
                Opening opening = new Opening ();
                opening.ecoName =
                    game.GetTagValue ("Site", null);
                opening.name =
                    game.GetTagValue ("White", null);
                opening.variation =
                    game.GetTagValue ("Black", null);
                opening.moves = game.Moves;
                if (opening.ecoName != null
                    && opening.name != null)
                    db.AddOpening (opening);
                else
                    Console.WriteLine
                        (Catalog.
                         GetString
                         ("skipping this opening. econame = [{0}], name = [{1}]"),
                         opening.ecoName,
                         opening.name);
            }
Example #40
0
 private City FindMatching(Opening opening, List<City> allCities)
 {
     int startCoordinate = Random.Range(0, allCities.Count);
     for (int i = 0; i < allCities.Count; i++) {
         City city = allCities[(i + startCoordinate) % allCities.Count];
         if (Matches(opening, city)) {
             return city;
         }
     }
     return null;
 }
Example #41
0
 private bool Matches(Opening opening, City city)
 {
     var openingRow = opening.row;
     var cityRow = city.GetBorder(opening.dir.Opposite());
     return cityRow != null && cityRow.Matches(openingRow);
 }