public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { if ((button != MouseButtons.Left) || !(g is TableLayoutPanelResizeGlyph)) { goto Label_02E0; } this.tableGlyph = g as TableLayoutPanelResizeGlyph; ISelectionService service = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { service.SetSelectedComponents(new object[] { this.designer.Component }, SelectionTypes.Click); } bool isColumn = this.tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; this.lastMouseLoc = mouseLoc; this.resizeProp = TypeDescriptor.GetProperties(this.tableGlyph.Style)[isColumn ? "Width" : "Height"]; IComponentChangeService service2 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service2 != null) { this.changedProp = TypeDescriptor.GetProperties(this.table)[isColumn ? "ColumnStyles" : "RowStyles"]; int[] widths = isColumn ? this.table.GetColumnWidths() : this.table.GetRowHeights(); if (this.changedProp != null) { this.GetActiveStyleCollection(isColumn); if ((this.styles != null) && this.CanResizeStyle(widths)) { IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host != null) { this.resizeTransaction = host.CreateTransaction(System.Design.SR.GetString("TableLayoutPanelRowColResize", new object[] { isColumn ? "Column" : "Row", this.designer.Control.Site.Name })); } try { int index = this.styles.IndexOf(this.tableGlyph.Style); this.rightStyle.index = this.IndexOfNextStealableStyle(true, index, widths); this.rightStyle.style = (TableLayoutStyle) this.styles[this.rightStyle.index]; this.rightStyle.styleProp = TypeDescriptor.GetProperties(this.rightStyle.style)[isColumn ? "Width" : "Height"]; this.leftStyle.index = this.IndexOfNextStealableStyle(false, index, widths); this.leftStyle.style = (TableLayoutStyle) this.styles[this.leftStyle.index]; this.leftStyle.styleProp = TypeDescriptor.GetProperties(this.leftStyle.style)[isColumn ? "Width" : "Height"]; service2.OnComponentChanging(this.table, this.changedProp); goto Label_02CD; } catch (CheckoutException exception) { if ((CheckoutException.Canceled.Equals(exception) && (this.resizeTransaction != null)) && !this.resizeTransaction.Canceled) { this.resizeTransaction.Cancel(); } throw; } } return false; } } Label_02CD: this.behaviorService.PushCaptureBehavior(this); this.pushedBehavior = true; Label_02E0: return false; }
public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) { if ((button != MouseButtons.Left) || !(g is TableLayoutPanelResizeGlyph)) { goto Label_02E0; } this.tableGlyph = g as TableLayoutPanelResizeGlyph; ISelectionService service = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { service.SetSelectedComponents(new object[] { this.designer.Component }, SelectionTypes.Click); } bool isColumn = this.tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; this.lastMouseLoc = mouseLoc; this.resizeProp = TypeDescriptor.GetProperties(this.tableGlyph.Style)[isColumn ? "Width" : "Height"]; IComponentChangeService service2 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service2 != null) { this.changedProp = TypeDescriptor.GetProperties(this.table)[isColumn ? "ColumnStyles" : "RowStyles"]; int[] widths = isColumn ? this.table.GetColumnWidths() : this.table.GetRowHeights(); if (this.changedProp != null) { this.GetActiveStyleCollection(isColumn); if ((this.styles != null) && this.CanResizeStyle(widths)) { IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host != null) { this.resizeTransaction = host.CreateTransaction(System.Design.SR.GetString("TableLayoutPanelRowColResize", new object[] { isColumn ? "Column" : "Row", this.designer.Control.Site.Name })); } try { int index = this.styles.IndexOf(this.tableGlyph.Style); this.rightStyle.index = this.IndexOfNextStealableStyle(true, index, widths); this.rightStyle.style = (TableLayoutStyle)this.styles[this.rightStyle.index]; this.rightStyle.styleProp = TypeDescriptor.GetProperties(this.rightStyle.style)[isColumn ? "Width" : "Height"]; this.leftStyle.index = this.IndexOfNextStealableStyle(false, index, widths); this.leftStyle.style = (TableLayoutStyle)this.styles[this.leftStyle.index]; this.leftStyle.styleProp = TypeDescriptor.GetProperties(this.leftStyle.style)[isColumn ? "Width" : "Height"]; service2.OnComponentChanging(this.table, this.changedProp); goto Label_02CD; } catch (CheckoutException exception) { if ((CheckoutException.Canceled.Equals(exception) && (this.resizeTransaction != null)) && !this.resizeTransaction.Canceled) { this.resizeTransaction.Cancel(); } throw; } } return(false); } } Label_02CD: this.behaviorService.PushCaptureBehavior(this); this.pushedBehavior = true; Label_02E0: return(false); }
public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) { GlyphCollection glyphs = base.GetGlyphs(selectionType); PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component)["Locked"]; bool flag = (descriptor != null) ? ((bool) descriptor.GetValue(base.Component)) : false; bool flag2 = this.EnsureAvailableStyles(); if (((selectionType != GlyphSelectionType.NotSelected) && !flag) && (this.InheritanceAttribute != System.ComponentModel.InheritanceAttribute.InheritedReadOnly)) { Point location = base.BehaviorService.MapAdornerWindowPoint(this.Table.Handle, this.Table.DisplayRectangle.Location); Rectangle rectangle = new Rectangle(location, this.Table.DisplayRectangle.Size); Point point2 = base.BehaviorService.ControlToAdornerWindow(this.Control); Rectangle rectangle2 = new Rectangle(point2, this.Control.ClientSize); int[] columnWidths = this.Table.GetColumnWidths(); int[] rowHeights = this.Table.GetRowHeights(); int num = DesignerUtils.RESIZEGLYPHSIZE / 2; bool flag3 = this.Table.RightToLeft == RightToLeft.Yes; int y = flag3 ? rectangle.Right : rectangle.X; if (!flag2) { return glyphs; } for (int i = 0; i < (columnWidths.Length - 1); i++) { if (columnWidths[i] != 0) { if (flag3) { y -= columnWidths[i]; } else { y += columnWidths[i]; } Rectangle rect = new Rectangle(y - num, rectangle2.Top, DesignerUtils.RESIZEGLYPHSIZE, rectangle2.Height); if (rectangle2.Contains(rect) && (this.Table.ColumnStyles[i] != null)) { TableLayoutPanelResizeGlyph glyph = new TableLayoutPanelResizeGlyph(rect, this.Table.ColumnStyles[i], Cursors.VSplit, this.Behavior); glyphs.Add(glyph); } } } y = rectangle.Y; for (int j = 0; j < (rowHeights.Length - 1); j++) { if (rowHeights[j] != 0) { y += rowHeights[j]; Rectangle rectangle4 = new Rectangle(rectangle2.Left, y - num, rectangle2.Width, DesignerUtils.RESIZEGLYPHSIZE); if (rectangle2.Contains(rectangle4) && (this.Table.RowStyles[j] != null)) { TableLayoutPanelResizeGlyph glyph2 = new TableLayoutPanelResizeGlyph(rectangle4, this.Table.RowStyles[j], Cursors.HSplit, this.Behavior); glyphs.Add(glyph2); } } } } return glyphs; }