public void SetControlRelativeValue(LayoutParameterEx lp, string strValue) { Debug.Assert(strValue != null); if (strValue == null) { throw new ArgumentNullException("strValue"); } if (strValue.Length > 0) { strValue += m_strControlRelative; } if (lp == LayoutParameterEx.X) { m_strPosX = strValue; } else if (lp == LayoutParameterEx.Y) { m_strPosY = strValue; } else if (lp == LayoutParameterEx.Width) { m_strSizeW = strValue; } else if (lp == LayoutParameterEx.Height) { m_strSizeH = strValue; } else { Debug.Assert(false); } }
private static int?GetModControlParameter(Control c, LayoutParameterEx p, string strModParam) { if (strModParam.Length == 0) { return(null); } Debug.Assert(c.Left == c.Location.X); Debug.Assert(c.Top == c.Location.Y); Debug.Assert(c.Width == c.Size.Width); Debug.Assert(c.Height == c.Size.Height); int iPrev; if (p == LayoutParameterEx.X) { iPrev = c.Left; } else if (p == LayoutParameterEx.Y) { iPrev = c.Top; } else if (p == LayoutParameterEx.Width) { iPrev = c.Width; } else if (p == LayoutParameterEx.Height) { iPrev = c.Height; } else { Debug.Assert(false); return(null); } double?dRel = ToControlRelativePercent(strModParam); if (dRel.HasValue) { return(iPrev + (int)((dRel.Value * (double)iPrev) / 100.0)); } Debug.Assert(false); return(null); }