Ejemplo n.º 1
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintRenderer render = new PrintRenderer(attendanceVms, course);

            bitmap = render.GenerateGrid();
            using (MemoryStream memory = new MemoryStream())
            {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Seek(0, SeekOrigin.Begin);
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
            }

            PrintDialog   dialog = new PrintDialog();
            PrintDocument doc    = new PrintDocument();

            doc.PrintPage += this.Doc_PrintPage;

            doc.DefaultPageSettings.Landscape = true;

            bool?result = dialog.ShowDialog();

            if (result.HasValue == result == true)
            {
                doc.PrinterSettings.PrinterName = dialog.PrintQueue.FullName;
                doc.Print();
            }
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            course = Course.GetCoursesByClassroom("C2427")[0];
            List <Attendance> attendances = Attendance.GetAttendancesByCourseId(course.Id);

            foreach (List <Attendance> ia in AttendancesSplit(attendances))
            {
                if (ia.Count > 0)
                {
                    Student             student = ia[0].Student;
                    AttendanceViewModel avm     = new AttendanceViewModel(course, student, ia);
                    attendanceVms.Add(avm);
                }
            }

            PrintRenderer render = new PrintRenderer(attendanceVms, course);

            bitmap = render.GenerateGrid();
            using (MemoryStream memory = new MemoryStream())
            {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Seek(0, SeekOrigin.Begin);
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
                image.Source = bitmapImage;
            }
        }