Ejemplo n.º 1
0
        protected override void OnKeyPress( KeyPressEventArgs e )
        {
            if (e.KeyChar == ('W' & 0x1F) &&
                _person != null &&
                _person.HasPhoto &&
                !_person.AddedByPhotographer &&
                Global.Skola.StudentCardTemplates.Count > _nStudentCardTemplate)
            {
                e.Handled = true;
                if (_person.StudentCardIsPrinted)
                    if (Global.askMsgBox(this, "Är du säker på att du vill skriva ut den här personen en gång till?", true) !=
                        DialogResult.Yes)
                        return;
                var mall = Global.Skola.StudentCardTemplates[_nStudentCardTemplate] as Template;
                try
                {
                    using (var painter = new Painter(300, mall.Page, null))
                    {
                        painter.ClearBackground();
                        using (var bmpPortrait = (Bitmap) Image.FromFile(_person.getViewImageFileName(TypeOfViewImage.BackdroppedHi)))
                            painter.PaintPerson(
                                0, 0, 0,
                                pl => bmpPortrait,
                                null,
                                _person,
                                true);
                        Printer.print(
                            painter.Bitmap,
                            TextConv.ConvertText(mall.Magnet, _person));
                        _person.StudentCardIsPrinted = true;
                    }
                }
                catch (Exception ex)
                {
                    Global.showMsgBox(this, ex.Message);
                }
                return;
            }

            base.OnKeyPress(e);
        }