home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 October / CMCD1004.ISO / Software / Shareware / Programare / netxp / netxp.exe / Samples / CS / Components / Form1.cs < prev    next >
Encoding:
Text File  |  2004-03-31  |  7.4 KB  |  214 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8. namespace Components
  9. {
  10.     /// <summary>
  11.     /// Summary description for Form1.
  12.     /// </summary>
  13.     public class Form1 : System.Windows.Forms.Form
  14.     {
  15.         private System.Windows.Forms.MainMenu mainMenu1;
  16.         private System.Windows.Forms.MenuItem menuItem1;
  17.         private System.Windows.Forms.MenuItem menuItem2;
  18.         private System.Windows.Forms.MenuItem menuItem3;
  19.         private NETXP.Components.Extenders.MenuImageExtender menuImageExtender1;
  20.         private NETXP.Components.ImageStore imageStore1;
  21.         private System.Windows.Forms.PictureBox pictureBox1;
  22.         private System.Windows.Forms.Button button1;
  23.         private NETXP.Components.ImageStore notifyBg;
  24.         private NETXP.Components.ImageStore notifyClose;
  25.         private NETXP.Components.NotifyIconEx notifyIconEx1;
  26.         private System.Windows.Forms.Button button2;
  27.         private System.ComponentModel.IContainer components;
  28.  
  29.         public Form1()
  30.         {
  31.             //
  32.             // Required for Windows Form Designer support
  33.             //
  34.             InitializeComponent();
  35.  
  36.             //
  37.             // TODO: Add any constructor code after InitializeComponent call
  38.             //
  39.         }
  40.  
  41.         /// <summary>
  42.         /// Clean up any resources being used.
  43.         /// </summary>
  44.         protected override void Dispose( bool disposing )
  45.         {
  46.             if( disposing )
  47.             {
  48.                 if (components != null) 
  49.                 {
  50.                     components.Dispose();
  51.                 }
  52.             }
  53.             base.Dispose( disposing );
  54.         }
  55.  
  56.         #region Windows Form Designer generated code
  57.         /// <summary>
  58.         /// Required method for Designer support - do not modify
  59.         /// the contents of this method with the code editor.
  60.         /// </summary>
  61.         private void InitializeComponent()
  62.         {
  63.             this.components = new System.ComponentModel.Container();
  64.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  65.             this.mainMenu1 = new System.Windows.Forms.MainMenu();
  66.             this.menuItem1 = new System.Windows.Forms.MenuItem();
  67.             this.menuItem2 = new System.Windows.Forms.MenuItem();
  68.             this.menuItem3 = new System.Windows.Forms.MenuItem();
  69.             this.menuImageExtender1 = new NETXP.Components.Extenders.MenuImageExtender(this.components);
  70.             this.imageStore1 = new NETXP.Components.ImageStore(this.components);
  71.             this.pictureBox1 = new System.Windows.Forms.PictureBox();
  72.             this.button1 = new System.Windows.Forms.Button();
  73.             this.notifyBg = new NETXP.Components.ImageStore(this.components);
  74.             this.notifyClose = new NETXP.Components.ImageStore(this.components);
  75.             this.notifyIconEx1 = new NETXP.Components.NotifyIconEx();
  76.             this.button2 = new System.Windows.Forms.Button();
  77.             this.SuspendLayout();
  78.             // 
  79.             // mainMenu1
  80.             // 
  81.             this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  82.                                                                                       this.menuItem1});
  83.             // 
  84.             // menuItem1
  85.             // 
  86.             this.menuItem1.Index = 0;
  87.             this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  88.                                                                                       this.menuItem2,
  89.                                                                                       this.menuItem3});
  90.             this.menuItem1.Text = "&Menu With Images";
  91.             // 
  92.             // menuItem2
  93.             // 
  94.             this.menuImageExtender1.SetImage(this.menuItem2, ((System.Drawing.Image)(resources.GetObject("menuItem2.Image"))));
  95.             this.menuItem2.Index = 0;
  96.             this.menuItem2.OwnerDraw = true;
  97.             this.menuItem2.Text = "&An Item";
  98.             // 
  99.             // menuItem3
  100.             // 
  101.             this.menuImageExtender1.SetImage(this.menuItem3, ((System.Drawing.Image)(resources.GetObject("menuItem3.Image"))));
  102.             this.menuItem3.Index = 1;
  103.             this.menuItem3.OwnerDraw = true;
  104.             this.menuItem3.Text = "Another &Item";
  105.             // 
  106.             // imageStore1
  107.             // 
  108.             this.imageStore1.Image = ((System.Drawing.Image)(resources.GetObject("imageStore1.Image")));
  109.             // 
  110.             // pictureBox1
  111.             // 
  112.             this.pictureBox1.Location = new System.Drawing.Point(32, 32);
  113.             this.pictureBox1.Name = "pictureBox1";
  114.             this.pictureBox1.Size = new System.Drawing.Size(128, 128);
  115.             this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
  116.             this.pictureBox1.TabIndex = 0;
  117.             this.pictureBox1.TabStop = false;
  118.             this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
  119.             // 
  120.             // button1
  121.             // 
  122.             this.button1.Location = new System.Drawing.Point(312, 32);
  123.             this.button1.Name = "button1";
  124.             this.button1.Size = new System.Drawing.Size(144, 23);
  125.             this.button1.TabIndex = 1;
  126.             this.button1.Text = "Test &Taskbar Notifier";
  127.             this.button1.Click += new System.EventHandler(this.button1_Click);
  128.             // 
  129.             // notifyBg
  130.             // 
  131.             this.notifyBg.Image = ((System.Drawing.Image)(resources.GetObject("notifyBg.Image")));
  132.             // 
  133.             // notifyClose
  134.             // 
  135.             this.notifyClose.Image = ((System.Drawing.Image)(resources.GetObject("notifyClose.Image")));
  136.             // 
  137.             // notifyIconEx1
  138.             // 
  139.             this.notifyIconEx1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIconEx1.Icon")));
  140.             this.notifyIconEx1.Text = "This is a test of the NotifyIconEx.";
  141.             this.notifyIconEx1.Visible = true;
  142.             // 
  143.             // button2
  144.             // 
  145.             this.button2.Location = new System.Drawing.Point(296, 96);
  146.             this.button2.Name = "button2";
  147.             this.button2.Size = new System.Drawing.Size(168, 23);
  148.             this.button2.TabIndex = 2;
  149.             this.button2.Text = "Test &Computer Browser";
  150.             this.button2.Click += new System.EventHandler(this.button2_Click);
  151.             // 
  152.             // Form1
  153.             // 
  154.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  155.             this.ClientSize = new System.Drawing.Size(480, 353);
  156.             this.Controls.Add(this.button2);
  157.             this.Controls.Add(this.button1);
  158.             this.Controls.Add(this.pictureBox1);
  159.             this.Menu = this.mainMenu1;
  160.             this.Name = "Form1";
  161.             this.Text = "Form1";
  162.             this.Load += new System.EventHandler(this.Form1_Load);
  163.             this.ResumeLayout(false);
  164.  
  165.         }
  166.         #endregion
  167.  
  168.         /// <summary>
  169.         /// The main entry point for the application.
  170.         /// </summary>
  171.         [STAThread]
  172.         static void Main() 
  173.         {
  174.             Application.Run(new Form1());
  175.         }
  176.  
  177.         private void Form1_Load(object sender, System.EventArgs e)
  178.         {
  179.             //use ImageStore
  180.             this.pictureBox1.Image = this.imageStore1.Image;
  181.             this.notifyIconEx1.ShowBalloon("Testing NotifyIconEx", "This is a balloon tip. This is impossible to do with the standard NotifyIcon.", NETXP.Components.NotifyInfoFlags.Info, 3000);
  182.         }
  183.  
  184.         private void pictureBox1_Click(object sender, System.EventArgs e)
  185.         {
  186.             this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
  187.         }
  188.  
  189.         private void button1_Click(object sender, System.EventArgs e)
  190.         {
  191.             NETXP.Components.TaskbarNotifier tn;
  192.             tn = new NETXP.Components.TaskbarNotifier();
  193.             tn.NormalTitleColor = SystemColors.HotTrack;
  194.             tn.NormalTitleFont = new Font(tn.NormalTitleFont, FontStyle.Bold);
  195.             tn.NormalContentColor = SystemColors.WindowText;
  196.             tn.HoverContentColor = SystemColors.HotTrack;
  197.             tn.HoverTitleColor = SystemColors.ActiveCaption;
  198.             tn.HoverTitleFont = tn.NormalTitleFont;
  199.             tn.SetBackgroundBitmap(notifyBg.Image,Color.FromArgb(255,0,255));
  200.             tn.SetCloseBitmap(notifyClose.Image,Color.FromArgb(255,0,255),new Point(127,8));
  201.             tn.TitleRectangle=new Rectangle(60,12,100,30);
  202.             tn.ContentRectangle=new Rectangle(8,43,133,64);
  203.             tn.Show("Notification", "The XMark service has started.", 250, 1500, 250);
  204.         }
  205.  
  206.         private void button2_Click(object sender, System.EventArgs e)
  207.         {
  208.             NETXP.Components.CompBrowser brf = new NETXP.Components.CompBrowser();
  209.             brf.ShowDialog(this);
  210.             MessageBox.Show(brf.SelectedComputer);
  211.         }
  212.     }
  213. }
  214.