Beispiel #1
0
 internal void Add(SideOffset subitem)
 {
     if (subitem == null)
     {
         throw new ArgumentNullException(nameof(subitem));
     }
     _subitems.Add(subitem);
 }
Beispiel #2
0
        internal static Line Create(SideOffset model)
        {
            if (!IsValidLineSide(model.Start, model.End, model.Side))
            {
                throw new ArgumentException();
            }

            return LineOffset(model);
        }
Beispiel #3
0
        private void AddItem(int side, float x1, float y1, float x2, float y2)
        {
            var item = new SideOffset
            {
                Side  = side,
                Start = new PointF(x1, y1),
                End   = new PointF(x2, y2)
            };

            this.SideOffsets.Add(item);
            this.MainOffset.Add(item);
        }
Beispiel #4
0
        private static Line LineOffset(SideOffset model)
        {
            float x1 = model.Start.X;
            float x2 = model.End.X;
            float y1 = model.Start.Y;
            float y2 = model.End.Y;

            double len = Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

            float offsetPixels = model.Offset;

            float x1p = (float)(x1 - offsetPixels * (y2-y1) / len);
            float x2p = (float)(x2 - offsetPixels * (y2-y1) / len);
            float y1p = (float)(y1 - offsetPixels * (x1-x2) / len);
            float y2p = (float)(y2 - offsetPixels * (x1-x2) / len);

            return new Line(model.Side, new PointF(x1p, y1p), new PointF(x2p, y2p));
        }