Esempio n. 1
0
        ///<inheritdoc/>
        public virtual IEnumerable <ILabelModelParameter> GetParameters(ILabel label, ILabelModel model)
        {
            SliderEdgeLabelModel        sliderEdgeLabelModel = (SliderEdgeLabelModel)model;
            List <ILabelModelParameter> result = new List <ILabelModelParameter>();
            IEdge         edge     = (IEdge)label.Owner;
            IPathGeometry geometry = GetPathGeometry(edge);

            if (geometry != null)
            {
                int count = geometry.GetSegmentCount();
                for (int i = 0; i < count; i++)
                {
                    result.Add(sliderEdgeLabelModel.CreateParameterFromSource(i, 0));
                    result.Add(sliderEdgeLabelModel.CreateParameterFromSource(i, 0.5));
                    result.Add(sliderEdgeLabelModel.CreateParameterFromSource(i, 1));
                }
            }
            return(result);
        }
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            SliderEdgeLabelModel exModel = Model as SliderEdgeLabelModel;

            if (exModel == null)
            {
                exModel = new SliderEdgeLabelModel();
            }

            bool fromSource = (Location & SliderParameterLocation.FromSource) == SliderParameterLocation.FromSource;

            if (fromSource)
            {
                return(exModel.CreateParameterFromSource(SegmentIndex, SegmentRatio));
            }
            else
            {
                return(exModel.CreateParameterFromTarget(SegmentIndex, SegmentRatio));
            }
        }
Esempio n. 3
0
            public void SetAnchor(SliderEdgeLabelModel labelModel, IEdge edge, OrientedRectangle geometry)
            {
                IPathGeometry pathGeometry = GetPathGeometry(edge);

                if (pathGeometry != null)
                {
                    int count = pathGeometry.GetSegmentCount();
                    int index = segmentIndex;
                    if (index >= count)
                    {
                        index = count - 1;
                    }
                    if (index < 0)
                    {
                        index = count + index;
                    }

                    if (index < 0)
                    {
                        index = 0;
                    }
                    else if (index >= count)
                    {
                        index = count - 1;
                    }

                    double thisRatio    = ratio;
                    var    validTangent = pathGeometry.GetTangent(index, thisRatio);
                    if (validTangent.HasValue)
                    {
                        var p = validTangent.Value.Point;
                        var t = validTangent.Value.Vector;
                        AnchorGeometry(geometry, labelModel.EdgeRelativeDistance, labelModel.Distance, p.X, p.Y, thisRatio, t.X, t.Y);
                        return;
                    }
                }
                geometry.Width  = -1;
                geometry.Height = -1;
            }
Esempio n. 4
0
 public SliderParameter(SliderEdgeLabelModel model, int segmentIndex, double ratio)
 {
     this.model        = model;
     this.segmentIndex = segmentIndex;
     this.ratio        = ratio;
 }