Invalidate() public méthode

public Invalidate ( ) : void
Résultat void
Exemple #1
0
        public void Close(ToolStripDropDownCloseReason reason)
        {
            if (!this.Visible)
            {
                return;
            }

            // Give users a chance to cancel the close
            ToolStripDropDownClosingEventArgs e = new ToolStripDropDownClosingEventArgs(reason);

            this.OnClosing(e);

            if (e.Cancel)
            {
                return;
            }

            // Don't actually close if AutoClose == true unless explicitly called
            if (!this.auto_close && reason != ToolStripDropDownCloseReason.CloseCalled)
            {
                return;
            }

            // Detach from the tracker
            ToolStripManager.AppClicked     -= new EventHandler(ToolStripMenuTracker_AppClicked);;
            ToolStripManager.AppFocusChange -= new EventHandler(ToolStripMenuTracker_AppFocusChange);

            // Hide this dropdown
            this.Hide();

            // Owner MenuItem needs to be told to redraw (it's no longer selected)
            if (owner_item != null)
            {
                owner_item.Invalidate();
            }

            // Recursive hide all child dropdowns
            foreach (ToolStripItem tsi in this.Items)
            {
                tsi.Dismiss(reason);
            }

            SetOwnerControl(null);

            this.OnClosed(new ToolStripDropDownClosedEventArgs(reason));
        }
Exemple #2
0
		/// <summary>
		/// Sets the icon on the specified item, from the specified action.
		/// </summary>
		/// <param name="item"></param>
		/// <param name="action"></param>
		/// <param name="iconSize"></param>
		internal static void SetIcon(ToolStripItem item, IAction action, IconSize iconSize)
		{
			if (action.IconSet != null && action.ResourceResolver != null)
			{
				try
				{
					var oldImage = item.Image;

					item.Image = action.IconSet.CreateIcon(iconSize, action.ResourceResolver);
					if (oldImage != null)
						oldImage.Dispose();

					item.Invalidate();
				}
				catch (Exception e)
				{
					// the icon was either null or not found - log some helpful message
					Platform.Log(LogLevel.Error, e);
				}
			}
		}
 private void ClearLastMouseDownedItem()
 {
     ToolStripItem lastMouseDownedItem = this.lastMouseDownedItem;
     this.lastMouseDownedItem = null;
     if (this.IsSelectionSuspended)
     {
         this.SetToolStripState(0x4000, false);
         if (lastMouseDownedItem != null)
         {
             lastMouseDownedItem.Invalidate();
         }
     }
 }
        protected override void SetVisibleCore(bool visible)
        {
            if (this.Visible == visible)
            {
                return;
            }

            if (visible)
            {
                // TODO: Move here the code from Show().
                if (currentMenu != null)
                {
                    this.is_visible = true;
                }
                else
                {
                    base.SetVisibleCore(visible);
                }
            }
            else
            {
                // Give users a chance to cancel the close
                ToolStripDropDownClosingEventArgs e = new ToolStripDropDownClosingEventArgs(closeReason);
                this.OnClosing(e);

                if (e.Cancel)
                {
                    return;
                }

                // Don't actually close if AutoClose == true unless explicitly called
                if (!this.auto_close && closeReason != ToolStripDropDownCloseReason.CloseCalled)
                {
                    return;
                }

                // Detach from the tracker
                ToolStripManager.AppClicked     -= new EventHandler(ToolStripMenuTracker_AppClicked);;
                ToolStripManager.AppFocusChange -= new EventHandler(ToolStripMenuTracker_AppFocusChange);

                // Owner MenuItem needs to be told to redraw (it's no longer selected)
                if (owner_item != null)
                {
                    owner_item.Invalidate();
                }

                // Recursive hide all child dropdowns
                foreach (ToolStripItem tsi in this.Items)
                {
                    tsi.Dismiss(closeReason);
                }

                // Hide this dropdown
                if (this.currentMenu != null)
                {
                    this.currentMenu.CancelTracking();
                    this.is_visible = false;
                }
                else
                {
                    base.SetVisibleCore(visible);
                }

                this.OnClosed(new ToolStripDropDownClosedEventArgs(closeReason));
            }
        }