// ---------------------------------------------------------------------------------- /// <summary> /// Initialize the editor /// </summary> // ---------------------------------------------------------------------------------- private void InitializeEditor(string scriptName) { Guid guid_microsoft_csharp_editor = new Guid("{A6C744A8-0E4A-4FC6-886A-064283054674}"); Guid guid_microsoft_csharp_editor_with_encoding = new Guid("{08467b34-b90f-4d91-bdca-eb8c8cf3033a}"); Guid editorType = guid_microsoft_csharp_editor;// VSConstants.VsEditorFactoryGuid.TextEditor_guid; Guid logicalViewGuid = Microsoft.VisualStudio.VSConstants.LOGVIEWID.Primary_guid; IVsWindowFrame ppWindowFrame = null; try { var psp = (System.IServiceProvider)ReplEditorPackage.CurrentPackage; var fileName = System.IO.Path.Combine(VSTools.ScriptsDirectory, scriptName); ppWindowFrame = Microsoft.VisualStudio.Shell.VsShellUtilities.OpenDocumentWithSpecificEditor(psp, fileName, editorType, logicalViewGuid); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("REPLException : " + ex.ToString()); //System.Windows.MessageBox.Show(ex.ToString()); } if (ppWindowFrame != null) { _ViewAdapter = VsShellUtilities.GetTextView(ppWindowFrame); _childWindowFrame = ppWindowFrame; _TextViewHost = _EditorAdapterFactory.GetWpfTextViewHost(_ViewAdapter); _docData = VSTools.GetPersistDocData(_TextViewHost); this.leftSide.Content = _TextViewHost; } }
private void ScriptSaveAs(object sender, RoutedEventArgs e) { //TODO: is an old ui, but it works... string fileName = Microsoft.VisualBasic.Interaction.InputBox("New script name", "Save script As", _CurrentScriptName, -1, -1); if (!string.IsNullOrEmpty(fileName)) { try { VSTools.SaveAs(_TextViewHost, _CurrentScriptName, ref fileName); _ScriptNameEntries = null; _CurrentScriptName = fileName; NotifyPropertyChanged(string.Empty); } catch (Exception ex) { VSTools.LogDebug("ScriptSaveAs Failed : {0}{1}", ex, Environment.NewLine); VSTools.ActivateLogWindow(); } } }
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { VSTools.Save(_docData); }
private bool IsDirtyDocument() { return(VSTools.IsDirty(_docData)); }