Ejemplo n.º 1
0
        private void contextMenuitemSaveAs_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog save_fileDialog = new SaveFileDialog()
            {
                Filter = "PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|BMP (*.bmp)|*.bmp|Word документ (*.docx)|*.docx"
            };

            if (save_fileDialog.ShowDialog() == true && !String.IsNullOrEmpty(save_fileDialog.FileName))
            {
                norms_ = PatientDB.Instance.GetTestNorms(test_type)[indicator_.Name];
                string             file_name = save_fileDialog.FileName;
                RenderTargetBitmap rtb       = new RenderTargetBitmap((int)chartControl.ActualWidth, (int)chartControl.ActualHeight, 100, 100, PixelFormats.Pbgra32);
                rtb.Render(chartControl);

                BitmapEncoder bitmap_encoder = null;
                if (file_name.Contains(".png"))
                {
                    bitmap_encoder = new PngBitmapEncoder();
                }
                else if (file_name.Contains(".jpg"))
                {
                    bitmap_encoder = new JpegBitmapEncoder();
                }
                else if (file_name.Contains(".bmp"))
                {
                    bitmap_encoder = new BmpBitmapEncoder();
                }

                else if (file_name.Contains(".docx"))
                {
                    DocumentGenerator.CreateDynamicsReport(CurrentPatient, test_list_, test_type, indicator_, file_name);
                    MessageBox.Show("Документ с отчетом о динамики показателей успешно сохранен!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                bitmap_encoder.Frames.Add(BitmapFrame.Create(rtb));
                using (FileStream fs = new FileStream(save_fileDialog.FileName, FileMode.Create))
                {
                    bitmap_encoder.Save(fs);
                    MessageBox.Show("График динамики показателей успешно сохранен!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Ejemplo n.º 2
0
        public Dictionary <string, TestNorms> GetTestNorms(Type test_type)
        {
            Assembly assembly_ = this.GetType().Assembly;

            using (Stream stream = assembly_.GetManifestResourceStream("SanusVitae.med_data.Norms.xml"))
            {
                var norms_list     = new Dictionary <string, TestNorms>();
                var indicators     = test_type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                var norms_document = XDocument.Load(stream).Root.Elements("test").Where(x => x.Attribute("name").Value.Equals(test_type.Name)).ToArray()[0];
                foreach (var indicator in indicators.Where(x => x.IsDefined(typeof(TestInfo))))
                {
                    var       indicator_norms = norms_document.Elements("indicator").Where(x => x.Attribute("name").Value.Equals(indicator.Name)).ToArray()[0];
                    TestNorms test_norms      = new TestNorms();
                    test_norms.Min      = Double.Parse(indicator_norms.Element("min").Value, CultureInfo.InvariantCulture);
                    test_norms.MinError = Double.Parse(indicator_norms.Element("min").Attribute("error").Value, CultureInfo.InvariantCulture);
                    test_norms.Max      = Double.Parse(indicator_norms.Element("max").Value, CultureInfo.InvariantCulture);
                    test_norms.MaxError = Double.Parse(indicator_norms.Element("max").Attribute("error").Value, CultureInfo.InvariantCulture);

                    norms_list.Add(indicator.Name, test_norms);
                }
                return(norms_list);
            }
        }