Exemplo n.º 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            //MessageBox.Show("!"+b.Tag.ToString()+"!");
            StringDataGroup      sdg = DataGroups[b.Tag.ToString()] as StringDataGroup;
            StringSelectorWindow ssw = new StringSelectorWindow();

            try
            {
                ssw.StringListView.ItemsSource = Strings[b.Tag.ToString()];
            }
            catch
            {
                return;
            }
            if (ssw.ShowDialog() ?? false)
            {
                string s = ssw.StringListView.SelectedItem as string;
                if (s != null)
                {
                    sdg.TbString = s;
                }
            }
        }
Exemplo n.º 2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Button          b   = sender as Button;
            string          key = b.Tag.ToString();
            StringDataGroup sdg = DataGroups[key] as StringDataGroup;
            List <string>   ss  = Strings[key];

            if (ss == null)
            {
                Strings.Add(key, new string[] { sdg.TbString }.ToList <string>());
            }
            else
            {
                if (!ss.Exists(x => x == sdg.TbString))
                {
                    ss.Add(sdg.TbString);
                }
            }

            FileStream    fs = new FileStream(@"Xml\strings.xml", FileMode.Create);
            XmlSerializer xs = new XmlSerializer(typeof(SerializableDictionary <string, List <string> >));

            xs.Serialize(fs, Strings);
            fs.Close();
            fs.Dispose();
        }
Exemplo n.º 3
0
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);
            if (DataGroups == null)
            {
                return;
            }
            foreach (KeyValuePair <string, DataGroup> kvp in DataGroups)
            {
                double k  = 1.2;
                double xs = this.ActualWidth / 100;
                double ys = this.ActualHeight / 100;
                double fs = Convert.ToInt32(this.ActualHeight / 30) * k;

                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), fs * sdg.FontScale, new SolidColorBrush(Colors.Black));
                    dc.DrawText(ft, new Point(sdg.ScreenPosition.X * xs, sdg.ScreenPosition.Y * ys));

                    /*dc.DrawLine(new Pen(new SolidColorBrush(Colors.Black), 1),
                     *  new Point(sdg.ScreenPosition.X * xs, sdg.ScreenPosition.Y * ys + ft.Baseline),
                     *  new Point(sdg.ScreenPosition.X * xs + ft.Width, sdg.ScreenPosition.Y * ys + ft.Baseline));//*/
                }
                CheckDataGroup cdg = kvp.Value as CheckDataGroup;
                if (cdg != null)
                {
                    string s = cdg.CheckString ?? "X";
                    if (cdg.Checked)
                    {
                        FormattedText ft = new FormattedText(s, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(cdg.FontName), fs * cdg.FontScale, new SolidColorBrush(Colors.Black));
                        dc.DrawText(ft, new Point(cdg.ScreenPosition.X * xs, cdg.ScreenPosition.Y * ys));
                    }
                }
            }
        }
Exemplo n.º 4
0
        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);
            }
        }