Правки по word

This commit is contained in:
kotcheshir73 2022-12-25 11:39:26 +04:00
parent 1f864dda44
commit ce7fc39ed4
3 changed files with 44 additions and 8 deletions

View File

@ -0,0 +1,12 @@
namespace ToolsOffice.Interfaces.Word
{
/// <summary>
/// Типы страниц
/// </summary>
public enum WordPageSizeType
{
A4_Portrait,
A4_Landscape
}
}

View File

@ -9,18 +9,19 @@ namespace ToolsOffice.Interfaces.Word
public class WordPageSizes public class WordPageSizes
{ {
private static readonly private static readonly
Dictionary<string, (double Height, double Width, double MarginBottom, double MarginTop, double MarginLeft, double MarginRigth, double MarginGutter, double Header, double Footer)> _sizes = new() Dictionary<WordPageSizeType, (double Height, double Width, double MarginBottom, double MarginTop, double MarginLeft, double MarginRigth, double MarginGutter, double Header, double Footer)> _sizes = new()
{ {
{ "А4", (29.7, 21, 1.5, 3, 2, 2, 0, 1.5, 1.5) } { WordPageSizeType.A4_Portrait, (29.7, 21, 1.5, 3, 2, 2, 0, 1.5, 1.5) },
{ WordPageSizeType.A4_Landscape, (21, 29.7, 1.5, 3, 2, 2, 0, 1.5, 1.5) }
}; };
public static List<string> Sizes => _sizes.Keys.ToList(); public static List<WordPageSizeType> Sizes => _sizes.Keys.ToList();
private readonly bool _hasKey; private readonly bool _hasKey;
private readonly string _key; private readonly WordPageSizeType _key;
public WordPageSizes(string key) public WordPageSizes(WordPageSizeType key)
{ {
_hasKey = _sizes.ContainsKey(key); _hasKey = _sizes.ContainsKey(key);
_key = key; _key = key;
@ -36,18 +37,41 @@ namespace ToolsOffice.Interfaces.Word
/// </summary> /// </summary>
public double? PageSizeWidth => _hasKey ? _sizes[_key].Width : null; public double? PageSizeWidth => _hasKey ? _sizes[_key].Width : null;
/// <summary>
/// Отступ от нижнего края
/// </summary>
public double? PageMarginBottom => _hasKey ? _sizes[_key].MarginBottom : null; public double? PageMarginBottom => _hasKey ? _sizes[_key].MarginBottom : null;
/// <summary>
/// Отступ от верхнего края
/// </summary>
public double? PageMarginTop => _hasKey ? _sizes[_key].MarginTop : null; public double? PageMarginTop => _hasKey ? _sizes[_key].MarginTop : null;
/// <summary>
/// Отступ от левого края
/// </summary>
public double? PageMarginLeft => _hasKey ? _sizes[_key].MarginLeft : null; public double? PageMarginLeft => _hasKey ? _sizes[_key].MarginLeft : null;
/// <summary>
/// Отступ от правого края
/// </summary>
public double? PageMarginRight => _hasKey ? _sizes[_key].MarginRigth : null; public double? PageMarginRight => _hasKey ? _sizes[_key].MarginRigth : null;
/// <summary>
/// Расстояние между полосами страницы
/// Если свойство MirrorMargins настроено на True, свойство Gutter добавляет дополнительное пространство на внутренние поля.
/// В противном случае дополнительное пространство добавляется в левую поля.
/// </summary>
public double? PageMarginGutter => _hasKey ? _sizes[_key].MarginGutter : null; public double? PageMarginGutter => _hasKey ? _sizes[_key].MarginGutter : null;
/// <summary>
/// Расстояние до верхнего колонтитула
/// </summary>
public double? PageHeader => _hasKey ? _sizes[_key].Header : null; public double? PageHeader => _hasKey ? _sizes[_key].Header : null;
/// <summary>
/// Расстояние до нижнего колонтитула
/// </summary>
public double? PageFooter => _hasKey ? _sizes[_key].Footer : null; public double? PageFooter => _hasKey ? _sizes[_key].Footer : null;
} }
} }

View File

@ -149,14 +149,14 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic
rowIndex++; rowIndex++;
} }
var pageSize = new WordPageSizes("А4"); var pageSize = new WordPageSizes(WordPageSizeType.A4_Landscape);
var docModel = new ModelWordDocumentWithHeaderAndTable var docModel = new ModelWordDocumentWithHeaderAndTable
{ {
Document = new ModelWordDocument Document = new ModelWordDocument
{ {
WordPageOrientation = TypeWordPageOrientation.Landscape, WordPageOrientation = TypeWordPageOrientation.Landscape,
PageSizeHeight = pageSize.PageSizeWidth, PageSizeHeight = pageSize.PageSizeHeight,
PageSizeWidth = pageSize.PageSizeHeight, PageSizeWidth = pageSize.PageSizeWidth,
PageMarginBottom = pageSize.PageMarginBottom, PageMarginBottom = pageSize.PageMarginBottom,
PageMarginTop = pageSize.PageMarginTop, PageMarginTop = pageSize.PageMarginTop,
PageMarginLeft = pageSize.PageMarginLeft, PageMarginLeft = pageSize.PageMarginLeft,