我正在开发文件监视系统。如果文件被更改,则显示通知。 现在我很难想要显示自定义通知设计而不是默认通知设计。
有人可以建议如何实施吗?
显示通知代码:
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
watcher.Created += new FileSystemEventHandler(watcher_Created);
watcher.Deleted += new FileSystemEventHandler(watcher_Deleted);
watcher.Renamed += new RenamedEventHandler(watcher_Renamed);
private void watcher_Changed(object sender, FileSystemEventArgs e)
{
this.notifyIcon1.ShowBalloonTip(1, "File " + e.ChangeType, e.FullPath, ToolTipIcon.Info);
}
private void watcher_Created(object sender, FileSystemEventArgs e)
{
this.notifyIcon1.ShowBalloonTip(1, "File " + e.ChangeType, e.FullPath, ToolTipIcon.Info);
}
private void watcher_Deleted(object sender, FileSystemEventArgs e)
{
this.notifyIcon1.ShowBalloonTip(1, "File " + e.ChangeType, e.FullPath, ToolTipIcon.Info);
}
private void watcher_Renamed(object sender, RenamedEventArgs e)
{
this.notifyIcon1.ShowBalloonTip(1, "File Renamed", e.OldFullPath + " renamed to " + e.FullPath, ToolTipIcon.Info);
}
自定义表单代码:
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Alert));
this.panel1 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.btnCancel = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.btnCancel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.panel3);
this.panel1.Controls.Add(this.panel2);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 60);
this.panel1.TabIndex = 0;
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.Lime;
this.panel3.Location = new System.Drawing.Point(0, 53);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(200, 5);
this.panel3.TabIndex = 1;
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Lime;
this.panel2.Controls.Add(this.btnCancel);
this.panel2.Controls.Add(this.pictureBox1);
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 22);
this.panel2.TabIndex = 0;
//
// btnCancel
//
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancel.Image = global::FolderChange.Properties.Resources.Cancel;
this.btnCancel.Location = new System.Drawing.Point(178, 3);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(16, 16);
this.btnCancel.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.btnCancel.TabIndex = 2;
this.btnCancel.TabStop = false;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// pictureBox1
//
this.pictureBox1.Image = global::FolderChange.Properties.Resources.favicon9;
this.pictureBox1.InitialImage = null;
this.pictureBox1.Location = new System.Drawing.Point(4, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(16, 16);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// Alert
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ClientSize = new System.Drawing.Size(200, 60);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Alert";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Alert";
this.Load += new System.EventHandler(this.Alert_Load);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.btnCancel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}