Пример #1
0
        void SaveTabToDisk(ISaveableTab etb)
        {
            string fileName = etb.GetFileFullPathAndName();
            // tooltip is exact name of file, and Text property of tab may contain "*" if file is modified and unsaved
            FileInfo fi = new FileInfo(fileName);

            if (fi.Name.StartsWith("Untitled", StringComparison.InvariantCulture))
            {
                // propose to reneame file
                var newPageName = GetNewNameInSaveAsDialogFromProposedName(fi.FullName);
                if (string.IsNullOrWhiteSpace(newPageName))
                {
                    return;
                    // user stopped save operation
                }
                //var etb = DoRealSaveAs(newPageName); there is no need for new tab in simple save operation
                fileName = newPageName;
            }
            else
            {
                // create deirectory if necessary
                if (Directory.Exists(fi.DirectoryName) == false)
                {
                    // Message with alert?
                    fi.Directory.Create();
                }
            }
            etb.SaveFile(fileName);
            AppendToMRU(fileName);
        }
Пример #2
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as ISaveableTab == null)
            {
                return;
            }
            ISaveableTab etb = tb as ISaveableTab;

            SaveTabToDisk(etb);
        }