/// <summary> /// Set the formatting to be used for the top edge image. /// </summary> /// <param name="fmt"> /// One of the HorizontalFormatting enumerated values. /// </param> public void SetTopEdgeFormatting(HorizontalFormatting fmt) { TopEdgeFormatting.Set(fmt); }
/// <summary> /// Return the formatting to be used for the top edge image. /// </summary> /// <param name="wnd"></param> /// <returns>One of the HorizontalFormatting enumerated values.</returns> public HorizontalFormatting GetTopEdgeFormatting(Window wnd) { return(TopEdgeFormatting.Get(wnd)); }
// implemets abstract from base protected override void AddImageRenderGeometryToWindowImpl(Window srcWindow, Rectf destRect, ColourRect modColours, Rectf?clipper, bool clipToDisplay) { var backgroundRect = destRect; Sizef imageSize; Lunatics.Mathematics.Vector2 imageOffsets; float leftfactor, rightfactor, topfactor, bottomfactor; bool calcColoursPerImage; // vars we use to track what to do with the side pieces. float topOffset = 0, bottomOffset = 0, leftOffset = 0, rightOffset = 0; float topWidth, bottomWidth, leftHeight, rightHeight; topWidth = bottomWidth = destRect.Width; leftHeight = rightHeight = destRect.Height; // calculate final overall colours to be used ColourRect renderSettingFinalColours; InitColoursRect(srcWindow, modColours, out renderSettingFinalColours); var renderSettings = new ImageRenderSettings(Rectf.Zero, clipper, !clipToDisplay, renderSettingFinalColours); //var renderSettingDestArea = renderSettings.destArea; //var renderSettingMultiplyColours = renderSettings.multiplyColours; calcColoursPerImage = !renderSettingFinalColours.IsMonochromatic(); // top-left image var componentImage = GetImage(FrameImageComponent.TopLeftCorner, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); imageOffsets = componentImage.GetRenderedOffset(); renderSettings.DestArea.d_min = destRect.d_min; renderSettings.DestArea.Size = imageSize; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // update adjustments required to edges do to presence of this element. topOffset += imageSize.Width + imageOffsets.X; leftOffset += imageSize.Height + imageOffsets.Y; topWidth -= topOffset; leftHeight -= leftOffset; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + imageOffsets.X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + imageOffsets.Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this element and append it to the Window's geometry var imageGeomBuffers = componentImage.CreateRenderGeometry(renderSettings); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // top-right image componentImage = GetImage(FrameImageComponent.TopRightCorner, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); imageOffsets = componentImage.GetRenderedOffset(); renderSettings.DestArea.Left = destRect.Right - imageSize.Width; renderSettings.DestArea.Top = destRect.Top; renderSettings.DestArea.Size = imageSize; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // update adjustments required to edges do to presence of this element. rightOffset += imageSize.Height + imageOffsets.Y; topWidth -= imageSize.Width - imageOffsets.X; rightHeight -= rightOffset; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + imageOffsets.X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + imageOffsets.Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this element and append it to the Window's geometry var imageGeomBuffers = componentImage.CreateRenderGeometry(renderSettings); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // bottom-left image componentImage = GetImage(FrameImageComponent.BottomLeftCorner, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); imageOffsets = componentImage.GetRenderedOffset(); renderSettings.DestArea.Left = destRect.Left; renderSettings.DestArea.Top = destRect.Bottom - imageSize.Height; renderSettings.DestArea.Size = imageSize; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // update adjustments required to edges do to presence of this element. bottomOffset += imageSize.Width + imageOffsets.X; bottomWidth -= bottomOffset; leftHeight -= imageSize.Height - imageOffsets.Y; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + imageOffsets.X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + imageOffsets.Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this element and append it to the Window's geometry var imageGeomBuffers = componentImage.CreateRenderGeometry(renderSettings); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // bottom-right image componentImage = GetImage(FrameImageComponent.BottomRightCorner, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); imageOffsets = componentImage.GetRenderedOffset(); renderSettings.DestArea.Left = destRect.Right - imageSize.Width; renderSettings.DestArea.Top = destRect.Bottom - imageSize.Height; renderSettings.DestArea.Size = imageSize; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // update adjustments required to edges do to presence of this element. bottomWidth -= imageSize.Width - imageOffsets.X; rightHeight -= imageSize.Height - imageOffsets.Y; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this element and append it to the Window's geometry var imageGeomBuffers = componentImage.CreateRenderGeometry(renderSettings); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // top image componentImage = GetImage(FrameImageComponent.TopEdge, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); renderSettings.DestArea.Left = destRect.Left + topOffset; renderSettings.DestArea.Right = (renderSettings.DestArea.Left + topWidth); renderSettings.DestArea.Top = destRect.Top; renderSettings.DestArea.Bottom = renderSettings.DestArea.Top + imageSize.Height; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // adjust background area to miss this edge backgroundRect.d_min.Y += imageSize.Height + componentImage.GetRenderedOffset().Y; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this image and append it to the Window's geometry var imageGeomBuffers = CreateRenderGeometryForImage(componentImage, VerticalFormatting.TopAligned, TopEdgeFormatting.Get(srcWindow), renderSettings.DestArea, renderSettings.MultiplyColours, clipper, clipToDisplay); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // bottom image componentImage = GetImage(FrameImageComponent.BottomEdge, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); renderSettings.DestArea.Left = destRect.Left + bottomOffset; renderSettings.DestArea.Right = renderSettings.DestArea.Left + bottomWidth; renderSettings.DestArea.Bottom = destRect.Bottom; renderSettings.DestArea.Top = renderSettings.DestArea.Bottom - imageSize.Height; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // adjust background area to miss this edge backgroundRect.d_max.Y -= imageSize.Height - componentImage.GetRenderedOffset().Y; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this image and append it to the Window's geometry var imageGeomBuffers = CreateRenderGeometryForImage(componentImage, VerticalFormatting.BottomAligned, BottomEdgeFormatting.Get(srcWindow), renderSettings.DestArea, renderSettings.MultiplyColours, clipper, clipToDisplay); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // left image componentImage = GetImage(FrameImageComponent.LeftEdge, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); renderSettings.DestArea.Left = destRect.Left; renderSettings.DestArea.Right = renderSettings.DestArea.Left + imageSize.Width; renderSettings.DestArea.Top = destRect.Top + leftOffset; renderSettings.DestArea.Bottom = renderSettings.DestArea.Top + leftHeight; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // adjust background area to miss this edge backgroundRect.d_min.X += imageSize.Width + componentImage.GetRenderedOffset().X; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this image and append it to the Window's geometry var imageGeomBuffers = CreateRenderGeometryForImage(componentImage, LeftEdgeFormatting.Get(srcWindow), HorizontalFormatting.LeftAligned, renderSettings.DestArea, renderSettings.MultiplyColours, clipper, clipToDisplay); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } // right image componentImage = GetImage(FrameImageComponent.RightEdge, srcWindow); if (componentImage != null) { // calculate final destination area imageSize = componentImage.GetRenderedSize(); renderSettings.DestArea.Top = destRect.Top + rightOffset; renderSettings.DestArea.Bottom = renderSettings.DestArea.Top + rightHeight; renderSettings.DestArea.Right = destRect.Right; renderSettings.DestArea.Left = renderSettings.DestArea.Right - imageSize.Width; renderSettings.DestArea = destRect.GetIntersection(renderSettings.DestArea); // adjust background area to miss this edge backgroundRect.d_max.X -= imageSize.Width - componentImage.GetRenderedOffset().X; // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (renderSettings.DestArea.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + renderSettings.DestArea.Width / destRect.Width; topfactor = (renderSettings.DestArea.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + renderSettings.DestArea.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } // create render geometry for this image and append it to the Window's geometry var imageGeomBuffers = CreateRenderGeometryForImage(componentImage, RightEdgeFormatting.Get(srcWindow), HorizontalFormatting.RightAligned, renderSettings.DestArea, renderSettings.MultiplyColours, clipper, clipToDisplay); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } componentImage = GetImage(FrameImageComponent.Background, srcWindow); if (componentImage != null) { // calculate colours that are to be used to this component image if (calcColoursPerImage) { leftfactor = (backgroundRect.Left + componentImage.GetRenderedOffset().X) / destRect.Width; rightfactor = leftfactor + backgroundRect.Width / destRect.Width; topfactor = (backgroundRect.Top + componentImage.GetRenderedOffset().Y) / destRect.Height; bottomfactor = topfactor + backgroundRect.Height / destRect.Height; renderSettings.MultiplyColours = renderSettingFinalColours.GetSubRectangle(leftfactor, rightfactor, topfactor, bottomfactor); } var horzFormatting = BackgroundHorzFormatting.Get(srcWindow); var vertFormatting = BackgroundVertFormatting.Get(srcWindow); var imageGeomBuffers = CreateRenderGeometryForImage(componentImage, vertFormatting, horzFormatting, backgroundRect, renderSettings.MultiplyColours, clipper, clipToDisplay); srcWindow.AppendGeometryBuffers(imageGeomBuffers); } }
/// <summary> /// Set the name of a property that will be used to obtain the formatting /// to use for the top edge image. /// </summary> /// <param name="propertyName"></param> public void SetTopEdgeFormattingPropertySource(string propertyName) { TopEdgeFormatting.SetPropertySource(propertyName); }