[C#] The name does not exist ...

The name does not exist ... [C#] - C#/.NET managed - Programmation

Marsh Posté le 11-01-2006 à 15:50:05    

Bonjour !
 
J'ai un petit Code don je n'arrive pas résoudre le problème.
 
Celui-ci m'affiche une erreur à la compil !
 
>> the name 'xxx' does not exist in the class or namespace SystemTray
 
xxx étant TitleClick / ContentClick et CloseClick.
 
Lignes 56,57,58 // 74,75,76 // 84,85,86.
 
si vous avez besoin d'autre information dite le moi !
 
merci d'avance ;)
 
PS: le Code est pas encore fini, donc ne cherche pas à quoi il dois aboutir ^^
 
 
 
 

Code :
  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. using CustomUIControls;
  8. using System.IO;
  9. namespace SystemTray
  10. {
  11. /// <summary>
  12. /// Description résumée de Form1.
  13. /// </summary>
  14. public class Form1 : System.Windows.Forms.Form
  15. {
  16.  private System.Windows.Forms.ContextMenu contextMenu;
  17.  private System.Windows.Forms.MenuItem menuItem_Hide;
  18.  private System.Windows.Forms.MenuItem menuItem_Show;
  19.  private System.Windows.Forms.MenuItem menuItem_About;
  20.  private System.Windows.Forms.MenuItem menuItem_Exit;
  21.  private System.Windows.Forms.MenuItem menuItem_Separator;
  22.  private System.Windows.Forms.NotifyIcon notifyIcon;
  23.  private System.Windows.Forms.Button button1;
  24.  private System.Windows.Forms.Label label1;
  25.  private System.ComponentModel.IContainer components;
  26.  private System.Windows.Forms.TextBox textBoxTitle;
  27.  private System.Windows.Forms.TextBox textBoxContent;
  28.  private System.Windows.Forms.TextBox textBoxDelayShowing;
  29.  private System.Windows.Forms.TextBox textBoxDelayStaying;
  30.  private System.Windows.Forms.TextBox textBoxDelayHiding;
  31.  private System.Windows.Forms.CheckBox checkBoxTitleClickable;
  32.  private System.Windows.Forms.CheckBox checkBoxContentClickable;
  33.  private System.Windows.Forms.CheckBox checkBoxCloseClickable;
  34.  private System.Windows.Forms.CheckBox checkBoxReShowOnMouseOver;  // Added Rev 002
  35.  private System.Windows.Forms.CheckBox checkBoxKeepVisibleOnMouseOver;
  36.  private System.Windows.Forms.CheckBox checkBoxSelectionRectangle; // Added Rev 002
  37.  TaskbarNotifier taskbarNotifier1;
  38.  TaskbarNotifier taskbarNotifier2;
  39.  TaskbarNotifier taskbarNotifier3;
  40.  public Form1()
  41.  {
  42.   //
  43.   // Requis pour la prise en charge du Concepteur Windows Forms
  44.   //
  45.   InitializeComponent();
  46.   textBoxContent.Text="This is a sample content, it can spread on multiple lines";
  47.   textBoxTitle.Text="Title";
  48.   textBoxDelayShowing.Text="500";
  49.   textBoxDelayStaying.Text="3000";
  50.   textBoxDelayHiding.Text="500";
  51.   checkBoxSelectionRectangle.Checked=true;
  52.   checkBoxTitleClickable.Checked=false;
  53.   checkBoxContentClickable.Checked=true;
  54.   checkBoxCloseClickable.Checked=true;
  55.   checkBoxKeepVisibleOnMouseOver.Checked = true;  // Added Rev 002
  56.   checkBoxReShowOnMouseOver.Checked = false;   // Added Rev 002
  57.   taskbarNotifier1=new TaskbarNotifier();
  58.   taskbarNotifier1.SetBackgroundBitmap(new Bitmap(GetType(),"skin.bmp" ),Color.FromArgb(255,0,255));
  59.   taskbarNotifier1.SetCloseBitmap(new Bitmap(GetType(),"close.bmp" ),Color.FromArgb(255,0,255),new Point(127,8));
  60.   taskbarNotifier1.TitleRectangle=new Rectangle(40,9,70,25);
  61.   taskbarNotifier1.ContentRectangle=new Rectangle(8,41,133,68);
  62.   taskbarNotifier1.TitleClick+=new EventHandler(TitleClick);
  63.   taskbarNotifier1.ContentClick+=new EventHandler(ContentClick);
  64.   taskbarNotifier1.CloseClick+=new EventHandler(CloseClick);
  65.   taskbarNotifier2=new TaskbarNotifier();
  66.   taskbarNotifier2.SetBackgroundBitmap(new Bitmap(GetType(),"skin2.bmp" ),Color.FromArgb(255,0,255));
  67.   taskbarNotifier2.SetCloseBitmap(new Bitmap(GetType(),"close2.bmp" ),Color.FromArgb(255,0,255),new Point(300,74));
  68.   taskbarNotifier2.TitleRectangle=new Rectangle(123,80,176,16);
  69.   taskbarNotifier2.ContentRectangle=new Rectangle(116,97,197,22);
  70.   taskbarNotifier2.TitleClick +=new EventHandler(TitleClick);
  71.   taskbarNotifier2.ContentClick +=new EventHandler(ContentClick);
  72.   taskbarNotifier2.CloseClick +=new EventHandler(CloseClick);
  73.   // Added Rev 002
  74.   taskbarNotifier3=new TaskbarNotifier();
  75.   taskbarNotifier3.SetBackgroundBitmap(new Bitmap(GetType(),"skin3.bmp" ),Color.FromArgb(255,0,255));
  76.   taskbarNotifier3.SetCloseBitmap(new Bitmap(GetType(),"close.bmp" ),Color.FromArgb(255,0,255),new Point(280,57));
  77.   taskbarNotifier3.TitleRectangle=new Rectangle(150, 57, 125, 28);
  78.   taskbarNotifier3.ContentRectangle=new Rectangle(75, 92, 215, 55);
  79.   taskbarNotifier3.TitleClick+=new EventHandler(TitleClick);
  80.   taskbarNotifier3.ContentClick+=new EventHandler(ContentClick);
  81.   taskbarNotifier3.CloseClick+=new EventHandler(CloseClick);   //
  82.   // TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
  83.   //
  84.  }
  85.  /// <summary>
  86.  /// Nettoyage des ressources utilisées.
  87.  /// </summary>
  88.  protected override void Dispose( bool disposing )
  89.  {
  90.   if( disposing )
  91.   {
  92.    if (components != null)
  93.    {
  94.     components.Dispose();
  95.    }
  96.   }
  97.   base.Dispose( disposing );
  98.  }
  99.  #region Code généré par le Concepteur Windows Form
  100.  /// <summary>
  101.  /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
  102.  /// le contenu de cette méthode avec l'éditeur de code.
  103.  /// </summary>
  104.  private void InitializeComponent()
  105.  {
  106.   this.components = new System.ComponentModel.Container();
  107.   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  108.   this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
  109.   this.contextMenu = new System.Windows.Forms.ContextMenu();
  110.   this.menuItem_Hide = new System.Windows.Forms.MenuItem();
  111.   this.menuItem_Show = new System.Windows.Forms.MenuItem();
  112.   this.menuItem_About = new System.Windows.Forms.MenuItem();
  113.   this.menuItem_Exit = new System.Windows.Forms.MenuItem();
  114.   this.menuItem_Separator = new System.Windows.Forms.MenuItem();
  115.   this.button1 = new System.Windows.Forms.Button();
  116.   this.label1 = new System.Windows.Forms.Label();
  117.   this.checkBoxSelectionRectangle = new System.Windows.Forms.CheckBox();
  118.   this.textBoxTitle = new System.Windows.Forms.TextBox();
  119.   this.textBoxContent = new System.Windows.Forms.TextBox();
  120.   this.textBoxDelayShowing = new System.Windows.Forms.TextBox();
  121.   this.textBoxDelayStaying = new System.Windows.Forms.TextBox();
  122.   this.textBoxDelayHiding = new System.Windows.Forms.TextBox();
  123.   this.checkBoxReShowOnMouseOver = new System.Windows.Forms.CheckBox();
  124.   this.checkBoxKeepVisibleOnMouseOver = new System.Windows.Forms.CheckBox();
  125.   this.checkBoxCloseClickable = new System.Windows.Forms.CheckBox();
  126.   this.checkBoxContentClickable = new System.Windows.Forms.CheckBox();
  127.   this.checkBoxTitleClickable = new System.Windows.Forms.CheckBox();
  128.   this.SuspendLayout();
  129.   //  
  130.   // notifyIcon
  131.   //  
  132.   this.notifyIcon.ContextMenu = this.contextMenu;
  133.   this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon" )));
  134.   this.notifyIcon.Text = "Exemple SystemTray";
  135.   this.notifyIcon.Visible = true;
  136.   this.notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon_DoubleClick);
  137.   //  
  138.   // contextMenu
  139.   //  
  140.   this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  141.      this.menuItem_Hide,
  142.      this.menuItem_Show,
  143.      this.menuItem_About,
  144.      this.menuItem_Exit,
  145.      this.menuItem_Separator});
  146.   //  
  147.   // menuItem_Hide
  148.   //  
  149.   this.menuItem_Hide.DefaultItem = true;
  150.   this.menuItem_Hide.Index = 0;
  151.   this.menuItem_Hide.Text = "Hide";
  152.   this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);
  153.   //  
  154.   // menuItem_Show
  155.   //  
  156.   this.menuItem_Show.Index = 1;
  157.   this.menuItem_Show.Text = "Show";
  158.   this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);
  159.   //  
  160.   // menuItem_About
  161.   //  
  162.   this.menuItem_About.Index = 2;
  163.   this.menuItem_About.Text = "About";
  164.   this.menuItem_About.Click += new System.EventHandler(this.menuItem_About_Click);
  165.   //  
  166.   // menuItem_Exit
  167.   //  
  168.   this.menuItem_Exit.Index = 3;
  169.   this.menuItem_Exit.Text = "Exit";
  170.   this.menuItem_Exit.Click += new System.EventHandler(this.menuItem_Exit_Click);
  171.   //  
  172.   // menuItem_Separator
  173.   //  
  174.   this.menuItem_Separator.Index = 4;
  175.   this.menuItem_Separator.Text = "-";
  176.   //  
  177.   // button1
  178.   //  
  179.   this.button1.Location = new System.Drawing.Point(200, 96);
  180.   this.button1.Name = "button1";
  181.   this.button1.TabIndex = 0;
  182.   this.button1.Text = "button1";
  183.   //  
  184.   // label1
  185.   //  
  186.   this.label1.Location = new System.Drawing.Point(176, 168);
  187.   this.label1.Name = "label1";
  188.   this.label1.TabIndex = 1;
  189.   this.label1.Text = "label1";
  190.   //
  191.   // checkBoxSelectionRectangle
  192.   //  
  193.   this.checkBoxSelectionRectangle.Location = new System.Drawing.Point(128, 48);
  194.   this.checkBoxSelectionRectangle.Name = "checkBoxSelectionRectangle";
  195.   this.checkBoxSelectionRectangle.Size = new System.Drawing.Size(160, 16);
  196.   this.checkBoxSelectionRectangle.TabIndex = 2;
  197.   this.checkBoxSelectionRectangle.Text = "Show Selection Rectangle";
  198.   //  
  199.   // textBoxTitle
  200.   //  
  201.   this.textBoxTitle.Location = new System.Drawing.Point(64, 32);
  202.   this.textBoxTitle.Name = "textBoxTitle";
  203.   this.textBoxTitle.Size = new System.Drawing.Size(224, 20);
  204.   this.textBoxTitle.TabIndex = 3;
  205.   this.textBoxTitle.Text = "textBoxTitle";
  206.   //  
  207.   // textBoxContent
  208.   //  
  209.   this.textBoxContent.Location = new System.Drawing.Point(64, 64);
  210.   this.textBoxContent.Name = "textBoxContent";
  211.   this.textBoxContent.Size = new System.Drawing.Size(224, 20);
  212.   this.textBoxContent.TabIndex = 4;
  213.   this.textBoxContent.Text = "textBoxContent";
  214.   //
  215.   // textBoxDelayShowing
  216.   //  
  217.   this.textBoxDelayShowing.Location = new System.Drawing.Point(32, 152);
  218.   this.textBoxDelayShowing.Name = "textBoxDelayShowing";
  219.   this.textBoxDelayShowing.Size = new System.Drawing.Size(56, 20);
  220.   this.textBoxDelayShowing.TabIndex = 10;
  221.   this.textBoxDelayShowing.Text = "textBoxDelayShowing";
  222.   //  
  223.   // textBoxDelayStaying
  224.   //  
  225.   this.textBoxDelayStaying.Location = new System.Drawing.Point(128, 152);
  226.   this.textBoxDelayStaying.Name = "textBoxDelayStaying";
  227.   this.textBoxDelayStaying.Size = new System.Drawing.Size(56, 20);
  228.   this.textBoxDelayStaying.TabIndex = 9;
  229.   this.textBoxDelayStaying.Text = "textBoxDelayStaying";
  230.   //  
  231.   // textBoxDelayHiding
  232.   //  
  233.   this.textBoxDelayHiding.Location = new System.Drawing.Point(216, 152);
  234.   this.textBoxDelayHiding.Name = "textBoxDelayHiding";
  235.   this.textBoxDelayHiding.Size = new System.Drawing.Size(56, 20);
  236.   this.textBoxDelayHiding.TabIndex = 8;
  237.   this.textBoxDelayHiding.Text = "textBoxDelayHiding";
  238.   //  
  239.   // checkBoxKeepVisibleOnMouseOver
  240.   //  
  241.   this.checkBoxKeepVisibleOnMouseOver.Location = new System.Drawing.Point(16, 72);
  242.   this.checkBoxKeepVisibleOnMouseOver.Name = "checkBoxKeepVisibleOnMouseOver";
  243.   this.checkBoxKeepVisibleOnMouseOver.Size = new System.Drawing.Size(268, 16);
  244.   this.checkBoxKeepVisibleOnMouseOver.TabIndex = 6;
  245.   this.checkBoxKeepVisibleOnMouseOver.Text = "Keep Visible when Mouse over window";
  246.   //  
  247.   // checkBoxCloseClickable
  248.   //  
  249.   this.checkBoxCloseClickable.Location = new System.Drawing.Point(16, 48);
  250.   this.checkBoxCloseClickable.Name = "checkBoxCloseClickable";
  251.   this.checkBoxCloseClickable.Size = new System.Drawing.Size(104, 16);
  252.   this.checkBoxCloseClickable.TabIndex = 3;
  253.   this.checkBoxCloseClickable.Text = "Close Clickable";
  254.   //  
  255.   // checkBoxContentClickable
  256.   //  
  257.   this.checkBoxContentClickable.Location = new System.Drawing.Point(128, 24);
  258.   this.checkBoxContentClickable.Name = "checkBoxContentClickable";
  259.   this.checkBoxContentClickable.Size = new System.Drawing.Size(112, 16);
  260.   this.checkBoxContentClickable.TabIndex = 1;
  261.   this.checkBoxContentClickable.Text = "Content Clickable";
  262.   //  
  263.   // checkBoxTitleClickable
  264.   //  
  265.   this.checkBoxTitleClickable.Location = new System.Drawing.Point(16, 24);
  266.   this.checkBoxTitleClickable.Name = "checkBoxTitleClickable";
  267.   this.checkBoxTitleClickable.Size = new System.Drawing.Size(96, 16);
  268.   this.checkBoxTitleClickable.TabIndex = 0;
  269.   this.checkBoxTitleClickable.Text = "Title Clickable";
  270.   //  
  271.   // Form1
  272.   //  
  273.   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  274.   this.ClientSize = new System.Drawing.Size(292, 273);
  275.   this.Controls.Add(this.label1);
  276.   this.Controls.Add(this.button1);
  277.   this.Controls.Add(this.textBoxDelayShowing);
  278.   this.Controls.Add(this.textBoxDelayStaying);
  279.   this.Controls.Add(this.textBoxDelayHiding);
  280.   this.Controls.Add(this.textBoxContent);
  281.   this.Controls.Add(this.textBoxTitle);
  282.   this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon" )));
  283.   this.Name = "Form1";
  284.   this.ShowInTaskbar = false;
  285.   this.Text = "Form1";
  286.   this.Resize += new System.EventHandler(this.Form1_Resize);
  287.   this.ResumeLayout(false);
  288.  }
  289.  #endregion
  290.  /// <summary>
  291.  /// Point d'entrée principal de l'application.
  292.  /// </summary>
  293.  [STAThread]
  294.  static void Main()
  295.  {
  296.   Application.Run(new Form1());
  297.  }
  298.  private void menuItem_Hide_Click(object sender, System.EventArgs e)
  299.  {
  300.   this.ShowInTaskbar = false;
  301.   this.Hide();
  302.  }
  303.  private void notifyIcon_DoubleClick(object sender, System.EventArgs e)
  304.  {
  305.   this.ShowInTaskbar = true;
  306.   this.Show();
  307.  }
  308.  private void menuItem_Show_Click(object sender, System.EventArgs e)
  309.  {
  310.   this.ShowInTaskbar = true;
  311.   this.Show();
  312.  }
  313.  private void menuItem_About_Click(object sender, System.EventArgs e)
  314.  {
  315.   MessageBox.Show("XXX France Copyright" );
  316.  }
  317.  private void menuItem_Exit_Click(object sender, System.EventArgs e)
  318.  {
  319.   notifyIcon.Visible = false;
  320.   Application.Exit();
  321.  }
  322.  private void Form1_Resize(object sender, System.EventArgs e)
  323.  {
  324.   if ( this.WindowState == FormWindowState.Minimized)
  325.   {
  326.    // le masque de la barre des taches
  327.    this.ShowInTaskbar = false;
  328.    // cache le form
  329.    this.Hide();
  330.   }
  331.  }
  332.  private void Up()
  333.  {
  334.   // reaffiche dans la barre des taches
  335.   this.ShowInTaskbar = true;
  336.   // reaffiche le form
  337.   this.Show();
  338.   // remet la taille normale
  339.   this.WindowState = FormWindowState.Normal;
  340.  }
  341.    public static long DirSize(DirectoryInfo d)
  342.  {
  343.   long Size = 0;
  344.   //ajout taille fichiers
  345.   FileInfo[] fis = d.GetFiles();
  346.   foreach(FileInfo fi in fis)
  347.     {
  348.      Size += fi.Length ;
  349.     }
  350.   //ajout taille sous dossier
  351.   DirectoryInfo[] dis = d.GetDirectories();
  352.      foreach(DirectoryInfo di in dis)
  353.     {
  354.      Size +=DirSize(di);
  355.     }
  356.     return(Size);
  357.  }
  358.  private void Errs()
  359.  {
  360.   DirectoryInfo d = new DirectoryInfo(@"%username%" );
  361.   foreach(DirectoryInfo xp in d.GetDirectories())
  362.    {
  363.     if(DirSize(xp) > 90000000)
  364.     {
  365.      notifyIcon.Icon = new Icon("globe2-floppy-orange.ico" );
  366.      taskbarNotifier1.CloseClickable=checkBoxCloseClickable.Checked;
  367.      taskbarNotifier1.TitleClickable=checkBoxTitleClickable.Checked;
  368.      taskbarNotifier1.ContentClickable=checkBoxContentClickable.Checked;
  369.      taskbarNotifier1.EnableSelectionRectangle=checkBoxSelectionRectangle.Checked;
  370.      taskbarNotifier1.KeepVisibleOnMousOver=checkBoxKeepVisibleOnMouseOver.Checked; // Added Rev 002
  371.      taskbarNotifier1.ReShowOnMouseOver=checkBoxReShowOnMouseOver.Checked;   // Added Rev 002
  372.      taskbarNotifier1.Show(textBoxTitle.Text,textBoxContent.Text,Int32.Parse(textBoxDelayShowing.Text),Int32.Parse(textBoxDelayStaying.Text),Int32.Parse(textBoxDelayHiding.Text));
  373.     }
  374.     if(DirSize(xp) > 100000000)
  375.     {
  376.      notifyIcon.Icon = new Icon("globe2-floppy-red.ico" );
  377.      taskbarNotifier1.CloseClickable=checkBoxCloseClickable.Checked;
  378.      taskbarNotifier1.TitleClickable=checkBoxTitleClickable.Checked;
  379.      taskbarNotifier1.ContentClickable=checkBoxContentClickable.Checked;
  380.      taskbarNotifier1.EnableSelectionRectangle=checkBoxSelectionRectangle.Checked;
  381.      taskbarNotifier1.KeepVisibleOnMousOver=checkBoxKeepVisibleOnMouseOver.Checked; // Added Rev 002
  382.      taskbarNotifier1.ReShowOnMouseOver=checkBoxReShowOnMouseOver.Checked;   // Added Rev 002
  383.      taskbarNotifier1.Show(textBoxTitle.Text,textBoxContent.Text,Int32.Parse(textBoxDelayShowing.Text),Int32.Parse(textBoxDelayStaying.Text),Int32.Parse(textBoxDelayHiding.Text));
  384.     }
  385.       if(DirSize(xp) < 90000000)
  386.     {
  387.      notifyIcon.Icon = new Icon("globe2-floppy-green.ico" );
  388.      taskbarNotifier1.CloseClickable=checkBoxCloseClickable.Checked;
  389.      taskbarNotifier1.TitleClickable=checkBoxTitleClickable.Checked;
  390.      taskbarNotifier1.ContentClickable=checkBoxContentClickable.Checked;
  391.      taskbarNotifier1.EnableSelectionRectangle=checkBoxSelectionRectangle.Checked;
  392.      taskbarNotifier1.KeepVisibleOnMousOver=checkBoxKeepVisibleOnMouseOver.Checked; // Added Rev 002
  393.      taskbarNotifier1.ReShowOnMouseOver=checkBoxReShowOnMouseOver.Checked;   // Added Rev 002
  394.      taskbarNotifier1.Show(textBoxTitle.Text,textBoxContent.Text,Int32.Parse(textBoxDelayShowing.Text),Int32.Parse(textBoxDelayStaying.Text),Int32.Parse(textBoxDelayHiding.Text));
  395.     }
  396.    }
  397.  }
  398. }
  399. }


Message édité par Zorh le 11-01-2006 à 15:52:23

---------------
---
Reply

Marsh Posté le 11-01-2006 à 15:50:05   

Reply

Marsh Posté le 11-01-2006 à 18:06:26    

il te faut créer les Event Handler TitleClick / ContentClick et CloseClick.
 
Ce sont des fonction dans ta classe sur lesquels vont pointer les délégués des composants donnés dans ton InitializeComponent
 
 

Code :
  1. taskbarNotifier2.TitleClick +=new EventHandler(TitleClick); 
  2. taskbarNotifier2.ContentClick +=new EventHandler(ContentClick);
  3. taskbarNotifier2.CloseClick +=new EventHandler(CloseClick);


 
il te manque donc les fonctions du genre :
 

Code :
  1. private void TitleClick(object sender, System.EventArgs e)
  2. {
  3. // Ton Code...
  4. }


 
Idem pour ContentClick et CloseClick.

Reply

Marsh Posté le 12-01-2006 à 09:30:54    

Han ! Quel Boeuf que je fait !
 
Merci ^^
 
Zorh


---------------
---
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed