Esempio n. 1
0
        private static void set_sat(ref double _r, ref double _g, ref double _b, double s)
        {
            DoubleRef r = new DoubleRef {
                Value = _r
            };
            DoubleRef g = new DoubleRef {
                Value = _g
            };
            DoubleRef b = new DoubleRef {
                Value = _b
            };

            DoubleRef min = REFMIN(r, REFMIN(g, b));
            DoubleRef mid = REFMID(r, g, b);
            DoubleRef max = REFMAX(r, REFMAX(g, b));

            if (max.Value > min.Value)
            {
                mid.Value = ((mid.Value - min.Value) * s) / (max.Value - min.Value);
                max.Value = s;
            }
            else
            {
                mid.Value = 0;
                max.Value = 0;
            }

            min.Value = 0;

            _r = r.Value;
            _g = g.Value;
            _b = b.Value;
        }
        private Double dilutionRate = 1;    // ml/sec

        public CultureSimulator(TurbidoAlgorithmLibrary _library)
        {
            library              = _library;
            lastTime             = new DoubleRef();
            lastOD               = new DoubleArrayRef(numberOfCultures);
            GrowthTimer          = new System.Timers.Timer(dataPointPeriod * 1000);
            GrowthTimer.Elapsed += this.GrowthTick;

            var rng = new CryptoRandomSource();

            // initialize cultures
            for (int i = 0; i < 4; i++)
            {
                if (culture_set == 'A')
                {
                    lastOD.values[i]     = rng.NextDouble() * initialOD;
                    lastOD.values[8 + i] = rng.NextDouble() * initialOD;
                    lastOD.values[4 + i] = lastOD.values[12 + i] = 0;
                }
                else
                {
                    lastOD.values[4 + i]  = rng.NextDouble() * initialOD;
                    lastOD.values[12 + i] = rng.NextDouble() * initialOD;
                    lastOD.values[i]      = lastOD.values[8 + i] = 0;
                }
            }
        }
Esempio n. 3
0
    public static void Main(string[] args)
    {
        TargetType target = new TargetType();
        SingleRef  s      = new SingleRef();
        DoubleRef  d      = new DoubleRef();
        TripleRef  t      = new TripleRef();

        TheRoot = s;

        object[] arr = new object[42];
        s.Item1 = arr;
        arr[27] = d;

        // parallel path.
        d.Item1 = new SingleRef()
        {
            Item1 = t
        };
        d.Item2 = t;

        s = new SingleRef();

        t.Item1 = new SingleRef()
        {
            Item1 = s
        };
        t.Item2 = s;
        t.Item3 = new object(); // dead path


        _dependent.Add(s, target);
        //s.Item1 = target;
        throw new Exception();
        GC.KeepAlive(target);
    }
Esempio n. 4
0
        /// <summary>
        /// Listen to any click events on the PDFViewCtrl
        /// </summary>
        private async void PDFViewCtrl_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
            {
                if (barcodeSelected == BarcodeType.None)
                {
                    return;
                }

                // Get click position
                Windows.Foundation.Point pt = e.GetCurrentPoint(PDFViewCtrl).Position;

                int pageNumber = PDFViewCtrl.GetPageNumberFromScreenPoint(pt.X, pt.Y);

                // Check if clicked outside the page bounds
                if (pageNumber == -1)
                {
                    return;
                }

                var  doc  = PDFViewCtrl.GetDoc();
                Page page = doc.GetPage(pageNumber);

                DoubleRef ref_x = new DoubleRef(pt.X);
                DoubleRef ref_y = new DoubleRef(pt.Y);
                PDFViewCtrl.ConvScreenPtToPagePt(ref_x, ref_y, pageNumber);

                int pgX = (int)ref_x.Value;
                int pgY = (int)ref_y.Value;

                pdftron.Common.Matrix2D mtx = page.GetDefaultMatrix();
                mtx.Mult(ref_x, ref_y);

                switch (barcodeSelected)
                {
                case BarcodeType.UPCA:
                    await PerformAddBarcode(doc, BarcodeFormat.UPC_A, barcodeData, ref_x.Value, ref_y.Value);

                    break;

                case BarcodeType.QRCode:
                    await PerformAddBarcode(doc, BarcodeFormat.QR_CODE, barcodeData, ref_x.Value, ref_y.Value);

                    break;

                case BarcodeType.DataMatrix:
                    await PerformAddBarcode(doc, BarcodeFormat.DATA_MATRIX, barcodeData, ref_x.Value, ref_y.Value);

                    break;
                }

                barcodeSelected      = BarcodeType.None;
                IsAddBarcodeSelected = false;
            }
        }
Esempio n. 5
0
 private static DoubleRef REFMID(DoubleRef x, DoubleRef y, DoubleRef z)
 {
     return(REFMAX(x, REFMIN(y, z)));
 }
Esempio n. 6
0
 private static DoubleRef REFMAX(DoubleRef x, DoubleRef y)
 {
     return(x.Value > y.Value ? x : y);
 }
Esempio n. 7
0
 private static DoubleRef REFMIN(DoubleRef x, DoubleRef y)
 {
     return(x.Value < y.Value ? x : y);
 }