Esempio n. 1
0
        public async Task <IResponse> CreateGridParameters(GridTemplate gridTemplate)
        {
            var newGrid = new GridFactory(gridTemplate.Vertexes, gridTemplate.Edges).Create();

            newGrid.OwnerId = gridTemplate.OwnerId;
            return(await base.CreateResource(newGrid));
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateGridParameters([FromBody] GridTemplate grid)
        {
            try
            {
                if (grid.OwnerId != HttpContext.Items[Text.UserId]?.ToString())
                {
                    return(StatusCode(StatusCodes.Status403Forbidden, new ErrorResponse(Text.UnownedResource).ToString()));
                }
                var oldGridModel = (GridModel)HttpContext.Items[Text.Grid];
                if (oldGridModel == null)
                {
                    return(StatusCode(StatusCodes.Status403Forbidden, new ErrorResponse(Text.ResourceDoesNotExist).ToString()));
                }
                var response = await _gridHandler.UpdateGridParameters(grid);

                return(StatusCode(StatusCodes.Status200OK, response.ToString()));
            }
            catch (Exception e)
            {
                if (e is ServerException)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(error: Text.ServerException, errorMessage: e.ToString()).ToString()));
                }
                return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(error: Text.InternalServerError, errorMessage: e.ToString()).ToString()));
            }
        }
Esempio n. 3
0
        private void GridTemplateLoad()
        {
            string    sql   = @"SELECT T.GROUPID, T.GROUPNAME, F_GETUSERNAME(T.LRY) USERNAME
                                    FROM DOC_GROUPDOC T
                                  WHERE F_CHK_DATARANGE(T.DEPTID, '{0}') = 'Y' AND T.FLAG='Y' AND T.TYPE='K' ";
            DataTable table = DbHelperOra.Query(string.Format(sql, UserAction.UserID)).Tables[0];

            GridTemplate.DataSource = table;
            GridTemplate.DataBind();
        }
Esempio n. 4
0
        public void GetNearestPointOnGridTest()
        {
            GridTemplate gt = GameObject.FindObjectOfType <GridTemplate>();

            Vector3 testPosition     = new Vector3(1.28f, 2.0f, 6.67f);
            Vector3 result           = gt.GetNearestPointOnGrid(testPosition);
            Vector3 expectedPosition = new Vector3(1.0f, 2f, 7.0f);

            Assert.AreEqual(result.x, expectedPosition.x);
            Assert.AreEqual(result.z, expectedPosition.z);
        }
Esempio n. 5
0
 /// <summary>
 /// Creates a new grid-only model from template.
 /// </summary>
 /// <param name="gridTemplate">The grid template.</param>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void NewGridOnly(GridTemplate gridTemplate)
 {
     _apiFile.NewGridOnly(
         gridTemplate.NumberOfStories,
         gridTemplate.TypicalStoryHeight,
         gridTemplate.BottomStoryHeight,
         gridTemplate.NumberOfLinesX,
         gridTemplate.NumberOfLinesY,
         gridTemplate.SpacingX,
         gridTemplate.SpacingY);
 }
        public void When_MirrorPlaneTop_Expect_Mirrored()
        {
            PointType[][][] blackUp = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK }
                }
            };

            GridTemplate blackUpGridTemplate = new GridTemplate(blackUp);

            GridTemplate mirroredBlackUp = GridTemplate.MirrorInPlane(blackUpGridTemplate, PlaneEnum.XZ);

            PointType[][][] blackDown = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.BLACK, PointType.BLACK, PointType.BLACK },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED },
                    new PointType[] { PointType.IGNORED, PointType.IGNORED, PointType.IGNORED }
                }
            };

            GridTemplate blackDownGridTemplate = new GridTemplate(blackDown);

            Assert.AreEqual(blackDownGridTemplate, mirroredBlackUp);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets a grid template. used for custom grids
        /// </summary>
        public GridTemplate GetGridTemplate(int templateId)
        {
            GridTemplate templateGrid = null;

            //todo - GTC: Custom Grids
            //var template = RbacEntities.CustomerGridTemplates.SingleOrDefault( m => m.CustomerGridTemplateId == templateId );

            //if ( template != null )
            //{

            //    templateGrid = new GridTemplate()
            //        {
            //            GridId = template.CustomerGridTemplateId,
            //            Controller = template.Controller,
            //            Action = template.Action,
            //            Version = template.Version,
            //            Selected = true
            //        };

            //    // Get the template columns
            //    foreach (var col in template.CustomerGridTemplateCols)
            //    {
            //        templateGrid.Grid.Add( new GridData()
            //            {
            //                //do not localize the title, the admin is using this peice and doesnt care about what the customer has set their overriden value to.
            //                Title = col.Title,
            //                Position = col.Position,
            //                OriginalTitle = col.OriginalTitle,
            //                OriginalPosition = col.OriginalPosition,
            //                IsHidden = col.IsHidden
            //            } );
            //    }
            //    // Order the grid columns
            //    templateGrid.Grid.Sort();

            //}

            return(templateGrid);
        }
Esempio n. 8
0
        public async Task <IActionResult> CreateGridParameters([FromBody] GridTemplate gridTemplate)
        {
            try
            {
                var oldGridModel = (GridModel)HttpContext.Items[Text.Grid];
                if (oldGridModel != null)
                {
                    return(StatusCode(StatusCodes.Status403Forbidden, new ErrorResponse(Text.GridConfigurationError).ToString()));
                }
                gridTemplate.OwnerId = HttpContext.Items[Text.UserId]?.ToString();
                var response = await _gridHandler.CreateGridParameters(gridTemplate);

                return(StatusCode(StatusCodes.Status201Created, response.ToString()));
            }
            catch (Exception e)
            {
                if (e is ServerException)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(error: Text.ServerException, errorMessage: e.ToString()).ToString()));
                }
                return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(error: Text.InternalServerError, errorMessage: e.ToString()).ToString()));
            }
        }
Esempio n. 9
0
        internal static void ConfigureGrid(ref Grid grid, ref IDesignerHost designerhost,
            ref IComponentChangeService componentChangeService,
            ref DesignerTransaction dt, GridTemplate template)
        {
            if (template == GridTemplate.None)
                return;

            switch (template)
            {
                case GridTemplate.ProductCatalog:
                    {
                        dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

                        grid.RecordsPerRow = 3;
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Product catalog";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Grid;
                        grid.Columns.Clear();

                        Text producttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        producttitle.ColumnId = "productTitle";
                        producttitle.Grid = grid;
                        producttitle.Title = "Title";
                        producttitle.Visibility = Visibility.Both;
                        producttitle.DisplayIndex = 10;

                        grid.Columns.Add(producttitle);

                        File productImageGrid = (File) designerhost.CreateComponent(typeof (File));
                        productImageGrid.ColumnId = "productImageGrid";
                        productImageGrid.Grid = grid;
                        productImageGrid.Title = "Grid image";
                        productImageGrid.HideDetailTitle = true;
                        productImageGrid.NewRowInGrid = true;
                        productImageGrid.Visibility = Visibility.Grid;
                        productImageGrid.DisplayIndex = 20;

                        grid.Columns.Add(productImageGrid);

                        File productImageEdit = (File) designerhost.CreateComponent(typeof (File));
                        productImageEdit.ColumnId = "productImageEdit";
                        productImageEdit.Title = "Edit image";
                        productImageEdit.Grid = grid;
                        productImageEdit.HideDetailTitle = true;
                        productImageEdit.NewRowInGrid = true;
                        productImageEdit.Visibility = Visibility.Detail;
                        productImageEdit.DisplayIndex = 20;

                        grid.Columns.Add(productImageEdit);

                        Text productGridDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productGridDescription.ColumnId = "productGridDescription";
                        productGridDescription.Title = "Grid description";
                        productGridDescription.Grid = grid;
                        productGridDescription.HideDetailTitle = true;
                        productGridDescription.Visibility = Visibility.Grid;
                        productGridDescription.IsHtml = true;
                        productGridDescription.DisplayIndex = 30;

                        grid.Columns.Add(productGridDescription);

                        Text productEditDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productEditDescription.ColumnId = "productGridDescription";
                        productEditDescription.Grid = grid;
                        productEditDescription.Title = "Edit description";
                        productEditDescription.HideDetailTitle = true;
                        productEditDescription.IsHtml = true;
                        productEditDescription.Visibility = Visibility.Detail;
                        productEditDescription.DisplayIndex = 30;

                        grid.Columns.Add(productEditDescription);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.UserRegistration:
                    {
                        grid.Width = Unit.Pixel(500);
                        grid.Title = "User login";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Detail;
                        grid.AllowCancel = false;
                        grid.AllowUpdate = true;
                        grid.RecordsPerRow = 1;

                        grid.Columns.Clear();

                        Text userloginID = (Text) designerhost.CreateComponent(typeof (Text));
                        userloginID.ColumnId = "LoginID";
                        userloginID.Title = "Login ID";
                        userloginID.Grid = grid;
                        userloginID.HideDetailTitle = true;
                        userloginID.Visibility = Visibility.Detail;
                        userloginID.DisplayIndex = 10;
                        userloginID.Required = true;
                        grid.Columns.Add(userloginID);

                        Text userpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        userpassword.ColumnId = "LoginPassword";
                        userpassword.Title = "Login password";
                        userpassword.Grid = grid;
                        userpassword.IsPassword = true;
                        userpassword.Visibility = Visibility.Detail;
                        userpassword.DisplayIndex = 20;
                        userpassword.ValidExpression = "[RepeatPassword] != [LoginPassword]";
                        userpassword.Required = true;
                        userpassword.MinSize = 5;
                        userpassword.MaxSize = 15;
                        userpassword.SystemMessage = "Your passwords did not match.";

                        grid.Columns.Add(userpassword);

                        Text repeatuserpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        repeatuserpassword.ColumnId = "RepeatPassword";
                        repeatuserpassword.Title = "Repeat password";
                        repeatuserpassword.NewRowInDetail = false;
                        repeatuserpassword.Grid = grid;
                        repeatuserpassword.IsPassword = true;
                        repeatuserpassword.Visibility = Visibility.Detail;
                        repeatuserpassword.DisplayIndex = 30;
                        repeatuserpassword.MinSize = 5;
                        repeatuserpassword.MaxSize = 15;
                        repeatuserpassword.Required = true;

                        grid.Columns.Add(repeatuserpassword);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.RowSummary:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Row summary";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Decimal productprice = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productprice.ColumnId = "Price";
                        productprice.Title = "Price";
                        productprice.Grid = grid;
                        productprice.Visibility = Visibility.Both;
                        productprice.DisplayIndex = 10;

                        grid.Columns.Add(productprice);

                        Number productQuantity = (Number) designerhost.CreateComponent(typeof (Number));
                        productQuantity.ColumnId = "Quantity";
                        productQuantity.Title = "Quantity";
                        productQuantity.Grid = grid;
                        productQuantity.Visibility = Visibility.Both;
                        productQuantity.DisplayIndex = 20;

                        grid.Columns.Add(productQuantity);

                        Decimal productSubSum = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productSubSum.ColumnId = "Total";
                        productSubSum.Title = "Sub total";
                        productSubSum.Grid = grid;
                        productSubSum.Visibility = Visibility.Grid;
                        productSubSum.DisplayIndex = 30;
                        productSubSum.DisplayTotalSummary = true;
                        productSubSum.Sum = "[Quantity]*[Price]";
                        grid.Columns.Add(productSubSum);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.DocumentDatabase:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Document database";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Text documenttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        documenttitle.ColumnId = "TitleDocument";
                        documenttitle.Title = "Title";
                        documenttitle.Grid = grid;
                        documenttitle.Visibility = Visibility.Both;
                        documenttitle.DisplayIndex = 10;
                        documenttitle.Required = true;

                        grid.Columns.Add(documenttitle);

                        Text htmldocument = (Text) designerhost.CreateComponent(typeof (Text));
                        htmldocument.ColumnId = "htmlDocument";
                        htmldocument.Title = "Document";
                        htmldocument.Grid = grid;
                        htmldocument.IsHtml = true;
                        htmldocument.WidthEditableColumn = Unit.Percentage(90);
                        htmldocument.HeightEditableColumn = Unit.Pixel(300);
                        htmldocument.Visibility = Visibility.Detail;
                        htmldocument.DisplayIndex = 20;
                        htmldocument.Required = true;

                        grid.Columns.Add(htmldocument);

                        File fileattachment = (File) designerhost.CreateComponent(typeof (File));
                        fileattachment.ColumnId = "FileAttachment";
                        fileattachment.Title = "File Attachment";
                        fileattachment.Grid = grid;
                        fileattachment.Visibility = Visibility.Both;
                        fileattachment.DisplayIndex = 30;
                        fileattachment.Required = false;

                        grid.Columns.Add(fileattachment);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
            }
        }
Esempio n. 10
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        uxMessagePlaceHolder.Controls.Clear();
        uxValidationSummaryPlaceHolder.Controls.Clear();
        uxValidationDenotePlaceHolder.Controls.Clear();
        uxLanguageControlPlaceHolder.Controls.Clear();
        uxButtonEventPlaceHolder.Controls.Clear();
        uxButtonCommandPlaceHolder.Controls.Clear();
        uxButtonEventInnerBoxPlaceHolder.Controls.Clear();
        uxTopContentBoxPlaceHolder.Controls.Clear();

        uxFilterPlaceHolder.Controls.Clear();
        uxSpecialFilterPlaceHolder.Controls.Clear();
        uxPageNumberPlaceHolder.Controls.Clear();
        uxGridPlaceHolder.Controls.Clear();
        uxBottomContentBoxPlaceHolder.Controls.Clear();

        uxContentPlaceHolder.Controls.Clear();

        // Message.
        ContentContainer container = new ContentContainer();

        if (MessageTemplate != null)
        {
            MessageTemplate.InstantiateIn(container);
            uxMessagePlaceHolder.Controls.Add(container);
            uxMessagePlaceHolder.Visible = true;
        }
        else
        {
            uxMessagePlaceHolder.Controls.Add(new LiteralControl("No Message Defined"));
            uxMessagePlaceHolder.Visible = false;
        }

        // Validation Summary
        container = new ContentContainer();
        if (ValidationSummaryTemplate != null)
        {
            ValidationSummaryTemplate.InstantiateIn(container);
            uxValidationSummaryPlaceHolder.Controls.Add(container);
            uxValidationSummaryPanel.Visible = true;
        }
        else
        {
            uxValidationSummaryPlaceHolder.Controls.Add(new LiteralControl("No Validation Summary Defined"));
            uxValidationSummaryPanel.Visible = false;
        }

        // Validation Denotes
        container = new ContentContainer();
        if (ValidationDenotesTemplate != null)
        {
            ValidationDenotesTemplate.InstantiateIn(container);
            uxValidationDenotePlaceHolder.Controls.Add(container);
            uxValidationDenotePanel.Visible = true;
        }
        else
        {
            uxValidationDenotePlaceHolder.Controls.Add(new LiteralControl("No Validation Denotes Defined"));
            uxValidationDenotePanel.Visible = false;
        }

        // If all message disapear message panel will not show.
        if (!uxMessagePlaceHolder.Visible & !uxValidationSummaryPanel.Visible)
        {
            uxMessagePanel.Visible = false;
        }
        else
        {
            uxMessagePanel.Visible = true;
        }

        container = new ContentContainer();
        if (LanguageControlTemplate != null)
        {
            LanguageControlTemplate.InstantiateIn(container);
            uxLanguageControlPlaceHolder.Controls.Add(container);
            uxLanguageControlPanel.Visible = true;
        }
        else
        {
            uxLanguageControlPlaceHolder.Controls.Add(new LiteralControl("No Language Control Defined"));
            uxLanguageControlPanel.Visible = false;
        }

        // If don't have any language and message top panel will not show.
        if (!uxFilterPanel.Visible & !uxLanguageControlPanel.Visible & !uxSpecialFilterPanel.Visible)
        {
            uxTopPagePanel.Visible = false;
        }
        else
        {
            uxTopPagePanel.Visible = true;
        }


        if (ButtonEventTemplate == null)
        {
            uxButtonEventPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            ButtonEventTemplate.InstantiateIn(container);
            uxButtonEventPlaceHolder.Controls.Add(container);
            uxButtonEventPanel.Visible = true;
        }

        if (ButtonCommandTemplate == null)
        {
            uxButtonCommandPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            ButtonCommandTemplate.InstantiateIn(container);
            uxButtonCommandPlaceHolder.Controls.Add(container);
            uxButtonCommandPanel.Visible = true;
        }

        if (ButtonEventInnerBoxTemplate == null)
        {
            uxButtonEventInnerBoxPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            ButtonEventInnerBoxTemplate.InstantiateIn(container);
            uxButtonEventInnerBoxPlaceHolder.Controls.Add(container);
            uxButtonEventInnerBoxPanel.Visible = true;
        }

        container = new ContentContainer();
        if (TopContentBoxTemplate != null)
        {
            TopContentBoxTemplate.InstantiateIn(container);
            uxTopContentBoxPlaceHolder.Controls.Add(container);
            uxTopContentBoxPanel.Visible = true;
        }
        else
        {
            uxTopContentBoxPlaceHolder.Controls.Add(new LiteralControl("No TopContentBox Content Defined"));
            uxTopContentBoxPlaceHolder.Visible = false;
            uxTopContentBoxPanel.Visible       = false;
        }

        container = new ContentContainer();
        if (ContentTemplate != null)
        {
            ContentTemplate.InstantiateIn(container);
            uxContentPlaceHolder.Controls.Add(container);
            uxContentPanel.Visible = true;
        }
        else
        {
            uxContentPlaceHolder.Controls.Add(new LiteralControl("No Template Defined"));
            uxContentPanel.Visible = false;
        }

        container = new ContentContainer();
        if (PlainContentTemplate != null)
        {
            PlainContentTemplate.InstantiateIn(container);
            uxPlainContentPlaceHolder.Controls.Add(container);
            uxPlainContentPanel.Visible = true;
        }
        else
        {
            uxPlainContentPlaceHolder.Controls.Add(new LiteralControl("No Template Defined"));
            uxPlainContentPanel.Visible = false;
        }

        if (FilterTemplate == null)
        {
            uxFilterPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            FilterTemplate.InstantiateIn(container);
            uxFilterPlaceHolder.Controls.Add(container);
            uxFilterPanel.Visible = true;
        }

        if (SpecialFilterTemplate == null)
        {
            uxSpecialFilterPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            SpecialFilterTemplate.InstantiateIn(container);
            uxSpecialFilterPlaceHolder.Controls.Add(container);
            uxSpecialFilterPanel.Visible = true;
        }

        if (PageNumberTemplate == null)
        {
            uxPageNumberPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            PageNumberTemplate.InstantiateIn(container);
            uxPageNumberPlaceHolder.Controls.Add(container);
            uxPageNumberPanel.Visible = true;
        }

        if (GridTemplate == null)
        {
            uxGridPanel.Visible = false;
        }
        else
        {
            container = new ContentContainer();
            GridTemplate.InstantiateIn(container);
            uxGridPlaceHolder.Controls.Add(container);
            uxGridPanel.Visible = true;
        }

        if (uxGridPanel.Visible || uxPageNumberPanel.Visible || uxTopContentBoxPlaceHolder.Visible || uxButtonCommandPanel.Visible || uxButtonEventInnerBoxPanel.Visible)
        {
            uxTopContentBoxSet.Visible = true;
        }
        else
        {
            uxTopContentBoxSet.Visible = false;
        }

        if (BottomContentBoxTemplate == null)
        {
            uxBottomContentBoxPlaceHolder.Visible = false;
            uxBottomContentBoxPanel.Visible       = false;
        }
        else
        {
            container = new ContentContainer();
            BottomContentBoxTemplate.InstantiateIn(container);
            uxBottomContentBoxPlaceHolder.Controls.Add(container);
            uxBottomContentBoxPlaceHolder.Visible = true;
        }

        if (HeaderMessageTemplate != null)
        {
            HeaderMessageTemplate.InstantiateIn(container);
            uxHeaderMeassagePlaceHolder.Controls.Add(container);
            uxHeaderMeassagePanel.Visible = true;
        }
        else
        {
            uxHeaderMeassagePlaceHolder.Controls.Add(new LiteralControl("No Template Defined"));
            uxHeaderMeassagePanel.Visible = false;
        }
    }
Esempio n. 11
0
        internal static void ConfigureGrid(ref Grid grid, ref IDesignerHost designerhost,
                                           ref IComponentChangeService componentChangeService,
                                           ref DesignerTransaction dt, GridTemplate template)
        {
            if (template == GridTemplate.None)
            {
                return;
            }

            switch (template)
            {
            case GridTemplate.ProductCatalog:
            {
                dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

                grid.RecordsPerRow     = 3;
                grid.Width             = Unit.Percentage(100);
                grid.Title             = "Product catalog";
                grid.DefaultVisibility = Visibility.None;
                grid.DisplayView       = DisplayView.Grid;
                grid.Columns.Clear();

                Text producttitle = (Text)designerhost.CreateComponent(typeof(Text));
                producttitle.ColumnId     = "productTitle";
                producttitle.Grid         = grid;
                producttitle.Title        = "Title";
                producttitle.Visibility   = Visibility.Both;
                producttitle.DisplayIndex = 10;

                grid.Columns.Add(producttitle);

                File productImageGrid = (File)designerhost.CreateComponent(typeof(File));
                productImageGrid.ColumnId        = "productImageGrid";
                productImageGrid.Grid            = grid;
                productImageGrid.Title           = "Grid image";
                productImageGrid.HideDetailTitle = true;
                productImageGrid.NewRowInGrid    = true;
                productImageGrid.Visibility      = Visibility.Grid;
                productImageGrid.DisplayIndex    = 20;

                grid.Columns.Add(productImageGrid);

                File productImageEdit = (File)designerhost.CreateComponent(typeof(File));
                productImageEdit.ColumnId        = "productImageEdit";
                productImageEdit.Title           = "Edit image";
                productImageEdit.Grid            = grid;
                productImageEdit.HideDetailTitle = true;
                productImageEdit.NewRowInGrid    = true;
                productImageEdit.Visibility      = Visibility.Detail;
                productImageEdit.DisplayIndex    = 20;

                grid.Columns.Add(productImageEdit);

                Text productGridDescription = (Text)designerhost.CreateComponent(typeof(Text));
                productGridDescription.ColumnId        = "productGridDescription";
                productGridDescription.Title           = "Grid description";
                productGridDescription.Grid            = grid;
                productGridDescription.HideDetailTitle = true;
                productGridDescription.Visibility      = Visibility.Grid;
                productGridDescription.IsHtml          = true;
                productGridDescription.DisplayIndex    = 30;

                grid.Columns.Add(productGridDescription);

                Text productEditDescription = (Text)designerhost.CreateComponent(typeof(Text));
                productEditDescription.ColumnId        = "productGridDescription";
                productEditDescription.Grid            = grid;
                productEditDescription.Title           = "Edit description";
                productEditDescription.HideDetailTitle = true;
                productEditDescription.IsHtml          = true;
                productEditDescription.Visibility      = Visibility.Detail;
                productEditDescription.DisplayIndex    = 30;

                grid.Columns.Add(productEditDescription);

                WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                return;
            }

            case GridTemplate.UserRegistration:
            {
                grid.Width             = Unit.Pixel(500);
                grid.Title             = "User login";
                grid.DefaultVisibility = Visibility.None;
                grid.DisplayView       = DisplayView.Detail;
                grid.AllowCancel       = false;
                grid.AllowUpdate       = true;
                grid.RecordsPerRow     = 1;

                grid.Columns.Clear();

                Text userloginID = (Text)designerhost.CreateComponent(typeof(Text));
                userloginID.ColumnId        = "LoginID";
                userloginID.Title           = "Login ID";
                userloginID.Grid            = grid;
                userloginID.HideDetailTitle = true;
                userloginID.Visibility      = Visibility.Detail;
                userloginID.DisplayIndex    = 10;
                userloginID.Required        = true;
                grid.Columns.Add(userloginID);

                Text userpassword = (Text)designerhost.CreateComponent(typeof(Text));
                userpassword.ColumnId        = "LoginPassword";
                userpassword.Title           = "Login password";
                userpassword.Grid            = grid;
                userpassword.IsPassword      = true;
                userpassword.Visibility      = Visibility.Detail;
                userpassword.DisplayIndex    = 20;
                userpassword.ValidExpression = "[RepeatPassword] != [LoginPassword]";
                userpassword.Required        = true;
                userpassword.MinSize         = 5;
                userpassword.MaxSize         = 15;
                userpassword.SystemMessage   = "Your passwords did not match.";

                grid.Columns.Add(userpassword);

                Text repeatuserpassword = (Text)designerhost.CreateComponent(typeof(Text));
                repeatuserpassword.ColumnId       = "RepeatPassword";
                repeatuserpassword.Title          = "Repeat password";
                repeatuserpassword.NewRowInDetail = false;
                repeatuserpassword.Grid           = grid;
                repeatuserpassword.IsPassword     = true;
                repeatuserpassword.Visibility     = Visibility.Detail;
                repeatuserpassword.DisplayIndex   = 30;
                repeatuserpassword.MinSize        = 5;
                repeatuserpassword.MaxSize        = 15;
                repeatuserpassword.Required       = true;

                grid.Columns.Add(repeatuserpassword);

                WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                return;
            }

            case GridTemplate.RowSummary:
            {
                grid.Width             = Unit.Percentage(100);
                grid.Title             = "Row summary";
                grid.DefaultVisibility = Visibility.None;
                grid.RecordsPerRow     = 1;
                grid.DisplayView       = DisplayView.Grid;

                grid.Columns.Clear();

                Decimal productprice = (Decimal)designerhost.CreateComponent(typeof(Decimal));
                productprice.ColumnId     = "Price";
                productprice.Title        = "Price";
                productprice.Grid         = grid;
                productprice.Visibility   = Visibility.Both;
                productprice.DisplayIndex = 10;

                grid.Columns.Add(productprice);

                Number productQuantity = (Number)designerhost.CreateComponent(typeof(Number));
                productQuantity.ColumnId     = "Quantity";
                productQuantity.Title        = "Quantity";
                productQuantity.Grid         = grid;
                productQuantity.Visibility   = Visibility.Both;
                productQuantity.DisplayIndex = 20;

                grid.Columns.Add(productQuantity);

                Decimal productSubSum = (Decimal)designerhost.CreateComponent(typeof(Decimal));
                productSubSum.ColumnId            = "Total";
                productSubSum.Title               = "Sub total";
                productSubSum.Grid                = grid;
                productSubSum.Visibility          = Visibility.Grid;
                productSubSum.DisplayIndex        = 30;
                productSubSum.DisplayTotalSummary = true;
                productSubSum.Sum = "[Quantity]*[Price]";
                grid.Columns.Add(productSubSum);

                WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                return;
            }

            case GridTemplate.DocumentDatabase:
            {
                grid.Width             = Unit.Percentage(100);
                grid.Title             = "Document database";
                grid.DefaultVisibility = Visibility.None;
                grid.RecordsPerRow     = 1;
                grid.DisplayView       = DisplayView.Grid;

                grid.Columns.Clear();

                Text documenttitle = (Text)designerhost.CreateComponent(typeof(Text));
                documenttitle.ColumnId     = "TitleDocument";
                documenttitle.Title        = "Title";
                documenttitle.Grid         = grid;
                documenttitle.Visibility   = Visibility.Both;
                documenttitle.DisplayIndex = 10;
                documenttitle.Required     = true;

                grid.Columns.Add(documenttitle);

                Text htmldocument = (Text)designerhost.CreateComponent(typeof(Text));
                htmldocument.ColumnId             = "htmlDocument";
                htmldocument.Title                = "Document";
                htmldocument.Grid                 = grid;
                htmldocument.IsHtml               = true;
                htmldocument.WidthEditableColumn  = Unit.Percentage(90);
                htmldocument.HeightEditableColumn = Unit.Pixel(300);
                htmldocument.Visibility           = Visibility.Detail;
                htmldocument.DisplayIndex         = 20;
                htmldocument.Required             = true;

                grid.Columns.Add(htmldocument);

                File fileattachment = (File)designerhost.CreateComponent(typeof(File));
                fileattachment.ColumnId     = "FileAttachment";
                fileattachment.Title        = "File Attachment";
                fileattachment.Grid         = grid;
                fileattachment.Visibility   = Visibility.Both;
                fileattachment.DisplayIndex = 30;
                fileattachment.Required     = false;

                grid.Columns.Add(fileattachment);

                WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                return;
            }
            }
        }
        public void When_MirrorPlane_Expect_Mirrored()
        {
            GridTemplate b1 = new  GridTemplate(GridTemplate.b1USW);

            PointType[][][] b1XZMirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.BLACK }
                }
            };

            PointType[][][] b1XYMirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.X, PointType.X, PointType.WHITE },
                    new PointType[] { PointType.X, PointType.BLACK, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.BLACK, PointType.X, PointType.WHITE },
                    new PointType[] { PointType.X, PointType.X, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                }
            };

            PointType[][][] b1YZMirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.BLACK },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                }
            };

            Assert.Multiple(() =>
            {
                Assert.AreEqual(new GridTemplate(b1XYMirror), GridTemplate.MirrorInPlane(b1, PlaneEnum.XY));
                Assert.AreEqual(new GridTemplate(b1XZMirror), GridTemplate.MirrorInPlane(b1, PlaneEnum.XZ));
                Assert.AreEqual(new GridTemplate(b1YZMirror), GridTemplate.MirrorInPlane(b1, PlaneEnum.YZ));
            });
        }
        public void When_ReflectPlane_Expect_Reflected()
        {
            GridTemplate b2 = new GridTemplate(GridTemplate.b2USW);
            GridTemplate b3 = new GridTemplate(GridTemplate.b3USW);

            PointType[][][] b2R1Mirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.BLACK },
                    new PointType[] { PointType.WHITE, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                }
            };

            PointType[][][] b2R2Mirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.BLACK },
                    new PointType[] { PointType.WHITE, PointType.X, PointType.X }
                }
            };

            PointType[][][] b3R3Mirror = new PointType[][][] /*x y z*/
            {
                new PointType[][]
                {
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE },
                    new PointType[] { PointType.WHITE, PointType.WHITE, PointType.WHITE }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.X, PointType.X, PointType.X },
                    new PointType[] { PointType.X, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.X, PointType.X, PointType.X }
                },
                new PointType[][]
                {
                    new PointType[] { PointType.X, PointType.X, PointType.X },
                    new PointType[] { PointType.X, PointType.BLACK, PointType.X },
                    new PointType[] { PointType.X, PointType.X, PointType.X }
                }
            };

            Assert.Multiple(() =>
            {
                Assert.AreEqual(new GridTemplate(b2R1Mirror), GridTemplate.Reflect(b2, Reflection.R1));
                Assert.AreEqual(new GridTemplate(b2R2Mirror), GridTemplate.Reflect(b2, Reflection.R2));
                Assert.AreEqual(new GridTemplate(b3R3Mirror), GridTemplate.Reflect(b3, Reflection.R3));
            });
        }