예제 #1
0
    /// <summary>
    /// Set the specified x and y location in T layer
    /// </summary>
    /// <param name="x">The x coordinate.</param>
    /// <param name="y">The y coordinate.</param>
    /// <typeparam name="T">The layer that will be set</typeparam>
    public void Set <T>(int x, int y, T item)
    {
        if (!this.ContainsKey(typeof(T)))
        {
            throw new ArgumentException();
        }

        IGridLayer <T> layer = this[typeof(T)] as IGridLayer <T>;

        if (layer == null)
        {
            throw new NullReferenceException();
        }

        if (layer.GetUpperBound(0) < x || x < 0)
        {
            throw new ArgumentException();
        }

        if (layer.GetUpperBound(1) < y || y < 0)
        {
            throw new ArgumentException();
        }

        layer[x, y] = item;
    }
예제 #2
0
    /// <summary>
    /// Add an instance, this will throw if the type already exists
    /// </summary>
    /// <param name="layer">A Layer holding an array of type T</param>
    /// <typeparam name="T">The type key in the dictionary</typeparam>
    public void Add <T>(IGridLayer <T> layer)
    {
        if (this.ContainsKey(typeof(T)))
        {
            throw new ArgumentException();
        }

        this.Add(typeof(T), layer);
    }
예제 #3
0
        public void Draw(IGridLayer grid)
        {
            Open();
            CADPoint leftpoint  = _drawing.CanvasToModel(new CADPoint(0, 0));
            CADPoint rightpoint = _drawing.CanvasToModel(new CADPoint(((CADPadCanvas)_drawing.Canvas).ActualWidth, ((CADPadCanvas)_drawing.Canvas).ActualHeight));
            double   gridX      = grid.SpacingX;
            double   gridY      = grid.SpacingY;

            var left   = Math.Floor(leftpoint.X / gridX) * gridX;
            var top    = Math.Ceiling(leftpoint.Y / gridY) * gridY;
            var right  = Math.Ceiling(rightpoint.X / gridX) * gridX;
            var bottom = Math.Floor(rightpoint.Y / gridY) * gridY;

            if (grid.GridStyle == CADPadServices.Enums.GridStyle.Lines)
            {
                while (left < right)
                {
                    DrawLine(_drawing, thisDC, Pen, new CADPoint(left, leftpoint.Y), new CADPoint(left, rightpoint.Y), true);

                    left += gridX;
                }
                while (bottom < top)
                {
                    DrawLine(_drawing, thisDC, Pen, new CADPoint(leftpoint.X, bottom), new CADPoint(rightpoint.X, bottom), true);

                    bottom += gridY;
                }
            }
            else if (grid.GridStyle == CADPadServices.Enums.GridStyle.Circle)
            {
                StreamGeometry geometry = new StreamGeometry();
                geometry.FillRule = FillRule.EvenOdd;
                using (StreamGeometryContext ctx = geometry.Open())
                {
                    for (double x = left; x <= right; x += gridX)
                    {
                        for (double y = bottom; y <= top; y += gridY)
                        {
                            DrawCircle(_drawing, thisDC, null, Pen, new CADPoint(x, y), 20, 20, true);
                        }
                    }
                }
                geometry.Freeze();

                thisDC.DrawGeometry(null, Pen, geometry);
            }

            Close();
        }
예제 #4
0
    /// <summary>
    /// Get T in the layer of type T, and at the coordinate x,y
    /// </summary>
    /// <param name="x">The x coordinate.</param>
    /// <param name="y">The y coordinate.</param>
    /// <typeparam name="T">Type of location to get</typeparam>
    public T Get <T>(int x, int y)
    {
        if (!this.ContainsKey(typeof(T)))
        {
            throw new ArgumentException();
        }

        IGridLayer <T> layer = this[typeof(T)] as IGridLayer <T>;

        if (layer == null)
        {
            throw new NullReferenceException();
        }

        return(layer[x, y]);
    }
예제 #5
0
    /// <summary>
    /// Get an instance of IGridLayer
    /// </summary>
    /// <typeparam name="T">The 1st type parameter.</typeparam>
    public IGridLayer <T> Get <T>()
    {
        if (!this.ContainsKey(typeof(T)))
        {
            throw new NullReferenceException();
        }

        IGridLayer <T> layer = this [typeof(T)] as IGridLayer <T>;

        if (layer == null)
        {
            throw new NullReferenceException();
        }

        return(layer);
    }
예제 #6
0
        public void DrawGrid()
        {
            if (_provider == null)
            {
                return;
            }
            ICanvas c = _provider.Canvas;

            if (c == null)
            {
                return;
            }
            IGridLayer gridLayer = c.LayerContainer.Get((lyr) => { return(lyr is IGridLayer); }) as IGridLayer;

            if (gridLayer == null)
            {
                return;
            }
            (gridLayer as IGridLayerAtrEdit).DrawDoubleBorder(IsDoubleBorderLine, InSize);
        }
예제 #7
0
        public XElement GetGridXml()
        {
            if (_provider == null)
            {
                return(null);
            }
            ICanvas c = _provider.Canvas;

            if (c == null)
            {
                return(null);
            }
            IGridLayer gridLayer = c.LayerContainer.Get((lyr) => { return(lyr is IGridLayer); }) as IGridLayer;

            if (gridLayer == null)
            {
                return(null);
            }
            (gridLayer as IGridLayerAtrEdit).DrawDoubleBorder(IsDoubleBorderLine, InSize);
            return(gridLayer.ToXml());
        }