public void PaddingOperatorTest() { Padding pad = new Padding(0); Assert.AreEqual(Padding.Empty, pad, "#A1"); Padding pad1 = new Padding(2, 4, 6, 8); Padding pad2 = new Padding(5, 5, 10, 11); Padding pad3 = pad1 + pad2; Assert.AreEqual(-1, pad3.All, "#B1"); Assert.AreEqual("{Left=7,Top=9,Right=16,Bottom=19}", pad3.ToString(), "#B2"); pad3 = Padding.Add(pad1, pad2); Assert.AreEqual(-1, pad3.All, "#C1"); Assert.AreEqual("{Left=7,Top=9,Right=16,Bottom=19}", pad3.ToString(), "#C2"); Padding pad4 = pad3 - pad1; Assert.AreEqual(-1, pad4.All, "#D1"); Assert.AreEqual("{Left=5,Top=5,Right=10,Bottom=11}", pad4.ToString(), "#D2"); pad4 = Padding.Subtract(pad3, pad1); Assert.AreEqual(-1, pad4.All, "#E1"); Assert.AreEqual("{Left=5,Top=5,Right=10,Bottom=11}", pad4.ToString(), "#E2"); }
private void AddPaddingBlock() { if (Input.Length % Cipher.BlockSize == 0) { Padding.Add(Block); Block = Cipher.Encrypt(Block); WriteBlock(); } }
protected override void OnDataGridViewChanged() { try { Padding dropDownPadding = new Padding(0, 0, 20, 0); this.Style.Padding = Padding.Add(this.InheritedStyle.Padding, dropDownPadding); } catch { } base.OnDataGridViewChanged(); }
private void AddPaddingBlock(byte[] previousBlock) { if (Input.Length % Cipher.BlockSize == 0) { Padding.Add(Block); Block = Block.XOR(previousBlock); Block = Cipher.Encrypt(Block); WriteBlock(); } }
private void AdjustPadding(int newDropDownButtonPaddingOffset) { int right = newDropDownButtonPaddingOffset - this.currentDropDownButtonPaddingOffset; if (right != 0) { this.currentDropDownButtonPaddingOffset = newDropDownButtonPaddingOffset; Padding padding = new Padding(0, 0, right, 0); base.Style.Padding = Padding.Add(base.InheritedStyle.Padding, padding); } }
private void PrepareRibbonBarForCompositionState() { RadRibbonBar ribbonBar = this.RibbonBar; if (ribbonBar == null) { return; } if (oldRadRibbonBarElementSettings == null) { oldRadRibbonBarElementSettings = new List <object>(); } if (this.CompositionEffectsEnabled) { if (this.oldRadRibbonBarElementSettings.Count == 0) { this.oldRadRibbonBarElementSettings.Add(ribbonBar.RibbonBarElement.CaptionFill.Visibility); this.oldRadRibbonBarElementSettings.Add(ribbonBar.RootElement.BackColor); this.oldRadRibbonBarElementSettings.Add(ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Visibility); this.oldRadRibbonBarElementSettings.Add(ribbonBar.QuickAccessToolBarHeight); this.oldRadRibbonBarElementSettings.Add(ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Margin); } ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Margin = Padding.Add(ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Margin, new Padding(20, 0, 0, 0)); ribbonBar.RibbonBarElement.CaptionFill.Visibility = ElementVisibility.Hidden; ribbonBar.RootElement.BackColor = Color.Transparent; ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Visibility = ElementVisibility.Hidden; ribbonBar.QuickAccessToolBarHeight = 27; if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1) { ribbonBar.RibbonBarElement.RibbonTabStripHolder.Children[0].PositionOffset = new Size(0, 3); } else { ribbonBar.RibbonBarElement.RibbonTabStripHolder.Children[0].PositionOffset = new Size(0, 1); } } else { if (this.oldRadRibbonBarElementSettings.Count > 0) { ribbonBar.RibbonBarElement.CaptionFill.Visibility = (ElementVisibility)this.oldRadRibbonBarElementSettings[0]; ribbonBar.RootElement.BackColor = (Color)this.oldRadRibbonBarElementSettings[1]; ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Visibility = (ElementVisibility)this.oldRadRibbonBarElementSettings[2]; ribbonBar.QuickAccessToolBarHeight = (int)this.oldRadRibbonBarElementSettings[3]; ribbonBar.RibbonBarElement.RibbonCaption.SystemButtons.Margin = (Padding)oldRadRibbonBarElementSettings[4]; ribbonBar.RibbonBarElement.RibbonTabStripHolder.Children[0].PositionOffset = new Size(0, 0); } } }
private Padding CalculateNCMetrics() { Padding borderThickness = this.GetBorderThickness(false); int headerTopMargin = this.Header.Visibility == ElementVisibility.Visible ? this.Header.Margin.Top : 0; int footerBottomMargin = this.Footer.Visibility == ElementVisibility.Visible ? this.Footer.Margin.Bottom : 0; Padding headerPadding = new Padding( 0, (int)this.Header.DesiredSize.Height + headerTopMargin, 0, (int)this.Footer.DesiredSize.Height + footerBottomMargin); return(Padding.Add(borderThickness, headerPadding)); }
internal Padding GetBorderThickness() { Padding result = this.ownBorderThickness = this.GetOwnBorderThickness(); for (int i = 0; i < this.Children.Count; i++) { if (this.Children[i] is BorderPrimitive) { BorderPrimitive childBorder = this.Children[i] as BorderPrimitive; result = Padding.Add(result, childBorder.GetBorderThickness()); } } this.BorderThickness = result; return(result); }
protected virtual Padding GetContentMargin() { if (this.panelElement.Border.Visibility != ElementVisibility.Visible) { return(Padding.Empty); } Padding p2 = this.panelElement.BorderThickness; if (this.RootElement.Shape != null && this.RootElement.ApplyShapeToControl && this.RootElement.Shape is RoundRectShape) { RoundRectShape shape = this.RootElement.Shape as RoundRectShape; p2 = Padding.Add(new Padding((int)((double)shape.Radius - Math.Sqrt((double)(shape.Radius * shape.Radius / 2)))), p2); } return(p2); }
public Padding GetBorderThickness() { Padding p1 = this.ownBorderThickness = this.GetOwnBorderThickness(); for (int index = 0; index < this.Children.Count; ++index) { if (this.Children[index] is BorderPrimitive) { BorderPrimitive child = this.Children[index] as BorderPrimitive; p1 = Padding.Add(p1, child.GetBorderThickness()); } } this.BorderThickness = p1; return(p1); }
protected override void OnDataGridViewChanged() { try { Padding dropDownPadding = new Padding(0, 0, 20, 0); if (this.InheritedStyle != null) { Style.Padding = Padding.Add(this.InheritedStyle.Padding, dropDownPadding); } } catch (NullReferenceException e) { Debug.WriteLine(e.Message); } base.OnDataGridViewChanged(); }
/// <summary> /// Adjusts the cell padding to widen the header by the drop-down button width. /// </summary> /// <param name="newDropDownButtonPaddingOffset">The new drop-down button width.</param> private void AdjustPadding(int newDropDownButtonPaddingOffset) { // Determine the difference between the new and current padding adjustment. int widthChange = newDropDownButtonPaddingOffset - _dropDownButtonPaddingOffset; // If the padding needs to change, store the new value and make the change. if (widthChange != 0) { // Store the offset for the drop-down button separately from the padding in case the client needs additional padding. _dropDownButtonPaddingOffset = newDropDownButtonPaddingOffset; // Create a new Padding using the adjustment amount, then add it to the cell's existing Style.Padding property value. Padding dropDownPadding = new Padding(0, 0, widthChange, 0); this.Style.Padding = Padding.Add(this.InheritedStyle.Padding, dropDownPadding); } }
private void ArrangeLayout(int length) { if (length == 3) { return; } button3.Visible = false; if (length == 2) { return; } button2.Visible = false; tableLayoutPanel2.Anchor = AnchorStyles.Right; var margin = tableLayoutPanel2.Margin; tableLayoutPanel2.Margin = Padding.Add(margin, new Padding(0, 0, 10, 0)); }
/// <summary> /// Calculates the non-client margin of the control /// based on the radius of the round rect shape. /// </summary> /// <returns>An instance of the <see cref="System.Windows.Forms.Padding"/> struct /// which represents the left, top, right and bottom margin.</returns> protected virtual Padding GetContentMargin() { if (this.panelElement.Border.Visibility == ElementVisibility.Visible) { Padding result = this.panelElement.BorderThickness; if (this.RootElement.Shape != null && this.RootElement.ApplyShapeToControl && this.RootElement.Shape is RoundRectShape) { RoundRectShape rRectShape = this.RootElement.Shape as RoundRectShape; int ncOffset = (int)(rRectShape.Radius - Math.Sqrt(rRectShape.Radius * rRectShape.Radius / 2)); result = Padding.Add(new Padding(ncOffset), result); } return(result); } return(Padding.Empty); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var lbl = new Label() { Padding = Padding.Add(new Padding(3), new Padding(3)) }; var frm = new Form1 { Controls = { lbl } }; IObservable <EventPattern <MouseEventArgs> > move = Observable.FromEventPattern <MouseEventArgs>(frm, "MouseMove"); move.Subscribe(evt => { lbl.Text = evt.EventArgs.Location.ToString(); }); Application.Run(frm); }
/// <summary> /// 调整单元格填充以按下拉按钮宽度加宽标题。 /// </summary> /// <param name="newDropDownButtonPaddingOffset">新的下拉按钮宽度。</param> private void AdjustPadding(Int32 newDropDownButtonPaddingOffset) { // 确定新填充调整和当前填充调整之间的差值 Int32 widthChange = newDropDownButtonPaddingOffset - currentDropDownButtonPaddingOffset; // 如果填充需要更改,请存储新值并进行更改。 if (widthChange != 0) { // 将下拉按钮的偏移量与填充分开存储,以防客户端需要额外的填充。 currentDropDownButtonPaddingOffset = newDropDownButtonPaddingOffset; // 使用调整金额创建新的填充,然后将其添加到单元格的现有 Style.pad 属性值中。 Padding dropDownPadding = new Padding(0, 0, widthChange, 0); Style.Padding = Padding.Add( InheritedStyle.Padding, dropDownPadding); } }
protected override SizeF MeasureContentCore(SizeF availableSize, SizeF desiredSize) { if (this.Data == null || this.IsDesignMode) { return(SizeF.Empty); } float num1 = 0.0f; float num2 = 0.0f; if (this.Data.Owner.ShowCheckBoxes) { switch (this.Data.Owner.CheckBoxesPosition) { case CheckBoxesPosition.Left: case CheckBoxesPosition.Right: num1 = this.ToggleElement.DesiredSize.Width; break; default: num2 = this.ToggleElement.DesiredSize.Height; break; } } desiredSize.Width += num1; desiredSize.Height += num2; RadListViewElement owner = this.Data.Owner; if (owner == null) { return(desiredSize); } bool arbitraryItemWidth = owner.AllowArbitraryItemWidth; bool arbitraryItemHeight = owner.AllowArbitraryItemHeight; CardListViewElement viewElement = owner.ViewElement as CardListViewElement; SizeF itemSize = (SizeF)owner.ItemSize; if (viewElement.CardTemplate.ContainerElement.LayoutTree.Root != null) { if (arbitraryItemWidth) { itemSize.Width = viewElement.CardTemplate.ContainerElement.LayoutTree.Root.Bounds.Width; } if (arbitraryItemHeight) { itemSize.Height = viewElement.CardTemplate.ContainerElement.LayoutTree.Root.Bounds.Height; } } desiredSize = itemSize; if (!arbitraryItemHeight && !arbitraryItemWidth) { this.layoutContainer.Measure(desiredSize); this.UpdateScrollbars(desiredSize); } else if (arbitraryItemHeight && !arbitraryItemWidth) { desiredSize.Width = itemSize.Width + num1; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { this.layoutContainer.Measure((SizeF) new Size(1, 1)); desiredSize.Height = this.layoutContainer.LayoutTree.Root.Bounds.Height; this.layoutContainer.Measure(desiredSize); } if (this.HorizontalScrollBar.Visibility != ElementVisibility.Collapsed) { desiredSize.Height += (float)this.HorizontalScrollBar.MinSize.Height; } this.UpdateScrollbars(desiredSize); this.VerticalScrollBar.Visibility = ElementVisibility.Collapsed; desiredSize.Height += num2; if (this.Data.Size.Height > 0) { desiredSize.Height = (float)this.Data.Size.Height; } } else if (!arbitraryItemHeight && arbitraryItemWidth) { desiredSize.Height = itemSize.Height + num2; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { desiredSize.Width = this.layoutContainer.LayoutTree.Root.Bounds.Width + (this.VerticalScrollBar.Visibility != ElementVisibility.Collapsed ? (float)this.VerticalScrollBar.MinSize.Width : 0.0f); this.layoutContainer.Measure(desiredSize); } this.UpdateScrollbars(desiredSize); this.HorizontalScrollBar.Visibility = ElementVisibility.Collapsed; if (this.VerticalScrollBar.Visibility != ElementVisibility.Collapsed) { desiredSize.Width += (float)this.VerticalScrollBar.MinSize.Width; } desiredSize.Width += num1; if (this.Data.Size.Width > 0) { desiredSize.Width = (float)this.Data.Size.Width; } } else { this.VerticalScrollBar.Visibility = ElementVisibility.Collapsed; this.HorizontalScrollBar.Visibility = ElementVisibility.Collapsed; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { desiredSize = this.layoutContainer.LayoutTree.Root.Bounds.Size; } this.layoutContainer.Measure(desiredSize); desiredSize.Width += num1; desiredSize.Height += num2; if (this.Data.Size.Width > 0) { desiredSize.Width = (float)this.Data.Size.Width; } if (this.Data.Size.Height > 0) { desiredSize.Height = (float)this.Data.Size.Height; } } Padding padding = Padding.Add(this.GetBorderThickness(true), this.Padding); desiredSize = SizeF.Add(desiredSize, new SizeF((float)padding.Horizontal, (float)padding.Vertical)); this.Data.ActualSize = desiredSize.ToSize(); return(desiredSize); }
public void Padding_Add_Invoke_ReturnsExpected(Padding p1, Padding p2, Padding expected) { Assert.Equal(expected, p1 + p2); Assert.Equal(expected, Padding.Add(p1, p2)); }