⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 individuationfolder.cs

📁 XP界面优化精灵, XP界面优化精灵
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.groupBox1.TabIndex = 2;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "文件夹选择";
			// 
			// bn_selectPath
			// 
			this.bn_selectPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_selectPath.Location = new System.Drawing.Point(360, 38);
			this.bn_selectPath.Name = "bn_selectPath";
			this.bn_selectPath.Size = new System.Drawing.Size(26, 16);
			this.bn_selectPath.TabIndex = 4;
			this.bn_selectPath.Text = "...";
			this.bn_selectPath.Click += new System.EventHandler(this.bn_selectPath_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(10, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(208, 17);
			this.label1.TabIndex = 2;
			this.label1.Text = "请选择一个需要个性化设置的文件夹:";
			// 
			// tb_path
			// 
			this.tb_path.Location = new System.Drawing.Point(12, 36);
			this.tb_path.Name = "tb_path";
			this.tb_path.Size = new System.Drawing.Size(376, 21);
			this.tb_path.TabIndex = 3;
			this.tb_path.Text = "";
			this.tb_path.TextChanged += new System.EventHandler(this.tb_path_TextChanged);
			// 
			// IndividuationFolder
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(448, 472);
			this.Controls.Add(this.tabControl);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "IndividuationFolder";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "个性化文件夹";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.IndividuationFolder_Load);
			this.tabControl.ResumeLayout(false);
			this.tp_1.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void IndividuationFolder_Load(object sender, System.EventArgs e)
		{
			this.TopMost =action.isTopMost ;
		}

		private void bn_selectPath_Click(object sender, System.EventArgs e)
		{
			FolderBrowserDialog fbd=new FolderBrowserDialog ();
			if(fbd.ShowDialog ()==DialogResult.OK )
			{
				this.tb_path .Text =fbd.SelectedPath ;
			}
		}

		private void bn_bg_Click(object sender, System.EventArgs e)
		{
			OpenFileDialog ofd =new OpenFileDialog ();
			ofd.Filter ="";
			if(ofd.ShowDialog ()==DialogResult.OK)
			{
				FBackGPath =ofd.FileName;
				this.lb_browser .Image =Image.FromFile (ofd.FileName);
			}
		}

		private void lb_fc_Click(object sender, System.EventArgs e)
		{
			ColorDialog cd=new ColorDialog ();
			if(cd.ShowDialog ()==DialogResult.OK)
			{
				Label b=(Label)sender;
				b.BackColor=cd.Color;
				if(b.Name =="lb_fc")
				{
					this.lb_browser.ForeColor =cd.Color ;
				}
				else
				{
					this.lb_browser.BackColor  =cd.Color ;
				}
			}
		}

		private void bn_changeIcon_Click(object sender, System.EventArgs e)
		{
			gi.setIconpath (Application.StartupPath+"\\data\\foldericon.icl",0);
			gi.ShowDialog ();
			string path =gi.geticonpath ();
			if(path.Length >0)
			{
				string temp =path .Substring (0,path.LastIndexOf (","));
				string temp2=path.Substring (path.LastIndexOf (",")+1);
				Icon ico=Extract.GetIcon (temp,int.Parse(temp2));
				this.pb_icon .Image =(Image)ico.ToBitmap ();
				this.IcoPath =temp;
				this.IconIndex =4;
			}
		}

		private void bn_save_Click(object sender, System.EventArgs e)
		{
			if(System.IO.Directory.Exists (this.tb_path .Text))
			{
				WriteFile();
				MessageBox.Show("文件夹己成功修改.",action.Caption);
//				if(MessageBox.Show ("文件夹己成功修改,是否要查看效果。",action.Caption,MessageBoxButtons.YesNo)==DialogResult.Yes)
//				{
//					System.Diagnostics.Process.Start (this.tb_path.Text);
//				}
			}
		}
		private void WriteFile()
		{
			try
			{
				//对文件夹
				System.Diagnostics.ProcessStartInfo p=new System.Diagnostics.ProcessStartInfo ("attrib.exe","-s -r -a -h "+this.tb_path .Text );
				p.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
				System.Diagnostics.Process.Start (p);
				if(File.Exists (this.tb_path .Text+"\\desktop.ini"))
				{
					//对文件
					System.Diagnostics.ProcessStartInfo spsi=new System.Diagnostics.ProcessStartInfo ("attrib.exe","-s -r -a -h "+this.tb_path .Text+"\\desktop.ini" );
					spsi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
					System.Diagnostics.Process.Start (spsi);
				}
				try
				{
					string path=this.tb_path .Text+"\\desktop.ini";
					string key ;
					string keyValue;
					string FileName = ".ShellClassInfo" ; 
					key = "IconFile"; 
					keyValue = this.IcoPath ;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					key = "IconIndex"; 
					keyValue = this.IconIndex.ToString () ;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					key = "InfoTip"; 
					keyValue = this.tb_foldertip .Text;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					FileName="{BE098140-A513-11D0-A3A4-00C04FD706EC}";
					key = "IconArea_TextBackground"; 
					Color c=this.lb_browser .BackColor  ;
					char cr=(char)c.R; 
					char cg=(char)c.G ; 
					char cb=(char)c.B ; 
					string tbg ="0x00"+System.Uri.HexEscape(cg).Remove (0,1).ToUpper()+System.Uri.HexEscape(cb).Remove (0,1).ToUpper ()+System.Uri.HexEscape(cr).Remove (0,1).ToUpper ();
					keyValue =tbg;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					key = "IconArea_Text"; 
					c=this.lb_browser.ForeColor;
					cr=(char)c.R;
					cg=(char)c.G ;
					cb=(char)c.B ;
					tbg ="0x00"+System.Uri.HexEscape(cg).Remove (0,1).ToUpper()+System.Uri.HexEscape(cb).Remove (0,1).ToUpper ()+System.Uri.HexEscape(cr).Remove (0,1).ToUpper ();
					keyValue =tbg;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					key = "IconArea_Image"; 
					keyValue = this.FBackGPath;
					WritePrivateProfileString(FileName,key,keyValue,path) ;

					FileName="ExtShellFolderViews";
					key = "{BE098140-A513-11D0-A3A4-00C04FD706EC}"; 
					keyValue ="{BE098140-A513-11D0-A3A4-00C04FD706EC}";
					WritePrivateProfileString(FileName,key,keyValue,path) ;
				}
				catch
				{
					MessageBox.Show("文件夹个性设置失败",action.Caption);
				}

				System.Diagnostics.ProcessStartInfo psi=new System.Diagnostics.ProcessStartInfo ("attrib.exe","+a +h "+this.tb_path .Text+"\\desktop.ini" );
				psi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
				System.Diagnostics.Process.Start (psi);
				System.Diagnostics.ProcessStartInfo psi2=new System.Diagnostics.ProcessStartInfo ("attrib.exe","+s +r "+this.tb_path .Text );
				psi2.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
				System.Diagnostics.Process.Start (psi2);
			}
			catch
			{
			}
		}

		private void bn_revert_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(System.IO.Directory.Exists (this.tb_path .Text))
				{
					//对文件夹
					System.Diagnostics.ProcessStartInfo p=new System.Diagnostics.ProcessStartInfo ("attrib.exe","-s -r -a -h "+this.tb_path .Text );
					p.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
					System.Diagnostics.Process.Start (p);
					if(File.Exists (this.tb_path .Text+"\\desktop.ini"))
					{
						//对文件
						System.Diagnostics.ProcessStartInfo spsi=new System.Diagnostics.ProcessStartInfo ("attrib.exe","-s -r -a -h "+this.tb_path .Text+@"\desktop.ini" );
						spsi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden ;
						System.Diagnostics.Process.Start (spsi);
						File.Delete (this.tb_path .Text+@"\desktop.ini");
						MessageBox.Show ("文件夹己还原。",action.Caption);
					}
					else
					{
						MessageBox.Show ("该文件夹未被添加效果。",action.Caption);
					}
				}
				
			}
			catch
			{
			}
		}

		private void tb_path_TextChanged(object sender, System.EventArgs e)
		{
			if(File.Exists (this.tb_path .Text+"\\desktop.ini"))
			{
				ReadFile();
			}
			else
			{
				lb_browser.ForeColor =Color.Black;
				lb_browser.Image =null;
				lb_browser.BackColor=Color.White;
				this.tb_foldertip.Text ="";
				this.lb_fbc.BackColor= Color.White;
				this.lb_fc.BackColor =Color.Black;
				this.pb_icon.Image =null;
			}
		}
		private void ReadFile()
		{
			#region 读INI
			StreamReader sr=new StreamReader (this.tb_path .Text+@"\desktop.ini",System.Text.Encoding.GetEncoding ("gb2312"));
			while(sr.Peek()>0)
			{
				string temp=sr.ReadLine ();
				if(temp.StartsWith ("InfoTip="))
				{
					this.tb_foldertip.Text =temp.Remove (0,8);
				}
				else if(temp.StartsWith ("IconArea_Image="))
				{
					temp=temp.Remove (0,15);
					if(temp.Length >0 && File.Exists (temp))
					{
						this.FBackGPath =temp;
						this.lb_browser.Image =Image.FromFile (temp);
					}
				}
				else if(temp.StartsWith ("IconFile="))
				{
					this.IcoPath =temp.Remove (0,9);
				}
				else if(temp.StartsWith ("IconIndex="))
				{
					this.IconIndex=int.Parse(temp.Remove (0,10));
					if(File.Exists(IcoPath))
					{
						Icon ico=Extract.GetIcon (this.IcoPath,this.IconIndex);
						this.pb_icon.Image =(Image)ico.ToBitmap ();
					}
				}
				else if(temp.StartsWith ("IconArea_TextBackground="))
				{
					temp=temp.Remove (0,28);
					if(temp.Length ==6)
					{
						string r="",b="",g="";
						r=temp.Substring (0,2);
						b=temp.Substring (2,2);
						g=temp.Substring (4,2);
						this.lb_browser.BackColor =Color.FromArgb (int.Parse (g,System.Globalization.NumberStyles.AllowHexSpecifier),int.Parse (b,System.Globalization.NumberStyles.AllowHexSpecifier),int.Parse (r,System.Globalization.NumberStyles.AllowHexSpecifier));
					}
				}
				else if(temp.StartsWith ("IconArea_Text="))
				{
					temp=temp.Remove (0,18);
					if(temp.Length ==6)
					{
						string r="",b="",g="";
						r=temp.Substring (0,2);
						b=temp.Substring (2,2);
						g=temp.Substring (4,2);
						this.lb_browser .ForeColor=Color.FromArgb (int.Parse (g,System.Globalization.NumberStyles.AllowHexSpecifier),int.Parse (b,System.Globalization.NumberStyles.AllowHexSpecifier),int.Parse (r,System.Globalization.NumberStyles.AllowHexSpecifier));
					}
				}
			}
			#endregion

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -