// 保存Mdi Child form尺寸位置状态到ApplicationInfo中 // parameters: // form Form对象 // strCfgTitle 配置信息路径。本函数将用此值作为SetString()或SetInt()的strPath参数使用 public void SaveMdiChildFormStates(Form form, string strCfgTitle, SizeStyle style) { if ((style & SizeStyle.Size) != 0) { FormWindowState savestate = form.WindowState; Size size = form.Size; Point location = form.Location; if (form.WindowState != FormWindowState.Normal) { size = form.RestoreBounds.Size; location = form.RestoreBounds.Location; } this.SetInt(strCfgTitle, "width", size.Width); this.SetInt(strCfgTitle, "height", size.Height); this.SetInt(strCfgTitle, "x", location.X); this.SetInt(strCfgTitle, "y", location.Y); } if ((style & SizeStyle.Layout) != 0) { if (this.SaveMdiLayout != null) { this.SaveMdiLayout(form, null); } } }
public void TestParse() { var pixelSize = new SizeStyle("50px"); Assert.IsTrue(pixelSize.IsValid); Assert.AreEqual(50, pixelSize.Value); Assert.AreEqual(SizeUnit.Pixels, pixelSize.Unit); var noUnitSize = new SizeStyle("50"); Assert.IsFalse(noUnitSize.IsValid); noUnitSize = new SizeStyle("0"); Assert.IsTrue(noUnitSize.IsValid); Assert.AreEqual(0, noUnitSize.Value); Assert.AreEqual(SizeUnit.Pixels, noUnitSize.Unit); var percentSize = new SizeStyle("40%"); Assert.IsTrue(percentSize.IsValid); Assert.AreEqual(40, percentSize.Value); Assert.AreEqual(SizeUnit.Percents, percentSize.Unit); var weightSize = new SizeStyle("2*"); Assert.IsTrue(weightSize.IsValid); Assert.AreEqual(2, weightSize.Value); Assert.AreEqual(SizeUnit.Weight, weightSize.Unit); }
public void Size_ConstructorTest() { SizeStyle target = new SizeStyle(); Assert.IsNotNull(target); Assert.AreEqual(StyleKeys.SizeItemKey, target.ItemKey); }
public void Size_WidthTest() { SizeStyle target = new SizeStyle(); // Default value PDFUnit expected = PDFUnit.Empty; PDFUnit actual = target.Width; Assert.AreEqual(expected, actual); // Set Value expected = 20; target.Width = expected; actual = target.Width; Assert.AreEqual(expected, actual); // Change Value expected = new PDFUnit(120, PageUnits.Millimeters); target.Width = expected; actual = target.Width; Assert.AreEqual(expected, actual); // Remove Value expected = PDFUnit.Empty; target.RemoveWidth(); actual = target.Width; Assert.AreEqual(expected, actual); }
private void method_1() { this.bool_0 = false; if (this.mapTemplateElement_0 != null) { SizeStyle sizeStyle = (this.mapTemplateElement_0 as MapTemplateGroupElement).SizeStyle; double sizeScale = (this.mapTemplateElement_0 as MapTemplateGroupElement).SizeScale; if (sizeStyle == SizeStyle.Fixed) { this.rdoFiexdSize.Checked = true; this.txtScale.Enabled = false; } else if (sizeStyle == SizeStyle.InsideWidthScale) { this.rdoWidthScale.Checked = true; this.txtScale.Enabled = true; } else { this.rdoSameAsWidth.Checked = true; this.txtScale.Enabled = false; } this.txtScale.Text = sizeScale.ToString(); } this.bool_0 = true; }
public UIImage() : base() { Name = "图标按钮"; SizeStyle = SizeStyle.Inline; Texture = Main.magicPixel; Color = Color.White; }
public UILabel() : base() { Text = "文字"; TextScale = 1f; TextColor = Color.White; BackgroundColor = Color.Transparent; IsLargeText = false; SizeStyle = SizeStyle.Inline; }
/// <summary> /// 渲染箭头(固定大小) /// </summary> /// <param name="rect">渲染区域</param> /// <param name="direction">箭头方向</param> /// <param name="style">大小样式</param> public void RenderArrow(Rectangle rect, ArrowDirection direction, SizeStyle style) { if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect)) { return; } this.CurrentTextPreferredRect = rect; RenderEngine.DrawArrow(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor, direction, style); }
// 包装后的版本 public void LoadMdiChildFormStates(Form form, string strCfgTitle, SizeStyle style) { LoadMdiChildFormStates(form, strCfgTitle, style, 600, 400); }
// 包装后的版本 public void LoadMdiChildFormStates(Form form, string strCfgTitle, SizeStyle style) { // 默认值可以按照屏幕分辨率估算 int nDefaultWidth = (int)(((double)Screen.PrimaryScreen.WorkingArea.Width) * 0.5); int nDefaultHeight = (int)(((double)Screen.PrimaryScreen.WorkingArea.Height) * 0.7); LoadMdiChildFormStates(form, strCfgTitle, style, nDefaultWidth, // 600, nDefaultHeight // 400 ); }
private float ComputeFilledWidth(VisualElement element, VisualElement child, DimensionalElement container, float remainingWidth) { SizeStyle widthStyle = child.Styles.Width; float margin; if (widthStyle != null) { switch (widthStyle.Unit) { case SizeUnit.Weight: margin = ComputeHorizontalMargin(element, child, container); child.Width = ((remainingWidth - margin) / element.TotalWidthWeight) * widthStyle.Value; return(child.BoxWidth); } } return(0); }
private float ComputeFilledHeight(VisualElement element, VisualElement child, DimensionalElement container, float remainingHeight) { SizeStyle heightStyle = child.Styles.Height; float margin; if (heightStyle != null) { switch (heightStyle.Unit) { case SizeUnit.Weight: margin = ComputeVerticalMargin(element, child, container); child.Height = ((remainingHeight - margin) / element.TotalHeightWeight) * heightStyle.Value; return(child.BoxHeight); } } return(0); }
public void Size_FullWidthTest() { SizeStyle target = new SizeStyle(); bool expected = false; Assert.AreEqual(expected, target.FullWidth); expected = true; target.FullWidth = expected; bool actual = target.FullWidth; Assert.AreEqual(expected, actual); expected = false; target.FullWidth = expected; actual = target.FullWidth; Assert.AreEqual(expected, actual); expected = false; target.RemoveFillWidth(); Assert.AreEqual(expected, actual); }
// http://blogs.msdn.com/b/rprabhu/archive/2005/11/28/497792.aspx // 2015/10/12 优化 // 从ApplicationInfo中读取信息,设置MDI Child form尺寸位置状态 // 和一般Form的区别是,不修改x,y信息 // parameters: // form Form对象 // strCfgTitle 配置信息路径。本函数将用此值作为GetString()或GetInt()的strPath参数使用 // strStyle size/layout 之一或者组合 public void LoadMdiChildFormStates(Form form, string strCfgTitle, SizeStyle style, int nDefaultWidth, int nDefaultHeight) { if ((style & SizeStyle.Size) != 0) { form.Size = new Size(this.GetInt( strCfgTitle, "width", nDefaultWidth), this.GetInt( strCfgTitle, "height", nDefaultHeight)); } if ((style & SizeStyle.Layout) != 0) { if (this.LoadMdiLayout != null) { this.LoadMdiLayout(form, null); } } }
private float ComputeHeight(VisualElement element, VisualElement child, DimensionalElement container) { SizeStyle heightStyle = child.Styles.Height; if (heightStyle != null) { switch (heightStyle.Unit) { case SizeUnit.Pixels: ComputeVerticalMargin(element, child, container); child.Height = heightStyle.Value; return(child.BoxHeight); case SizeUnit.Percents: ComputeVerticalMargin(element, child, container); child.Height = (container.Height / 100) * heightStyle.Value; return(child.BoxHeight); } } return(0); }
private float ComputeWidth(VisualElement element, VisualElement child, DimensionalElement container) { SizeStyle widthStyle = child.Styles.Width; if (widthStyle != null) { switch (widthStyle?.Unit) { case SizeUnit.Pixels: ComputeHorizontalMargin(element, child, container); child.Width = widthStyle.Value; return(child.BoxWidth); case SizeUnit.Percents: ComputeHorizontalMargin(element, child, container); child.Width = (container.Width / 100) * widthStyle.Value; return(child.BoxWidth); } } return(0); }
private VisualElement GetTestLayout(SizeStyle width, SizeStyle height) { var root = new VisualElement(); root.Styles.Layout = new LayoutStyle { Type = LayoutType.Row }; root.Styles.Background = new BackgroundStyle { Color = Color.WhiteSmoke }; var el1 = new VisualElement(); el1.Styles.Width = width; el1.Styles.Height = height; el1.Styles.Background = new BackgroundStyle { Color = Color.Red }; root.AddChildren(el1); return(root); }