Exemplo n.º 1
0
 /// <summary>
 /// Removes the specified <code>TrayIcon</code> from the
 /// <code>SystemTray</code>.
 ///
 /// <para> All icons added by the application are automatically
 /// removed from the <code>SystemTray</code> upon application exit
 /// and also when the desktop system tray becomes unavailable.
 ///
 /// </para>
 /// <para> If <code>trayIcon</code> is <code>null</code> or was not
 /// added to the system tray, no exception is thrown and no action
 /// is performed.
 ///
 /// </para>
 /// </summary>
 /// <param name="trayIcon"> the <code>TrayIcon</code> to be removed </param>
 /// <seealso cref= #add(TrayIcon) </seealso>
 /// <seealso cref= TrayIcon </seealso>
 public virtual void Remove(TrayIcon trayIcon)
 {
     if (trayIcon == null)
     {
         return;
     }
     TrayIcon[] oldArray = null, newArray = null;
     lock (this)
     {
         oldArray = SystemTray_Renamed.TrayIcons;
         List <TrayIcon> icons = (List <TrayIcon>)AppContext.AppContext.get(typeof(TrayIcon));
         // TrayIcon with no peer is not contained in the array.
         if (icons == null || !icons.Remove(trayIcon))
         {
             return;
         }
         trayIcon.RemoveNotify();
         newArray = SystemTray_Renamed.TrayIcons;
     }
     FirePropertyChange("trayIcons", oldArray, newArray);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a <code>TrayIcon</code> to the <code>SystemTray</code>.
        /// The tray icon becomes visible in the system tray once it is
        /// added.  The order in which icons are displayed in a tray is not
        /// specified - it is platform and implementation-dependent.
        ///
        /// <para> All icons added by the application are automatically
        /// removed from the <code>SystemTray</code> upon application exit
        /// and also when the desktop system tray becomes unavailable.
        ///
        /// </para>
        /// </summary>
        /// <param name="trayIcon"> the <code>TrayIcon</code> to be added </param>
        /// <exception cref="NullPointerException"> if <code>trayIcon</code> is
        /// <code>null</code> </exception>
        /// <exception cref="IllegalArgumentException"> if the same instance of
        /// a <code>TrayIcon</code> is added more than once </exception>
        /// <exception cref="AWTException"> if the desktop system tray is missing </exception>
        /// <seealso cref= #remove(TrayIcon) </seealso>
        /// <seealso cref= #getSystemTray </seealso>
        /// <seealso cref= TrayIcon </seealso>
        /// <seealso cref= java.awt.Image </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void add(TrayIcon trayIcon) throws AWTException
        public virtual void Add(TrayIcon trayIcon)
        {
            if (trayIcon == null)
            {
                throw new NullPointerException("adding null TrayIcon");
            }
            TrayIcon[]      oldArray = null, newArray = null;
            List <TrayIcon> icons    = null;

            lock (this)
            {
                oldArray = SystemTray_Renamed.TrayIcons;
                icons    = (List <TrayIcon>)AppContext.AppContext.get(typeof(TrayIcon));
                if (icons == null)
                {
                    icons = new List <TrayIcon>(3);
                    AppContext.AppContext.put(typeof(TrayIcon), icons);
                }
                else if (icons.Contains(trayIcon))
                {
                    throw new IllegalArgumentException("adding TrayIcon that is already added");
                }
                icons.Add(trayIcon);
                newArray = SystemTray_Renamed.TrayIcons;

                trayIcon.ID = ++CurrentIconID;
            }
            try
            {
                trayIcon.AddNotify();
            }
            catch (AWTException e)
            {
                icons.Remove(trayIcon);
                throw e;
            }
            FirePropertyChange("trayIcons", oldArray, newArray);
        }
Exemplo n.º 3
0
 public virtual void RemoveNotify(TrayIcon trayIcon)
 {
     trayIcon.RemoveNotify();
 }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addNotify(TrayIcon trayIcon) throws AWTException
            public virtual void AddNotify(TrayIcon trayIcon)
            {
                trayIcon.AddNotify();
            }