示例#1
0
        private static AdaptiveCard HolidayListAdaptiveCard(List <string> date, List <string> description)
        {
            var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
            List <AdaptiveColumn> columns = new List <AdaptiveColumn>();
            AdaptiveColumn        column  = AdaptiveCardHelper.AddAdaptiveColumn();
            AdaptiveColumn        column1 = AdaptiveCardHelper.AddAdaptiveColumn();
            AdaptiveColumn        column2 = AdaptiveCardHelper.AddAdaptiveColumn();

            AdaptiveCardHelper.AddItemToAdaptiveColumn(column, AdaptiveCardHelper.AddTextBlock("Sr. No", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Accent));
            AdaptiveCardHelper.AddItemToAdaptiveColumn(column1, AdaptiveCardHelper.AddTextBlock("Date", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Good));
            AdaptiveCardHelper.AddItemToAdaptiveColumn(column2, AdaptiveCardHelper.AddTextBlock("Description", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Dark));

            for (int i = 0; i < date.Count; i++)
            {
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column, AdaptiveCardHelper.AddTextBlock((i + 1).ToString()));
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column1, AdaptiveCardHelper.AddTextBlock((date[i]).ToString()));
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column2, AdaptiveCardHelper.AddTextBlock((description[i]).ToString()));
            }

            var columnSet = new AdaptiveColumnSet();

            columnSet.Columns.Add(column);
            columnSet.Columns.Add(column1);
            columnSet.Columns.Add(column2);
            var container = new AdaptiveContainer();

            container.Style = AdaptiveContainerStyle.Emphasis;
            container.Items.Add(columnSet);
            card.Body.Add(container);
            return(card);
        }
        private static AdaptiveCard HolidayListAdaptiveCardMoreDynamic(List <string> date, List <string> description)
        {
            var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
            List <AdaptiveColumn> columns = new List <AdaptiveColumn>();
            AdaptiveColumn        column  = AdaptiveCardHelper.AddAdaptiveColumn();
            AdaptiveColumn        column1 = AdaptiveCardHelper.AddAdaptiveColumn();
            AdaptiveColumn        column2 = AdaptiveCardHelper.AddAdaptiveColumn();

            AdaptiveCardHelper.AddTextBlockWithColumn(column, "Sr.No", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Accent);
            AdaptiveCardHelper.AddTextBlockWithColumn(column1, "Date", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Good);
            AdaptiveCardHelper.AddTextBlockWithColumn(column2, "Description", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Dark);

            for (int i = 0; i < date.Count; i++)
            {
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column, AdaptiveCardHelper.AddTextBlock((i + 1).ToString()));
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column1, AdaptiveCardHelper.AddTextBlock((date[i]).ToString()));
                AdaptiveCardHelper.AddItemToAdaptiveColumn(column2, AdaptiveCardHelper.AddTextBlock((description[i]).ToString()));
            }

            var columnSet = new AdaptiveColumnSet();

            columnSet.Columns.Add(column);
            columnSet.Columns.Add(column1);
            columnSet.Columns.Add(column2);
            AdaptiveContainer container = AdaptiveCardHelper.AddAdaptiveContainer(columnSet);

            card.Body.Add(container);
            return(card);


            ////++++++++++++++++++++++++++++++++++++++++++++
            ///https://stackoverflow.com/questions/11632816/can-i-count-properties-before-i-create-an-object-in-the-constructor
            /////https://stackoverflow.com/questions/27335689/creating-objects-within-a-loop
            ///https://social.msdn.microsoft.com/Forums/SECURITY/en-US/d7e26819-2731-402a-90a5-b512cb11eca5/how-do-i-create-a-loop-that-creates-multiple-objects-of-a-class?forum=csharpgeneral
            //var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
            //List<AdaptiveColumn> columns = new List<AdaptiveColumn>();
            ////AdaptiveColumn column = AdaptiveCardHelper.AddAdaptiveColumn();
            ////AdaptiveColumn column1 = AdaptiveCardHelper.AddAdaptiveColumn();
            ////AdaptiveColumn column2 = AdaptiveCardHelper.AddAdaptiveColumn();
            //for (int i = 0; i < 2; i++)
            //{
            //    columns.Add(new AdaptiveColumn());
            //}

            //AdaptiveCardHelper.AddTextBlockWithColumn(columns[0], "Sr.No", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Accent);
            //AdaptiveCardHelper.AddTextBlockWithColumn(columns[1], "Date", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Good);
            //AdaptiveCardHelper.AddTextBlockWithColumn(columns[2], "Description", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Dark);

            //for (int i = 0; i < date.Count; i++)
            //{
            //    //for (int i1 = 0; i1 < 2; i1++)
            //    //{
            //    //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[i1], AdaptiveCardHelper.AddTextBlock((i + 1).ToString()));
            //    //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[i1+1], AdaptiveCardHelper.AddTextBlock((date[i]).ToString()));
            //    //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[i1+2], AdaptiveCardHelper.AddTextBlock((description[i]).ToString()));
            //    //}
            //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[0], AdaptiveCardHelper.AddTextBlock((i + 1).ToString()));
            //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[1], AdaptiveCardHelper.AddTextBlock((date[i]).ToString()));
            //    AdaptiveCardHelper.AddItemToAdaptiveColumn(columns[2], AdaptiveCardHelper.AddTextBlock((description[i]).ToString()));
            //}

            //var columnSet = new AdaptiveColumnSet();
            //columnSet.Columns.Add(columns[0]);
            //columnSet.Columns.Add(columns[1]);
            //columnSet.Columns.Add(columns[2]);
            //AdaptiveContainer container = AdaptiveCardHelper.AddAdaptiveContainer(columnSet);
            //card.Body.Add(container);
            //return card;
        }