예제 #1
0
        private void DrawWells(DrawingContext drawingContext, double usableWidth, double usableHeight)
        {
            double yUnit = usableHeight / rows;
            double xUnit = usableWidth / cols;

            PlateData plateData = GlobalVars.Instance.PlatesInfo.CurrentPlateData;
            double    maxVol    = plateData.Max();

            for (int y = 0; y < rows; y++)
            {
                DrawYAxis(y, yUnit, drawingContext);
                for (int x = 0; x < cols; x++)
                {
                    if (y == 0)
                    {
                        DrawXAxis(x, xUnit, drawingContext);
                    }

                    double xStart = xUnit * x;
                    double yStart = yUnit * y;

                    DrawRects(new Point(border + xStart, border + yStart), xUnit, yUnit, x, y, plateData, maxVol, drawingContext);
                }
            }
        }
예제 #2
0
        private void DrawRects(Point ptStart, double width, double height,
                               int x, int y,
                               PlateData plateDate, double maxVol,
                               DrawingContext drawingContext)
        {
            int  id       = GetID(x, y);
            Size cellSize = new Size(width, height);
            //rect
            Color           thinPenColor = Colors.Gray;
            Pen             thinPen      = new Pen(new SolidColorBrush(thinPenColor), 1);
            SolidColorBrush renderBrush  = new SolidColorBrush(Colors.Transparent);

            drawingContext.DrawRectangle(renderBrush, thinPen, new Rect(ptStart, cellSize));

            //vol
            double vol2Show = 0;

            if (plateDate.Stage == AcquiredStage.BackGround)
            {
                SolidColorBrush volBrush = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0));
                double          val      = plateDate[id].backGround;
                vol2Show = val;
                DrawVol(val, maxVol, cellSize, ptStart, volBrush, thinPen, drawingContext);
            }
            else
            {
                SolidColorBrush volBrush = new SolidColorBrush(Colors.LightBlue);
                double          val      = plateDate[id].sampleVal - plateDate[id].backGround;
                val      = Math.Max(val, 0);
                vol2Show = val;
                DrawVol(val, maxVol, cellSize, ptStart, volBrush, thinPen, drawingContext);
            }

            //id & volume
            int xStart = (int)(ptStart.X + width * 0.1);
            int yStart = (int)(ptStart.Y + height * 0.2);

            var txtSrcPos = new FormattedText(
                string.Format("{0}{1}", (char)(y + 'A'), x + 1),
                System.Globalization.CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface("Courier new"),
                height / 4,
                Brushes.Blue);

            int yStartVol = (int)(ptStart.Y + height * 0.6);
            var txtVol    = new FormattedText(
                string.Format("{0:F}", vol2Show),
                System.Globalization.CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface("Courier new"),
                height / 4,
                Brushes.Blue);

            //drawingContext.DrawText(txt, new Point(xStart, yStart));
            drawingContext.DrawText(txtSrcPos, new Point(xStart, yStart));
            drawingContext.DrawText(txtVol, new Point(xStart, yStartVol));
        }
예제 #3
0
        public static void Write()
        {
            PlateData     plateData = GlobalVars.Instance.PlatesInfo.CurrentPlateData;
            string        sFileName = GlobalVars.Instance.PlatesInfo.CurrentPlateData.FilePath;
            AcquiredStage curStage  = plateData.Stage;
            Application   excel     = new Application();
            Workbook      workBook  = excel.Workbooks.Open(sFileName);
            Worksheet     xlsWs     = null;
            Range         ExcelCellText;

            xlsWs = (Worksheet)workBook.Worksheets.get_Item(2);
            string sCell = curStage == AcquiredStage.BackGround ? "C12" : "C2";

            ExcelCellText     = xlsWs.get_Range(sCell, Missing.Value);
            ExcelCellText     = ExcelCellText.get_Resize(8, 12);
            double[,] myArray = new double[8, 12];
            int curIndex = 0;

            for (int r = 0; r < myArray.GetLength(0); r++)
            {
                for (int c = 0; c < myArray.GetLength(1); c++)
                {
                    double val = curStage == AcquiredStage.BackGround ? plateData.Values[curIndex].backGround : plateData.Values[curIndex].sampleVal;
                    myArray[r, c] = val;
                    curIndex++;
                }
            }
            ExcelCellText.set_Value(Missing.Value, myArray);
            workBook.Save();
            try
            {
                if (curStage == AcquiredStage.SampleVal)
                {
                    Process.Start("explorer.exe", sFileName);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("未能打印!");
            }
            workBook.Close();
            excel.Quit();
        }