/// <summary> /// New EventHandler for The LocationChanging so that ToolStripPanelCell Listens to the Location Property on the ToolStrips's being changed. /// The ToolStrip needs to Raft (Join) to the approriate Location Depending on the new Location w.r.t to the oldLocation ... /// Hence the need for this event listener. /// </summary> private void OnToolStripLocationChanging(object sender, ToolStripLocationCancelEventArgs e) { if (ToolStripPanelRow == null) { return; } if (!currentlySizing && !currentlyDragging) { try { currentlyDragging = true; Point newloc = e.NewLocation; // detect if we havent yet performed a layout - force one so we can // properly join to the row. if (ToolStripPanelRow != null && ToolStripPanelRow.Bounds == Rectangle.Empty) { ToolStripPanelRow.ToolStripPanel.PerformUpdate(true); } if (_wrappedToolStrip != null) { ToolStripPanelRow.ToolStripPanel.Join(_wrappedToolStrip, newloc); } } finally { currentlyDragging = false; e.Cancel = true; } } }
private void OnToolStripLocationChanging(object sender, ToolStripLocationCancelEventArgs e) { if ((this.ToolStripPanelRow != null) && (!this.currentlySizing && !this.currentlyDragging)) { try { this.currentlyDragging = true; Point newLocation = e.NewLocation; if ((this.ToolStripPanelRow != null) && (this.ToolStripPanelRow.Bounds == Rectangle.Empty)) { this.ToolStripPanelRow.ToolStripPanel.PerformUpdate(true); } if (this._wrappedToolStrip != null) { this.ToolStripPanelRow.ToolStripPanel.Join(this._wrappedToolStrip, newLocation); } } finally { this.currentlyDragging = false; e.Cancel = true; } } }
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) { Point location = base.Location; if ((!this.IsCurrentlyDragging && !this.IsLocationChanging) && this.IsInToolStripPanel) { ToolStripLocationCancelEventArgs e = new ToolStripLocationCancelEventArgs(new Point(x, y), false); try { if ((location.X != x) || (location.Y != y)) { this.SetToolStripState(0x400, true); this.OnLocationChanging(e); } if (!e.Cancel) { base.SetBoundsCore(x, y, width, height, specified); } } finally { this.SetToolStripState(0x400, false); } } else { if (this.IsCurrentlyDragging) { Region transparentRegion = this.Renderer.GetTransparentRegion(this); if ((transparentRegion != null) && ((location.X != x) || (location.Y != y))) { try { base.Invalidate(transparentRegion); base.Update(); } finally { transparentRegion.Dispose(); } } } this.SetToolStripState(0x400, false); base.SetBoundsCore(x, y, width, height, specified); } }
internal virtual void OnLocationChanging(ToolStripLocationCancelEventArgs e) { ToolStripLocationCancelEventHandler handler = (ToolStripLocationCancelEventHandler) base.Events[EventLocationChanging]; if (handler != null) { handler(this, e); } }