private void SaveToolStripRow(ToolStripPanelRow row, ToolStripSettingElementCollection newSettings, string position, int rowIndex) { foreach (ToolStrip strip in row.Controls) { newSettings.Add(new ToolStripSettingElement { Dock = position, Row = rowIndex, Left = strip.Left, Top = strip.Top, Name = strip.Name, Visible = strip.Visible }); } }
/// <summary> /// Comprime en largeur les conteneurs <see cref="ToolStrip"/> des rangées. /// </summary> /// <param name="rows">tableau des rangées à comprimer</param> private void DoShrinkRows( ToolStripPanelRow[] rows ) { for ( int ix = 0 ; ix < rows.Length ; ix++ ) DoShrinkRow( rows[ ix ] ); }
// todo (ToolStripPanelEnh) tenir compte des contraintes MinimumSize et MaximumSize /// <summary> /// Dimensionnement et placement des conteneurs <see cref="ToolStrip"/> d'une rangée donnée. /// </summary> /// <remarks> /// Seuls les éléments <see cref="ToolStripItem"/> étirables (pour lesquels <see cref="IsSpring"/> retourne true) /// des conteneurs <see cref="ToolStrip"/> sont étirés par cette méthode. /// <br/> /// Si la rangée comporte un ou plusieurs conteneur comportant un ou plusieurs éléments étirables, /// l'étirement s'effectue au pro rata de la taille actuels des éléments étirables de telle manière /// que la rangée soit complètement occupée. /// </remarks> /// <param name="row">rangée dont les éléments sont à redimensionner</param> private void DoRearrangeRow( ToolStripPanelRow row ) { // récupérer les contrôles de la tangée Control[] controls = DoGetControlsOfRow( row ); if ( controls == null || controls.Length == 0 ) return; // initialisations des infos int fixWidth = 7 + row.Margin.Horizontal + row.Padding.Horizontal; int varWidth = 0; int varCount = 0; // récupérer les infos de dimensions horizontales for ( int ix = 0 ; ix < controls.Length ; ix++ ) { ToolStrip strip = (ToolStrip) controls[ ix ]; if ( !strip.Visible ) continue; // dimensions horizontales hors éléments contenus fixWidth += 2 + strip.GripRectangle.Width + strip.GripMargin.Horizontal + strip.Padding.Horizontal + strip.Margin.Horizontal; // déterminer les largeurs fixes et variables for ( int iy = 0 ; iy < strip.Items.Count ; iy++ ) { ToolStripItem item = strip.Items[ iy ]; if ( IsSpring( item ) ) { varCount++; varWidth += item.Width; fixWidth += item.Margin.Horizontal; } else fixWidth += item.Width + item.Margin.Horizontal; } } // facteur d'étirement float factor = 0; if ( varCount != 0 ) { int newWidth = row.Bounds.Width; int remains = newWidth - fixWidth; if ( varWidth == 0 ) varWidth = varCount; factor = Math.Abs( (float) remains / (float) varWidth ); } // ancre de placement horizontal int leftAnchor = row.Bounds.Left; // tenter d'expanser le conteneur strip for ( int ix = 0 ; ix < controls.Length ; ix++ ) { ToolStrip strip = (ToolStrip) controls[ ix ]; bool stripChanged = false; // position horizontale du contrôle Point location = new Point( leftAnchor, row.Bounds.Top ); if ( strip.Location != location ) strip.Location = location; // largeur du contrôle s'il est étirable if ( factor != 0 ) { for ( int iy = 0 ; iy < strip.Items.Count ; iy++ ) { ToolStripItem item = strip.Items[ iy ]; if ( !IsSpring( item ) ) continue; int width = Convert.ToInt32(item.Width * factor); if ( width < 1 ) width = 1; if (item.Width != width) { item.Width = width; stripChanged = true; } } } // forcer le conteneur à être mis à jour en fonction de la nouvelle dimension if (stripChanged) base.OnLayout(new LayoutEventArgs(strip, "PreferredSize")); // prochaine position possible if ( strip.Visible ) leftAnchor += strip.Width; } }
public void Insert (int index, ToolStripPanelRow value) { base.Insert (index, value); }
public void CopyTo (ToolStripPanelRow[] array, int index) { base.CopyTo (array, index); }
public void AddRange (ToolStripPanelRow[] value) { if (value == null) throw new ArgumentNullException ("value"); foreach (ToolStripPanelRow tspr in value) this.Add (tspr); }
public ToolStripPanelRowCollection (ToolStripPanel owner, ToolStripPanelRow[] value) : this (owner) { if (value != null) foreach (ToolStripPanelRow tspr in value) this.Add (tspr); }
private void SaveToolStripRow(ToolStripPanelRow Row, ToolStripSettings newSettings, string Position, int rowIndex) { foreach(ToolStrip strip in Row.Controls) { //if(strip != menuStrip) { ToolStripSetting setting = new ToolStripSetting(); setting.Dock = Position; setting.Row = rowIndex; setting.Left = strip.Left; setting.Top = strip.Top; setting.Name = strip.Name; setting.Visible = strip.Visible; newSettings.Add(setting); //} } }
public void Insert(int index, ToolStripPanelRow value) { if (value == null) { throw new ArgumentNullException("value"); } base.InnerList.Insert(index, value); this.OnAdd(value, index); }
public void AddRange(ToolStripPanelRow[] value) { if (value == null) { throw new ArgumentNullException("value"); } ToolStripPanel owner = this.owner; if (owner != null) { owner.SuspendLayout(); } try { for (int i = 0; i < value.Length; i++) { this.Add(value[i]); } } finally { if (owner != null) { owner.ResumeLayout(); } } }
public int Add(ToolStripPanelRow value) { if (value == null) { throw new ArgumentNullException("value"); } int index = base.InnerList.Add(value); this.OnAdd(value, index); return index; }
public ToolStripPanelRowCollection(ToolStripPanel owner, ToolStripPanelRow[] value) { this.owner = owner; this.AddRange(value); }
public HorizontalRowManager(ToolStripPanelRow owner) : base(owner) { owner.SuspendLayout(); base.FlowLayoutSettings.WrapContents = false; base.FlowLayoutSettings.FlowDirection = FlowDirection.LeftToRight; owner.ResumeLayout(false); }
public VerticalRowManager(ToolStripPanelRow owner) : base(owner) { owner.SuspendLayout(); base.FlowLayoutSettings.WrapContents = false; base.FlowLayoutSettings.FlowDirection = FlowDirection.TopDown; owner.ResumeLayout(false); }
public ToolStripPanelRowManager(ToolStripPanelRow owner) { this.owner = owner; }
public ToolStripPanelRowControlCollection(ToolStripPanelRow owner, Control[] value) { this.owner = owner; this.AddRange(value); }
private void OnAdd(ToolStripPanelRow value, int index) { if (this.owner != null) { LayoutTransaction.DoLayout(this.owner, value, PropertyNames.Parent); } }
private void OnAfterRemove(ToolStripPanelRow row) { }
private void AddControlToRows (Control control) { if (this.rows.Count > 0) if (this.rows[this.rows.Count - 1].CanMove ((ToolStrip)control)) { this.rows[this.rows.Count - 1].OnControlAdded (control, 0); return; } ToolStripPanelRow new_row = new ToolStripPanelRow (this); if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right) new_row.SetBounds (new Rectangle (0, 0, 25, this.Height)); else new_row.SetBounds (new Rectangle (0, 0, this.Width, 25)); this.rows.Add (new_row); new_row.OnControlAdded (control, 0); }
public void Remove(ToolStripPanelRow value) { base.InnerList.Remove(value); this.OnAfterRemove(value); }
public int Add (ToolStripPanelRow value) { return base.Add (value); }
private void MoveInsideContainer(ToolStrip toolStripToDrag, Point clientLocation) { ISupportToolStripPanel panel = toolStripToDrag; if (!panel.IsCurrentlyDragging || this.DragBounds.Contains(clientLocation)) { bool flag = false; ClearDragFeedback(); if ((((toolStripToDrag.Site != null) && toolStripToDrag.Site.DesignMode) && base.IsHandleCreated) && ((clientLocation.X < 0) || (clientLocation.Y < 0))) { Point pt = base.PointToClient(WindowsFormsUtils.LastCursorPoint); if (base.ClientRectangle.Contains(pt)) { clientLocation = pt; } } ToolStripPanelRow toolStripPanelRow = panel.ToolStripPanelRow; bool flag2 = false; if (((toolStripPanelRow != null) && toolStripPanelRow.Visible) && (toolStripPanelRow.ToolStripPanel == this)) { if (toolStripToDrag.IsCurrentlyDragging) { flag2 = toolStripPanelRow.DragBounds.Contains(clientLocation); } else { flag2 = toolStripPanelRow.Bounds.Contains(clientLocation); } } if (flag2) { panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), clientLocation); } else { ToolStripPanelRow row2 = this.PointToRow(clientLocation); if (row2 == null) { int count = this.RowsInternal.Count; if (this.Orientation == System.Windows.Forms.Orientation.Horizontal) { count = (clientLocation.Y <= base.Padding.Left) ? 0 : count; } else { count = (clientLocation.X <= base.Padding.Left) ? 0 : count; } ToolStripPanelRow row3 = null; if (this.RowsInternal.Count > 0) { if (count == 0) { row3 = this.RowsInternal[0]; } else if (count > 0) { row3 = this.RowsInternal[count - 1]; } } if (((row3 != null) && (row3.ControlsInternal.Count == 1)) && row3.ControlsInternal.Contains(toolStripToDrag)) { row2 = row3; if (toolStripToDrag.IsInDesignMode) { Point endClientLocation = (this.Orientation == System.Windows.Forms.Orientation.Horizontal) ? new Point(clientLocation.X, row2.Bounds.Y) : new Point(row2.Bounds.X, clientLocation.Y); panel.ToolStripPanelRow.MoveControl(toolStripToDrag, this.GetStartLocation(toolStripToDrag), endClientLocation); } } else { row2 = new ToolStripPanelRow(this); this.RowsInternal.Insert(count, row2); } } else if (!row2.CanMove(toolStripToDrag)) { int index = this.RowsInternal.IndexOf(row2); if (((toolStripPanelRow != null) && (toolStripPanelRow.ControlsInternal.Count == 1)) && ((index > 0) && ((index - 1) == this.RowsInternal.IndexOf(toolStripPanelRow)))) { return; } row2 = new ToolStripPanelRow(this); this.RowsInternal.Insert(index, row2); clientLocation.Y = row2.Bounds.Y; } flag = toolStripPanelRow != row2; if ((!flag && (toolStripPanelRow != null)) && (toolStripPanelRow.ControlsInternal.Count > 1)) { toolStripPanelRow.LeaveRow(toolStripToDrag); toolStripPanelRow = null; flag = true; } if (flag) { if (toolStripPanelRow != null) { toolStripPanelRow.LeaveRow(toolStripToDrag); } row2.JoinRow(toolStripToDrag, clientLocation); } if (flag && panel.IsCurrentlyDragging) { for (int i = 0; i < this.RowsInternal.Count; i++) { LayoutTransaction.DoLayout(this.RowsInternal[i], this, PropertyNames.Rows); } if (this.RowsInternal.IndexOf(row2) > 0) { System.Windows.Forms.IntSecurity.AdjustCursorPosition.Assert(); try { Point point3 = toolStripToDrag.PointToScreen(toolStripToDrag.GripRectangle.Location); if (this.Orientation == System.Windows.Forms.Orientation.Vertical) { point3.X += toolStripToDrag.GripRectangle.Width / 2; point3.Y = Cursor.Position.Y; } else { point3.Y += toolStripToDrag.GripRectangle.Height / 2; point3.X = Cursor.Position.X; } Cursor.Position = point3; } finally { CodeAccessPermission.RevertAssert(); } } } } } }
public bool Contains (ToolStripPanelRow value) { return base.Contains (value); }
public void Remove(ToolStripPanelRow value) { InnerList.Remove(value); OnAfterRemove(value); }
public int IndexOf (ToolStripPanelRow value) { return base.IndexOf (value); }
public bool Contains(ToolStripPanelRow value) { return(InnerList.Contains(value)); }
public void Remove (ToolStripPanelRow value) { base.Remove (value); }
public int IndexOf(ToolStripPanelRow value) { return(InnerList.IndexOf(value)); }
/// <summary> /// Comprime en largeur les conteneurs <see cref="ToolStrip"/> d'une rangée. /// </summary> /// <param name="row">rangée à comprimer</param> private void DoShrinkRow( ToolStripPanelRow row ) { int leftAnchor = 0; Control[] strips = row.Controls; for ( int ix = 0 ; ix < strips.Length ; ix++ ) { ToolStrip strip = (ToolStrip) strips[ ix ]; Point location = new Point( leftAnchor, row.Bounds.Top ); if ( strip.Location != location ) strip.Location = location; DoShrinkToolStrip( strip ); //OnLayout(new LayoutEventArgs(strip, "Bounds")); //OnLayout(new LayoutEventArgs(strip, "PreferredSize")); if ( strip.Visible ) leftAnchor += strip.Width; } }
private static void SaveToolStripRow(ToolStripPanelRow row, ToolStripSettings newSettings, String position, int rowIndex) { foreach (ToolStrip strip in row.Controls) { ToolStripSetting setting = new ToolStripSetting(); setting.Dock = position; setting.Row = rowIndex; setting.Left = strip.Left; setting.Top = strip.Top; setting.Name = strip.Name; setting.Visible = strip.Visible; newSettings.Add(newSettings.Count, setting); } }
/// <summary> /// Récupérer le tableau des contrôles associé à une rangée /// </summary> /// <remarks> /// Lorsque les rangées sont en cours de glissement via la souris, l'accès à la propriété /// Controls d'une rangée provoque une exception. Je n'ai pas trouvé de moyen pour contourner /// cette difficulté en évitant l'exception. /// </remarks> /// <param name="row">rangée contenant les contrôles ou null</param> /// <returns>tableau des contrôles ou null</returns> private Control[] DoGetControlsOfRow( ToolStripPanelRow row ) { try { return row.Controls; } catch { return new Control[ 0 ]; } }
public ToolStripPanelRowControlCollection(ToolStripPanelRow owner) { this.owner = owner; }