📄 dirtyfilesdialog.cs
字号:
// DirtyFilesDialog.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Drawing;
using System.Windows.Forms;
using SharpDevelop.Gui.Window;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Gui.Dialogs {
public class DirtyFilesDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Button savebutton;
private System.Windows.Forms.Button saveallbutton;
private System.Windows.Forms.Button discardallbutton;
private System.Windows.Forms.Button cancelbutton;
MainWindow mainwindow;
public DirtyFilesDialog(MainWindow mainwindow)
{
this.mainwindow = mainwindow;
this.InitializeComponent();
ImageList images = new ImageList();
listView1.Columns.Add(Resource.GetString("Dialog.DirtyFiles.Files"), listView1.Width - 5, HorizontalAlignment.Left);
foreach (ContentWindow cwindow in mainwindow.MdiChildren) {
if (cwindow.Dirty) {
images.Images.Add(cwindow.Icon);
ListViewItem item = new ListViewItem(cwindow.Untitled ? cwindow.Text : cwindow.FileName, images.Images.Count - 1);
item.Selected = true;
listView1.Items.Add(item);
}
}
listView1.SmallImageList = images;
}
void DiscardAll(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
void SaveAll(object sender, EventArgs e)
{
foreach (ContentWindow cwindow in mainwindow.MdiChildren) {
if (cwindow.Dirty) {
cwindow.SaveContent();
}
}
DialogResult = DialogResult.OK;
}
void SaveSelected(object sender, EventArgs e)
{
foreach (ContentWindow cwindow in mainwindow.MdiChildren) {
if (cwindow.Dirty) {
foreach (ListViewItem item in listView1.SelectedItems) {
if ((cwindow.Untitled && item.Text == cwindow.Text) || (item.Text == cwindow.FileName)) {
cwindow.SaveContent();
break;
}
}
}
}
DialogResult = DialogResult.OK;
}
private void InitializeComponent() {
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.savebutton = new System.Windows.Forms.Button();
this.saveallbutton = new System.Windows.Forms.Button();
this.discardallbutton = new System.Windows.Forms.Button();
this.cancelbutton = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {this.listView1});
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(312, 272);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = Resource.GetString("Dialog.DirtyFiles.DirtyFiles");
//
// listView1
//
this.listView1.HideSelection = false;
this.listView1.FullRowSelect = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listView1.Location = new System.Drawing.Point(8, 16);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(296, 248);
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
//
// savebutton
//
this.savebutton.Location = new System.Drawing.Point(328, 16);
this.savebutton.Name = "savebutton";
this.savebutton.TabIndex = 1;
this.savebutton.Size = new System.Drawing.Size(96, 24);
this.savebutton.Text = Resource.GetString("Dialog.DirtyFiles.SaveButton");
this.savebutton.Click += new EventHandler(SaveSelected);
//
// saveallbutton
//
this.saveallbutton.Location = new System.Drawing.Point(328, 48);
this.saveallbutton.Name = "saveallbutton";
this.saveallbutton.TabIndex = 2;
this.saveallbutton.Size = new System.Drawing.Size(96, 24);
this.saveallbutton.Text = Resource.GetString("Dialog.DirtyFiles.SaveAllButton");
this.saveallbutton.Click += new EventHandler(SaveAll);
//
// discardallbutton
//
this.discardallbutton.Location = new System.Drawing.Point(328, 80);
this.discardallbutton.Name = "discardallbutton";
this.discardallbutton.TabIndex = 3;
this.discardallbutton.Size = new System.Drawing.Size(96, 24);
this.discardallbutton.Text = Resource.GetString("Dialog.DirtyFiles.DiscardAllButton");
this.discardallbutton.Click += new EventHandler(DiscardAll);
//
// cancelbutton
//
this.cancelbutton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelbutton.Location = new System.Drawing.Point(328, 112);
this.cancelbutton.Name = "cancelbutton";
this.cancelbutton.TabIndex = 4;
this.cancelbutton.Size = new System.Drawing.Size(96, 24);
this.cancelbutton.Text = Resource.GetString("Global.CancelButtonText");
//
// Win32Form1
//
this.AcceptButton = this.savebutton;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.cancelbutton;
this.ClientSize = new System.Drawing.Size(430, 290);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.cancelbutton,
this.discardallbutton,
this.saveallbutton,
this.savebutton,
this.groupBox1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = Resource.GetString("Dialog.DirtyFiles.DialogName");
this.TopMost = true;
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -