public void Save(VSSAVEFLAGS flags, out int pfCanceled) { pfCanceled = 0; switch (flags) { case VSSAVEFLAGS.VSSAVE_Save: if (_neverSaved) { goto case VSSAVEFLAGS.VSSAVE_SaveAs; } Save(_filename); break; case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = _filename; if (saveDialog.ShowDialog() == true) { Save(saveDialog.FileName); _neverSaved = false; } else { pfCanceled = 1; } break; } }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: editorControl.cbIsDirty.IsChecked = false; editorControl.IsDirty = false; break; case VSSAVEFLAGS.VSSAVE_SaveAs: break; case VSSAVEFLAGS.VSSAVE_SilentSave: break; case VSSAVEFLAGS.VSSAVE_SaveCopyAs: break; default: break; } return(VSConstants.S_OK); }
private static void SaveDocDataToFileCallBack(object caller, CallbackArgs arguments) { arguments.ReturnValue = VSConstants.S_OK; VSSAVEFLAGS dwSave = (VSSAVEFLAGS)arguments.GetParameter(0); IPersistFileFormat editorInstance = (IPersistFileFormat)arguments.GetParameter(1); string fileName = (string)arguments.GetParameter(2); //Call Save on the EditorInstance depending on the Save Flags switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: editorInstance.Save(fileName, 0, 0); arguments.SetParameter(3, fileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; case VSSAVEFLAGS.VSSAVE_SaveAs: String newFileName = Path.Combine(Path.GetTempPath(), Path.GetFileName(fileName)); editorInstance.Save(newFileName, 1, 0); //Call Save with new file and remember=1 arguments.SetParameter(3, newFileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; case VSSAVEFLAGS.VSSAVE_SaveCopyAs: newFileName = Path.Combine(Path.GetTempPath(), Path.GetFileName(fileName)); editorInstance.Save(newFileName, 0, 0); //Call Save with new file and remember=0 arguments.SetParameter(3, newFileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; } }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = ""; pfSaveCanceled = 0; return(VSConstants.E_NOTIMPL); }
/// <summary> /// Saves the hierarchy item to disk. /// </summary> /// <param name="dwSave">Flags whose values are taken from the VSSAVEFLAGS enumeration.</param> /// <param name="silentSaveAsName">File name to be applied when dwSave is set to VSSAVE_SilentSave. </param> /// <param name="itemid">Item identifier of the hierarchy item saved from VSITEMID. </param> /// <param name="punkDocData">Pointer to the IUnknown interface of the hierarchy item saved.</param> /// <param name="pfCancelled">TRUE if the save action was canceled. </param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public override int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled) { // Don't ignore/unignore file changes // Use Advise/Unadvise to work around rename situations try { this.StopObservingNestedProjectFile(); Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); Debug.Assert(punkDocData != IntPtr.Zero, "docData intptr was zero"); // Get an IPersistFileFormat object from docData object (we don't call release on punkDocData since did not increment its ref count) IPersistFileFormat persistFileFormat = Marshal.GetTypedObjectForIUnknown(punkDocData, typeof(IPersistFileFormat)) as IPersistFileFormat; Debug.Assert(persistFileFormat != null, "The docData object does not implement the IPersistFileFormat interface"); IVsUIShell uiShell = this.GetService(typeof(SVsUIShell)) as IVsUIShell; string newName; uiShell.SaveDocDataToFile(dwSave, persistFileFormat, silentSaveAsName, out newName, out pfCancelled); // When supported do a rename of the nested project here } finally { // Succeeded or not we must hook to the file change events // Don't ignore/unignore file changes // Use Advise/Unadvise to work around rename situations this.ObserveNestedProjectFile(); } return(VSConstants.S_OK); }
private static void SaveDocDataToFileCallBack(object caller, CallbackArgs arguments) { arguments.ReturnValue = VSConstants.S_OK; VSSAVEFLAGS dwSave = (VSSAVEFLAGS)arguments.GetParameter(0); IPersistFileFormat editorInstance = (IPersistFileFormat)arguments.GetParameter(1); string fileName = (string)arguments.GetParameter(2); //Call Save on the EditorInstance depending on the Save Flags switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: editorInstance.Save(fileName, 0, 0); arguments.SetParameter(3, fileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; case VSSAVEFLAGS.VSSAVE_SaveAs: string newFileName = Environment.GetEnvironmentVariable("SystemDrive") + Path.DirectorySeparatorChar + "NewTempFile.rtf"; editorInstance.Save(newFileName, 1, 0); //Call Save with new file and remember=1 arguments.SetParameter(3, newFileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; case VSSAVEFLAGS.VSSAVE_SaveCopyAs: newFileName = Environment.GetEnvironmentVariable("SystemDrive") + Path.DirectorySeparatorChar + "NewTempFile.rtf"; editorInstance.Save(newFileName, 0, 0); //Call Save with new file and remember=0 arguments.SetParameter(3, newFileName); // setting pbstrMkDocumentNew arguments.SetParameter(4, 0); // setting pfSaveCanceled break; } }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { // todo: pbstrMkDocumentNew = this.filePath; pfSaveCanceled = 0; return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { // We don't support save as so we don't need to the two out parameters. pbstrMkDocumentNew = null; pfSaveCanceled = 0; return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { // We don't support save as so we don't need to the two out parameters. pbstrMkDocumentNew = null; pfSaveCanceled = 0; return VSConstants.S_OK; }
int IVsPersistDocData.SaveDocData( VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = string.Empty; pfSaveCanceled = 0; return(VSConstants.E_NOTIMPL); }
public int SaveItem(VSSAVEFLAGS dwSave, string pszSilentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCanceled) { if (itemid == VSConstants.VSITEMID_ROOT) { Save(dwSave, out pfCanceled); return(VSConstants.S_OK); } pfCanceled = 0; return(VSConstants.E_FAIL); }
public override int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled) { HierarchyNode hierNode = this.NodeFromItemId(itemid); Debug.Assert(hierNode != null, "Hierarchy node not found"); if(hierNode != this) { return ErrorHandler.ThrowOnFailure(hierNode.SaveItem(dwSave, silentSaveAsName, itemid, punkDocData, out pfCancelled)); } else { return ErrorHandler.ThrowOnFailure(base.SaveItem(dwSave, silentSaveAsName, itemid, punkDocData, out pfCancelled)); } }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; // _view.Name; pfSaveCanceled = 0; if (String.IsNullOrEmpty(_view.OriginalSql) == true) { using (TableNameDialog dlg = new TableNameDialog("View", _view.Name)) { if (dlg.ShowDialog(this) == DialogResult.Cancel) { pfSaveCanceled = 1; return(VSConstants.S_OK); } _view.Name = dlg.TableName; } } CommitQueryBuilder(); string query = _view.GetSqlText(); if (String.IsNullOrEmpty(query) == false) { using (DbTransaction trans = _view.GetConnection().BeginTransaction()) { try { using (DbCommand cmd = _view.GetConnection().CreateCommand()) { cmd.CommandText = query; cmd.ExecuteNonQuery(); } trans.Commit(); } catch (Exception) { trans.Rollback(); throw; } } } _dirty = false; _view.Committed(); NotifyChanges(); SQLiteCommandHandler.Refresh(_accessor, _itemId); return(VSConstants.S_OK); }
public override int SaveItem(VSSAVEFLAGS saveFlag, string silentSaveAsName, uint itemid, IntPtr docData, out int cancelled) { BaseFileNode node = this.NodeFromItemId(itemid) as BaseFileNode; if (node != null) { int result = base.SaveItem(saveFlag, silentSaveAsName, itemid, docData, out cancelled); if (result == VSConstants.S_OK) { ReparseFileNode(node); } return(result); } return(base.SaveItem(saveFlag, silentSaveAsName, itemid, docData, out cancelled)); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { string oldMoniker = Moniker; pfSaveCanceled = 1; pbstrMkDocumentNew = null; try { // Call out to the derived nodes to do the save work if (Save()) { pfSaveCanceled = 0; } } catch (Exception ex) { MySqlSourceTrace.WriteAppErrorToLog(ex, null, Resources.DocumentNode_UnableToSaveObjectError, true); return(VSConstants.S_OK); } if (pfSaveCanceled == 0) { // then mark the document has clean and unchanged Dirty = false; IsNew = false; //notify any listeners that our save is done OnDataSaved(); Name = GetCurrentName(); UpdateRegisteredNode(oldMoniker, Moniker); pbstrMkDocumentNew = string.Format("/Connection/{0}s/{1}", NodeId, Name); VsShellUtilities.RenameDocument(MySqlDataProviderPackage.Instance, oldMoniker, Moniker); // update server explorer Refresh(); Load(); } return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { string oldMoniker = Moniker; pfSaveCanceled = 1; pbstrMkDocumentNew = null; try { // Call out to the derived nodes to do the save work if (Save()) { pfSaveCanceled = 0; } } catch (Exception ex) { MessageBox.Show("Unable to save object with error: " + ex.Message); return(VSConstants.S_OK); } if (pfSaveCanceled == 0) { // then mark the document has clean and unchanged Dirty = false; IsNew = false; //notify any listeners that our save is done OnDataSaved(); Name = GetCurrentName(); pbstrMkDocumentNew = String.Format("/Connection/{0}s/{1}", NodeId, Name); VsShellUtilities.RenameDocument(MySqlDataProviderPackage.Instance, oldMoniker, Moniker); // update server explorer Refresh(); Load(); } return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; UnadviseFileChanges(); var vsUIShell = GetService(typeof(SVsUIShell)) as IVsUIShell; var hr = vsUIShell.SaveDocDataToFile(dwSave, this, null, out pbstrMkDocumentNew, out pfSaveCanceled); if (pbstrMkDocumentNew != null) { AdviseFileChanges(pbstrMkDocumentNew); } else { AdviseFileChanges(_document.Filename); } return(hr); }
/// <summary> /// Saves the document data. Before actually saving the file, we first need to indicate to the environment /// that a file is about to be saved. This is done through the "SVsQueryEditQuerySave" service. We call the /// "QuerySaveFile" function on the service instance and then proceed depending on the result returned as follows: /// If result is QSR_SaveOK - We go ahead and save the file and the file is not read only at this point. /// If result is QSR_ForceSaveAs - We invoke the "Save As" functionality which will bring up the Save file name /// dialog /// If result is QSR_NoSave_Cancel - We cancel the save operation and indicate that the document could not be saved /// by setting the "pfSaveCanceled" flag /// If result is QSR_NoSave_Continue - Nothing to do here as the file need not be saved /// </summary> /// <param name="dwSave">Flags which specify the file save options: /// VSSAVE_Save - Saves the current file to itself. /// VSSAVE_SaveAs - Prompts the User for a filename and saves the file to the file specified. /// VSSAVE_SaveCopyAs - Prompts the user for a filename and saves a copy of the file with a name specified. /// VSSAVE_SilentSave - Saves the file without prompting for a name or confirmation. /// </param> /// <param name="pbstrMkDocumentNew">Pointer to the path to the new document</param> /// <param name="pfSaveCanceled">value 1 if the document could not be saved</param> /// <returns></returns> int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { var queryEditQuerySave = (IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave)); // Call QueryEditQuerySave uint result = 0; hr = queryEditQuerySave.QuerySaveFile( _fileName, // filename 0, // flags null, // file attributes out result); // result if (ErrorHandler.Failed(hr)) return hr; // Process according to result from QuerySave switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: // Note that this is also case tagVSQuerySaveResult.QSR_NoSave_UserCanceled because these // two tags have the same value. pfSaveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { // Call the shell to do the save for us var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { // Call the shell to do the SaveAS for us var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: // In this case there is nothing to do. break; default: throw new NotSupportedException("Unsupported result from QEQS"); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // Make sure the file name as the right extension if (String.Compare(MyExtension, Path.GetExtension(_fileName), true, CultureInfo.CurrentCulture) != 0) { _fileName += MyExtension; } // Call the shell to do the save for us var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; break; } default: throw new ArgumentException("Unsupported Save flag"); } return VSConstants.S_OK; }
int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave)); uint result; hr = queryEditQuerySave.QuerySaveFile( _FileName, 0, null, out result); if (ErrorHandler.Failed(hr)) { return(hr); } switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: pfSaveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { hr = ServiceLocator.GetGlobalService <SVsUIShell, IVsUIShell>().SaveDocDataToFile( dwSave, this, _FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { hr = ServiceLocator.GetGlobalService <SVsUIShell, IVsUIShell>().SaveDocDataToFile( VSSAVEFLAGS.VSSAVE_SaveAs, this, _FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: break; default: throw new InvalidOperationException("Unsupported result from Query Edit/Query Save"); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { if (String.Compare(FileExtensionUsed, Path.GetExtension(_FileName), true, CultureInfo.CurrentCulture) != 0) { _FileName += FileExtensionUsed; } hr = ServiceLocator.GetGlobalService <SVsUIShell, IVsUIShell>().SaveDocDataToFile(dwSave, this, _FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } break; } default: throw new ArgumentException("Unsupported save flag value"); } return(VSConstants.S_OK); }
int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; IVsUIShell uiShell = (IVsUIShell)serviceProvider.GetService(typeof(IVsUIShell)); switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { tagVSQuerySaveResult qsResult; hr = QuerySave(out qsResult); if (ErrorHandler.Failed(hr)) return hr; if (qsResult == tagVSQuerySaveResult.QSR_NoSave_Cancel) pfSaveCanceled = ~0; else if (qsResult == tagVSQuerySaveResult.QSR_SaveOK) { hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } else if (qsResult == tagVSQuerySaveResult.QSR_ForceSaveAs) { hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // --- Make sure the file name as the right extension if (String.Compare(".mysql", Path.GetExtension(fileName), true, CultureInfo.CurrentCulture) != 0) fileName += ".mysql"; // --- Call the shell to do the save for us hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; break; } default: throw new ArgumentException("Unable to save file"); } return VSConstants.S_OK; }
/// <summary> /// Saves the document data. Before actually saving the file, we first need to indicate to the environment /// that a file is about to be saved. This is done through the "SVsQueryEditQuerySave" service. We call the /// "QuerySaveFile" function on the service instance and then proceed depending on the result returned as follows: /// If result is QSR_SaveOK - We go ahead and save the file and the file is not read only at this point. /// If result is QSR_ForceSaveAs - We invoke the "Save As" functionality which will bring up the Save file name /// dialog /// If result is QSR_NoSave_Cancel - We cancel the save operation and indicate that the document could not be saved /// by setting the "saveCanceled" flag /// If result is QSR_NoSave_Continue - Nothing to do here as the file need not be saved /// </summary> /// <param name="saveFlag">Flags which specify the file save options: /// VSSAVE_Save - Saves the current file to itself. /// VSSAVE_SaveAs - Prompts the User for a filename and saves the file to the file specified. /// VSSAVE_SaveCopyAs - Prompts the user for a filename and saves a copy of the file with a name specified. /// VSSAVE_SilentSave - Saves the file without prompting for a name or confirmation. /// </param> /// <param name="newFilePath">The path to the new document</param> /// <param name="saveCanceled">value 1 if the document could not be saved</param> /// <returns></returns> int IVsPersistDocData.SaveDocData(VSSAVEFLAGS saveFlag, out string newFilePath, out int saveCanceled) { newFilePath = null; saveCanceled = 0; int hr = VSConstants.S_OK; switch (saveFlag) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2) GetVsService(typeof (SVsQueryEditQuerySave)); // Call QueryEditQuerySave uint result = 0; hr = queryEditQuerySave.QuerySaveFile( fileName, // filename 0, // flags null, // file attributes out result); // result if (ErrorHandler.Failed(hr)) return hr; // Process according to result from QuerySave switch ((tagVSQuerySaveResult) result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: // Note that this is also case tagVSQuerySaveResult.QSR_NoSave_UserCanceled because these // two tags have the same value. saveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell) GetVsService(typeof (SVsUIShell)); hr = uiShell.SaveDocDataToFile(saveFlag, this, fileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { // Call the shell to do the SaveAS for us IVsUIShell uiShell = (IVsUIShell) GetVsService(typeof (SVsUIShell)); hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, fileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: // In this case there is nothing to do. break; default: throw new COMException(Resources.SCCError); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // Make sure the file name as the right extension if (string.Compare(StringConstants.SnippetExtension, Path.GetExtension(fileName), true, CultureInfo.InvariantCulture) != 0) { fileName += StringConstants.SnippetExtension; } // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell) GetVsService(typeof (SVsUIShell)); hr = uiShell.SaveDocDataToFile(saveFlag, this, fileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) return hr; break; } default: throw new ArgumentException(Resources.BadSaveFlags); } ; return VSConstants.S_OK; }
int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { ThreadHelper.ThrowIfNotOnUIThread(); pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr = VSConstants.S_OK; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave)); // Call QueryEditQuerySave uint result = 0; hr = queryEditQuerySave.QuerySaveFile( fileName, // filename 0, // flags null, // file attributes out result); // result if (ErrorHandler.Failed(hr)) { return(hr); } // Process according to result from QuerySave switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: // Note that this is also case tagVSQuerySaveResult.QSR_NoSave_UserCanceled because these // two tags have the same value. pfSaveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { // Call the shell to do the SaveAS for us IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: // In this case there is nothing to do. break; default: throw new COMException(Resources.ExceptionMessageQEQS); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // Make sure the file name as the right extension if (string.Compare(Constants.fileExtension, System.IO.Path.GetExtension(fileName), true, CultureInfo.CurrentCulture) != 0) { fileName += Constants.fileExtension; } // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } break; } default: throw new ArgumentException(Resources.ExceptionMessageSaveFlag); } ; return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; return VSConstants.S_OK; }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { XmlNode configurationNode = _document.SelectSingleNode("/configuration"); var moduleConfigSection = configurationNode.SelectSingleNode(@"./configSections/section[@name=""modules""]"); if (moduleConfigSection == null) { XmlNode configSectionNode = configurationNode.SelectSingleNode("./configSections"); if (configSectionNode == null) { configSectionNode = _document.CreateElement("configSections"); configurationNode.InsertAfter(configSectionNode, null); //make it the first element } XmlElement section = _document.CreateElement("section"); XmlAttribute attribute = _document.CreateAttribute("name"); attribute.Value = "modules"; section.Attributes.Append(attribute); attribute = _document.CreateAttribute("type"); attribute.Value = "Prism.Modularity.ModulesConfigurationSection, Prism.Wpf"; section.Attributes.Append(attribute); configSectionNode.AppendChild(section); } var modulesNode = _document.SelectSingleNode("/configuration/modules"); if (modulesNode == null) { modulesNode = _document.CreateElement("modules"); configurationNode.AppendChild(modulesNode); } modulesNode.RemoveAll(); foreach (var m in _designer.Modules) { XmlElement element = _document.CreateElement("module"); XmlAttribute attribute = _document.CreateAttribute("assemblyFile"); attribute.Value = m.AssemblyFile; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("moduleType"); attribute.Value = m.ModuleType; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("moduleName"); attribute.Value = m.ModuleName; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("startupLoaded"); attribute.Value = m.StartupLoaded.ToString(); element.Attributes.Append(attribute); if (m.Dependencies.Count > 0) { XmlElement dependencies = _document.CreateElement("dependencies"); foreach (var d in m.Dependencies) { XmlElement dElement = _document.CreateElement("dependency"); XmlAttribute dAttribute = _document.CreateAttribute("moduleName"); dAttribute.Value = d.ModuleName; dElement.Attributes.Append(dAttribute); dependencies.AppendChild(dElement); } element.AppendChild(dependencies); } modulesNode.AppendChild(element); } _document.Save(_fileName); _isDirty = false; break; } } return VSConstants.S_OK; }
// -------------------------------------------------------------------------------- /// <summary> /// Helper method used by editors that implement the IVsPersistDocData interface. /// </summary> /// <param name="grfSave">Specifies file Save options.</param> /// <param name="pPersistFile"> /// Pointer to the IUnknown interface of the file in which the doc data is to /// be saved. /// </param> /// <param name="pszUntitledPath"> /// File path to which the doc data for an as-yet unsaved document is to be saved. /// </param> /// <param name="pbstrDocumentNew">New document file name.</param> /// <param name="pfCanceled"> /// Set to true if the user aborts the save by clicking the Cancel button. /// </param> /// <returns> /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// </returns> // -------------------------------------------------------------------------------- public static int SaveDocDataToFile(VSSAVEFLAGS grfSave, object pPersistFile, string pszUntitledPath, out string pbstrDocumentNew, out int pfCanceled) { return UIShell.SaveDocDataToFile(grfSave, pPersistFile, pszUntitledPath, out pbstrDocumentNew, out pfCanceled); }
int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; IVsUIShell uiShell = (IVsUIShell)serviceProvider.GetService(typeof(IVsUIShell)); switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { tagVSQuerySaveResult qsResult; hr = QuerySave(out qsResult); if (ErrorHandler.Failed(hr)) { return(hr); } if (qsResult == tagVSQuerySaveResult.QSR_NoSave_Cancel) { pfSaveCanceled = ~0; } else if (qsResult == tagVSQuerySaveResult.QSR_SaveOK) { hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } else if (qsResult == tagVSQuerySaveResult.QSR_ForceSaveAs) { hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // --- Make sure the file name as the right extension if (String.Compare(".mysql", Path.GetExtension(fileName), true, CultureInfo.CurrentCulture) != 0) { fileName += ".mysql"; } // --- Call the shell to do the save for us hr = uiShell.SaveDocDataToFile(dwSave, this, fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } break; } default: throw new ArgumentException("Unable to save file"); } return(VSConstants.S_OK); }
int IVsUIShell.SaveDocDataToFile(VSSAVEFLAGS grfSave, object persistFile, string pszUntitledPath, out string pbstrDocumentNew, out int canceled) { throw new NotImplementedException(); }
/// <summary> /// Saves the hierarchy item to disk. /// </summary> /// <param name="dwSave">Flags whose values are taken from the VSSAVEFLAGS enumeration.</param> /// <param name="silentSaveAsName">File name to be applied when dwSave is set to VSSAVE_SilentSave. </param> /// <param name="itemid">Item identifier of the hierarchy item saved from VSITEMID. </param> /// <param name="punkDocData">Pointer to the IUnknown interface of the hierarchy item saved.</param> /// <param name="pfCancelled">TRUE if the save action was canceled. </param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public override int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled) { // Don't ignore/unignore file changes // Use Advise/Unadvise to work around rename situations try { this.StopObservingNestedProjectFile(); Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); Debug.Assert(punkDocData != IntPtr.Zero, "docData intptr was zero"); // Get an IPersistFileFormat object from docData object (we don't call release on punkDocData since did not increment its ref count) IPersistFileFormat persistFileFormat = Marshal.GetTypedObjectForIUnknown(punkDocData, typeof(IPersistFileFormat)) as IPersistFileFormat; Debug.Assert(persistFileFormat != null, "The docData object does not implement the IPersistFileFormat interface"); IVsUIShell uiShell = this.GetService(typeof(SVsUIShell)) as IVsUIShell; string newName; uiShell.SaveDocDataToFile(dwSave, persistFileFormat, silentSaveAsName, out newName, out pfCancelled); // When supported do a rename of the nested project here } finally { // Succeeded or not we must hook to the file change events // Don't ignore/unignore file changes // Use Advise/Unadvise to work around rename situations this.ObserveNestedProjectFile(); } return VSConstants.S_OK; }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { throw new NotImplementedException(); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; return(VSErr.S_OK); }
int IVsUIShell.SaveDocDataToFile(VSSAVEFLAGS grfSave, object pPersistFile, string pszUntitledPath, out string pbstrDocumentNew, out int pfCanceled) { throw new Exception("The method or operation is not implemented."); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; UnadviseFileChanges(); var vsUIShell = GetService(typeof(SVsUIShell)) as IVsUIShell; var hr = vsUIShell.SaveDocDataToFile(dwSave, this, null, out pbstrMkDocumentNew, out pfSaveCanceled); if (pbstrMkDocumentNew != null) AdviseFileChanges(pbstrMkDocumentNew); else AdviseFileChanges(_document.Filename); return hr; }
public int SaveDocDataToFile(VSSAVEFLAGS grfSave, object pPersistFile, string pszUntitledPath, out string pbstrDocumentNew, out int pfCanceled) { throw new NotImplementedException(); }
public static int SaveDocDataToFile(VSSAVEFLAGS grfSave, [CanBeNull] object pPersistFile, [CanBeNull] string pszUntitledPath, [CanBeNull] out string pbstrDocumentNew, out int pfCanceled) { return(UIShell.SaveDocDataToFile(grfSave, pPersistFile, pszUntitledPath, out pbstrDocumentNew, out pfCanceled)); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { string oldMoniker = Moniker; pfSaveCanceled = 1; pbstrMkDocumentNew = null; try { // Call out to the derived nodes to do the save work if (Save()) pfSaveCanceled = 0; } catch (Exception ex) { MessageBox.Show("Unable to save object with error: " + ex.Message); return VSConstants.S_OK; } if (pfSaveCanceled == 0) { // then mark the document has clean and unchanged Dirty = false; IsNew = false; //notify any listeners that our save is done OnDataSaved(); Name = GetCurrentName(); pbstrMkDocumentNew = String.Format("/Connection/{0}s/{1}", NodeId, Name); VsShellUtilities.RenameDocument(MySqlDataProviderPackage.Instance, oldMoniker, Moniker); // update server explorer Refresh(); Load(); } return VSConstants.S_OK; }
/// <summary> /// Saves the document /// </summary> /// <param name="saveFlag">Save flags</param> /// <param name="newFilePath">File path</param> /// <param name="saveCanceled">True if save was not successuful</param> public int SaveDocData(VSSAVEFLAGS saveFlag, out string newFilePath, out int saveCanceled) { newFilePath = null; saveCanceled = 0; int hr = VSConstants.S_OK; switch (saveFlag) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)Package.GetGlobalService(typeof(SVsQueryEditQuerySave)); // Call QueryEditQuerySave uint result = 0; hr = queryEditQuerySave.QuerySaveFile( FileName, // filename 0, // flags null, // file attributes out result); // result if (ErrorHandler.Failed(hr)) { return(hr); } // Process according to result from QuerySave switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: // Note that this is also case tagVSQuerySaveResult.QSR_NoSave_UserCanceled because these // two tags have the same value. saveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(saveFlag, (IPersistFileFormat)this, FileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { // Call the shell to do the SaveAS for us IVsUIShell uiShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, (IPersistFileFormat)this, FileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: // In this case there is nothing to do. break; default: throw new COMException("Invalid QuerySave result."); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // Call the shell to do the save for us IVsUIShell uiShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(saveFlag, (IPersistFileFormat)this, FileName, out newFilePath, out saveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } break; } default: throw new ArgumentException("Invalid VSSAVEFLAGS."); } return(VSConstants.S_OK); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { XmlNode configurationNode = _document.SelectSingleNode("/configuration"); var moduleConfigSection = configurationNode.SelectSingleNode(@"./configSections/section[@name=""modules""]"); if (moduleConfigSection == null) { XmlNode configSectionNode = configurationNode.SelectSingleNode("./configSections"); if (configSectionNode == null) { configSectionNode = _document.CreateElement("configSections"); configurationNode.InsertAfter(configSectionNode, null); //make it the first element } XmlElement section = _document.CreateElement("section"); XmlAttribute attribute = _document.CreateAttribute("name"); attribute.Value = "modules"; section.Attributes.Append(attribute); attribute = _document.CreateAttribute("type"); attribute.Value = "Prism.Modularity.ModulesConfigurationSection, Prism.Wpf"; section.Attributes.Append(attribute); configSectionNode.AppendChild(section); } var modulesNode = _document.SelectSingleNode("/configuration/modules"); if (modulesNode == null) { modulesNode = _document.CreateElement("modules"); configurationNode.AppendChild(modulesNode); } modulesNode.RemoveAll(); foreach (var m in _designer.Modules) { XmlElement element = _document.CreateElement("module"); XmlAttribute attribute = _document.CreateAttribute("assemblyFile"); attribute.Value = m.AssemblyFile; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("moduleType"); attribute.Value = m.ModuleType; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("moduleName"); attribute.Value = m.ModuleName; element.Attributes.Append(attribute); attribute = _document.CreateAttribute("startupLoaded"); attribute.Value = m.StartupLoaded.ToString(); element.Attributes.Append(attribute); if (m.Dependencies.Count > 0) { XmlElement dependencies = _document.CreateElement("dependencies"); foreach (var d in m.Dependencies) { XmlElement dElement = _document.CreateElement("dependency"); XmlAttribute dAttribute = _document.CreateAttribute("moduleName"); dAttribute.Value = d.ModuleName; dElement.Attributes.Append(dAttribute); dependencies.AppendChild(dElement); } element.AppendChild(dependencies); } modulesNode.AppendChild(element); } _document.Save(_fileName); _isDirty = false; break; } } return(VSConstants.S_OK); }
public int SaveItem(VSSAVEFLAGS dwSave, string pszSilentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCanceled) { if (itemid == VSConstants.VSITEMID_ROOT) { Save(dwSave, out pfCanceled); return VSConstants.S_OK; } pfCanceled = 0; return VSConstants.E_FAIL; }
int IVsPersistHierarchyItem2.SaveItem(VSSAVEFLAGS dwSave, string pszSilentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCanceled) { return ((IVsPersistDocData)_control).SaveDocData(dwSave, out pszSilentSaveAsName, out pfCanceled); }
/// <summary> /// Saves the hierarchy item to disk. /// </summary> /// <param name="dwSave">Flags whose values are taken from the <see cref="VSSAVEFLAGS"/> enumeration.</param> /// <param name="pszSilentSaveAsName">File name to be applied when <paramref name="dwSave"/> is set to VSSAVE_SilentSave.</param> /// <param name="itemid">Item identifier of the hierarchy item saved from VSITEMID.</param> /// <param name="punkDocData">Pointer to the <b>IUnknown</b> interface of the hierarchy item saved.</param> /// <param name="pfCanceled">TRUE if the save action was canceled.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> /// <remarks> /// <para>The caller of this method is responsible for determining whether the document is /// in the Running Document Table and should pass in the correct punkDocData parameter. It /// is not necessary for the implementer of this method to call the IVsRunningDocumentTable::FindAndLockDocument /// method when punkDocData is NULL.</para> /// <para>When a document is saved, this method is called to enable the owning hierarchy /// to establish control. Then the hierarchy can use any private mechanism to persist the /// document. For hierarchies that use standard editors, the implementation of SaveItem /// method is to call the following:</para> /// <list type="bullet"> /// <item>For VSSAVE_Save and VSSAVE_SaveAs, it will Query Interface (QI) for IVsPersistDocData /// on the DocData object and call IVsPersistDocData2::SaveDocData.</item> /// <item>For VSSAVE_SilentSave, it will QI for interface IPersistFileFormat on the DocData /// object and use this interface in a call to the method IVsUIShell::SaveDocDataToFile passing /// the parameters VSSAVE_SilentSave, pPersistFile, pszSilentSaveAsName lpstrUntitledPath, /// &bstrDocumentNew, and &fCanceled).</item> /// </list> /// </remarks> int IVsPersistHierarchyItem2.SaveItem(VSSAVEFLAGS dwSave, string pszSilentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCanceled) { if (punkDocData == IntPtr.Zero) { Tracer.Fail("Invalid parameter 'punkDocData'."); throw new ArgumentException("The caller is responsible for determining whether the document is in the Running Document Table and should pass in the correct parameter.", "punkDocData"); } pfCanceled = 0; string newFileName; bool silentSave = ((dwSave & VSSAVEFLAGS.VSSAVE_SilentSave) == VSSAVEFLAGS.VSSAVE_SilentSave); int hr; if (silentSave) { // For VSSAVE_SilentSave we should have an IPersistFileFormat object. IPersistFileFormat persistFileFormat = Marshal.GetObjectForIUnknown(punkDocData) as IPersistFileFormat; if (persistFileFormat == null) { Tracer.Fail("The environment should be passing us an IPersistFileFormat object."); throw new ArgumentException("Expected IPersistFileFormat object.", "punkDocData"); } // Save the document. IVsUIShell vsUIShell = (IVsUIShell)this.ServiceProvider.GetServiceOrThrow(typeof(SVsUIShell), typeof(IVsUIShell), classType, "IVsPersistHierarchyItem2.SaveItem"); hr = vsUIShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SilentSave, persistFileFormat, pszSilentSaveAsName, out newFileName, out pfCanceled); NativeMethods.ThrowOnFailure(hr); } else { IVsPersistDocData persistDocData = Marshal.GetObjectForIUnknown(punkDocData) as IVsPersistDocData; if (persistDocData == null) { Tracer.Fail("The environment should be passing us an IVsPersistDocData object."); throw new ArgumentException("Expected IVsPersistDocData object.", "punkDocData"); } // Save the document. hr = persistDocData.SaveDocData(dwSave, out newFileName, out pfCanceled); } return NativeMethods.S_OK; }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = _table.Name; pfSaveCanceled = 0; if (String.IsNullOrEmpty(_table.OriginalSql) == true) { using (TableNameDialog dlg = new TableNameDialog("Table", _table.Name)) { if (dlg.ShowDialog(this) == DialogResult.Cancel) { pfSaveCanceled = 1; return VSConstants.S_OK; } _table.Name = dlg.TableName; } } string sql = GetChangeScript(); using (DbTransaction trans = _table.GetConnection().BeginTransaction()) { try { using (DbCommand cmd = _table.GetConnection().CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); } trans.Commit(); } catch (Exception) { trans.Rollback(); throw; } } _dirty = false; _table.Committed(); NotifyChanges(); _sqlText.Text = _table.OriginalSql; NpgsqlCommandHandler.Refresh(_accessor, _itemId); _dataGrid_SelectionChanged(this, EventArgs.Empty); RefreshToolbars(); return VSConstants.S_OK; }
public int SaveDocData(VSSAVEFLAGS saveFlags, out string monikerNew, out int isSaveCancelled) { monikerNew = string.Empty; isSaveCancelled = -1; return(VSConstants.S_OK); }
/// <summary> /// Saves the document data. Before actually saving the file, we first need to /// indicate to the environment that a file is about to be saved. This is done /// through the "SVsQueryEditQuerySave" service. We call the "QuerySaveFile" /// function on the service instance and then proceed depending on the result /// returned as follows: /// /// If result is QSR_SaveOK - We go ahead and save the file and the file is not /// read only at this point. /// /// If result is QSR_ForceSaveAs - We invoke the "Save As" functionality which will /// bring up the Save file name dialog. /// /// If result is QSR_NoSave_Cancel - We cancel the save operation and indicate that /// the document could not be saved by setting the "pfSaveCanceled" flag. /// /// If result is QSR_NoSave_Continue - Nothing to do here as the file need not be /// saved. /// </summary> /// <param name="dwSave">Flags which specify the file save options: /// VSSAVE_Save - Saves the current file to itself. /// VSSAVE_SaveAs - Prompts the User for a filename and saves the file to /// the file specified. /// VSSAVE_SaveCopyAs - Prompts the user for a filename and saves a copy of the /// file with a name specified. /// VSSAVE_SilentSave - Saves the file without prompting for a name or confirmation. /// </param> /// <param name="pbstrMkDocumentNew">Pointer to the path to the new document.</param> /// <param name="pfSaveCanceled">Value 1 if the document could not be saved.</param> /// <returns>S_OK if the method succeeds.</returns> int IVsPersistDocData.SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { var queryEditQuerySave = (IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave)); // --- Call QueryEditQuerySave hr = queryEditQuerySave.QuerySaveFile( FileName, // filename 0, // flags null, // file attributes out uint result); // result if (ErrorHandler.Failed(hr)) { return(hr); } // Process according to result from QuerySave switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: // --- This is also case tagVSQuerySaveResult.QSR_NoSave_UserCanceled because these // --- two tags have the same value. pfSaveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { // Call the shell to do the save for us hr = VsUiShell.SaveDocDataToFile(dwSave, this, FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { // Call the shell to do the SaveAS for us hr = VsUiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: // In this case there is nothing to do. break; default: throw new COMException("Unsupported result from QEQS"); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { // Make sure the file name as the right extension if (String.Compare(FileExtensionUsed, Path.GetExtension(FileName), true, CultureInfo.CurrentCulture) != 0) { FileName += FileExtensionUsed; } // Call the shell to do the save for us hr = VsUiShell.SaveDocDataToFile(dwSave, this, FileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) { return(hr); } break; } default: throw new ArgumentException("Unsupported Save flag."); } return(VSConstants.S_OK); }
public override int SaveItem(VSSAVEFLAGS saveFlag, string silentSaveAsName, uint itemid, IntPtr docData, out int cancelled) { BaseFileNode node = this.NodeFromItemId(itemid) as BaseFileNode; if (node != null) { int result = base.SaveItem(saveFlag, silentSaveAsName, itemid, docData, out cancelled); if (result == VSConstants.S_OK) ReparseFileNode(node); return result; } return base.SaveItem(saveFlag, silentSaveAsName, itemid, docData, out cancelled); }
/// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.SaveItem"]/*' /> public virtual int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled){ string docNew; pfCancelled = 0; if ((VSSAVEFLAGS.VSSAVE_SilentSave & dwSave) != 0){ IPersistFileFormat pff = (IPersistFileFormat)Marshal.GetObjectForIUnknown(punkDocData); this.projectMgr.UIShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SilentSave, pff, silentSaveAsName, out docNew, out pfCancelled); }else{ IVsPersistDocData dd = (IVsPersistDocData)Marshal.GetObjectForIUnknown(punkDocData); dd.SaveDocData(dwSave, out docNew, out pfCancelled); } if (pfCancelled != 0 && docNew != null && docNew != silentSaveAsName){ // update config file with new filename? } return 0; }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; pfSaveCanceled = 0; int hr; switch (dwSave) { case VSSAVEFLAGS.VSSAVE_Save: case VSSAVEFLAGS.VSSAVE_SilentSave: { IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave)); uint result; hr = queryEditQuerySave.QuerySaveFile( _fileName, // --- filename 0, // --- flags null, // --- file attributes out result); // --- result if (ErrorHandler.Failed(hr)) return hr; switch ((tagVSQuerySaveResult)result) { case tagVSQuerySaveResult.QSR_NoSave_Cancel: pfSaveCanceled = ~0; break; case tagVSQuerySaveResult.QSR_SaveOK: { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_ForceSaveAs: { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SaveAs, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; } break; case tagVSQuerySaveResult.QSR_NoSave_Continue: break; default: throw new COMException("Resources.ExceptionMessageQEQS"); } break; } case VSSAVEFLAGS.VSSAVE_SaveAs: case VSSAVEFLAGS.VSSAVE_SaveCopyAs: { if (String.Compare(FileExtensionUsed, Path.GetExtension(_fileName), true, CultureInfo.CurrentCulture) != 0) _fileName += FileExtensionUsed; IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); hr = uiShell.SaveDocDataToFile(dwSave, this, _fileName, out pbstrMkDocumentNew, out pfSaveCanceled); if (ErrorHandler.Failed(hr)) return hr; break; } default: throw new ArgumentException("Resources.ExceptionMessageSaveFlag"); } return VSConstants.S_OK; }
int IVsPersistDocData.SaveDocData(VSSAVEFLAGS saveFlags, out string fileName, out int saveCanceled) { throw new NotImplementedException(); }
public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled) { pbstrMkDocumentNew = null; // _view.Name; pfSaveCanceled = 0; if (String.IsNullOrEmpty(_view.OriginalSql) == true) { using (TableNameDialog dlg = new TableNameDialog("View", _view.Name)) { if (dlg.ShowDialog(this) == DialogResult.Cancel) { pfSaveCanceled = 1; return VSConstants.S_OK; } _view.Name = dlg.TableName; } } CommitQueryBuilder(); string query = _view.GetSqlText(); if (String.IsNullOrEmpty(query) == false) { using (DbTransaction trans = _view.GetConnection().BeginTransaction()) { try { using (DbCommand cmd = _view.GetConnection().CreateCommand()) { cmd.CommandText = query; cmd.ExecuteNonQuery(); } trans.Commit(); } catch (Exception) { trans.Rollback(); throw; } } } _dirty = false; _view.Committed(); NotifyChanges(); SQLiteCommandHandler.Refresh(_accessor, _itemId); return VSConstants.S_OK; }