Exemplo n.º 1
0
        public void RenameFile(string projectName, string oldFileName, string newFileName)
        {
            var project          = GetProject(projectName);
            var projectDirectory = Path.GetDirectoryName(project.FullName);

            VsShellUtilities.RenameDocument(
                ServiceProvider.GlobalProvider,
                Path.Combine(projectDirectory, oldFileName),
                Path.Combine(projectDirectory, newFileName));
        }
Exemplo n.º 2
0
        static void SaveAs(string oldFileName, ref string newScriptName, IServiceProvider site)
        {
            //make sure that fileName has .cs extension
            newScriptName = System.IO.Path.ChangeExtension(newScriptName, ".cs");
            //make sure that user enter only filename with any dicrectory
            newScriptName = System.IO.Path.GetFileName(newScriptName);

            oldFileName = System.IO.Path.Combine(VSTools.ScriptsDirectory, oldFileName);
            var newFileName = System.IO.Path.Combine(VSTools.ScriptsDirectory, newScriptName);

            VsShellUtilities.RenameDocument(site, oldFileName, newFileName);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }