📄 frmmove.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Text;
namespace SkyMail
{
/// <summary>
/// Frmmove 的摘要说明。
/// </summary>
public class Frmmove : System.Windows.Forms.Form
{
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TreeView treeView1;
private System.ComponentModel.IContainer components;
private string fname="";
public Frmmove()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Frmmove));
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// button2
//
this.button2.Location = new System.Drawing.Point(272, 40);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 24);
this.button2.TabIndex = 10;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(272, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 24);
this.button1.TabIndex = 9;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// treeView1
//
this.treeView1.ImageList = this.imageList1;
this.treeView1.Location = new System.Drawing.Point(8, 8);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("本地文件夹", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("收件箱", 9, 9),
new System.Windows.Forms.TreeNode("发件箱", 10, 10),
new System.Windows.Forms.TreeNode("已发送邮件", 11, 11),
new System.Windows.Forms.TreeNode("垃圾箱", 12, 12)})});
this.treeView1.Size = new System.Drawing.Size(256, 216);
this.treeView1.TabIndex = 6;
//
// Frmmove
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(344, 229);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.treeView1,
this.button2});
this.Name = "Frmmove";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "邮件转移";
this.Load += new System.EventHandler(this.Frmmove_Load);
this.ResumeLayout(false);
}
#endregion
private void label1_Click(object sender, System.EventArgs e)
{
}
public string getfname()
{
return(fname);
}
private void button1_Click(object sender, System.EventArgs e)
{
StreamWriter sw=new StreamWriter(@"user.dr",true,Encoding.GetEncoding("GB2312"));
string con=treeView1.SelectedNode.FullPath;
string[] f=con.Trim().Split((char)92);
string parstr;
string childstr;
if(f.Length>2)
{
parstr=f[1];
childstr=f[2];
}
else
{
parstr=f[0];
childstr=f[1];
}
switch (childstr)
{
case "收件箱":
fname="main.wg";
break;
case "发件箱":
fname="out.wg";
break;
case "已发送邮件":
fname="sent.wg";
break;
case "垃圾箱":
fname="trash.wg";
break;
}
if(fname.Trim().Length<1)
{
for(int i=0;i<treeView1.Nodes.Count;i++)
{
if(treeView1.Nodes[i].Text.Equals(parstr)) //如果第一层就已经找到了父节点,则判断有没有重名的文件夹
{
for(int r=0;r<treeView1.Nodes[i].Nodes.Count;r++)
{
if(treeView1.Nodes[i].Nodes[r].Text.Equals(childstr))
{
fname=childstr.Trim() + "0"+".wg";
}
}
}
for(int j=0;j<treeView1.Nodes[i].Nodes.Count;j++)
{
if(treeView1.Nodes[i].Nodes[j].Text.Equals(parstr))
{
for(int r=0;r<treeView1.Nodes[i].Nodes[j].Nodes.Count;r++)
{
if(treeView1.Nodes[i].Nodes[j].Nodes[r].Text.Equals(childstr))
{
fname=childstr.Trim() + "1"+".wg";
}
}
break;
}
}
}
}
this.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Frmmove_Load(object sender, System.EventArgs e)
{
treeView1.ExpandAll();
FileInfo s=new FileInfo("user.dr");
if(s.Exists)
{
StreamReader sr=new StreamReader(@"user.dr",Encoding.GetEncoding("GB2312"));
string con=sr.ReadToEnd();
sr.Close();
if (con.Trim().Length >0)
{
string[] fdir=con.Trim().Split(new char[]{'\n'});
for(int h=0;h<fdir.Length;h++ )
{
string[] fcon=fdir[h].Split((char)92);
string parstr=fcon[0].Trim();
string childstr=fcon[1].Trim();
for(int i=0;i<treeView1.Nodes.Count ;i++)
{
for(int j=0;j<treeView1.Nodes[i].Nodes.Count;j++)
{
if(treeView1.Nodes[i].Nodes[j].Text.IndexOf(parstr)!=-1)
{
treeView1.Nodes[i].Nodes[j].Nodes.Add(childstr);
break;
}
}
if(treeView1.Nodes[i].Text.IndexOf(parstr)!=-1)
{
treeView1.Nodes[i].Nodes.Add(childstr);
break;
}
}
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -