private void DocsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DocumentDescription selDoc     = DocsList.SelectedItem as DocumentDescription;
            FileStream          fs         = new FileStream(@"Xml\" + selDoc.XmlFileName, FileMode.Open);
            XmlSerializer       xs         = new XmlSerializer(typeof(List <DataGroup>));
            List <DataGroup>    dataGroups = xs.Deserialize(fs) as List <DataGroup>;

            fs.Close();
            fs.Dispose();
            DataGroupList.ItemsSource = dataGroups;
            TextBox tb = new TextBox();

            DataGroups = new Dictionary <string, DataGroup>();
            foreach (DataGroup dg in dataGroups)
            {
                DataGroups.Add(dg.Name, dg);
            }
            DisplayDoc.DataGroups = DataGroups;
        }
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            DocumentDescription doc = DocsList.SelectedItem as DocumentDescription;

            if (doc == null)
            {
                return;
            }
            if (DataGroups == null)
            {
                return;
            }


            PrintDialog pd = new PrintDialog();

            if (doc.PrintOrientation.ToLower() == "landscape")
            {
                pd.PrintTicket.PageOrientation = PageOrientation.Landscape;
            }
            else
            {
                pd.PrintTicket.PageOrientation = PageOrientation.Portrait;
            }
            pd.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
            if (pd.ShowDialog() ?? false)
            {
                if (doc.PrintOrientation.ToLower() == "landscape")
                {
                    pd.PrintTicket.PageOrientation = PageOrientation.Landscape;
                }
                else
                {
                    pd.PrintTicket.PageOrientation = PageOrientation.Portrait;
                }
                pd.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
                MessageBox.Show("Kérem helyezze be a nyomtatványt " + doc.PrintOrientation + " tájolással. \nHa kész, nyomja meg az OK gombot.", "Dokumentum tájolás", MessageBoxButton.OK, MessageBoxImage.Information);
                PrintQueue        pq  = pd.PrintQueue;
                PrintCapabilities pc  = pq.GetPrintCapabilities();
                DrawingVisual     vis = new DrawingVisual();
                DrawingContext    dc  = vis.RenderOpen();
                string            prn = pq.Name;
                PrinterSettings   ps;
                if (Printers.ContainsKey(prn))
                {
                    ps = Printers[prn];
                }
                else
                {
                    ps = Printers["Default"];
                }

                double stx  = ps.XOffset + (pc.OrientedPageMediaWidth ?? 870) / 2;
                double dsty = ps.YOffset + pc.PageImageableArea.OriginHeight;

                double defaultFontSize = 14;
                double mmphi           = 0.254;

                foreach (KeyValuePair <string, DataGroup> kvp in DataGroups)
                {
                    StringDataGroup sdg = kvp.Value as StringDataGroup;
                    if (sdg != null)
                    {
                        string        s   = sdg.TbString ?? "";
                        FormattedText ft  = new FormattedText(s, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(sdg.FontName), defaultFontSize * sdg.FontScale, new SolidColorBrush(Colors.Black));
                        double        sty = dsty - ft.Baseline;
                        dc.DrawText(ft, new Point(stx + sdg.PrintPosition.X / mmphi, sty + sdg.PrintPosition.Y / mmphi));//*/
                    }
                    CheckDataGroup cdg = kvp.Value as CheckDataGroup;
                    if (cdg != null)
                    {
                        if (cdg.Checked)
                        {
                            string        s   = cdg.CheckString ?? "X";
                            FormattedText ft  = new FormattedText(s, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(cdg.FontName), defaultFontSize * cdg.FontScale, new SolidColorBrush(Colors.Black));
                            double        sty = dsty - ft.Baseline;
                            dc.DrawText(ft, new Point(stx + cdg.PrintPosition.X / mmphi, sty + cdg.PrintPosition.Y / mmphi));//*/
                        }
                    }
                }


                dc.Close();

                pd.PrintVisual(vis, doc.Name);
            }
        }