本文整理汇总了C#中Document.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Select方法的具体用法?C# Document.Select怎么用?C# Document.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document.Select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHtml
public string CreateHtml(Document document)
{
_document = document;
var htmlText = new StringBuilder();
foreach (var htmlFragment in _document.Select(createHtmlFragment))
{
htmlText.Append(htmlFragment.CreateHtml());
}
return replaceLineBreaks(htmlText.ToString());
}
示例2: createPDF
protected bool createPDF(string fileName, bool pdf, string pdfName)
{
doc = null;
try {
doc = app.Documents.Open(fileName, Visible: true, ReadOnly: false);
doc.Select();
if (pdf) {
saveAsPDF(doc, pdfName);
}
Logger.log(fileName);
(doc as _Document).Close(SaveChanges: false);
return true;
} catch (Exception e) {
try { (doc as _Document).Close(SaveChanges: false); } catch { }
Logger.log("ERROR: " + fileName);
Logger.log("--" + e.Message);
return false;
}
}
示例3: GetDistinctCaveatsFromDocuments
public static Caveat[] GetDistinctCaveatsFromDocuments(Document[] installationReceiptDocuments)
{
// before: { "Caveat1Name:Caveat1Desc", "Caveat1Name:Caveat1Desc", "Caveat2Name:Caveat2Desc", "Caveat1Name:Caveat1Desc;Caveat3Name:Caveat3Desc"}
var caveats = installationReceiptDocuments
.Select(receiptDocuments => receiptDocuments.Caveats)
// during: deal with the multiple caveats in one string that Junaid spoke about
.SelectMany(caveatsString => caveatsString.Split(';'))
.Distinct()
// during: { "Caveat1Name:Caveat1Desc", "Caveat2Name:Caveat2Desc", "Caveat3Name:Caveat3Desc"}
.Select(c =>
new Caveat()
{
Status = false,
Name = c.Split(':')[0],
Description = c.Split(':')[1]
})
.ToArray();
// after: { new Caveat { status = false, name = Caveat1Name, Desc = Caveat1Desc }, new Caveat { status = false, name = Caveat2Name, Desc = Caveat2Desc }, ... }
return caveats;
}
示例4: InsertEntry
private void InsertEntry(Document document)
{
IEditableTextBuffer textBuffer = document.GetContent<IEditableTextBuffer>();
if (textBuffer == null) return;
string changeLogFileName = document.FileName;
string changeLogFileNameDirectory = Path.GetDirectoryName(changeLogFileName);
string selectedFileName = GetSelectedFile();
string selectedFileNameDirectory = Path.GetDirectoryName(selectedFileName);
string eol = document.Editor != null ? document.Editor.EolMarker : Environment.NewLine;
int pos = GetHeaderEndPosition (document);
if (pos > 0 && selectedFileNameDirectory.StartsWith(changeLogFileNameDirectory)) {
string text = "\t* "
+ selectedFileName.Substring(changeLogFileNameDirectory.Length + 1) + ": "
+ eol + eol;
int insertPos = Math.Min (pos + 2, textBuffer.Length);
textBuffer.InsertText (insertPos, text);
insertPos += text.Length;
textBuffer.Select (insertPos, insertPos);
textBuffer.CursorPosition = insertPos;
document.Select ();
}
}
示例5: InsertEntry
static void InsertEntry(Document document)
{
var textBuffer = document.GetContent<TextEditor>();
if (textBuffer == null) return;
string changeLogFileName = document.FileName;
string changeLogFileNameDirectory = Path.GetDirectoryName(changeLogFileName);
string selectedFileName = GetSelectedFile();
string selectedFileNameDirectory = Path.GetDirectoryName(selectedFileName);
string eol = document.Editor != null ? document.Editor.EolMarker : Environment.NewLine;
int pos = GetHeaderEndPosition (document);
if (pos > 0 && selectedFileNameDirectory.StartsWith (changeLogFileNameDirectory, StringComparison.Ordinal)) {
string text = "\t* "
+ selectedFileName.Substring(changeLogFileNameDirectory.Length + 1) + ": "
+ eol + eol;
int insertPos = Math.Min (pos + 2, textBuffer.Length);
textBuffer.InsertText (insertPos, text);
insertPos += text.Length;
textBuffer.CaretOffset = insertPos;
textBuffer.SetSelection (insertPos, insertPos);
document.Select ();
}
}
示例6: createBlank
protected bool createBlank(string fileName)
{
try {
doc = app.Documents.Open(fileName, Visible: true, ReadOnly: false);
doc.Select();
doc.PageSetup.LeftMargin = 60;
doc.PageSetup.TopMargin = 30;
doc.PageSetup.BottomMargin = 30;
doc.PageSetup.RightMargin = 30;
doc.PageSetup.FooterDistance = 30;
doc.PageSetup.HeaderDistance = 0;
int x=doc.Range().Tables.Count;
Table first=doc.Range().Tables[1];
resetTable(first);
first.Range.Font.Size = 13;
first.Columns.Add();
first.AutoFormat(ApplyBorders: false, ApplyShading: false, ApplyFont: false, ApplyColor: false, ApplyHeadingRows: false,
ApplyLastRow: false, ApplyFirstColumn: false, AutoFit: false, ApplyLastColumn: false);
first.Rows[1].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
Table tab =first.Rows[1].Cells[1].Range.Tables.Add(first.Rows[1].Cells[1].Range, 1, 4);
tab.Rows.Add();
tab.Rows.Add();
tab.Rows.Add();
tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
tab.Rows[1].Cells[1].Merge(tab.Rows[1].Cells[2]);
tab.Rows[1].Cells[1].Range.Text = "Бланк переключений";
tab.Rows[2].Cells[4].Range.Paragraphs.Add();
tab.Rows[2].Cells[4].Range.Paragraphs.First.Range.Select();
app.Selection.Range.Fields.Add(app.Selection.Range, Text: "Date ");
tab.Rows[2].Cells[4].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
tab.Rows[2].Cells[1].Range.Text = "№";
tab.Rows[2].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
tab.Rows[2].Cells[2].Range.Text = "______";
tab.Rows[2].Cells[2].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
tab.Rows[2].Cells[2].Range.Font.Color = WdColor.wdColorWhite;
tab.Rows[2].Cells[3].Range.Text = "/" + getNumber(fileName);
tab.Rows[2].Cells[3].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
tab.Rows[2].Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle;
tab.Rows[2].Cells[1].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthAuto;
tab.Rows[2].Cells[2].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthAuto;
tab.Rows[2].Cells[3].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthAuto;
tab.Rows[2].Cells[4].PreferredWidthType = WdPreferredWidthType.wdPreferredWidthAuto;
tab.Rows[3].Cells[1].Merge(tab.Rows[3].Cells[2]);
tab.Rows[3].Cells[1].Merge(tab.Rows[3].Cells[2]);
tab.Rows[3].Cells[1].Merge(tab.Rows[3].Cells[2]);
tab.Rows[3].Cells[1].Range.Text = "Начало ____час____мин";
tab.Rows[3].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
tab.Rows[4].Cells[1].Merge(tab.Rows[4].Cells[2]);
tab.Rows[4].Cells[1].Merge(tab.Rows[4].Cells[2]);
tab.Rows[4].Cells[1].Merge(tab.Rows[4].Cells[2]);
tab.Rows[4].Cells[1].Range.Text = "Конец ____час____мин";
tab.Rows[4].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
/*tab.Rows[2].Cells[1].PreferredWidth = 20;
tab.Rows[2].Cells[2].PreferredWidth = 50;
tab.Rows[2].Cells[3].PreferredWidth = 30;*/
first.Rows[1].Cells[2].Range.InsertAfter("Филиал ОАО \"РусГидро\"\n - \"Воткинская ГЭС\"");
first.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitWindow);
Table last=doc.Range().Tables[doc.Range().Tables.Count];
resetTable(last);
last.Range.Font.Size = 12;
last.TopPadding = 10;
last.Columns.Add();
last.Rows.Add();
last.Rows.Add();
last.Rows.Add();
last.AutoFormat(ApplyBorders: false, ApplyShading: false, ApplyFont: false, ApplyColor: false, ApplyHeadingRows: false,
ApplyLastRow: false, ApplyFirstColumn: false, AutoFit: false, ApplyLastColumn: false);
last.Rows[1].Cells[1].Range.Text = "Типовой бланк переключений проверен, соответствует схемам, переключения в указанной в нем последовательности могут быть выполнены";
last.Rows[2].Cells[1].Range.Text = "Переключения разрешаю (НСС):";
last.Rows[2].Cells[2].Range.Text = "_________/_____________________/";
last.Rows[3].Cells[1].Range.Text = "Лицо, производящее переключение (ДЭМ/МГ):";
last.Rows[3].Cells[2].Range.Text = "_________/_____________________/";
last.Rows[4].Cells[1].Range.Text = "Лицо контролируюшее (НС):";
last.Rows[4].Cells[2].Range.Text = "_________/_____________________/";
last.Rows[2].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
last.Rows[3].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
last.Rows[4].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
last.Rows[2].Cells[2].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
//.........这里部分代码省略.........
示例7: createTipBlank
protected bool createTipBlank(string fileName, bool pdf, string pdfName)
{
doc = null;
try {
doc = app.Documents.Open(fileName, Visible: true, ReadOnly: false);
doc.Select();
doc.PageSetup.LeftMargin = 60;
doc.PageSetup.TopMargin = 30;
doc.PageSetup.BottomMargin = 30;
doc.PageSetup.RightMargin = 30;
doc.PageSetup.FooterDistance = 30;
doc.PageSetup.HeaderDistance = 0;
int x=doc.Range().Tables.Count;
Table first=doc.Range().Tables[1];
resetTable(first);
first.Range.Font.Size = 13;
first.Columns.Add();
first.AutoFormat(ApplyBorders: false, ApplyShading: false, ApplyFont: false, ApplyColor: false, ApplyHeadingRows: false,
ApplyLastRow: false, ApplyFirstColumn: false, AutoFit: true, ApplyLastColumn: false);
first.Rows[1].Cells[1].Range.Text = "Типовой бланк переключений \n№" + getNumber(fileName);
first.Rows[1].Cells[2].Range.Text = "Утверждаю\nГлавный инженер филиала\nОАО \"РусГидро\" - \"Воткинская ГЭС\"\n__________________Э.М. Скрипка\n\"____\"_____________2012г.";
first.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitWindow);
Table last=doc.Range().Tables[doc.Range().Tables.Count];
resetTable(last);
last.Range.Font.Size = 12;
last.TopPadding = 20;
last.Columns.Add();
last.Columns.Add();
last.Rows.Add();
last.AutoFormat(ApplyBorders: false, ApplyShading: false, ApplyFont: false, ApplyColor: false, ApplyHeadingRows: false,
ApplyLastRow: false, ApplyFirstColumn: false, AutoFit: true, ApplyLastColumn: false);
last.Rows[1].Cells[1].Range.Text = "Начальник СТСУ";
last.Rows[1].Cells[2].Range.Text = "_____________________";
last.Rows[1].Cells[3].Range.Text = "Кочеев Н.Н.";
last.Rows[2].Cells[1].Range.Text = "Начальник ОС";
last.Rows[2].Cells[2].Range.Text = "_____________________";
last.Rows[2].Cells[3].Range.Text = "Иванов А.В.";
last.Rows[1].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
last.Rows[1].Cells[3].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
last.Rows[2].Cells[1].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
last.Rows[2].Cells[3].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
last.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitWindow);
//replaceSpaces(first);
//replaceSpaces(last);
replaceSpaces(doc);
//makeSchema(doc);
addFooter(fileName, doc, true);
podpis(doc, 7);
if (pdf) {
saveAsPDF(doc, pdfName);
}
Logger.log(fileName);
(doc as _Document).Close(SaveChanges: true);
return true;
} catch (Exception e) {
try { (doc as _Document).Close(SaveChanges: false); } catch { }
Logger.log("ERROR: " + fileName);
Logger.log("--" + e.Message);
return false;
}
}