Exemple #1
0
        private List <Dimension> CreateDimensions(
            Document doc,
            GridParameters p,
            List <Grid> grid)
        {
            /*
             * This method create dimensions between grid axes,
             * for all orientations, one dimension line by one orientation
             */

            List <Dimension> dimensions = new List <Dimension>();

            // The view in which the dimensions will be drawn
            View view = GetView(doc);

            Orientation[] orientations = p.GetOrientations().ToArray();

            Dictionary <Orientation, List <Grid> > gridsByOrientations
                = DivideGridByOrientation(p, grid, orientations.ToList());

            foreach (Orientation orientation in orientations)
            {
                if (p.GetNumber(orientation) > 1)
                {
                    CreateDimensionForOrientation(
                        doc,
                        gridsByOrientations,
                        view,
                        p,
                        orientation);
                }
            }

            return(dimensions);
        }
        public void InitializeParameters(
            SetParametersForm form,
            ref GridParameters gridParameters,
            ref LevelsParameters levelsParameters,
            DisplayUnitType unit)
        {
            /*
             * This method parse user input from form, convert to internal units,
             * and place values in parameters sets
             */

            /// Parsing user input in numbers fields
            gridParameters.numVert    = Int32.Parse(form.verticalAxesNumber);
            gridParameters.numHoriz   = Int32.Parse(form.horizontalAxesNumber);
            levelsParameters.numLevel = Int32.Parse(form.levelsNumber);

            /// Parsing user input in distance fields and convert to internal units
            gridParameters.distVert = UnitUtils.ConvertToInternalUnits(
                Double.Parse(form.verticalAxesDistance), unit);

            gridParameters.distHoriz = UnitUtils.ConvertToInternalUnits(
                Double.Parse(form.horizontalAxesDistance), unit);

            levelsParameters.distLevel = UnitUtils.ConvertToInternalUnits(
                Double.Parse(form.levelsDistance), unit);
        }
Exemple #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ProductGridViewModel()
        {
            GetProductData();

            ProductGridParameters = new GridParameters <ProductModel>()
            {
                GridTitle               = "Sample Data " + ProductList.Count.ToString("N0") + " records",
                GridTitleColor          = "darkblue",
                GridTableColor          = "darkblue",
                DataList                = ProductList,
                BootstrapColumnClass    = "col-lg",
                BootstrapContainerClass = "container-fluid",
                ShowEditColumn          = true,
                EditButtonText          = "Edit",
                PrimaryKeyName          = "ProductId",
                ShowFilterRow           = true,
                ShowAddNew              = true,
                ShowPager               = true,
                PageSize                = 8,
                SummaryColumnName       = nameof(ProductModel.UnitsInStock),
                SummaryFormat           = "n0",
                SummaryTitle            = "Total Units In Stock:",
                SummaryType             = GridParameters <ProductModel> .SummaryTypeEnum.Sum
            };
        }
Exemple #4
0
        private Dictionary <Orientation, List <Grid> > DivideGridByOrientation(
            GridParameters p,
            List <Grid> grid,
            List <Orientation> orientations)
        {
            Dictionary <Orientation, List <Grid> > gridsByOrientation
                = new Dictionary <Orientation, List <Grid> >();

            int count = default;

            foreach (Orientation orientation in orientations)
            {
                int         linesByOrientation = p.GetNumber(orientation);
                List <Grid> oneOrientationGrid = new List <Grid>();

                for (int i = 0, n = linesByOrientation; i < n; i++)
                {
                    oneOrientationGrid.Add(grid[count + i]);
                }

                count += linesByOrientation;

                gridsByOrientation.Add(orientation, oneOrientationGrid);
            }

            return(gridsByOrientation);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public SalesGridViewModel()
        {
            GetSalesData();                   //get the sample data from the CSV file
            //GetSalesDataFromSqlServer();     //get the sample data from the database

            SalesGridParameters = new GridParameters <SalesModel>()
            {
                GridTitle               = "Sample Data " + SalesList.Count.ToString("N0") + " records",
                GridTitleColor          = "darkgreen",
                GridTableColor          = "darkgreen",
                DataList                = SalesList,
                BootstrapColumnClass    = "col-md",
                BootstrapContainerClass = "container-fluid",
                ShowEditColumn          = false,
                EditButtonText          = "Edit",
                PrimaryKeyName          = "OrderId",
                ShowFilterRow           = true,
                ShowAddNew              = false,
                ShowPager               = true,
                PageSize                = 1000,
                SummaryColumnName       = nameof(SalesModel.TotalProfit),
                SummaryFormat           = "n2",
                SummaryTitle            = "Total Profit:",
                SummaryType             = GridParameters <SalesModel> .SummaryTypeEnum.Sum
            };
        }
Exemple #6
0
 public void CopyTo(GridParameters other)
 {
     other.xSize      = xSize;
     other.ySize      = ySize;
     other.scanHeight = scanHeight;
     other.xDimension = xDimension;
     other.yDimension = yDimension;
     other.gridType   = gridType;
 }
Exemple #7
0
        List <Grid> CreateAxesGrid(
            Document doc,
            GridParameters p)
        {
            List <Grid> list = new List <Grid>();

            foreach (Orientation orientation in p.GetOrientations())
            {
                list.AddRange(CreateAxes(doc, p, orientation));
            }

            return(list);
        }
        private ActionResult BindUserList(UserModel model)
        {
            if (TempData["message"] != null)
            {
                model.MessageClass  = (string)TempData["MessageClass"];
                model.IsShowMessage = 1;
                model.Message       = (string)TempData["message"];
            }
            else
            {
                model.MessageClass  = "";
                model.IsShowMessage = 0;
                model.Message       = "";
            }

            //get grid parameters from URL/POST (if any)
            var activeGridParameters = GridParameters.GetGridParameters();
            int pageSize             = 10; //displayed rows per page


            model.Flag   = 1;
            model.Status = 1;
            AdminUserHelper objAdminUserHelper = new AdminUserHelper();



            ActiveUserList = objAdminUserHelper.GetAdminUserByStatus(model).ToList(); //.Where(x => x.IsSuper != 1)
            var ActiveUser = GetUserDataUsingLINQ(activeGridParameters.Sort,          //order by column
                                                  activeGridParameters.SortDirection, //order by direction
                                                  activeGridParameters.Page ?? 1,     //returned page
                                                  pageSize, ActiveUserList);          //displayed rows per page


            model.Status = 0;
            var InActiveGridParameters = GridParameters.GetGridParameters();

            InActiveUserList = objAdminUserHelper.GetAdminUserByStatus(model);
            var InActiveUser = GetUserDataUsingLINQ(InActiveGridParameters.Sort,          //order by column
                                                    InActiveGridParameters.SortDirection, //order by direction
                                                    InActiveGridParameters.Page ?? 1,     //returned page
                                                    pageSize, InActiveUserList);          //displayed rows per page


            //set record count for use in view


            ViewBag.ActiveGridRecordCount   = ActiveUserList.Count;
            ViewBag.InActiveGridRecordCount = InActiveUserList.Count;

            return(View(Tuple.Create(ActiveUser, InActiveUser, model)));
        }
Exemple #9
0
        public MainForm()
        {
            InitializeComponent();

            gridParameters = new GridParameters(6, 4)
            {
                Shirt  = Image.FromFile(Path.Combine(Application.StartupPath, "Resources\\Shirt.png")),
                Images = new ImageLoader().LoadImages(Path.Combine(Application.StartupPath, "Resources\\Images"))
            };

            mainTableControl.EndGame += MainTableControl_EndGame;

            mainTableControl.GridParameters = gridParameters;
            mainTableControl.SetCards(new PairsGenerator().GenerateCards(gridParameters));
        }
        public CardParameters[] GenerateCards(GridParameters gridParameters)
        {
            int width  = gridParameters.Width;
            int height = gridParameters.Height;

            if (width * height % 2 == 1)
            {
                throw new ArgumentException("Количество ячеек должно быть чётным.");
            }

            Image shirt = gridParameters.Shirt;

            Image[] images = gridParameters.Images;

            var cardParameters = new CardParameters[height, width];
            var random         = new Random();

            int cardCounter = 0;

            while (cardCounter < width * height)
            {
                var hiddenImageForPair = images[random.Next(0, images.Length)];

                int pairsCounter = 0;

                do
                {
                    int column = random.Next(0, width);
                    int row    = random.Next(0, height);

                    if (cardParameters[row, column] == null)
                    {
                        cardParameters[row, column] = new CardParameters(new Card()
                        {
                            ShirtImage  = shirt,
                            HiddenImage = hiddenImageForPair
                        }, row, column);

                        ++pairsCounter;
                        ++cardCounter;
                    }
                } while (pairsCounter < 2);
            }

            return(cardParameters.Cast <CardParameters>().ToArray());
        }
Exemple #11
0
    public Grid(IQueryable <T> queryable, GridParameters parameters)
    {
        Parameters = parameters;

        if (queryable is null || parameters is null)
        {
            return;
        }

        queryable = Filter(queryable, parameters.Filters);

        Count = queryable.LongCount();

        queryable = Order(queryable, parameters.Order);

        queryable = Page(queryable, parameters.Page);

        List = queryable.AsEnumerable();
    }
        /// <summary>
        /// Get the named parameter for the given expiry/tenor pairing
        /// </summary>
        /// <param name="expiry"></param>
        /// <param name="tenor"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public decimal GetParameter(string expiry, string tenor, ParameterType parameter)
        {
            GridParameters row = GetRow(expiry, tenor);

            switch (parameter)
            {
            case ParameterType.Beta:
                return(row.Beta);

            case ParameterType.Nu:
                return(row.Nu);

            case ParameterType.Rho:
                return(row.Rho);

            default:
                throw new ArgumentException("Expiry/tenor pair is not contained by this Grid.");
            }
        }
        public ActionResult List(string msg)
        {
            RoleModel model = new RoleModel();

            //get grid parameters from URL/POST (if any)
            var activeGridParameters = GridParameters.GetGridParameters();
            int pageSize             = 10; //displayed rows per page


            model.Flag     = 1;
            model.Status   = 1;
            model.RoleType = "S";
            RoleHelper objHelper = new RoleHelper();



            ActiveRolesList = objHelper.GetRoleByStatus(model);
            var ActiveRole = GetDataUsingLINQ(activeGridParameters.Sort,          //order by column
                                              activeGridParameters.SortDirection, //order by direction
                                              activeGridParameters.Page ?? 1,     //returned page
                                              pageSize, ActiveRolesList);         //displayed rows per page


            model.Status = 0;
            var InActiveGridParameters = GridParameters.GetGridParameters();

            InActiveRolesList = objHelper.GetRoleByStatus(model);
            var InActiveRole = GetDataUsingLINQ(InActiveGridParameters.Sort,          //order by column
                                                InActiveGridParameters.SortDirection, //order by direction
                                                InActiveGridParameters.Page ?? 1,     //returned page
                                                pageSize, InActiveRolesList);         //displayed rows per page


            //set record count for use in view


            ViewBag.ActiveGridRecordCount   = ActiveRolesList.Count;
            ViewBag.InActiveGridRecordCount = InActiveRolesList.Count;

            return(View(Tuple.Create(ActiveRole, InActiveRole, model)));
        }
Exemple #14
0
        public static void GenerateHollowGrid(List <uint> indices,
                                              uint rowIndex, uint columnIndex,
                                              uint rowEndIndex, uint columnEndIndex,
                                              uint sideVertexCount)
        {
            uint rowCount    = rowEndIndex - rowIndex;
            uint columnCount = columnEndIndex - columnIndex;

            GridParameters[] parameters = new GridParameters[4]
            {
                new GridParameters(rowIndex, columnIndex, rowIndex + rowCount / 4, columnEndIndex),
                new GridParameters(rowIndex + rowCount / 4, columnIndex, rowEndIndex - rowCount / 4, columnCount / 4 + 1),
                new GridParameters(rowIndex + rowCount / 4, columnEndIndex - columnCount / 4, rowEndIndex - rowCount / 4, columnEndIndex),
                new GridParameters(rowEndIndex - rowCount / 4, columnIndex, rowEndIndex, columnEndIndex)
            };

            for (int i = 0; i < parameters.Length; i++)
            {
                GenerateFullGrid(indices,
                                 parameters[i].RowIndex, parameters[i].ColumnIndex,
                                 parameters[i].RowEndIndex, parameters[i].ColumnEndIndex,
                                 sideVertexCount);
            }
        }
Exemple #15
0
        public static void GenerateHollowGrid(List<uint> indices,
            uint rowIndex, uint columnIndex,
            uint rowEndIndex, uint columnEndIndex,
            uint sideVertexCount)
        {
            uint rowCount = rowEndIndex - rowIndex;
            uint columnCount = columnEndIndex - columnIndex;

            GridParameters[] parameters = new GridParameters[4]
            {
                new GridParameters(rowIndex, columnIndex, rowIndex + rowCount / 4, columnEndIndex),
                new GridParameters(rowIndex + rowCount / 4, columnIndex, rowEndIndex - rowCount / 4, columnCount / 4 + 1),
                new GridParameters(rowIndex + rowCount / 4, columnEndIndex - columnCount / 4, rowEndIndex - rowCount / 4, columnEndIndex),
                new GridParameters(rowEndIndex - rowCount / 4, columnIndex, rowEndIndex, columnEndIndex)
            };

            for (int i = 0; i < parameters.Length; i++)
            {
                GenerateFullGrid(indices,
                                 parameters[i].RowIndex, parameters[i].ColumnIndex,
                                 parameters[i].RowEndIndex, parameters[i].ColumnEndIndex,
                                 sideVertexCount);
            }
        }
 public Task <Grid <CheckHistoryModel> > GridAsync(GridParameters parameters)
 {
     return(Queryable.Select(CheckHistoryExpression.Model).GridAsync(parameters));
 }
Exemple #17
0
        private List <Grid> CreateAxes(Document doc, GridParameters p, Orientation orientation)
        {
            List <Grid> list     = new List <Grid>();
            Line        line     = default;
            Grid        gridLine = default;

            double perpendicularSize = p.GetSize(p.GetPerpendicularOrientation(orientation));

            double startPoint = p.GetStartPoint(orientation);
            double endPoint   = p.GetEndPoint(orientation);

            int    number   = p.GetNumber(orientation);
            double distance = p.GetDistance(orientation);

            using (Transaction transaction = new Transaction(doc))
            {
                try
                {
                    // Iteration start with one (1), not zero (0)!
                    for (int i = 1, n = number; i <= n; i++)
                    {
                        string name   = default;
                        double offset = default;

                        if (distance > 0)
                        {
                            offset = (distance * i) - (perpendicularSize / 2);
                        }

                        double x0 = default;
                        double x1 = default;

                        double y0 = default;
                        double y1 = default;

                        switch (orientation)
                        {
                        case Orientation.Vertical:
                            x0   = x1 = offset;
                            y0   = startPoint;
                            y1   = endPoint;
                            name = "1";
                            break;

                        case Orientation.Horizontal:
                            x0   = startPoint;
                            x1   = endPoint;
                            y0   = y1 = offset;
                            name = "A";
                            break;
                        }

                        transaction.Start($"Create {orientation.ToString().ToLower()} axis");

                        line = Line.CreateBound(
                            new XYZ(x0, y0, 0),
                            new XYZ(x1, y1, 0));

                        gridLine = Grid.Create(doc, line);

                        // Initialize grid axes elevation
                        double indent    = GetElevationIndent();
                        double elevation = GetHighestElevation(doc);
                        gridLine.SetVerticalExtents(0 - indent, indent + elevation);

                        // Set name for first axis in orientation
                        if (i == 1)
                        {
                            ElementCategoryFilter    gridsFilter   = new ElementCategoryFilter(BuiltInCategory.OST_Grids);
                            FilteredElementCollector existingGrids = new FilteredElementCollector(doc)
                                                                     .WherePasses(gridsFilter)
                                                                     .WhereElementIsNotElementType();

                            List <string> existingGridsName = new List <string>();

                            foreach (Grid grid in existingGrids)
                            {
                                existingGridsName.Add(grid.Name);
                            }

                            if (existingGridsName.Contains(name))
                            {
                                string prefixName;

                                do
                                {
                                    SetPrefixForm setPrefixForm = new SetPrefixForm(orientation.ToString());
                                    setPrefixForm.ShowDialog();

                                    if (setPrefixForm.DialogResult == DialogResult.Cancel)
                                    {
                                        throw new OperationCanceledException();
                                    }

                                    prefixName = $"{setPrefixForm.prefix} {name}";
                                }while (existingGridsName.Contains(prefixName));

                                gridLine.Name = prefixName;
                            }
                            else
                            {
                                gridLine.Name = name;
                            }
                        }

                        transaction.Commit();

                        list.Add(gridLine);
                    }
                }
                catch (ArgumentException)
                {
                    System.Windows.Forms.MessageBox.Show("The axes can't have same name");
                }
            }

            return(list);
        }
Exemple #18
0
 public Task <Grid <UserModel> > GridAsync(GridParameters parameters)
 {
     return(Queryable.Select(UserExpression.Model).GridAsync(parameters));
 }
Exemple #19
0
 public Task <Grid <NotificationModel> > GridAsync(GridParameters parameters)
 {
     return(Queryable.Select(NotificationExpression.Model).GridAsync(parameters));
 }
Exemple #20
0
 public static Task <Grid <T> > GridAsync <T>(this IQueryable <T> queryable, GridParameters parameters)
 {
     return(Task.FromResult(new Grid <T>(queryable, parameters)));
 }
Exemple #21
0
 public Task <Grid <TargetAppModel> > GridAsync(GridParameters parameters)
 {
     return(_targetAppRepository.GridAsync(parameters));
 }
 public Task <Grid <TargetAppModel> > GridAsync(GridParameters parameters)
 {
     return(Queryable.Select(TargetAppExpression.Model).GridAsync(parameters));
 }
Exemple #23
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // Get application, document and units objects
            UIApplication uiApp = commandData.Application;
            Document      doc   = uiApp.ActiveUIDocument.Document;
            Units         units = doc.GetUnits();

            // Get length unit, using in project
            DisplayUnitType unit = units
                                   .GetFormatOptions(UnitType.UT_Length).DisplayUnits;

            // Show form for get data from user
            SetParametersForm form = new SetParametersForm(units);

            form.ShowDialog();

            // Stop running if user pressed cancel button or ESC
            if (form.DialogResult == DialogResult.Cancel)
            {
                return(Result.Cancelled);
            }

            // Defining parameters sets
            GridParameters   gridParameters   = new GridParameters();
            LevelsParameters levelsParameters = new LevelsParameters();

            // Try initialize parameters set, using data entered by user
            try
            {
                InitializeParameters(form, ref gridParameters, ref levelsParameters, unit);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }

            using (TransactionGroup transactionGroup = new TransactionGroup(doc))
            {
                transactionGroup.Start("Create levels, and axes grid with dimensions");

                // Get from document highest level elevation
                double highestElevation = GetHighestElevation(doc);

                if (levelsParameters.CreateALevels)
                {
                    // Creating levels with user entered parameters
                    List <Level> levels = CreateLevels(doc, levelsParameters, highestElevation);

                    // Creating plans for new levels
                    CreatePlans(doc, levels);
                }

                if (gridParameters.CreateAGrid)
                {
                    List <Grid> grid = new List <Grid>();

                    try
                    {
                        // Creating axes grid with user entered parameters
                        grid = CreateAxesGrid(doc, gridParameters);
                    }
                    catch (OperationCanceledException)
                    {
                        MessageBox.Show("The axes cant't have the same name");

                        return(Result.Cancelled);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    // Creating dimensions
                    CreateDimensions(doc, gridParameters, grid);
                }

                transactionGroup.Assimilate();
            }

            // Notyfy app, that external command complete succeeded
            return(Result.Succeeded);
        }
Exemple #24
0
 public Task <IActionResult> GridAsync([FromQuery] GridParameters parameters)
 {
     return(_userService.GridAsync(parameters).ResultAsync());
 }
Exemple #25
0
 public Task <Grid <CheckHistoryModel> > GridAsync(GridParameters parameters)
 {
     return(_checkHistoryRepository.GridAsync(parameters));
 }
Exemple #26
0
 public Task <Grid <UserModel> > ListAsync(GridParameters parameters)
 {
     return(_userRepository.Queryable.Select(UserExpression.Model).ListAsync(parameters));
 }
Exemple #27
0
 public static Grid <T> Grid <T>(this IQueryable <T> queryable, GridParameters parameters)
 {
     return(new(queryable, parameters));
 }
Exemple #28
0
 public void CopyTo(GridParameters other)
 {
     other.xSize = xSize;
     other.ySize = ySize;
     other.scanHeight = scanHeight;
     other.xDimension = xDimension;
     other.yDimension = yDimension;
     other.gridType = gridType;
 }
 public Task <Grid <NotificationModel> > GridAsync(GridParameters parameters)
 {
     return(_notificationRepository.GridAsync(parameters));
 }
Exemple #30
0
        private void CreateDimensionForOrientation(
            Document doc,
            Dictionary <Orientation, List <Grid> > grids,
            View view,
            GridParameters p,
            Orientation orientation)
        {
            List <Grid> gridByOrientation = grids[orientation];

            // Originale last points
            XYZ oFirst = gridByOrientation.First().Curve.GetEndPoint(0);
            XYZ oLast  = gridByOrientation.Last().Curve.GetEndPoint(0);

            // Last points with offset
            XYZ endPointFirst = default;
            XYZ endPointLast  = default;

            // Offset size as half of distance
            double offset = p.GetDistance(
                p.GetPerpendicularOrientation(orientation)) / 2;

            switch (orientation)
            {
            case Orientation.Vertical:
                endPointFirst = new XYZ(oFirst.X, oFirst.Y + offset, oFirst.Z);
                endPointLast  = new XYZ(oLast.X, oLast.Y + offset, oLast.Z);
                break;

            case Orientation.Horizontal:
                endPointFirst = new XYZ(oFirst.X + offset, oFirst.Y, oFirst.Z);
                endPointLast  = new XYZ(oLast.X + offset, oLast.Y, oLast.Z);
                break;
            }

            Line dimensionLine = Line.CreateBound(endPointFirst, endPointLast);

            ReferenceArray axesReferences = new ReferenceArray();

            foreach (Grid grid in gridByOrientation)
            {
                Options options = new Options()
                {
                    ComputeReferences        = true,
                    IncludeNonVisibleObjects = false,
                    View = view
                };
                foreach (GeometryObject geometry in grid.get_Geometry(options))
                {
                    if (geometry is Line)
                    {
                        Line line = geometry as Line;
                        axesReferences.Append(line.Reference);
                    }
                }
            }

            using (Transaction transaction = new Transaction(doc))
            {
                try
                {
                    transaction.Start(
                        $"Create dimensions between axes in " +
                        $"{orientation.ToString().ToLower()} orientation");;

                    doc.Create.NewDimension(view, dimensionLine, axesReferences);

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
 public Task <Grid <UserModel> > GridAsync(GridParameters parameters)
 {
     return(_userRepository.GridAsync(parameters));
 }
Exemple #32
0
 public IActionResult Grid([FromQuery] GridParameters parameters)
 {
     return(_userService.GridAsync(parameters).ApiResult());
 }