<?xml version="1.0"?>
-<Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"
- Foreground="Gray"
- Background="White">
- <HorizontalStack Name="hstack" Margin="0" Spacing="2" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
- <Label Foreground="DimGray" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"
- Text="{../../../Value}" Margin="1" TextAlignment="Right"/>
- <VerticalStack Width="-1" Height="{../../../HeightPolicy}" Spacing="0" >
- <Button MouseRepeat="true" Width="12" Height="8" MouseClick="../../../../onUp"
- Template="#Crow.Templates.ArrowButTemplate.crow">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/>
- </Button>
-
- <Button MouseRepeat="true" Width="12" Height="8" MouseClick="../../../../onDown"
- Template="#Crow.Templates.ArrowButTemplate.crow">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
- </Button>
- </VerticalStack>
- </HorizontalStack>
-</Border>
\ No newline at end of file
+<HorizontalStack Name="hstack" Margin="0" Spacing="0" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
+ <Border BorderWidth="1" Height="{../../HeightPolicy}" Width="80%" Background="White"
+ Foreground="DimGray" Margin="0">
+ <Label Foreground="DimGray" Height="{../../../HeightPolicy}" Width="Stretched"
+ Text="{../../../Value}" TextAlignment="Right" Margin="0"/>
+ </Border>
+ <VerticalStack Width="20%" Height="Stretched" Spacing="0" Margin="0" Background="Red">
+ <Button MouseRepeat="true" Width="Stretched" Height="50%" Margin="0" MouseClick="../../../onUp"
+ Template="#Crow.Templates.ArrowButTemplate.crow">
+ <Image Path="#Crow.Images.Icons.updown.svg" SvgSub="up" Margin="0"/>
+ </Button>
+ <Button MouseRepeat="true" Width="Stretched" Height="50%" Margin="0" MouseClick="../../../onDown"
+ Template="#Crow.Templates.ArrowButTemplate.crow">
+ <Image Path="#Crow.Images.Icons.updown.svg" SvgSub="down" Margin="0"/>
+ </Button>
+ </VerticalStack>
+</HorizontalStack>
if (lc == 0)
lc = 1;
- return (int)(fe.Height * lc) + Margin * 2;
+ return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
}
foreach (string s in lines) {
Rectangle cb = ClientRectangle;
- //ignore text alignment if size to content = true
- //TODO: split horizontal and vertical logic
- if (Width == Measure.Fit || Height == Measure.Fit)
+ rText.X = cb.X;
+ rText.Y = cb.Y;
+
+ if (horizontalStretch) {
+ widthRatio = (float)cb.Width / (float)rText.Width;
+ if (!verticalStretch)
+ heightRatio = widthRatio;
+ }
+
+ if (verticalStretch) {
+ heightRatio = (float)cb.Height / (float)rText.Height;
+ if (!horizontalStretch)
+ widthRatio = heightRatio;
+ }
+
+ rText.Width = (int)(widthRatio * (float)rText.Width);
+ rText.Height = (int)(heightRatio * (float)rText.Height);
+
+ switch (TextAlignment)
{
+ case Alignment.TopLeft: //ok
rText.X = cb.X;
rText.Y = cb.Y;
- }else{
- if (horizontalStretch) {
- widthRatio = (float)cb.Width / rText.Width;
- if (!verticalStretch)
- heightRatio = widthRatio;
- }
-
- if (verticalStretch) {
- heightRatio = (float)cb.Height / rText.Height;
- if (!horizontalStretch)
- widthRatio = heightRatio;
- }
-
- rText.Width = (int)(widthRatio * rText.Width);
- rText.Height = (int)(heightRatio * rText.Height);
-
- switch (TextAlignment)
- {
- case Alignment.TopLeft: //ok
- rText.X = cb.X;
- rText.Y = cb.Y;
- break;
- case Alignment.Top: //ok
- rText.Y = cb.Y;
- rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
- break;
- case Alignment.TopRight: //ok
- rText.Y = cb.Y;
- rText.X = cb.Right - rText.Width;
- break;
- case Alignment.Left://ok
- rText.X = cb.X;
- rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
- break;
- case Alignment.Right://ok
- rText.X = cb.X + cb.Width - rText.Width;
- rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
- break;
- case Alignment.Bottom://ok
- rText.X = cb.Width / 2 - rText.Width / 2;
- rText.Y = cb.Height - rText.Height;
- break;
- case Alignment.BottomLeft://ok
- rText.X = cb.X;
- rText.Y = cb.Bottom - rText.Height;
- break;
- case Alignment.BottomRight://ok
- rText.Y = cb.Bottom - rText.Height;
- rText.X = cb.Right - rText.Width;
- break;
- case Alignment.Center://ok
- rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
- rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
- break;
- }
+ break;
+ case Alignment.Top: //ok
+ rText.Y = cb.Y;
+ rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
+ break;
+ case Alignment.TopRight: //ok
+ rText.Y = cb.Y;
+ rText.X = cb.Right - rText.Width;
+ break;
+ case Alignment.Left://ok
+ rText.X = cb.X;
+ rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
+ break;
+ case Alignment.Right://ok
+ rText.X = cb.X + cb.Width - rText.Width;
+ rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
+ break;
+ case Alignment.Bottom://ok
+ rText.X = cb.Width / 2 - rText.Width / 2;
+ rText.Y = cb.Height - rText.Height;
+ break;
+ case Alignment.BottomLeft://ok
+ rText.X = cb.X;
+ rText.Y = cb.Bottom - rText.Height;
+ break;
+ case Alignment.BottomRight://ok
+ rText.Y = cb.Bottom - rText.Height;
+ rText.X = cb.Right - rText.Width;
+ break;
+ case Alignment.Center://ok
+ rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
+ rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
+ break;
}
- gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
+ gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0);
fe = gr.FontExtents;
#region draw text cursor