public IDocument OpenDocument(Uri uri, ISledDocumentClient client) { var sd = SledDocument.Create(uri, client); sd.Read(); // Let the control do it itself; it will also // supply an icon if the document is readonly. sd.RegisterControl(); if (sd.Editor != null) { sd.Editor.FileDragDropped += SledDocumentEditorFileDragDropped; } return(sd); }
private SledDocument(Uri uri, ISledDocumentClient client, bool bHidden) { m_uri = uri; m_type = client == null ? "SledDocument" : client.Info.FileType; m_bHiddenDoc = bHidden; var filePath = uri.LocalPath; var fileName = Path.GetFileName(filePath); var ext = Path.GetExtension(filePath); // Set up language plugin (if any) LanguagePlugin = null; if (!m_bHiddenDoc) { if (s_languagePluginService.Get != null) { LanguagePlugin = s_languagePluginService.Get.GetPluginForExtension(ext); } } // Create new syntax editor m_editor = TextEditorFactory.CreateSyntaxHighlightingEditor(); m_editor.Control.Tag = this; m_editor.Control.Name = fileName; // Grab reference to image if (s_imgLock == null) { s_imgLock = GetLockImage(); } // Check if readonly if (!m_bHiddenDoc) { m_bReadOnly = IsReadOnly; // Create hosting control m_control = new SledDocumentControl(m_editor, this, client == null ? null : client.EmbeddedTypes) { Name = fileName, Tag = this }; } // Create control info m_controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center, !m_bReadOnly ? null : s_imgLock); if (!m_bHiddenDoc) { m_controlInfo.IsDocument = true; } // Using a custom context menu, so disable the default m_editor.DefaultContextMenuEnabled = false; m_editor.EditorTextChanged += EditorEditorTextChanged; m_editor.KeyPress += EditorKeyPress; m_editor.ShowContextMenu += EditorShowContextMenu; m_editor.MouseHoveringOverToken += EditorMouseHoveringOverToken; if (client == null) { return; } // Set syntax highlighting for document SledDocumentSyntaxHighlighter.FeedHighlighterToSyntaxEditor(client.SyntaxHighlighter, m_editor); }
public static SledDocument Create(Uri uri, ISledDocumentClient client) { return(new SledDocument(uri, client, false)); }
public static SledDocument CreateHidden(Uri uri, ISledDocumentClient client) { return(new SledDocument(uri, client, true)); }
public FileCommandTag(Command command, ISledDocumentClient client) { Cmd = command; Client = client; }
public IDocument OpenDocument(Uri uri, ISledDocumentClient client) { var sd = SledDocument.Create(uri, client); sd.Read(); // Let the control do it itself; it will also // supply an icon if the document is readonly. sd.RegisterControl(); if (sd.Editor != null) sd.Editor.FileDragDropped += SledDocumentEditorFileDragDropped; return sd; }