本文整理汇总了C#中Document.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetType方法的具体用法?C# Document.GetType怎么用?C# Document.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintPreview
public void PrintPreview(Document doc)
{
var sci = App.GetService<IEditorService>().GetEditor(doc.GetType()).Instance.Control as ScintillaControl;
if (sci != null)
PrintPreview(new ScintillaPrintDocument(sci, doc.Title));
}
示例2: Replace
public void Replace(string textToFind, string textToReplace, Document doc, SearchFlags flags, SearchScope scope, int startPosition, int endPosition)
{
var ed = App.Editor(doc.GetType()) as ITextEditor;
if (lastSettings != null &&
(lastSettings.LastDocument != doc || ed.SelectionStart != lastSettings.LastStartPosition || ed.SelectionEnd != lastSettings.LastEndPosition))
lastSettings = null;
if (lastSettings != null)
{
ed.ReplaceText(lastSettings.LastStartPosition, lastSettings.LastEndPosition, lastSettings.TextToReplace);
lastSettings.LastEndPosition = lastSettings.LastStartPosition + lastSettings.TextToReplace.Length;
}
var res = Search(textToFind, doc, flags, scope, (d,r) => {
var editor = (ITextEditor)App.GetService<IEditorService>().GetEditor(d.GetType()).Instance;
var docServ = App.GetService<IDocumentService>();
if (docServ.GetActiveDocument() != d)
docServ.SetActiveDocument(d);
editor.SelectText(r.StartPosition, r.EndPosition - r.StartPosition);
lastSettings.LastStartPosition = r.StartPosition;
lastSettings.TextToReplace = textToReplace;
var sci = editor.Control as ScintillaControl;
if (sci != null)
sci.PutArrow(sci.GetLineFromPosition(r.StartPosition));
return true;
}, false, lastSettings != null ? lastSettings.LastEndPosition : startPosition, endPosition, null);
IsFinished(res);
}
示例3: IsPrintAvailable
public bool IsPrintAvailable(Document doc)
{
if (doc == null)
return false;
var editor = App.GetService<IEditorService>().GetEditor(doc.GetType());
return editor.Instance.Control is ScintillaControl;
}
示例4: AddForm
public AddForm(Document d)
{
InitializeComponent();
this.id_current_doc = d.ID;
this.txtTitle.Text = d.Title;
this.txtAuthor.Text = d.Author;
this.chkB_CopyR.Checked = (d.Copyright=="true"? true:false);
switch (d.GetType().Name)
{
case "Article" :
Article ar = (Article)d;
this.userControl11.txt_R_title.Text = ar.Review_title;
this.userControl11.txt_E_Name.Text = ar.Review_Editor;
this.userControl11.spin_R_numb.Text = ar.Review_Number;
this.userControl11.xpandListBox.SelectedItem = this.userControl11.xpder_Article;
break;
case "Audio" :
Audio au = (Audio)d;
this.userControl11.spin_Minutes_Audio.Value = au.Duration.Minutes;
this.userControl11.spin_Secondes_Audio.Value = au.Duration.Secondes;
this.userControl11.xpandListBox.SelectedItem = this.userControl11.xpder_Audio;
break;
case "Book":
Book b = (Book)d;
this.userControl11.txt_E_Book.Text = b.Editor;
this.userControl11.spin_Publication.Text = b.PublicationYear;
this.userControl11.xpandListBox.SelectedItem = this.userControl11.xpder_Book;
break;
case "Multimedia":
Multimedia m = (Multimedia)d;
this.userControl11.spin_Hours_VMulti.Value = m.Image.Hours;
this.userControl11.spin_Minutes_VMulti.Value = m.Image.Minutes;
this.userControl11.spin_Secondes_VMulti.Value = m.Image.Secondes;
this.userControl11.spin_Minutes_AMulti.Value = m.Sound.Minutes;
this.userControl11.spin_Secondes_AMulti.Value = m.Sound.Secondes;
this.userControl11.txtTitle_Multi.Text = m.Text_title;
this.userControl11.xpandListBox.SelectedItem = this.userControl11.xpder_MultiM;
break;
case "Video":
Video v = (Video)d;
this.userControl11.spin_Hours_Video.Value = v.Duration.Hours;
this.userControl11.spin_Minutes_Video.Value = v.Duration.Minutes;
this.userControl11.spin_Secondes_Video.Value = v.Duration.Secondes;
this.userControl11.xpandListBox.SelectedItem = this.userControl11.xpder_Video;
break;
default:
break;
}
}
示例5: PageSetup
public void PageSetup(Document doc)
{
var sci = App.GetService<IEditorService>().GetEditor(doc.GetType()).Instance.Control as ScintillaControl;
if (sci != null)
{
var printDoc = new ScintillaPrintDocument(sci, doc.Title);
if (ShowPageSetupDialog(printDoc) == DialogResult.OK)
Print(false, printDoc);
}
}
示例6: SaveDocument
public bool SaveDocument(Document doc, bool saveAs)
{
if(!doc.OnDisk || saveAs)
{
saveDocumentDialog.FileName = doc.FileName;
DocumentClassAttribute attr = DocumentClassAttribute.ForType(doc.GetType());
string extensions = String.Join(";", Array.ConvertAll<string, string>(attr.FileExtensions, delegate(string ext) { return "*" + ext; }));
saveDocumentDialog.Filter = attr.Name + "(" + extensions + ")|" + extensions + "|All files (*.*)|*.*";
saveDocumentDialog.DefaultExt = "*" + attr.FileExtensions[0];
if (saveDocumentDialog.ShowDialog() == DialogResult.OK)
{
// If first time it's been saved then rename it in the project
if(!saveAs)
{
DocumentItem documentItem = Manager.Project.FindDocument(doc.FileName);
if (documentItem != null)
Manager.Project.RenameDocument(documentItem, saveDocumentDialog.FileName);
}
doc.FileName = saveDocumentDialog.FileName;
}
else
return false;
}
return doc.SaveDocument();
}
示例7: ChooseViewType
private Type ChooseViewType(Document doc)
{
DocumentClassAttribute attr = DocumentClassAttribute.ForType(doc.GetType());
if (attr == null)
return null;
else
return attr.ViewType;
}
示例8: UpdateGridWithChangedDocument
public void UpdateGridWithChangedDocument(Document doc)
{
ListViewItem rowToUpdate = null;
foreach (ListViewItem row in this.grdDocs.Items)
{
if (row.Text == doc.ID)
{
rowToUpdate = row;
}
}
if (rowToUpdate != null)
{
rowToUpdate.Text = doc.ID;
rowToUpdate.SubItems[1].Text = doc.GetType().Name;
rowToUpdate.SubItems[2].Text = doc.Title;
rowToUpdate.SubItems[3].Text = doc.Author;
rowToUpdate.SubItems[4].Text = doc.Copyright;
}
}
示例9: AddDocumentToGrid
public void AddDocumentToGrid(Document doc)
{
if (!this.grdDocs.Items.ContainsKey(doc.ID))
{
ListViewItem parent;
parent = this.grdDocs.Items.Add(doc.ID);
parent.SubItems.Add(doc.GetType().ToString().Split('.')[2]);
parent.SubItems.Add(doc.Title);
parent.SubItems.Add(doc.Author);
parent.SubItems.Add(doc.Copyright);
parent.Name = doc.ID;
}
}
示例10: ReplaceAll
public void ReplaceAll(string text, string textToReplace, Document doc, SearchFlags flags, SearchScope scope)
{
lastSettings = null;
scanned = null;
var items = new List<ResultItem>();
var sw = new Stopwatch();
sw.Start();
var rootEditor = (ITextEditor)App.GetService<IEditorService>().GetEditor(doc.GetType()).Instance;
rootEditor.BeginUndoAction();
var startPos = scope == SearchScope.Selection ? rootEditor.SelectionStart :
scope == SearchScope.Current ? rootEditor.CaretPosition : 0;
var endPos = scope == SearchScope.Selection ? rootEditor.SelectionEnd : 0;
for (;;)
{
var res = Search(text, lastSettings != null ? lastSettings.LastDocument : doc, flags, scope, (d, r) => {
var editor = (ITextEditor)App.GetService<IEditorService>().GetEditor(d.GetType()).Instance;
var loc = editor.GetLocationFromPosition(d, r.StartPosition);
var txt = editor.GetContent(d, loc.Line).TrimStart(' ', '\t');
var item = new ResultItem(txt, d, loc.Line, loc.Column, r.EndPosition - r.StartPosition);
var docSrv = App.GetService<IDocumentService>();
if (docSrv.GetActiveDocument() != d)
{
rootEditor.EndUndoAction();
docSrv.SetActiveDocument(d);
editor.BeginUndoAction();
rootEditor = editor;
}
var sci = editor.Control as ScintillaControl;
if (sci != null)
sci.ReplaceText(r.StartPosition, r.EndPosition, textToReplace);
else
editor.ReplaceText(r.StartPosition, r.EndPosition, textToReplace);
lastSettings.LastStartPosition = r.StartPosition;
lastSettings.TextToReplace = textToReplace;
lastSettings.LastEndPosition = r.StartPosition + textToReplace.Length;
if (items.Contains(item))
return false;
else
{
items.Add(item);
return true;
}
}, true,
lastSettings != null ? lastSettings.LastEndPosition : startPos,
lastSettings != null ? lastSettings.MaxPosition : endPos, null);
if (!res)
break;
}
rootEditor.EndUndoAction();
sw.Stop();
var s = (Single)sw.ElapsedMilliseconds / 1000;
var svc = App.GetService<IResultGridService>();
svc.AddItems(items);
App.OpenView("ResultGrid");
App.GetService<IStatusBarService>().SetStatusString(StatusType.Information, "{0} entries replaced. Replace took: {1:F2} s.", items.Count, s);
}
示例11: Search
private bool Search(string textToFind, Document doc, SearchFlags flags, SearchScope scope, Func<Document,SearchResult,Boolean> foundAction, bool silent,
int startPosition, int endPosition, SearchManager sm)
{
lastSettings = null;
var editor = (ITextEditor)App.Editor(doc.GetType());
sm = sm ?? new SearchManager(editor.GetContent(doc));
var sp = startPosition;
var ep = endPosition;
var res = sm.Search(flags, textToFind, sp, ep);
if (res.Found)
{
lastSettings = new SearchSettings
{
Text = textToFind,
Flags = flags,
Scope = scope,
LastEndPosition = res.EndPosition,
LastDocument = doc,
MaxPosition = ep,
SearchManager = silent ? sm : null
};
if (!silent)
sm.Dispose();
return foundAction(doc, res);
}
else if (scope == SearchScope.AllDocuments)
{
sm.Dispose();
sm = null;
var srv = App.GetService<IDocumentService>();
var newDoc = GetNextDocument(doc);
if (newDoc != null)
{
if (scanned == null)
scanned = new List<Document>();
if (scanned.IndexOf(newDoc) != -1)
return false;
else
scanned.Add(newDoc);
if (!silent)
srv.SetActiveDocument(newDoc);
if (silent)
sm = new SearchManager(editor.GetContent(newDoc));
return Search(textToFind, newDoc, flags, scope, foundAction, silent, 0, 0, sm);
}
return false;
}
else
{
sm.Dispose();
return false;
}
}
示例12: SearchAll
public void SearchAll(string text, Document doc, SearchFlags flags, SearchScope scope)
{
lastSettings = null;
scanned = null;
var items = new List<ResultItem>();
var sw = new Stopwatch();
sw.Start();
var sm = default(SearchManager);
var status = "{0} element(s) found. Search took: {1:F2} s.";
var rootEditor = (ITextEditor)App.GetService<IEditorService>().GetEditor(doc.GetType()).Instance;
var startPos = scope == SearchScope.Selection ? rootEditor.SelectionStart :
scope == SearchScope.Current ? rootEditor.CaretPosition : 0;
var endPos = scope == SearchScope.Selection ? rootEditor.SelectionEnd : 0;
for(;;)
{
var res = Search(text, lastSettings != null ? lastSettings.LastDocument : doc, flags, scope, (d,r) =>
{
var editor = (ITextEditor)App.GetService<IEditorService>().GetEditor(d.GetType()).Instance;
var loc = editor.GetLocationFromPosition(d, r.StartPosition);
var txt = editor.GetContent(d, loc.Line).TrimStart(' ', '\t');
var item = new ResultItem(txt, d, loc.Line, loc.Column, r.EndPosition - r.StartPosition);
if (items.Count >= 1000)
{
status = "Too many entries found. Showing first {0}. Search took: {1:F2} s.";
return false;
}
else if (items.Contains(item))
return false;
else
{
items.Add(item);
return true;
}
}, true,
lastSettings != null ? lastSettings.LastEndPosition : 0,
lastSettings != null ? lastSettings.MaxPosition : endPos, sm);
if (!res)
break;
sm = lastSettings.SearchManager;
}
sw.Stop();
var s = (Single)sw.ElapsedMilliseconds / 1000;
var svc = App.GetService<IResultGridService>();
svc.AddItems(items);
App.OpenView("ResultGrid");
App.GetService<IStatusBarService>().SetStatusString(StatusType.Information, status, items.Count, s);
}
示例13: CreateWatcher
private void CreateWatcher(Document doc)
{
if (doc.FileInfo != null)
{
var oldw = doc.Tag as FileSystemWatcher;
if (oldw != null)
oldw.Dispose();
var w = new FileSystemWatcher(doc.FileInfo.DirectoryName);
w.Filter = doc.FileInfo.Name;
w.EnableRaisingEvents = true;
w.Deleted += (o, e) => doc.IsDirty = true;
w.Renamed += (o, e) => doc.IsDirty = true;
w.Changed += (o, e) =>
{
try
{
w.EnableRaisingEvents = false;
var ed = App.GetService<IEditorService>().GetEditor(doc.GetType());
if (doc.IsDirty)
{
var srv = App.GetService<IDialogService>();
if (srv.ShowWarningDialog("File '{0}' was modified outside of Elide. Do you want to reload it and loose changes?", doc.FileInfo))
{
ed.Instance.ReloadDocument(doc, true);
SetActiveDocument(doc);
}
else
doc.IsDirty = true;
}
else
{
try
{
ed.Instance.ReloadDocument(doc, true);
}
catch
{
ed.Instance.ReloadDocument(doc, true);
}
}
}
finally
{
w.EnableRaisingEvents = true;
}
};
doc.Tag = w;
}
}
示例14: IsBrowserFirefoxOrAtleastIE8
private static bool IsBrowserFirefoxOrAtleastIE8(Document browser)
{
// Only do this check for WatiN.Core.IE all other
// Browser drivers are assummed to support latest W3C standards
var browserType = browser.GetType();
if (!browserType.Equals(typeof(IE))) return true;
var browserVersion = 7;
var ieUserAgent = browser.Eval("window.navigator.userAgent");
if (!string.IsNullOrEmpty(ieUserAgent) && new Regex(@"MSIE [8-9](\.\d+);").IsMatch(ieUserAgent))
{
browserVersion = 8;
}
return (browserType.Equals(typeof(IE)) && browserVersion > 7);
}
示例15: IsBrowserFirefoxOrAtleastIE8
private static bool IsBrowserFirefoxOrAtleastIE8(Document browser)
{
var browserVersion = 7;
var ieUserAgent = browser.Eval("window.navigator.userAgent");
if (!string.IsNullOrEmpty(ieUserAgent) && new Regex(@"MSIE 8(\.\d+);").IsMatch(ieUserAgent))
{
browserVersion = 8;
}
var browserType = browser.GetType();
return browserType.Equals(typeof(FireFox)) ||
(browserType.Equals(typeof(IE)) && browserVersion > 7);
}