コード例 #1
0
        private void DrawElements(Graphics graphics)
        {
            LayoutProperties layoutProperties = new LayoutProperties();

            layoutProperties.DesignAreaLocation = DesignAreaLocation;
            layoutProperties.DesignAreaSize     = DesignAreaSize;
            layoutProperties.ViewportLocation   = ViewportLocation;
            layoutProperties.ViewportSize       = ViewportSize;
            layoutProperties.ZoomRatio          = ZoomRatio;

            foreach (LayoutElement element in Layout.Elements)
            {
                LayoutElementRenderer elementRenderer = GetElementRendererForElementType(element.TypeName);
                if (elementRenderer != null)
                {
                    elementRenderer.Draw(element, graphics, layoutProperties);

                    if (IsElementInSelection(element))
                    {
                        TransformHandleType transformHandleType = TransformHandleType.All;
                        VisualLayoutElement visualLayoutElement = element as VisualLayoutElement;
                        if (visualLayoutElement != null && !visualLayoutElement.Rotatable)
                        {
                            if (!KeyboardHelper.IsShiftKeyPressed)
                            {
                                transformHandleType = TransformHandleType.All;
                            }
                            else
                            {
                                transformHandleType = TransformHandleType.OnlyCorners;
                            }
                        }

                        DesignerHelper.DrawTransformHandles(graphics, element, layoutProperties, transformHandleType);
                    }
                }
                else
                {
                    throw new Exception("Element renderer for element type not found!");
                }
            }
        }