Exemplo n.º 1
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass =
                CssClass.ConcatenateWithSpace(
                    allStylesBothStatesClass + " " +
                    ( style == SectionStyle.Normal ? getSectionClass( normalClosedClass, normalExpandedClass ) : getSectionClass( boxClosedClass, boxExpandedClass ) ) );

            if( heading.Any() ) {
                var headingControls =
                    new WebControl( HtmlTextWriterTag.H1 ) { CssClass = headingClass }.AddControlsReturnThis( heading.GetLiteralControl() )
                        .ToSingleElementArray()
                        .Concat( postHeadingControls );
                if( expanded.HasValue ) {
                    var toggleClasses = style == SectionStyle.Normal ? new[] { normalClosedClass, normalExpandedClass } : new[] { boxClosedClass, boxExpandedClass };

                    var headingContainer =
                        new Block(
                            new[] { new EwfLabel { Text = "Click to Expand", CssClass = closeClass }, new EwfLabel { Text = "Click to Close", CssClass = expandClass } }.Concat(
                                headingControls ).ToArray() ) { CssClass = headingClass };
                    var actionControlStyle = new CustomActionControlStyle( c => c.AddControlsReturnThis( headingContainer ) );

                    this.AddControlsReturnThis(
                        disableStatePersistence
                            ? new CustomButton( () => "$( '#" + ClientID + "' ).toggleClass( '" + StringTools.ConcatenateWithDelimiter( " ", toggleClasses ) + "', 200 )" )
                                {
                                    ActionControlStyle = actionControlStyle
                                }
                            : new ToggleButton( this.ToSingleElementArray(), actionControlStyle, toggleClasses: toggleClasses ) as Control );
                }
                else {
                    var headingContainer = new Block( headingControls.ToArray() ) { CssClass = headingClass };
                    this.AddControlsReturnThis( new Block( headingContainer ) );
                }
            }
            if( contentControls.Any() )
                this.AddControlsReturnThis( new Block( contentControls.ToArray() ) { CssClass = contentClass } );
        }
Exemplo n.º 2
0
        private Block getExportButton( IEnumerable<object> headers, List<IEnumerable<object>> tableData )
        {
            var block =
                new Block(
                    new PostBackButton(
                        PostBack.CreateFull(
                            id: PostBack.GetCompositeId( setup.PostBackIdBase, "export" ),
                            actionGetter: () => new PostBackAction(
                                                    new SecondaryResponse(
                                                    () => new EwfResponse(
                                                              ContentTypes.Csv,
                                                              new EwfResponseBodyCreator(
                                                              output => {
                                                                  var csv = new CsvFileWriter();
                                                                  var writer = new StreamWriter( output );

                                                                  csv.AddValuesToLine( headers.ToArray() );
                                                                  csv.WriteCurrentLineToFile( writer );
                                                                  foreach( var td in tableData ) {
                                                                      csv.AddValuesToLine( td.ToArray() );
                                                                      csv.WriteCurrentLineToFile( writer );
                                                                  }
                                                              } ),
                                                              () => "{0} {1}".FormatWith( setup.ExportFileName, DateTime.Now ) + FileExtensions.Csv ) ) ) ),
                        new TextActionControlStyle( "Export" ),
                        usesSubmitBehavior: false ) );
            block.Style.Add( "text-align", "right" );
            return block;
        }