Esempio n. 1
0
        private void ExportToPdf(MetaDrawPsm psm, string path)
        {
            System.Reflection.PropertyInfo[] temp = psm.GetType().GetProperties();

            for (int i = 4; i < temp.Length; i++)
            {
                propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(psm, null));
            }
            dataGridProperties.Items.Refresh();
            DrawPsm(psm.ScanNum, psm.FullSequence);

            double wid = 0;

            dataGridProperties.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            dataGridProperties.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            foreach (DataGridColumn col in dataGridProperties.Columns)
            {
                wid += col.ActualWidth;
            }
            PDFOutPut.Background = Brushes.White;
            PDFOutPut.ColumnDefinitions[0].Width = new GridLength(wid + 10);
            PDFOutPut.Measure(new Size(wid + gbPSM.ActualWidth + 10, 600));
            PDFOutPut.Arrange(new Rect(new Size(wid + gbPSM.ActualWidth + 10, 600)));
            dataGridProperties.Measure(new Size(wid + 22, 600));
            dataGridProperties.Arrange(new Rect(new Size(wid + 5, 600)));

            dataGridProperties.Arrange(new Rect(new Size(wid + 5, 600)));
            var rtb = new RenderTargetBitmap((int)(wid + gbPSM.ActualWidth) + 11, 600, 96, 96, PixelFormats.Pbgra32);

            rtb.Render(PDFOutPut);
            BitmapFrame bf = BitmapFrame.Create(rtb);

            var encoder = new BmpBitmapEncoder();

            encoder.Frames.Add(bf);
            using (var stream = new MemoryStream())
            {
                encoder.Save(stream);
                var img = System.Drawing.Bitmap.FromStream(stream);
                PdfWriter.WriteToPdf(img, (int)(wid + gbPSM.ActualWidth) + 11, 600, path);
            }

            dataGridProperties.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            dataGridProperties.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
            PDFOutPut.ColumnDefinitions[0].Width             = new GridLength(1, GridUnitType.Star);
        }
Esempio n. 2
0
        /// <summary>
        /// Event triggers when a different cell is selected in the PSM data grid
        /// </summary>
        private void dataGridScanNums_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (dataGridScanNums.SelectedItem == null)
            {
                return;
            }

            // draw the selected PSM
            propertyView.Clear();
            MetaDrawPsm row = (MetaDrawPsm)dataGridScanNums.SelectedItem;

            System.Reflection.PropertyInfo[] temp = row.GetType().GetProperties();

            for (int i = 4; i < temp.Length; i++)
            {
                propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(row, null));
            }
            dataGridProperties.Items.Refresh();
            DrawPsm(row.ScanNum, row.FullSequence);
        }