Initial population

This commit is contained in:
Jon
2026-03-07 19:22:22 -06:00
parent 647f55feb9
commit cae1a3ec46
108 changed files with 28484 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
using Microsoft.Office.Interop.Word;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using System.Windows.Media.Animation;
namespace JRCookbookBusiness
{
internal static class clsWord
{
private static Microsoft.Office.Interop.Word.Application mobjWord;
private static bool mblnWordRunning = false;
internal const int WORD_CHAPTER_NAME_FONT_SIZE = 18;
internal const int WORD_RECIPE_NAME_FONT_SIZE = 18;
internal const int WORD_RECIPE_SECTION_HEADING_FONT_SIZE = 14;
internal const int WORD_NORMAL_FONT_SIZE = 10;
internal const int WORD_NUTRITION_FONT_SIZE = 8;
internal static Microsoft.Office.Interop.Word.Application WordApplication { get { return mobjWord; } }
internal static void AddHalfSpaceLineAtEndOfDocument()
{
mobjWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory);
mobjWord.Selection.TypeParagraph();
mobjWord.Selection.MoveUp(Microsoft.Office.Interop.Word.WdUnits.wdLine, 1);
mobjWord.Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;
mobjWord.Selection.ParagraphFormat.LineSpacing = 4F;
mobjWord.Selection.ParagraphFormat.SpaceAfter = 0F;
mobjWord.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdStory);
}
internal static void Insert_HeaderText(String headerText)
{
if (mobjWord.ActiveWindow.View.SplitSpecial != WdSpecialPane.wdPaneNone)
{
mobjWord.ActiveWindow.Panes[2].Close();
}
if (mobjWord.ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView || mobjWord.ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)
{
mobjWord.ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;
}
mobjWord.Selection.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
mobjWord.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader;
mobjWord.Selection.WholeStory();
mobjWord.Selection.Delete(Microsoft.Office.Interop.Word.WdUnits.wdCharacter, 1);
mobjWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
mobjWord.Selection.TypeText(headerText);
mobjWord.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekMainDocument;
}
internal static void Insert_PageNumberFooter(ref bool isFirstPageOfContent)
{
if (mobjWord.ActiveWindow.View.SplitSpecial != WdSpecialPane.wdPaneNone)
{
mobjWord.ActiveWindow.Panes[2].Close();
}
if (mobjWord.ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView || mobjWord.ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)
{
mobjWord.ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;
}
mobjWord.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageFooter;
mobjWord.Selection.WholeStory();
mobjWord.Selection.Delete(Microsoft.Office.Interop.Word.WdUnits.wdCharacter, 1);
if (isFirstPageOfContent)
{
mobjWord.Selection.HeaderFooter.PageNumbers.RestartNumberingAtSection = true;
mobjWord.Selection.HeaderFooter.PageNumbers.StartingNumber = 1;
isFirstPageOfContent = false;
}
else
{
mobjWord.Selection.HeaderFooter.PageNumbers.RestartNumberingAtSection = false;
}
mobjWord.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
mobjWord.Selection.TypeText("Page ");
mobjWord.Selection.Fields.Add(mobjWord.Selection.Range, Microsoft.Office.Interop.Word.WdFieldType.wdFieldEmpty, "PAGE \\* Arabic ", 1);
mobjWord.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekMainDocument;
}
internal static void ResetWord()
{
if (mblnWordRunning)
{
ShutDownWord();
}
mobjWord = new Microsoft.Office.Interop.Word.Application();
mobjWord.Visible = false;
//mobjWord.Activate();
//mobjWord.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;
mblnWordRunning= true;
}
internal static void ShutDownWord()
{
if (mblnWordRunning)
{
mobjWord.Quit();
mobjWord = null;
mblnWordRunning = false;
}
}
}
}