Skip to content

Commit

Permalink
#20 vertical alignment of body (as part of theme)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyCorbett committed Jan 10, 2019
1 parent acb9f5c commit ce47b94
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 5 deletions.
7 changes: 5 additions & 2 deletions OnlyV.ImageCreation/BibleTextImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public BibleTextImage()
BodyDropShadowOpacity = 0.5;
BodyDropShadowBlurRadius = 10;
BodyDropShadowDepth = 10;
BodyVerticalAlignment = OnlyVBodyVerticalAlignment.Middle;

UseTildeParaSeparator = true;
TrimPunctuation = false;
Expand Down Expand Up @@ -182,7 +183,9 @@ public Color BackgroundColor
public double BodyDropShadowBlurRadius { get; set; }

public double BodyDropShadowDepth { get; set; }


public OnlyVBodyVerticalAlignment BodyVerticalAlignment { get; set; }

private Brush BackgroundBrush => _backgroundBrush ?? (_backgroundBrush = new SolidColorBrush(BackgroundColor));

public IEnumerable<BitmapSource> Generate(string epubPath, int bookNumber, string chapterAndVerses)
Expand Down Expand Up @@ -479,7 +482,7 @@ private DrawingVisual DrawBody(

int lineCount = linesForBmp.Length;
double adjustmentForShortLineCount = 0;
if (lineCount < linesPerImage)
if (BodyVerticalAlignment == OnlyVBodyVerticalAlignment.Middle && lineCount < linesPerImage)
{
adjustmentForShortLineCount = (lineHeight * (linesPerImage - lineCount)) / 2;
}
Expand Down
1 change: 1 addition & 0 deletions OnlyV.Themes.Common/OnlyV.Themes.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="Services\UI\BusyCursor.cs" />
<Compile Include="Services\UI\IUserInterfaceService.cs" />
<Compile Include="Services\UI\UserInterfaceService.cs" />
<Compile Include="Specs\OnlyVBodyVerticalAlignment.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
4 changes: 4 additions & 0 deletions OnlyV.Themes.Common/Specs/OnlyVBodyTextSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public OnlyVBodyTextSpec()
LineSpacing = OnlyVLineSpacing.Normal;

DropShadow = new OnlyVDropShadowSpec { Show = true };

BodyVerticalAlignment = OnlyVBodyVerticalAlignment.Middle;
}

public OnlyVFontSpec Font { get; set; }
Expand All @@ -24,5 +26,7 @@ public OnlyVBodyTextSpec()
public OnlyVLineSpacing LineSpacing { get; set; }

public OnlyVDropShadowSpec DropShadow { get; set; }

public OnlyVBodyVerticalAlignment BodyVerticalAlignment { get; set; }
}
}
8 changes: 8 additions & 0 deletions OnlyV.Themes.Common/Specs/OnlyVBodyVerticalAlignment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace OnlyV.Themes.Common.Specs
{
public enum OnlyVBodyVerticalAlignment
{
Top,
Middle
}
}
1 change: 1 addition & 0 deletions OnlyV/Services/Images/ImagesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private void ApplyFormatting(
bibleTextImage.BodyDropShadowColor = ConvertFromString(theme.BodyText.DropShadow.Colour, Colors.Black);
bibleTextImage.BodyDropShadowDepth = theme.BodyText.DropShadow.Depth;
bibleTextImage.BodyDropShadowOpacity = theme.BodyText.DropShadow.Opacity;
bibleTextImage.BodyVerticalAlignment = theme.BodyText.BodyVerticalAlignment;

// title text...
bibleTextImage.TitleFont.FontFamily = new FontFamily(theme.TitleText.Font.Family);
Expand Down
3 changes: 2 additions & 1 deletion OnlyVThemeCreator/Helpers/StandardTextSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static IReadOnlyCollection<StandardTextSample> GetStandardList()
{
new StandardTextSample(100, 1, "3:15,16"),
new StandardTextSample(101, 19, "119:1-8"),
new StandardTextSample(102, 66, "21:1-4")
new StandardTextSample(102, 66, "21:1-4"),
new StandardTextSample(103, 43, "11:35")
};
}
}
Expand Down
9 changes: 7 additions & 2 deletions OnlyVThemeCreator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@
materialDesign:HintAssist.Hint="{x:Static resx:Resources.FONT_WEIGHT}"
Style="{StaticResource FloatingHintComboBoxStyle}" />

<Label Style="{StaticResource LabelStyle}"
<Label Style="{StaticResource LabelStyle}"
Content="{x:Static resx:Resources.FONT_COLOR}" />
<xctk:ColorPicker
SelectedColor="{Binding BodyTextColour}"
Style="{StaticResource ColorPickerStyle}" />

<Label Style="{StaticResource LabelStyle}" Content="{x:Static resx:Resources.FONT_OPACITY}" />
<Label Style="{StaticResource LabelStyle}" Content="{x:Static resx:Resources.FONT_OPACITY}" />
<Slider Style="{StaticResource SliderStyle}"
Minimum="0"
Maximum="1"
Expand All @@ -339,6 +339,11 @@
materialDesign:HintAssist.Hint="{x:Static resx:Resources.HORZ_ALIGNMENT}"
Style="{StaticResource FloatingHintComboBoxStyle}" />

<ComboBox ItemsSource="{Binding VerticalAlignments}"
SelectedValue="{Binding BodyVerticalAlignment}"
materialDesign:HintAssist.Hint="{x:Static resx:Resources.VERT_ALIGNMENT}"
Style="{StaticResource FloatingHintComboBoxStyle}" />

<ComboBox ItemsSource="{Binding LineSpacings}"
SelectedValue="{Binding LineSpacing}"
materialDesign:HintAssist.Hint="{x:Static resx:Resources.LINE_SPACING}"
Expand Down
9 changes: 9 additions & 0 deletions OnlyVThemeCreator/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions OnlyVThemeCreator/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@
<data name="USE_DROP_SHADOW" xml:space="preserve">
<value>Use drop-shadow</value>
</data>
<data name="VERT_ALIGNMENT" xml:space="preserve">
<value>Vertical alignment</value>
</data>
<data name="WANT_TO_SAVE" xml:space="preserve">
<value>The theme has changed. Do you want to save?</value>
<comment>Question displayed in the dialog box that prompts you to save a theme</comment>
Expand Down
21 changes: 21 additions & 0 deletions OnlyVThemeCreator/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ public ImageSource ImageSource
OnlyVHorizontalTextAlignment.Right
};

public OnlyVBodyVerticalAlignment[] VerticalAlignments { get; } =
{
OnlyVBodyVerticalAlignment.Top,
OnlyVBodyVerticalAlignment.Middle
};

public OnlyVLineSpacing[] LineSpacings { get; } =
{
OnlyVLineSpacing.VerySmall,
Expand Down Expand Up @@ -507,6 +513,20 @@ public bool BodyTextDropShadow
}
}

public OnlyVBodyVerticalAlignment BodyVerticalAlignment
{
get => _currentTheme.BodyText.BodyVerticalAlignment;
set
{
if (_currentTheme.BodyText.BodyVerticalAlignment != value)
{
_currentTheme.BodyText.BodyVerticalAlignment = value;
RaisePropertyChanged();
UpdateImage();
}
}
}

public Color? BodyDropShadowColour
{
get => ConvertFromString(_currentTheme.BodyText.DropShadow.Colour, _defaultDropShadowColor);
Expand Down Expand Up @@ -1000,6 +1020,7 @@ private void ApplyFormatting()
_imageService.BodyDropShadowOpacity = BodyDropShadowOpacity;
_imageService.BodyDropShadowBlurRadius = BodyDropShadowBlurRadius;
_imageService.BodyDropShadowDepth = BodyDropShadowDepth;
_imageService.BodyVerticalAlignment = BodyVerticalAlignment;

// title text...
_imageService.TitleFont.FontFamily = new FontFamily(TitleTextFontFamilyName);
Expand Down

0 comments on commit ce47b94

Please sign in to comment.