Ejemplo n.º 1
0
        public override void Notify(MessageType msg, NamedElement element, object param)
        {
            base.Notify(msg, element, param);
            switch (msg)
            {
            case MessageType.NamedElementRemove:
                if (element is ScaleBase)
                {
                    ScaleBase scaleBase2 = (ScaleBase)element;
                    if (scaleBase2.Name == this.scaleName && scaleBase2.ParentElement == this.ParentElement && this.scaleName != "Default")
                    {
                        this.scaleName = string.Empty;
                    }
                }
                break;

            case MessageType.NamedElementRename:
                if (element is ScaleBase)
                {
                    ScaleBase scaleBase = (ScaleBase)element;
                    if (scaleBase.Name == this.scaleName && scaleBase.ParentElement == this.ParentElement)
                    {
                        this.scaleName = (string)param;
                    }
                }
                break;
            }
        }
Ejemplo n.º 2
0
 protected bool Equals(OverlayConfig other)
 {
     return(MinOverlayArea.Equals(other.MinOverlayArea) && MinSourceArea.Equals(other.MinSourceArea) &&
            AspectRatio1.Equals(other.AspectRatio1) && AspectRatio2.Equals(other.AspectRatio2) &&
            Angle1.Equals(other.Angle1) && Angle2.Equals(other.Angle2) && MinSampleArea == other.MinSampleArea &&
            RequiredSampleArea == other.RequiredSampleArea && MaxSampleDiff.Equals(other.MaxSampleDiff) &&
            Subpixel == other.Subpixel && ScaleBase.Equals(other.ScaleBase) && Branches == other.Branches &&
            AcceptableDiff.Equals(other.AcceptableDiff) && Correction == other.Correction);
 }
Ejemplo n.º 3
0
        private ConsoleColor GetNoteColor(Note note, ScaleBase scale)
        {
            if (scale.Notes.Any(x => x.Note == note))
            {
                return(ConsoleColor.Green);
            }

            return(ConsoleColor.DarkGray);
        }
Ejemplo n.º 4
0
        private void PrintFretboard(Note rootNote, ScaleBase scale, int numberOfFrets, Fretboard fretboard)
        {
            PrintScaleInfo(rootNote, scale);

            PrintFretNumbers(numberOfFrets);

            PrintFretboardNotes(scale, fretboard);

            PrintFretboardMarks(numberOfFrets);
        }
Ejemplo n.º 5
0
        private void PrintScaleInfo(Note rootNote, ScaleBase scale)
        {
            Console.WriteLine($"{rootNote} {scale.Name} Scale");
            Console.Write("Notes: ");
            foreach (var note in scale.Notes)
            {
                Console.Write($"{note.Note} ");
            }

            Console.WriteLine();
        }
Ejemplo n.º 6
0
        public override void PointerValueChanged(PointerBase sender)
        {
            ScaleBase scaleBase = sender.GetScaleBase();

            if (scaleBase != null)
            {
                foreach (RangeBase range in this.Ranges)
                {
                    if (range.ScaleName == scaleBase.Name)
                    {
                        range.PointerValueChanged(sender.Data);
                    }
                }
                scaleBase.PointerValueChanged(sender);
            }
        }
Ejemplo n.º 7
0
        internal override void PointerValueChanged(PointerBase sender)
        {
            ScaleBase scaleBase = sender.GetScaleBase();

            if (scaleBase == null)
            {
                return;
            }
            foreach (RangeBase range in Ranges)
            {
                if (range.ScaleName == scaleBase.Name)
                {
                    range.PointerValueChanged(sender.Data);
                }
            }
            scaleBase.PointerValueChanged(sender);
        }
Ejemplo n.º 8
0
        void IPointerProvider.DataValueChanged(bool initialize)
        {
            if (!initialize)
            {
                GetGaugeBase()?.PointerValueChanged(this);
            }
            ScaleBase scaleBase = GetScaleBase();

            if (scaleBase != null)
            {
                double valueLimit = scaleBase.GetValueLimit(data.Value, snappingEnabled, snappingInterval);
                if (initialize || !dampeningEnabled || !Data.StartDampening(valueLimit, scaleBase.MinimumLog, scaleBase.Maximum, dampeningSweepTime, Common.GaugeCore.RefreshRate))
                {
                    Position = valueLimit;
                }
            }
        }
        public GraphicsPath GetPointerPath(GaugeGraphics g)
        {
            if (!this.Visible)
            {
                return(null);
            }
            GraphicsPath graphicsPath = new GraphicsPath();
            ScaleBase    scale        = this.GetScale();

            scale.GetPositionFromValue(scale.GetValueLimit(base.Position));
            if (this.Type == LinearPointerType.Marker || this.Image != string.Empty)
            {
                MarkerStyleAttrib markerStyleAttrib = this.GetMarkerStyleAttrib(g);
                if (markerStyleAttrib.path != null)
                {
                    graphicsPath.AddPath(markerStyleAttrib.path, false);
                }
            }
            else if (this.Type == LinearPointerType.Bar)
            {
                BarStyleAttrib barStyleAttrib = this.GetBarStyleAttrib(g);
                if (barStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (barStyleAttrib.primaryPath != null)
                {
                    graphicsPath.AddPath(barStyleAttrib.primaryPath, false);
                }
            }
            else if (this.Type == LinearPointerType.Thermometer)
            {
                BarStyleAttrib thermometerStyleAttrib = this.GetThermometerStyleAttrib(g);
                if (thermometerStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (thermometerStyleAttrib.totalPath != null)
                {
                    graphicsPath.AddPath(thermometerStyleAttrib.primaryPath, false);
                }
            }
            return(graphicsPath);
        }
Ejemplo n.º 10
0
 private void PrintFretboardNotes(ScaleBase scale, Fretboard fretboard)
 {
     foreach (var fretNote in fretboard.StringNotes)
     {
         WriteColor(fretNote[0].ToString().PadRight(3, ' '), GetNoteColor(fretNote[0].Note, scale));
         Console.Write("|");
         for (int i = 1; i < fretNote.Length; i++)
         {
             Console.Write("-");
             var note = fretNote[i].ToString();
             WriteColor(note, GetNoteColor(fretNote[i].Note, scale));
             var separator = new string('-', 3 - note.Length) + "|";
             Console.Write(separator);
         }
         Console.WriteLine();
     }
 }
Ejemplo n.º 11
0
        public virtual void DragTo(int x, int y, PointF refPoint)
        {
            ScaleBase scaleBase = this.GetScaleBase();
            double    value     = scaleBase.GetValue(refPoint, new PointF((float)x, (float)y));

            value = scaleBase.GetValueLimit(value, this.SnappingEnabled, this.SnappingInterval);
            PointerPositionChangeEventArgs pointerPositionChangeEventArgs = new PointerPositionChangeEventArgs(value, DateTime.Now, this.Name, false);

            if (this.Common != null)
            {
                this.Common.GaugeContainer.OnPointerPositionChange(this, pointerPositionChangeEventArgs);
                if (pointerPositionChangeEventArgs.Accept)
                {
                    this.dragging = true;
                    this.Value    = value;
                }
            }
        }
Ejemplo n.º 12
0
        internal virtual void DragTo(int x, int y, PointF refPoint)
        {
            ScaleBase scaleBase = GetScaleBase();
            double    value     = scaleBase.GetValue(refPoint, new PointF(x, y));

            value = scaleBase.GetValueLimit(value, SnappingEnabled, SnappingInterval);
            PointerPositionChangeEventArgs pointerPositionChangeEventArgs = new PointerPositionChangeEventArgs(value, DateTime.Now, Name, playbackMode: false);

            if (Common != null)
            {
                Common.GaugeContainer.OnPointerPositionChange(this, pointerPositionChangeEventArgs);
                if (pointerPositionChangeEventArgs.Accept)
                {
                    dragging = true;
                    Value    = value;
                }
            }
        }
Ejemplo n.º 13
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinOverlayArea.GetHashCode();
         hashCode = (hashCode * 397) ^ MinSourceArea.GetHashCode();
         hashCode = (hashCode * 397) ^ AspectRatio1.GetHashCode();
         hashCode = (hashCode * 397) ^ AspectRatio2.GetHashCode();
         hashCode = (hashCode * 397) ^ Angle1.GetHashCode();
         hashCode = (hashCode * 397) ^ Angle2.GetHashCode();
         hashCode = (hashCode * 397) ^ MinSampleArea;
         hashCode = (hashCode * 397) ^ RequiredSampleArea;
         hashCode = (hashCode * 397) ^ MaxSampleDiff.GetHashCode();
         hashCode = (hashCode * 397) ^ Subpixel.GetHashCode();
         hashCode = (hashCode * 397) ^ ScaleBase.GetHashCode();
         hashCode = (hashCode * 397) ^ Branches;
         hashCode = (hashCode * 397) ^ AcceptableDiff.GetHashCode();
         hashCode = (hashCode * 397) ^ Correction;
         return(hashCode);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 生成n个随机点,X轴坐标是每隔x px出现一次,Y轴坐标的大小是随机生成的
        /// 及对应点画圆点
        /// </summary>
        /// <param name="chartCanvas"></param>
        public static Tuple <List <Ellipse>, PointCollection> DrawPointGen <T1, T2>(this Canvas canvas,
                                                                                    ScaleBase <T1> scaleBaseX, ScaleBase <T2> scaleBaseY,
                                                                                    MouseButtonEventHandler mouseDownHandler,
                                                                                    MouseEventHandler mouseLeaveHandler,
                                                                                    MouseEventHandler MouseEnterHandler,
                                                                                    Color colorEllipse,
                                                                                    int genCount = 10, int ellipseSize = 10, double leftX = 10)
            where T1 : struct
            where T2 : struct
        {
            PointCollection points        = new PointCollection();
            List <Ellipse>  pointEllipses = new List <Ellipse>();
            //随机生成n个点
            Random rPoint = new Random(DateTime.Now.Millisecond);
            int    ranY   = Convert.ToInt32(scaleBaseY.AllScaleNumber - 2);

            for (int i = 0; i < scaleBaseX.AllScaleNumber; i++)
            {
                double x_point = leftX + Math.Round(i * scaleBaseX.minScale * scaleBaseX.ScaleRate);//ellipseSize是为了补偿圆点的大小,到精确的位置
                double y_point = Math.Round(rPoint.Next(ranY) * scaleBaseY.minScale * scaleBaseY.ScaleRate);


                var newpoint = new Point(x_point, y_point);

                points.Add(newpoint);

                //生成圆
                #region 生成圆
                Ellipse newEllipse = canvas.DrawEllipse(newpoint, 10, colorEllipse, i.ToString(), false);

                newEllipse.MouseDown  += mouseDownHandler;
                newEllipse.MouseLeave += mouseLeaveHandler;
                newEllipse.MouseEnter += MouseEnterHandler;

                pointEllipses.Add(newEllipse);

                #endregion
            }
            return(new Tuple <List <Ellipse>, PointCollection>(pointEllipses, points));
        }
Ejemplo n.º 15
0
        public MarkerStyleAttrib GetMarkerStyleAttrib(GaugeGraphics g)
        {
            MarkerStyleAttrib markerStyleAttrib  = new MarkerStyleAttrib();
            float             absoluteDimension  = g.GetAbsoluteDimension(this.MarkerLength);
            float             absoluteDimension2 = g.GetAbsoluteDimension(this.Width);

            markerStyleAttrib.path = g.CreateMarker(new PointF(0f, 0f), absoluteDimension2, absoluteDimension, this.MarkerStyle);
            float num = 0f;

            if (this.Placement == Placement.Cross || this.Placement == Placement.Inside)
            {
                num = (float)(num + 180.0);
            }
            if (this.GetGauge().GetOrientation() == GaugeOrientation.Vertical)
            {
                num = (float)(num + 270.0);
            }
            if (num > 0.0)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Rotate(num);
                    markerStyleAttrib.path.Transform(matrix);
                }
            }
            float     num2              = this.CalculateMarkerDistance();
            ScaleBase scale             = this.GetScale();
            float     positionFromValue = scale.GetPositionFromValue(scale.GetValueLimit(base.Position));
            PointF    pointOrigin       = Point.Empty;

            pointOrigin             = ((this.GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num2, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num2)));
            markerStyleAttrib.brush = g.GetMarkerBrush(markerStyleAttrib.path, this.MarkerStyle, pointOrigin, 0f, this.FillColor, this.FillGradientType, this.FillGradientEndColor, this.FillHatchStyle);
            using (Matrix matrix2 = new Matrix())
            {
                matrix2.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
                markerStyleAttrib.path.Transform(matrix2);
                return(markerStyleAttrib);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// ies the axis.
        /// </summary>
        /// <param name="scale">The scale.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="title">The title.</param>
        /// <returns>System.Double.</returns>
        public static double YAxis(ScaleBase scale, AxisBase axis, RadzenAxisTitle title)
        {
            var ticks = scale.Ticks(axis.TickDistance);

            double length = 0;

            for (var y = ticks.Start; y <= ticks.End; y += ticks.Step)
            {
                var text = axis.Format(scale, y);

                length = Math.Max(length, TextMeasurer.TextWidth(text));
            }

            if (!String.IsNullOrEmpty(title.Text))
            {
                length += title.Size + 32;
            }

            length += 9 + axis.StrokeWidth;

            return(Math.Max(24, length));
        }
Ejemplo n.º 17
0
        void IPointerProvider.DataValueChanged(bool initialize)
        {
            if (!initialize)
            {
                GaugeBase gaugeBase = this.GetGaugeBase();
                if (gaugeBase != null)
                {
                    gaugeBase.PointerValueChanged(this);
                }
            }
            ScaleBase scaleBase = this.GetScaleBase();

            if (scaleBase != null)
            {
                double valueLimit = scaleBase.GetValueLimit(this.data.Value, this.snappingEnabled, this.snappingInterval);
                if (!initialize && this.dampeningEnabled && this.Data.StartDampening(valueLimit, scaleBase.MinimumLog, scaleBase.Maximum, this.dampeningSweepTime, this.Common.GaugeCore.RefreshRate))
                {
                    return;
                }
                this.Position = valueLimit;
            }
        }
Ejemplo n.º 18
0
        Boolean Equal(ScaleBase s1, ScaleBase s2)
        {
            if (s1.GetType() != s2.GetType())
            {
                return(false);
            }

            if (s1 is Linear)
            {
                var ss1 = s1 as Linear;
                var ss2 = s2 as Linear;

                return(ss1.DomainStart == ss2.DomainStart && ss1.DomainEnd == ss2.DomainEnd && ss1.RangeStart == ss2.RangeStart && ss1.RangeEnd == ss2.RangeEnd && ss1.TickCount == ss2.TickCount);
            }
            else if (s1 is Ordinal)
            {
                var ss1 = s1 as Ordinal;
                var ss2 = s2 as Ordinal;

                if (ss1.Domain.Count != ss2.Domain.Count)
                {
                    return(false);
                }
                Int32 n = ss1.Domain.Count, i;
                for (i = 0; i < n; ++i)
                {
                    if (ss1.Domain[i] != ss2.Domain[i])
                    {
                        return(false);
                    }
                }
                return(ss1.RangeStart == ss2.RangeStart && ss1.RangeEnd == ss2.RangeEnd);
            }

            return(false);
        }
Ejemplo n.º 19
0
        public void Update(Boolean useTransition)
        {
            if (Equal(previousScale, Scale))
            {
                UpdateWithSameScale(useTransition);
                return;
            }

            AxisLine.SetValue(linePrimary1, Scale.RangeStart);
            AxisLine.SetValue(linePrimary2, Scale.RangeEnd);
            AxisLine.SetValue(lineSecondary1, 0);
            AxisLine.SetValue(lineSecondary2, 0);

            List <TextBlock> previousTickLabels  = tickLabels;
            List <Line>      previousTickMarkers = tickMarkers;

            Int32 tickCount = Scale.TickCount;

            Storyboard axisStoryboard = new Storyboard()
            {
                //BeginTime = Const.AnimationDelay
            };

            #region remove previous ticks

            if (previousTickLabels != null)
            {
                if (useTransition)
                {
                    Int32       index = 0;
                    List <Tick> ticks = previousScale.GetTicks();
                    foreach (TextBlock tickLabel in previousTickLabels)
                    {
                        Tick tick       = ticks[index];
                        Line tickMarker = previousTickMarkers[index];

                        if (previousScale.GetType() == Scale.GetType() && !(Scale is Ordinal)) // 같고 ordinal이 아니어야 (linear)야 position animation 가능
                        {
                            // text block animation
                            axisStoryboard.Children.Add(
                                Util.GenerateDoubleAnimation(tickLabel, canvasPrimaryString, Scale.ClampedMap(tick.DomainValue) - (Double)tickLabel.GetValue(tickLabelSizeProperty) / 2)
                                );

                            // tick marker animation 1 & 2 (for two Xs or Ys)
                            axisStoryboard.Children.Add(
                                Util.GenerateDoubleAnimation(tickMarker, linePrimary1String, Scale.ClampedMap(tick.DomainValue), true)
                                );

                            axisStoryboard.Children.Add(
                                Util.GenerateDoubleAnimation(tickMarker, linePrimary2String, Scale.ClampedMap(tick.DomainValue), true)
                                );
                        }

                        // make text block opacity 0
                        axisStoryboard.Children.Add(
                            Util.GenerateDoubleAnimation(tickLabel, "Opacity", 0)
                            );

                        // make tick marker opacity 0
                        axisStoryboard.Children.Add(
                            Util.GenerateDoubleAnimation(tickMarker, "Opacity", 0)
                            );

                        tickLabel.SetValue(canvasSecondary, Orientation == Orientations.Horizontal ? (24 - tickLabel.ActualHeight) / 2 : -tickLabel.ActualWidth - 10);

                        index++;
                    }
                }
                else
                {
                    foreach (TextBlock tickLabel in previousTickLabels)
                    {
                        AxisCanvas.Children.Remove(tickLabel);
                    }

                    foreach (Line tickMarker in previousTickMarkers)
                    {
                        AxisCanvas.Children.Remove(tickMarker);
                    }
                }
            }

            #endregion

            #region add new ticks

            tickLabels  = new List <TextBlock>();
            tickMarkers = new List <Line>();

            var currentTicks = Scale.GetTicks();

            foreach (Tick tick in currentTicks)
            {
                TextBlock tickLabel = new TextBlock()
                {
                    Text    = tick.Label,
                    Style   = Resources["TickLabelStyle"] as Style,
                    Opacity = 0
                };

                Line tickMarker = new Line()
                {
                    Style   = Resources["TickMarkerStyle"] as Style,
                    Opacity = 0
                };

                AxisCanvas.Children.Add(tickLabel);
                tickLabel.Measure(new Size(Double.MaxValue, Double.MaxValue));

                if (Orientation == Orientations.Vertical)
                {
                    if (tickLabel.ActualWidth > 28)
                    {
                        tickLabel.FontSize = tickLabel.FontSize * 28 / tickLabel.ActualWidth;
                        tickLabel.Measure(new Size(Double.MaxValue, Double.MaxValue));
                    }
                    tickLabel.Height = tickLabel.ActualHeight;
                }
                else if (Orientation == Orientations.Horizontal)
                {
                    tickLabel.MaxWidth = Math.Abs(Scale.RangeEnd - Scale.RangeStart) / currentTicks.Count;
                    tickLabel.Measure(new Size(Double.MaxValue, Double.MaxValue));
                    //tickLabel.Width = tickLabel.ActualWidth;
                }

                tickLabel.SetValue(canvasPrimary, previousScale.ClampedMap(tick.DomainValue) - (Double)tickLabel.GetValue(tickLabelSizeProperty) / 2);
                tickLabel.SetValue(canvasSecondary, Orientation == Orientations.Horizontal ? (24 - tickLabel.ActualHeight) / 2 : -tickLabel.ActualWidth - 10);

                AxisCanvas.Children.Add(tickMarker);

                tickMarker.SetValue(linePrimary1, previousScale.ClampedMap(tick.DomainValue));
                tickMarker.SetValue(linePrimary2, previousScale.ClampedMap(tick.DomainValue));
                tickMarker.SetValue(lineSecondary1, 0);
                tickMarker.SetValue(lineSecondary2, Orientation == Orientations.Horizontal ? 3 : -3);

                if (!useTransition || (previousScale.GetType() != Scale.GetType() || Scale is Ordinal)) // position animation disabled because two scales have different types
                {
                    tickLabel.SetValue(canvasPrimary, tick.RangeValue - (Double)tickLabel.GetValue(tickLabelSizeProperty) / 2);
                    tickMarker.SetValue(linePrimary1, tick.RangeValue);
                    tickMarker.SetValue(linePrimary2, tick.RangeValue);
                }
                else
                {
                    axisStoryboard.Children.Add(
                        Util.GenerateDoubleAnimation(tickLabel, canvasPrimaryString, tick.RangeValue - (Double)tickLabel.GetValue(tickLabelSizeProperty) / 2)
                        );

                    axisStoryboard.Children.Add(
                        Util.GenerateDoubleAnimation(tickMarker, linePrimary1String, tick.RangeValue, true)
                        );

                    axisStoryboard.Children.Add(
                        Util.GenerateDoubleAnimation(tickMarker, linePrimary2String, tick.RangeValue, true)
                        );
                }

                if (useTransition)
                {
                    axisStoryboard.Children.Add(
                        Util.GenerateDoubleAnimation(tickLabel, "Opacity", LabelOpacityGetter == null ? 1 : LabelOpacityGetter(tick.DomainValue, 0, tickLabel))
                        );

                    axisStoryboard.Children.Add(
                        Util.GenerateDoubleAnimation(tickMarker, "Opacity", 1)
                        );
                }
                else
                {
                    tickLabel.Opacity  = LabelOpacityGetter == null ? 1 : LabelOpacityGetter(tick.DomainValue, 0, tickLabel);
                    tickMarker.Opacity = 1;
                }

                tickLabels.Add(tickLabel);
                tickMarkers.Add(tickMarker);
            }
            #endregion

            axisStoryboard.Completed += delegate
            {
                if (previousTickLabels != null)
                {
                    foreach (TextBlock tickLabel in previousTickLabels)
                    {
                        AxisCanvas.Children.Remove(tickLabel);
                    }

                    foreach (Line tickMarker in previousTickMarkers)
                    {
                        AxisCanvas.Children.Remove(tickMarker);
                    }
                }
            };

            axisStoryboard.Begin();

            previousScale = Scale.Clone();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化设备层
        /// </summary>
        /// <param name="num">初始化相机数量</param>
        /// <param name="protocol">重量采集协议</param>
        public bool Initialization(int num, string protocol)
        {
            MvBarCode.MvBarCodeGlobalVar.Log.Info("抵达设备层初始化");

            //不是离线模式才去发现设备
            if (!MvBarCode.MvBarCodeGlobalVar.LocalImageMode)
            {
                // 搜索设备
                List <IDeviceInfo> li = Enumerator.EnumerateDevices();
                if (li.Count < num)
                {
                    MvBarCode.MvBarCodeGlobalVar.Log.ErrorFormat("初始化失败,实际发现设备:{0},计划发现设备:{1}", li.Count.ToString(), num.ToString());
                    return(false);
                }
            }
            else
            {
                MvBarCode.MvBarCodeGlobalVar.Log.Info("离线模式:初始化设备");
            }

            // 初始化相机
            if (_BarCodeCamera == null)
            {
                // 按照索引号初始化相机
                _BarCodeCamera = new BarCodeCamera[num];
            }

            // 初始化相机组中的相机对象
            for (var i = 0; i < num; ++i)
            {
                if (_BarCodeCamera[i] == null)
                {
                    _BarCodeCamera[i] = new BarCodeCamera(i);
                }
            }

            // 初始化电子秤
            if (_Scale == null)
            {
                _Scale = ScaleBase.GetScale(protocol);
                if (_Scale == null)
                {
                    MvBarCode.MvBarCodeGlobalVar.Log.ErrorFormat("scale为null,初始化失败");
                    return(false);
                }

                // 控制采样数量
                _Scale.SampleNum = 4;

                // 控制采样精度
                _Scale.MaxDeviation = 0.03;

                StringBuilder builder = new StringBuilder(128);
                GetPrivateProfileString("WeightParam", "SampleNum", "4", builder, 128, Environment.CurrentDirectory + "\\config.ini");
                int result;
                int.TryParse(builder.ToString(), out result);
                if (result > 4)
                {
                    _Scale.SampleNum = result;
                }

                GetPrivateProfileString("WeightParam", "MaxDeviation", "0.03", builder, 128, Environment.CurrentDirectory + "\\config.ini");
                double result2;
                double.TryParse(builder.ToString(), out result2);
                if (result2 > 0)
                {
                    _Scale.MaxDeviation = result2;
                }
            }

            return(true);
        }