public virtual HResult OpenItem(INiHierarchy hier, out INiWindowFrame windowFrame) { windowFrame = null; try { if ((NiHierarchyType?)hier.GetPropertyEx(NiHierarchyProperty.ItemType) == NiHierarchyType.File) { string fileName; ErrorUtil.ThrowOnFailure(((INiProjectItem)hier).GetFileName(out fileName)); return ((INiOpenDocumentManager)GetService(typeof(INiOpenDocumentManager))).OpenStandardEditor( null, fileName, hier, this, out windowFrame ); } return HResult.False; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult IsDocumentOpen(string document, out INiHierarchy hier, out INiWindowFrame windowFrame) { hier = null; windowFrame = null; try { if (document == null) { throw new ArgumentNullException("document"); } OpenDocument openDocument; if (_openDocuments.TryGetValue(document, out openDocument)) { hier = openDocument.Item; windowFrame = openDocument.WindowFrame; return(HResult.OK); } return(HResult.False); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
protected string GetAllTextFromWindowFrame(INiWindowFrame windowFrame) { var textLines = windowFrame.GetPropertyEx(NiFrameProperty.DocData) as INiTextLines; if (textLines == null) { var docView = windowFrame.GetPropertyEx(NiFrameProperty.DocView) as INiWindowPane; if (docView != null) { var textBufferProvider = docView as INiTextBufferProvider; if (textBufferProvider != null) { INiTextBuffer textBuffer; ErrorUtil.ThrowOnFailure(textBufferProvider.GetTextBuffer(out textBuffer)); textLines = textBuffer as INiTextLines; } } } if (textLines != null) { int line; int index; ErrorUtil.ThrowOnFailure(textLines.GetLastLineIndex(out line, out index)); string result; ErrorUtil.ThrowOnFailure(textLines.GetLineText(0, 0, line, index, out result)); return(result); } return(null); }
public virtual HResult OpenItem(INiHierarchy hier, out INiWindowFrame windowFrame) { windowFrame = null; try { if ((NiHierarchyType?)hier.GetPropertyEx(NiHierarchyProperty.ItemType) == NiHierarchyType.File) { string fileName; ErrorUtil.ThrowOnFailure(((INiProjectItem)hier).GetFileName(out fileName)); return(((INiOpenDocumentManager)GetService(typeof(INiOpenDocumentManager))).OpenStandardEditor( null, fileName, hier, this, out windowFrame )); } return(HResult.False); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public static object GetPropertyEx(this INiWindowFrame self, int property) { object result; ErrorUtil.ThrowOnFailure(self.GetProperty(property, out result)); return(result); }
protected override bool FindNext() { _current = _current == null ? GetCurrentWindowFrame(_serviceProvider) : null; return(_current != null); }
public HResult Open(out INiWindowFrame windowFrame) { windowFrame = null; try { return FindProject().OpenItem(this, out windowFrame); } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public OpenDocument(NiOpenDocumentManager manager, string document, INiHierarchy item, INiWindowFrame windowFrame, int rdtCookie, INiPersistDocData docData) { _manager = manager; _rdtCookie = rdtCookie; _docData = docData; Document = document; Item = item; WindowFrame = windowFrame; new Listener(this); if (docData != null) { ErrorUtil.ThrowOnFailure(windowFrame.GetCaption(out _initialCaption)); UpdateDirtyFlag(); ((NiShell)manager.GetService(typeof(INiShell))).RequerySuggested += OpenDocument_RequerySuggested; } }
protected override bool FindNext() { if (_current == null) { _current = GetCurrentWindowFrame(_serviceProvider); } else { var allOpen = ((INiShell)_serviceProvider.GetService(typeof(INiShell))).GetDocumentWindows().ToArray(); int index = Array.IndexOf(allOpen, _current); if (index == -1 || allOpen.Length == 1) { _current = null; } else if (index == allOpen.Length - 1) { _current = allOpen[0]; } else { _current = allOpen[index + 1]; } } if (_seen.Contains(_current)) { _current = null; } if (_current != null) { _seen.Add(_current); } return(_current != null); }
public static void SetPropertyEx(this INiWindowFrame self, int property, object value) { ErrorUtil.ThrowOnFailure(self.SetProperty(property, value)); }
protected override bool FindNext() { if (_current == null) { _current = GetCurrentWindowFrame(_serviceProvider); } else { var allOpen = ((INiShell)_serviceProvider.GetService(typeof(INiShell))).GetDocumentWindows().ToArray(); int index = Array.IndexOf(allOpen, _current); if (index == -1 || allOpen.Length == 1) _current = null; else if (index == allOpen.Length - 1) _current = allOpen[0]; else _current = allOpen[index + 1]; } if (_seen.Contains(_current)) _current = null; if (_current != null) _seen.Add(_current); return _current != null; }
protected override bool FindNext() { _current = _current == null ? GetCurrentWindowFrame(_serviceProvider) : null; return _current != null; }
protected string GetAllTextFromWindowFrame(INiWindowFrame windowFrame) { var textLines = windowFrame.GetPropertyEx(NiFrameProperty.DocData) as INiTextLines; if (textLines == null) { var docView = windowFrame.GetPropertyEx(NiFrameProperty.DocView) as INiWindowPane; if (docView != null) { var textBufferProvider = docView as INiTextBufferProvider; if (textBufferProvider != null) { INiTextBuffer textBuffer; ErrorUtil.ThrowOnFailure(textBufferProvider.GetTextBuffer(out textBuffer)); textLines = textBuffer as INiTextLines; } } } if (textLines != null) { int line; int index; ErrorUtil.ThrowOnFailure(textLines.GetLastLineIndex(out line, out index)); string result; ErrorUtil.ThrowOnFailure(textLines.GetLineText(0, 0, line, index, out result)); return result; } return null; }
public HResult GetWindowFrameForWindowPane(INiWindowPane windowPane, out INiWindowFrame windowFrame) { windowFrame = null; try { DockContent dockContent; if (_dockContents.TryGetValue(windowPane, out dockContent)) windowFrame = dockContent.GetProxy(); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult CreateToolWindow(INiWindowPane windowPane, NiDockStyle dockStyle, NiToolWindowOrientation toolWindowOrientation, out INiWindowFrame toolWindow) { toolWindow = null; try { if (windowPane == null) throw new ArgumentNullException("windowPane"); var dockContent = new DockContent(windowPane, dockStyle, toolWindowOrientation) { Site = new SiteProxy(this) }; dockContent.Disposed += dockContent_Disposed; _dockContents.Add(windowPane, dockContent); toolWindow = dockContent.GetProxy(); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public static void SetPropertyEx(this INiWindowFrame self, NiFrameProperty property, object value) { SetPropertyEx(self, (int)property, value); }
public static object GetPropertyEx(this INiWindowFrame self, NiFrameProperty property) { return(GetPropertyEx(self, (int)property)); }
public HResult OpenStandardEditor(Guid?editorGuid, string document, INiHierarchy hier, IServiceProvider serviceProvider, out INiWindowFrame windowFrame) { windowFrame = null; try { if (document == null) { throw new ArgumentNullException("document"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } INiEditorFactory editorFactory; Guid resolvedEditorGuid; var hr = ((NiEnv)GetService(typeof(INiEnv))).GetStandardEditorFactory(null, document, out editorFactory, out resolvedEditorGuid); if (ErrorUtil.Failure(hr)) { return(hr); } if (editorFactory == null) { return(HResult.False); } return(OpenSpecificEditor( document, resolvedEditorGuid, editorFactory, hier, serviceProvider, out windowFrame )); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public HResult OpenSpecificEditor(string document, Guid editorType, INiHierarchy hier, IServiceProvider serviceProvider, out INiWindowFrame windowFrame) { windowFrame = null; try { INiEditorFactory editorFactory; var hr = ((INiEnv)GetService(typeof(INiEnv))).GetStandardEditorFactory(editorType, null, out editorFactory); if (ErrorUtil.Failure(hr)) { return(hr); } return(OpenSpecificEditor(document, editorType, editorFactory, hier, serviceProvider, out windowFrame)); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
private HResult OpenSpecificEditor(string document, Guid editorType, INiEditorFactory editorFactory, INiHierarchy hier, IServiceProvider serviceProvider, out INiWindowFrame windowFrame) { windowFrame = null; try { if (document == null) { throw new ArgumentNullException("document"); } if (editorFactory == null) { throw new ArgumentNullException("editorFactory"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } OpenDocument openDocument; if (_openDocuments.TryGetValue(document, out openDocument)) { ErrorUtil.ThrowOnFailure(openDocument.WindowFrame.Show()); return(HResult.OK); } string editorCaption; INiWindowPane windowPane; var hr = editorFactory.CreateEditor(document, out editorCaption, out windowPane); if (ErrorUtil.Failure(hr)) { return(hr); } if (windowPane == null) { return(HResult.False); } hr = windowPane.SetSite(serviceProvider); if (ErrorUtil.Failure(hr)) { return(hr); } hr = ((INiShell)GetService(typeof(INiShell))).CreateToolWindow( windowPane, NiDockStyle.Document, NiToolWindowOrientation.Top, out windowFrame ); if (ErrorUtil.Failure(hr)) { return(hr); } ErrorUtil.ThrowOnFailure(windowFrame.SetCaption( editorCaption ?? Path.GetFileName(document) )); hr = windowPane.Initialize(); if (ErrorUtil.Failure(hr)) { return(hr); } var docData = windowPane as INiPersistDocData; if (docData == null) { var textBufferProvider = windowPane as INiTextBufferProvider; if (textBufferProvider != null) { INiTextBuffer textBuffer; hr = textBufferProvider.GetTextBuffer(out textBuffer); if (ErrorUtil.Failure(hr)) { return(hr); } docData = textBuffer; } } int rdtCooke = -1; if (docData != null) { hr = docData.LoadDocData(document); if (ErrorUtil.Failure(hr)) { return(hr); } hr = ((INiRunningDocumentTable)GetService(typeof(INiRunningDocumentTable))).Register( document, hier, docData, out rdtCooke ); if (ErrorUtil.Failure(hr)) { return(hr); } } windowFrame.SetPropertyEx(NiFrameProperty.DocCookie, rdtCooke); windowFrame.SetPropertyEx(NiFrameProperty.DocView, windowPane); windowFrame.SetPropertyEx(NiFrameProperty.DocData, docData); windowFrame.SetPropertyEx(NiFrameProperty.Document, document); windowFrame.SetPropertyEx(NiFrameProperty.EditorType, editorType); windowFrame.SetPropertyEx(NiFrameProperty.Hierarchy, hier); windowFrame.SetPropertyEx(NiFrameProperty.Type, NiFrameType.Document); _openDocuments.Add(document, new OpenDocument( this, document, hier, windowFrame, rdtCooke, docData )); return(windowFrame.Show()); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }