Added properties and methods

This commit is contained in:
Rich
2010-02-02 20:50:34 +00:00
parent b80775a454
commit 710cfee31d
2 changed files with 278 additions and 10 deletions

View File

@@ -68,8 +68,17 @@ namespace LBWordLibrary
}
protected Object InvokeMethod(string methodName, params Object[] parameters)
{
if (parameters != null)
FixParameters(parameters);
return DoInvokeMember(methodName, parameters, BindingFlags.InvokeMethod, null);
}
private void FixParameters(object[] parameters)
{
// Loop through parameters checking to make sure that none of them are LBComObjects
for (int i = 0; i < parameters.Length; i++)
if (parameters[i] is LBComObject)
parameters[i] = (parameters[i] as LBComObject).Item;
}
protected Object InvokeMethod(string methodName)
{
return InvokeMethod(methodName, null);
@@ -86,15 +95,15 @@ namespace LBWordLibrary
tmp.Item = InvokeMethod("Add");
return tmp;
}
public TItem this[int item]
{
get
{
TItem tmp = new TItem();
tmp.Item = GetProperty("Item", item);
return tmp;
}
}
//public TItem this[int item]
//{
// get
// {
// TItem tmp = new TItem();
// tmp.Item = GetProperty("Item", item);
// return tmp;
// }
//}
}
public partial class LBApplicationClass : LBComObject
{
@@ -209,6 +218,10 @@ namespace LBWordLibrary
{
get { return new LBInlineShapes(GetProperty("InlineShapes")); }
}
public LBParagraphs Paragraphs
{
get { return new LBParagraphs(GetProperty("Paragraphs")); }
}
public void WholeStory()
{
InvokeMethod("WholeStory");
@@ -241,6 +254,26 @@ namespace LBWordLibrary
{
return InvokeMethod("EndKey", Unit, Extend) as int? ?? 0;
}
public void TypeText(string Text)
{
InvokeMethod("TypeText", Text);
}
public int EndOf()
{
return InvokeMethod("EndOf", Missing.Value, Missing.Value) as int? ?? 0;
}
public int EndOf(object Unit, object Extend)
{
return InvokeMethod("EndOf", Unit, Extend) as int? ?? 0;
}
public LBRange GoTo()
{
return new LBRange(InvokeMethod("GoTo", Missing.Value, Missing.Value, Missing.Value, Missing.Value));
}
public LBRange GoTo(object What, object Which, object Count, object Name)
{
return new LBRange(InvokeMethod("GoTo", What, Which, Count, Name));
}
}
public partial class LBDocumentClass : LBComObject
{
@@ -258,6 +291,14 @@ namespace LBWordLibrary
{
get { return (GetProperty("FullName").ToString()); }
}
public LBShapes Shapes
{
get { return new LBShapes(GetProperty("Shapes")); }
}
public LBWindow ActiveWindow
{
get { return new LBWindow(GetProperty("ActiveWindow")); }
}
public void SaveAs2000()
{
InvokeMethod("SaveAs2000", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
@@ -290,6 +331,14 @@ namespace LBWordLibrary
{
InvokeMethod("ExportAsFixedFormat", OutputFileName, ExportFormat, OpenAfterExport, OptimizeFor, Range, From, To, Item, IncludeDocProps, KeepIRM, CreateBookmarks, DocStructureTags, BitmapMissingFonts, UseISO19005_1, FixedFormatExtClassPtr);
}
public LBRange Range()
{
return new LBRange(InvokeMethod("Range", Missing.Value, Missing.Value));
}
public LBRange Range(object Start, object End)
{
return new LBRange(InvokeMethod("Range", Start, End));
}
}
public partial class LBWindow : LBComObject
{
@@ -321,6 +370,18 @@ namespace LBWordLibrary
{
get { return new LBParagraphFormatClass(GetProperty("ParagraphFormat")); }
}
public LBParagraphs Paragraphs
{
get { return new LBParagraphs(GetProperty("Paragraphs")); }
}
public LBRange GoTo()
{
return new LBRange(InvokeMethod("GoTo", Missing.Value, Missing.Value, Missing.Value, Missing.Value));
}
public LBRange GoTo(object What, object Which, object Count, object Name)
{
return new LBRange(InvokeMethod("GoTo", What, Which, Count, Name));
}
}
public partial class LBParagraphFormatClass : LBComObject
{
@@ -444,6 +505,26 @@ namespace LBWordLibrary
get { return (LBWdColor)GetProperty("Color"); }
set { SetProperty("Color", value); }
}
public int Position
{
get { return (GetProperty("Position") as int? ?? 0); }
set { SetProperty("Position", value); }
}
public int Subscript
{
get { return (GetProperty("Subscript") as int? ?? 0); }
set { SetProperty("Subscript", value); }
}
public int Superscript
{
get { return (GetProperty("Superscript") as int? ?? 0); }
set { SetProperty("Superscript", value); }
}
public float Size
{
get { return (GetProperty("Size") as float? ?? 0); }
set { SetProperty("Size", value); }
}
}
public enum LBWdInformation
{
@@ -498,6 +579,44 @@ namespace LBWordLibrary
return new LBInlineShape(InvokeMethod("AddPicture", FileName, LinkToFile, SaveWithDocument, Range));
}
}
public partial class LBParagraphs : LBComObjectList<LBParagraphs, LBParagraph> /* Collection */
{
public LBParagraphs(Object item)
{
Item = item;
}
public int Count
{
get { return (GetProperty("Count") as int? ?? 0); }
}
public LBParagraph First
{
get { return new LBParagraph(GetProperty("First")); }
}
public LBParagraph Last
{
get { return new LBParagraph(GetProperty("Last")); }
}
public System.Object GetEnumerator()
{
return InvokeMethod("GetEnumerator");
}
}
public partial class LBShapes : LBComObjectList<LBShapes, LBShape> /* Collection */
{
public LBShapes(Object item)
{
Item = item;
}
public LBShape AddPicture(string FileName)
{
return new LBShape(InvokeMethod("AddPicture", FileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
}
public LBShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Left, object Top, object Width, object Height, object Anchor)
{
return new LBShape(InvokeMethod("AddPicture", FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height, Anchor));
}
}
public enum LBWdExportFormat
{
wdExportFormatPDF = 17,
@@ -677,6 +796,39 @@ namespace LBWordLibrary
set { SetProperty("Width", value); }
}
}
public partial class LBParagraph : LBComObject
{
public LBParagraph() { }
public LBParagraph(Object item) : base(item) { }
public LBRange Range
{
get { return new LBRange(GetProperty("Range")); }
}
}
public partial class LBShape : LBComObject
{
public LBShape() { }
public LBShape(Object item) : base(item) { }
public float Height
{
get { return (GetProperty("Height") as float? ?? 0); }
set { SetProperty("Height", value); }
}
public float Width
{
get { return (GetProperty("Width") as float? ?? 0); }
set { SetProperty("Width", value); }
}
public LBRange Anchor
{
get { return new LBRange(GetProperty("Anchor")); }
}
public LBMsoTriState LockAspectRatio
{
get { return (LBMsoTriState)GetProperty("LockAspectRatio"); }
set { SetProperty("LockAspectRatio", value); }
}
}
public partial class LBPages : LBComObjectList<LBPages, LBPage> /* Collection */
{
public LBPages(Object item)
@@ -847,4 +999,31 @@ namespace LBWordLibrary
wdTable = 15,
wdItem = 16
}
public enum LBWdGoToDirection
{
wdGoToAbsolute = 1,
wdGoToNext = 2,
wdGoToPrevious = 3,
wdGoToLast = -1
}
public enum LBWdGoToItem
{
wdGoToSection = 0,
wdGoToPage = 1,
wdGoToTable = 2,
wdGoToLine = 3,
wdGoToFootnote = 4,
wdGoToEndnote = 5,
wdGoToComment = 6,
wdGoToField = 7,
wdGoToGraphic = 8,
wdGoToObject = 9,
wdGoToEquation = 10,
wdGoToHeading = 11,
wdGoToPercent = 12,
wdGoToSpellingError = 13,
wdGoToGrammaticalError = 14,
wdGoToProofreadingError = 15,
wdGoToBookmark = -1
}
}