Пример #1
0
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
 {
     vm = (PresenterVM)navigationParameter;
     vm.ErrorMessage            = string.Empty;
     this.DataContext           = vm;
     this.BottomAppBar.IsOpen   = true;
     this.BottomAppBar.IsSticky = true;
 }
Пример #2
0
        public async Task <FileContentResult> GetCSVData(int id)
        {
            PresenterVM vm   = new PresenterVM();
            var         list = await vm.GetAllCSVResponsesBySurveyId(id);

            var exporter  = new CsvExport <ResponseCSV>(list);
            var content   = exporter.ExportToString();
            var fileName  = vm.CurrentSurvey.SurveyTitle.Replace(" ", string.Empty) + ".csv";
            var byteArray = Encoding.UTF8.GetBytes(content);

            return(File(byteArray, "text/csv", fileName));
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            VM = (PresenterVM)navigationParameter;
            VM.ErrorMessage = string.Empty;
            //await VM.LoadQuestionsForCurrentSurvey();
            if (!VM.CurrentSurvey.Questions.Any())
            {
                CollectionIsEmptyNotification();
            }


            this.BottomAppBar.IsOpen   = true;
            this.BottomAppBar.IsSticky = true;
        }
Пример #4
0
 protected override void PreparetPrintContent()
 {
     if (firstPage == null)
     {
         vm = (PresenterVM)VM;
         var ht     = 400; // itemListView.ActualHeight;
         var wd     = 300; // itemListView.ActualWidth;
         var imgUrl = string.Format(url, vm.CurrentQuestion.Id, wd, ht);
         firstPage = new ReportPrint()
         {
             ImageUrl = imgUrl
         };
     }
     PrintingRoot.Children.Add(firstPage);
     PrintingRoot.InvalidateMeasure();
     PrintingRoot.UpdateLayout();
 }
Пример #5
0
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
 {
     VM = (PresenterVM)navigationParameter;
     VM.ErrorMessage = string.Empty;
 }
Пример #6
0
        public async Task <FileContentResult> BarChart(int id, int?w, int?h)
        {
            PresenterVM vm        = new PresenterVM();
            var         responses = await vm.GetResponsesAndLoadDataByQuestionId(id);


            Chart c = new Chart();

            c.Titles.Add(vm.CurrentQuestion.QuestionText);
            c.AntiAliasing            = AntiAliasingStyles.All;
            c.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            c.Width  = w.HasValue ? w.Value : 640; //SET HEIGHT
            c.Height = h.HasValue ? h.Value : 480; //SET WIDTH

            ChartArea ca = new ChartArea();

            ca.BackColor          = Color.FromArgb(248, 248, 248);
            ca.BackSecondaryColor = Color.FromArgb(255, 255, 255);
            ca.BackGradientStyle  = GradientStyle.TopBottom;

            ca.AxisY.IsMarksNextToAxis            = true;
            ca.AxisY.Title                        = "Total Responses";
            ca.AxisY.LineColor                    = Color.FromArgb(157, 157, 157);
            ca.AxisY.MajorTickMark.Enabled        = true;
            ca.AxisY.MinorTickMark.Enabled        = true;
            ca.AxisY.MajorTickMark.LineColor      = Color.FromArgb(157, 157, 157);
            ca.AxisY.MinorTickMark.LineColor      = Color.FromArgb(200, 200, 200);
            ca.AxisY.LabelStyle.ForeColor         = Color.FromArgb(89, 89, 89);
            ca.AxisY.LabelStyle.Format            = "{0:0.0}";
            ca.AxisY.LabelStyle.IsEndLabelVisible = false;
            ca.AxisY.LabelStyle.Font              = new Font("Calibri", 4, FontStyle.Regular);
            ca.AxisY.MajorGrid.LineColor          = Color.FromArgb(234, 234, 234);

            ca.AxisX.IsMarksNextToAxis       = true;
            ca.AxisX.LabelStyle.Enabled      = false;
            ca.AxisX.LineColor               = Color.FromArgb(157, 157, 157);
            ca.AxisX.MajorGrid.LineWidth     = 0;
            ca.AxisX.MajorTickMark.Enabled   = true;
            ca.AxisX.MinorTickMark.Enabled   = true;
            ca.AxisX.MajorTickMark.LineColor = Color.FromArgb(157, 157, 157);
            ca.AxisX.MinorTickMark.LineColor = Color.FromArgb(200, 200, 200);

            c.ChartAreas.Add(ca);

            //Series s = new Series();
            //s.Font = new Font("Lucida Sans Unicode", 6f);
            //s.Color = Color.FromArgb(215, 47, 6);
            //s.BorderColor = Color.FromArgb(159, 27, 13);

            Legend l = new Legend("test");

            l.Docking   = Docking.Bottom;
            l.BackColor = Color.White;
            l.Alignment = StringAlignment.Center;

            c.Legends.Add(l);

            var cnt = 0;

            foreach (var r in responses.ToLookup(x => x.OptionId))
            {
                var       count = r.Count();
                DataPoint p     = new DataPoint();
                p.Color = ColorCollection[cnt];
                p.BackSecondaryColor = ConvertToDarker(p.Color);
                p.BackGradientStyle  = GradientStyle.LeftRight;
                p.XValue             = r.Key;
                p.YValues            = new double[] { count };
                p.LegendText         = vm.CurrentQuestion.Options.First(x => x.Id == r.Key).OptionText;
                p.YValues            = new double[] { count };
                cnt++;

                Series s = new Series();
                s.LegendText  = vm.CurrentQuestion.Options.First(x => x.Id == r.Key).OptionText;
                s.Font        = new Font("Lucida Sans Unicode", 6f);
                s.Color       = p.Color;
                s.BorderColor = Color.FromArgb(159, 27, 13);
                s.Points.Add(p);
                c.Series.Add(s);
            }



            var ms = new MemoryStream();

            c.SaveImage(ms, ChartImageFormat.Png);

            var fs = new FileContentResult(ms.ToArray(), "image/png");

            return(fs);
        }