コード例 #1
0
        internal void UpdatePolygons(Size layoutSize)
        {
            // determine side count and orientation
            int sides = (int)SidesUpDown.Value;
            PolygonOrientation orientation = (OnEdgeToggle.IsChecked == true ?
                                              PolygonOrientation.OnEdge : PolygonOrientation.OnVertex);

            // compute side length based on layout size and side count
            double layout = Math.Min(layoutSize.Width, layoutSize.Height);
            double length = 2.5 * layout / sides;

            StandardPolygon = new RegularPolygon(length, sides, orientation);

            // determine inflation relative to standard polygon
            int inflation = (int)InflationUpDown.Value;

            InflatedPolygon = StandardPolygon.Inflate(inflation);
        }
コード例 #2
0
        private void UpdatePolygons()
        {
            // determine side count and integral parameters
            int sides = (SquareToggle.IsChecked == true ? 4 : 6);
            PolygonOrientation orientation = (OnEdgeToggle.IsChecked == true ?
                                              PolygonOrientation.OnEdge : PolygonOrientation.OnVertex);
            bool vertexNeighbors = (sides <= 4 ? (VertexNeighborsToggle.IsChecked == true) : false);

            // adjust side length based on side count
            double length = (double)(160.0 / sides);

            StandardPolygon = new RegularPolygon(length, sides, orientation, vertexNeighbors);
            InsetPolygon    = StandardPolygon.Inflate(-3.0);

            // store inset vertices as stream geometry
            InsetGeometry = new StreamGeometry();
            using (StreamGeometryContext context = InsetGeometry.Open())
                InsetPolygon.Draw(context, PointD.Empty, true);
            InsetGeometry.Freeze();

            // determine valid & default controls
            EnableControls(sides, orientation);
        }