Esempio n. 1
0
        /* Menu callback */
        public void FileOperation(ToolStripMenuItem item, EventHandler <TextChangedEventArgs> textChanged)
        {
            var doc = _tabStrip.SelectedItem;
            var id  = string.IsNullOrEmpty(item.Text) ? item.Tag.ToString() : item.Text.ToUpper();

            switch (id)
            {
            case "NEW":
                CreateTab(textChanged);
                break;

            case "OPEN":
                OpenFile(textChanged);
                break;

            case "SAVE":
                SaveFile(doc);
                break;

            case "SAVE AS...":
                var fileName = SaveFileAs(doc);
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }
                SaveFile(doc);
                break;

            case "SAVE ALL":
                SaveAllFiles();
                break;

            case "CLOSE":
                if (doc != null)
                {
                    /* Check that the file doesn't need saving */
                    _tabStrip.RemoveTab(doc);
                }
                break;

            case "PRINT":
                if (doc != null)
                {
                    ((FastColoredTextBox)doc.Tag).Print();
                }
                break;
            }
        }
Esempio n. 2
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            /* Check all open documents prior to closing to see if we need to save any */
            var items = _tsFiles.Items.Cast <FaTabStripItem>().ToList();

            foreach (var tab in items)
            {
                var args = new TabStripItemClosingEventArgs(tab);
                OnTabStripItemClosing(args);
                if (args.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
                _tsFiles.RemoveTab(tab);
            }
            /* Save application settings */
            SettingsManager.Save();
            base.OnFormClosing(e);
        }