📄 ddesktop.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO ;
using Wallpaper;
using System.Runtime.InteropServices ;
using System.Diagnostics ;
namespace XP界面优化精灵
{
/// <summary>
/// dDesktop 的摘要说明。
/// </summary>
public class dDesktop : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.ListBox DDesktopList;
private System.Windows.Forms.Button bn_install;
private System.Windows.Forms.Button bn_cancel;
private System.Windows.Forms.Button bn_change;
private AxShockwaveFlashObjects.AxShockwaveFlash wb_look;
private System.Windows.Forms.TabPage tab22;
private System.Windows.Forms.Label lb_bg;
private System.Windows.Forms.TextBox tb_bgpath;
private System.Windows.Forms.TextBox tb_bmpath;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button bn_selectpath;
private System.Windows.Forms.Button bn_selectpath2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public dDesktop()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(dDesktop));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tab22 = new System.Windows.Forms.TabPage();
this.bn_selectpath2 = new System.Windows.Forms.Button();
this.bn_selectpath = new System.Windows.Forms.Button();
this.tb_bmpath = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.tb_bgpath = new System.Windows.Forms.TextBox();
this.lb_bg = new System.Windows.Forms.Label();
this.wb_look = new AxShockwaveFlashObjects.AxShockwaveFlash();
this.bn_install = new System.Windows.Forms.Button();
this.bn_cancel = new System.Windows.Forms.Button();
this.bn_change = new System.Windows.Forms.Button();
this.DDesktopList = new System.Windows.Forms.ListBox();
this.tabControl1.SuspendLayout();
this.tab22.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.wb_look)).BeginInit();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tab22);
this.tabControl1.Location = new System.Drawing.Point(6, 8);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(554, 424);
this.tabControl1.TabIndex = 1;
//
// tab22
//
this.tab22.BackColor = System.Drawing.Color.White;
this.tab22.Controls.Add(this.bn_selectpath2);
this.tab22.Controls.Add(this.bn_selectpath);
this.tab22.Controls.Add(this.tb_bmpath);
this.tab22.Controls.Add(this.label1);
this.tab22.Controls.Add(this.tb_bgpath);
this.tab22.Controls.Add(this.lb_bg);
this.tab22.Controls.Add(this.wb_look);
this.tab22.Controls.Add(this.bn_install);
this.tab22.Controls.Add(this.bn_cancel);
this.tab22.Controls.Add(this.bn_change);
this.tab22.Controls.Add(this.DDesktopList);
this.tab22.Location = new System.Drawing.Point(4, 21);
this.tab22.Name = "tab22";
this.tab22.Size = new System.Drawing.Size(546, 399);
this.tab22.TabIndex = 0;
this.tab22.Text = "动态桌面";
//
// bn_selectpath2
//
this.bn_selectpath2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bn_selectpath2.Location = new System.Drawing.Point(492, 318);
this.bn_selectpath2.Name = "bn_selectpath2";
this.bn_selectpath2.Size = new System.Drawing.Size(32, 16);
this.bn_selectpath2.TabIndex = 22;
this.bn_selectpath2.Text = "...";
this.bn_selectpath2.Click += new System.EventHandler(this.bn_selectpath2_Click);
//
// bn_selectpath
//
this.bn_selectpath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bn_selectpath.Location = new System.Drawing.Point(492, 288);
this.bn_selectpath.Name = "bn_selectpath";
this.bn_selectpath.Size = new System.Drawing.Size(32, 16);
this.bn_selectpath.TabIndex = 21;
this.bn_selectpath.Text = "...";
this.bn_selectpath.Click += new System.EventHandler(this.bn_selectpath_Click);
//
// tb_bmpath
//
this.tb_bmpath.Location = new System.Drawing.Point(286, 316);
this.tb_bmpath.Name = "tb_bmpath";
this.tb_bmpath.Size = new System.Drawing.Size(240, 21);
this.tb_bmpath.TabIndex = 20;
this.tb_bmpath.Text = "";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(226, 320);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 17);
this.label1.TabIndex = 19;
this.label1.Text = "背景音乐:";
//
// tb_bgpath
//
this.tb_bgpath.Location = new System.Drawing.Point(286, 286);
this.tb_bgpath.Name = "tb_bgpath";
this.tb_bgpath.Size = new System.Drawing.Size(240, 21);
this.tb_bgpath.TabIndex = 18;
this.tb_bgpath.Text = "";
//
// lb_bg
//
this.lb_bg.AutoSize = true;
this.lb_bg.Location = new System.Drawing.Point(226, 290);
this.lb_bg.Name = "lb_bg";
this.lb_bg.Size = new System.Drawing.Size(60, 17);
this.lb_bg.TabIndex = 17;
this.lb_bg.Text = "背景图片:";
//
// wb_look
//
this.wb_look.ContainingControl = this;
this.wb_look.Enabled = true;
this.wb_look.Location = new System.Drawing.Point(16, 14);
this.wb_look.Name = "wb_look";
this.wb_look.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wb_look.OcxState")));
this.wb_look.Size = new System.Drawing.Size(508, 264);
this.wb_look.TabIndex = 16;
//
// bn_install
//
this.bn_install.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bn_install.Location = new System.Drawing.Point(238, 352);
this.bn_install.Name = "bn_install";
this.bn_install.Size = new System.Drawing.Size(118, 23);
this.bn_install.TabIndex = 14;
this.bn_install.Text = "安装新动态桌面";
this.bn_install.Click += new System.EventHandler(this.bn_install_Click);
//
// bn_cancel
//
this.bn_cancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bn_cancel.Location = new System.Drawing.Point(448, 352);
this.bn_cancel.Name = "bn_cancel";
this.bn_cancel.TabIndex = 12;
this.bn_cancel.Text = "还原";
this.bn_cancel.Click += new System.EventHandler(this.bn_cancel_Click);
//
// bn_change
//
this.bn_change.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bn_change.Location = new System.Drawing.Point(364, 352);
this.bn_change.Name = "bn_change";
this.bn_change.TabIndex = 11;
this.bn_change.Text = "确定";
this.bn_change.Click += new System.EventHandler(this.button3_Click);
//
// DDesktopList
//
this.DDesktopList.ItemHeight = 12;
this.DDesktopList.Location = new System.Drawing.Point(14, 288);
this.DDesktopList.Name = "DDesktopList";
this.DDesktopList.Size = new System.Drawing.Size(206, 88);
this.DDesktopList.TabIndex = 1;
this.DDesktopList.SelectedIndexChanged += new System.EventHandler(this.DDesktopList_SelectedIndexChanged);
//
// dDesktop
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(566, 440);
this.Controls.Add(this.tabControl1);
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 = "dDesktop";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "动态桌面";
this.TopMost = true;
this.Load += new System.EventHandler(this.dDesktop_Load);
this.tabControl1.ResumeLayout(false);
this.tab22.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.wb_look)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void dDesktop_Load(object sender, System.EventArgs e)
{
this.DDesktopList.Items.Clear ();
this.TopMost =action.isTopMost ;
GetWallpaperList();
if(this.DDesktopList.Items.Count >0)
{
this.wb_look.Movie =Application.StartupPath +"\\Wallpaper\\"+this.DDesktopList.Items [0].ToString ();
}
}
private void button3_Click(object sender, System.EventArgs e)
{
try
{
if(this.DDesktopList.SelectedItems.Count >0)
{
MakeHtml(Application.StartupPath +"\\Wallpaper\\"+this.DDesktopList.SelectedItem.ToString ());
Wallpaper.ADesktopClass wa=new ADesktopClass ();
wa.ChangeWallpaper(System.Environment.SystemDirectory+"\\XPSuit.html",1,true);
}
}
catch
{
Process.Start ("regsvr32.exe","\""+Application.StartupPath +"\\data\\Wallpaper.dll\"");
}
}
private void GetWallpaperList()
{
string[] f=Directory.GetFiles (Application.StartupPath+"\\Wallpaper");
foreach(string path in f)
{
string subpath=path.Substring (path.LastIndexOf ("\\")+1);
this.DDesktopList.Items.Add ((object)subpath);
}
}
private void DDesktopList_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.wb_look.Movie =Application.StartupPath +"\\Wallpaper\\"+this.DDesktopList.SelectedItem.ToString ();
}
private void MakeHtml(string DDesktopPath)
{
StreamWriter sw=new StreamWriter (System.Environment.SystemDirectory+"\\XPSuit.html",false,System.Text.Encoding.GetEncoding ("GB2312"));
sw.WriteLine ("<HTML>\r\n<BODY background=\""+this.tb_bgpath.Text+"\">");
sw.WriteLine ("<object height=768 width=1024 align=absmiddle classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>");
sw.WriteLine ("<param name=\"movie\" value=\""+DDesktopPath+"\">");
sw.WriteLine ("<param name=\"quality\" value=\"high\"><param name=\"wmode\" value=\"transparent\"></object>");
sw.WriteLine ("<bgsound src=\""+this.tb_bmpath.Text+"\" loop=\"-1\">");
sw.WriteLine ("</BODY></HTML>");
sw.Close ();
}
private void bn_install_Click(object sender, System.EventArgs e)
{
try
{
OpenFileDialog ofd=new OpenFileDialog ();
ofd.Filter ="*.swf | *.swf";
if(ofd.ShowDialog ()==DialogResult.OK )
{
string filename=ofd.FileName.Substring (ofd.FileName.LastIndexOf("\\")+1);
if(File.Exists (Application.StartupPath+"\\Wallpaper\\"+filename))
{
DialogResult dr=MessageBox.Show ("文件己存在,是否替换该文件",action.Caption,System.Windows.Forms.MessageBoxButtons.YesNoCancel);
if(dr==DialogResult.Yes)
{
File.Copy (ofd.FileName ,Application.StartupPath+"\\Wallpaper\\"+filename,true);
}
else if (dr==DialogResult.No )
{
SaveFileDialog sfd=new SaveFileDialog ();
sfd.Filter ="*.swf | *.swf";
sfd.InitialDirectory=Application.StartupPath+"\\Wallpaper\\";
if(sfd.ShowDialog ()==DialogResult.OK )
{
File.Copy (ofd.FileName ,sfd.FileName);
}
}
}
else
{
File.Copy (ofd.FileName ,Application.StartupPath+"\\Wallpaper\\"+filename,true);
}
dDesktop_Load (sender,e);
}
}
catch
{
}
}
private void bn_selectpath_Click(object sender, System.EventArgs e)
{
OpenFileDialog ofd=new OpenFileDialog ();
ofd.Filter ="*.jpg | *.jpg";
if(ofd.ShowDialog ()==DialogResult.OK )
{
this.tb_bgpath.Text =ofd.FileName ;
}
}
private void bn_selectpath2_Click(object sender, System.EventArgs e)
{
OpenFileDialog ofd=new OpenFileDialog ();
ofd.Filter ="*.mp3 | *.mp3";
if(ofd.ShowDialog ()==DialogResult.OK )
{
this.tb_bmpath.Text =ofd.FileName ;
}
}
private void bn_cancel_Click(object sender, System.EventArgs e)
{
Wallpaper.ADesktopClass wa=new ADesktopClass ();
wa.ChangeWallpaper("",1,true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -