1:   //  FileTabStripCommands.cs
2:   //  Copyright (C) 2002 Mike Krueger
3:   //
4:   //  This program is free software; you can redistribute it and/or modify
5:   //  it under the terms of the GNU General Public License as published by
6:   //  the Free Software Foundation; either version 2 of the License, or
7:   //  (at your option) any later version.
8:   //
9:   //  This program is distributed in the hope that it will be useful,
10:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12:   //  GNU General Public License for more details.
13:   //
14:   //  You should have received a copy of the GNU General Public License
15:   //  along with this program; if not, write to the Free Software
16:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17:  
18:   using System;
19:   using System.IO;
20:   using System.Threading;
21:   using System.Drawing;
22:   using System.Drawing.Printing;
23:   using System.Collections;
24:   using System.ComponentModel;
25:   using System.Windows.Forms;
26:   using System.Diagnostics;
27:  
28:   using Core.AddIns;
29:   using Core.Util;
30:   using Core.Properties;
31:   using Core.Gui;
32:   using Core.Gui.Creators;
33:  
34:   using SharpDevelop.Gui;
35:   using SharpDevelop.Gui.Dialogs;
36:   using SharpDevelop.Gui.Components;
37:  
38:   namespace SharpDevelop.Base.Commands.TabStrip {
39:       
40:       public class CloseFileTab : AbstractMenuCommand
41:       {
42:           public override void Run()
43:           {
44:               OpenFileTab tab                = (OpenFileTab)Owner;
45:               OpenFileTab.MyTabPage selected = (OpenFileTab.MyTabPage)tab.SelectedTab;
46:               
47:               IWorkbenchWindow window tab.ClickedWindow;
48:               
49:               if (window != null) {
50:                   window.CloseWindow(false);
51:                   if (window != selected.Window) {
52:                       tab.SelectedTab selected;
53:                   }
54:               }
55:           }
56:       }
57:  
58:       public class SaveFileTab : AbstractMenuCommand
59:       {
60:           public override void Run()
61:           {
62:               OpenFileTab tab = (OpenFileTab)Owner;
63:               OpenFileTab.MyTabPage selected = (OpenFileTab.MyTabPage)tab.SelectedTab;
64:               
65:               IWorkbenchWindow window tab.ClickedWindow;
66:               
67:               if (window != null) {
68:                   WorkbenchSingleton.Workbench.ProjectManager.MarkFileDirty(window.WindowContent.ContentName);
69:                   window.WindowContent.SaveFile();
70:               }
71:           }
72:       }
73:       
74:       public class SaveFileAsTab : AbstractMenuCommand
75:       {
76:           public override void Run()
77:           {
78:               OpenFileTab tab = (OpenFileTab)Owner;
79:               OpenFileTab.MyTabPage selected = (OpenFileTab.MyTabPage)tab.SelectedTab;
80:               
81:               IWorkbenchWindow window tab.ClickedWindow;
82:               
83:               if (window != null) {
84:                   SaveFileDialog fdiag new SaveFileDialog();
85:                   fdiag.OverwritePrompt true;
86:                   fdiag.AddExtension    true;
87:                   
88:                   fdiag.Filter          String.Join("|", (string[])(AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string)));
89:                   
90:                   if (fdiag.ShowDialog() == DialogResult.OK) {
91:                       string fileName fdiag.FileName;
92:                       // currently useless, because the fdiag.FileName can't
93:                       // handle wildcard extensions :(
94:                       if (Path.GetExtension(fileName).StartsWith("?") || Path.GetExtension(fileName) == "*") {
95:                           fileName Path.ChangeExtension(fileName"");
96:                       }
97:                           
98:                       window.WindowContent.SaveFile(fileName);
99:                       MessageBox.Show(fileName"File saved"MessageBoxButtons.OK);
100:                   }
101:                   fdiag.Dispose();
102:               }
103:           }
104:       }
105:       
106:       
107:       public class CopyPathName : AbstractMenuCommand
108:       {
109:           public override void Run()
110:           {
111:               OpenFileTab tab = (OpenFileTab)Owner;
112:               
113:               IWorkbenchWindow window tab.ClickedWindow;
114:               
115:               if (window != null && window.WindowContent.ContentName != null) {
116:                   Clipboard.SetDataObject(new DataObject(DataFormats.Textwindow.WindowContent.ContentName));
117:               }
118:           }
119:       }
120:       
121:       public class Restore : AbstractMenuCommand
122:       {
123:           public override void Run()
124:           {
125:               OpenFileTab tab = (OpenFileTab)Owner;
126:               
127:               IWorkbenchWindow window tab.ClickedWindow;
128:               
129:               if (window != null && window is Form) {
130:                   ((Form)window).WindowState FormWindowState.Normal;
131:               }
132:           }
133:       }
134:       public class Maximize : AbstractMenuCommand
135:       {
136:           public override void Run()
137:           {
138:               OpenFileTab tab  = (OpenFileTab)Owner;
139:               
140:               IWorkbenchWindow window tab.ClickedWindow;
141:               
142:               if (window != null && window is Form) {
143:                   ((Form)window).WindowState FormWindowState.Maximized;
144:               }
145:           }
146:       }
147:       public class Minimize : AbstractMenuCommand
148:       {
149:           public override void Run()
150:           {
151:               OpenFileTab tab = (OpenFileTab)Owner;
152:               
153:               IWorkbenchWindow window tab.ClickedWindow;
154:               
155:               if (window != null && window is Form) {
156:                   ((Form)window).WindowState FormWindowState.Minimized;
157:               }
158:           }
159:       }
160:  
161:   }

This page was automatically generated by SharpDevelop.