示例#1
0
 public void EnqueueTick(MetricTick tick)
 {
     if (EnableMetrics)
     {
         tick.Id = Guid.NewGuid();
         _ticks.Enqueue(tick);
     }
 }
示例#2
0
        public async Task <MetricTick> InsertMetricTicksAsync(MetricTick metricTick)
        {
            try
            {
                await _metricTicks.InsertOneAsync(metricTick);

                return(metricTick);
            }
            catch (MongoDB.Driver.MongoWriteException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
示例#3
0
        private void DrawRulerMetricMeasure(int start, int end, MetricTick tick)
        {
            if(tick == MetricTick.Millimeter)
            {
                int mmDivision = (end - start) / 5;

                for(int i = 1; i < 5; i++)
                {
                    DrawRulerMetricMark(start + (mmDivision * i), tick);
                }

                return;
            }

            int midPoint = (start + end) / 2;

            DrawRulerMetricMeasure(start, midPoint, tick - 1);
            DrawRulerMetricMark(midPoint, tick);
            DrawRulerMetricMeasure(midPoint, end, tick - 1);
        }
示例#4
0
        private void DrawRulerMetricMark(int position, MetricTick tick, string label = "")
        {
            Line line = new Line()
            {
                Style = (Style)this.LayoutRoot.Resources[tick.ToString()],
                Y1 = position,
                Y2 = position
            };

            if(tick == MetricTick.Centimeter)
            {
                line.Name = "tick_cm_" + label;
                TextBlock textBlock = new TextBlock()
                {
                    Name = "label_" + line.Name,
                    Text = label,
                    FontSize = 24,
                    Foreground = new SolidColorBrush(Colors.Black),
                    RenderTransform = new RotateTransform()
                    {
                        Angle = 90
                    }
                };

                textBlock.Margin = new Thickness(line.X2 + 36, line.Y1 - 6, 0, 0);
                this.RulerGrid.Children.Add(textBlock);
            }

            Debug.WriteLine("Drawing line {0} at {1}", tick.ToString(), line.Y1);
            this.RulerGrid.Children.Add(line);
        }