Esempio n. 1
0
        public GroupMetrics(string ID_Type, Metrics metrics)
            : base()
        {
            MetricsList.Add(metrics);

            _objectType = ID_Type;
            _originX    = metrics.OriginX;
            _originY    = metrics.OriginY;
            _top        = metrics.Top;
            _right      = metrics.Right;
            _bottom     = metrics.Bottom;
            _left       = metrics.Left;
        }
Esempio n. 2
0
        /// <summary>
        /// The relevant CSSObjectClasses are set when creating the anchorMetrics and drawObject.Metrics,
        /// so don't need to be mentioned again when calling the base constructor here.
        /// Note that the drawObject.Metrics added here will be used for both horizontal and vertical
        /// collision checking. Additional metrics can be added _after_ doing horizontal justification
        /// if that is not the intended behaviour -- using the virtual Add(metrics) function.
        /// </summary>
        /// <param name="firstMetrics">The first metrics object in this AnchorMetrics.</param>
        /// <param name="drawObject">An attached drawObject with drawObject.Metrics != null</param>
        public AnchorMetrics(Metrics firstMetrics, List <DrawObject> drawObjects)
            : base(CSSObjectClass.none)
        {
            _top    = firstMetrics.Top;
            _right  = firstMetrics.Right;
            _bottom = firstMetrics.Bottom;
            _left   = firstMetrics.Left;
            MetricsList.Add(firstMetrics);

            foreach (var drawObject in drawObjects)
            {
                this.Add(drawObject.Metrics);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// An ExtenderMetrics is a textMetrics followed by (possibly dotted) horizontal line with a solid vertical end marker line on its right.
        /// </summary>
        /// <param name="left">The left coordinate of the displayed extender (with or without text)</param>
        /// <param name="right">The right coordinate of the displayed extender</param>
        /// <param name="hLineY">The y-coordinate of the horizontal line.</param>
        /// <param name="strokeDashArray">If null, the line will be solid.</param>
        /// <param name="endMarkerHeight">Is negative if extender is under its containing staff.</param>
        public ExtenderMetrics(CSSObjectClass cssObjectClass, TextMetrics textMetrics, double left, double right, double hLineY, string strokeDashArray, double endMarkerHeight,
                               bool displayEndMarker)
            : base(cssObjectClass)
        {
            _left    = left;
            _right   = right;
            _top     = hLineY; // the real height of the extender is ignored
            _bottom  = hLineY;
            _originX = _left;
            _originY = hLineY;

            _textMetrics      = textMetrics;
            _strokeDashArray  = strokeDashArray;
            _endMarkerHeight  = endMarkerHeight;
            _displayEndMarker = displayEndMarker;

            MetricsList.Add(textMetrics); // will be moved automatically
        }
Esempio n. 4
0
        // TupletMetrics(textMetrics, bracketHoriz, bracketLeft, bracketRight, bracketHeight, isOver)
        public TupletMetrics(TextMetrics textMetrics, double bracketHoriz, double bracketLeft, double bracketRight, double bracketHeight, bool isOver)
            : base(CSSObjectClass.tupletBracket)
        {
            _tupletTextMetrics = textMetrics;
            _text = textMetrics.TextInfo.Text;

            double bracketTop    = (isOver) ? bracketHoriz: bracketHoriz - bracketHeight;
            double bracketBottom = (isOver) ? bracketHoriz + bracketHeight : bracketHoriz;

            _top    = (textMetrics.Top < bracketTop) ? textMetrics.Top : bracketTop;
            _right  = (textMetrics.Right > bracketRight) ? textMetrics.Right : bracketRight;
            _bottom = (textMetrics.Bottom > bracketBottom) ? textMetrics.Bottom : bracketBottom;
            _left   = (textMetrics.Left < bracketLeft) ? textMetrics.Left : bracketLeft;

            _bracketBoundary = new TupletBracketBoundaryMetrics(bracketTop, bracketRight, bracketBottom, bracketLeft, isOver);

            MetricsList.Add(textMetrics);
            MetricsList.Add(_bracketBoundary);
        }
Esempio n. 5
0
 static Coefficient()
 {
     using (var reader = new StreamReader($"{Const.SettingsDirName}/{Const.CoefficientsSettings}"))
     {
         Dictionary <int, (string, Metric)> columnNumToName = null;
         while (!reader.EndOfStream)
         {
             string[] data = reader.ReadLine()?.Split(';');
             if (data?[0] == "Name")
             {
                 columnNumToName = new Dictionary <int, (string, Metric)>(data.Length);
                 bool isMetric = false;
                 for (var i = 0; i < data.Length; i++)
                 {
                     if (data[i] == "#Metrics")
                     {
                         isMetric = true;
                         columnNumToName.Add(i, ("", null));
                     }
                     else
                     {
                         Metric m = null;
                         if (isMetric)
                         {
                             m = new Metric(data[i]);
                             MetricsList.Add(m);
                         }
                         columnNumToName.Add(i, (data[i], m));
                     }
                 }
             }
             else if (!string.IsNullOrEmpty(data?[0]))
             {
                 CoefficientList.Add(ParseCoefficient(data, columnNumToName));
             }
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Adds the metrics to the MetricsList and includes it in this object's boundary.
 /// The boundary is used for collision checking. All objects which should move together with this object
 /// must be added to the MetricsList.
 /// </summary>
 /// <param name="metrics"></param>
 public virtual void Add(Metrics metrics)
 {
     MetricsList.Add(metrics);
     ResetBoundary();
 }