public IControlTranslator ToElement(bool transferChild) { PmsPanelWrapper panel = new PmsPanelWrapper(); panel.BackColor = this.BackColor; panel.BorderName = this.BorderName; if (null != ExternDatas && ExternDatas.Count > 0) { panel.ExternDatas = new List <ExternData>(); foreach (ExternData ed in this.ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } panel.ExternDatas.Add(new ExternData(ed.Key, value)); } } if (null != this.Border) { panel.Border = this.Border.Clone() as ElementBorder; panel.Border.OwnerElement = panel; } panel.Transparent = this.Transparent; panel.ForeColor = this.ForeColor; panel.HasBottomBorder = this.HasBottomBorder; panel.HasLeftBorder = this.HasLeftBorder; panel.HasRightBorder = this.HasRightBorder; panel.HasTopBorder = this.HasTopBorder; panel.HasBorder = HasBorder; panel.Visible = Visible; panel.MESType = MESType; if (_orginalHeight > 0) { panel.Height = this._orginalHeight; } else { panel.Height = this.Height; } if (_orginalWidth > 0) { panel.Width = _orginalWidth; } else { panel.Width = this.Width; } panel.VerticalScale = 1f; panel.HorizontalScale = 1f; if (_orginalLocation != Point.Empty) { panel.Location = this._orginalLocation; } else { panel.Location = this.Location; } panel.Text = this.Text; panel.RealText = RealText; panel.AutoSize = AutoSize; try { if (_orginalFontSize > 0) { panel.Font = new Font(Font.FontFamily, _orginalFontSize); } else { panel.Font = new Font(this.Font.FontFamily, this.Font.Size); } } catch (Exception) { } if (null != this.SourceField) { panel.SourceField = this.SourceField.Clone() as SourceField; } panel.MoveX = this.MoveX; panel.MoveY = this.MoveY; panel.Name = this.Name; panel.TotalHeight = this.TotalHeight; panel.OrignalHeight = this.OrignalHeight; panel.VisibleExpression = VisibleExpression; if (transferChild) { IList <IElement> elements = Elements; if (null != elements && elements.Count > 0) { foreach (IElement element in elements) { if (element is IElementTranslator) { IElement tmp = ((IElementTranslator)element).ToElement(transferChild) as IElement; if (null != tmp) { panel.Elements.Add(tmp); tmp.Parent = panel; } } } } } if (null != ((IElement)this).ExtendObject) { ((IElement)panel).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(panel); }
/// <summary> /// 克隆 /// </summary> /// <returns></returns> public object Clone() { PmsPanelWrapper panel = new PmsPanelWrapper(); panel.BackColor = this.BackColor; panel.BorderName = this.BorderName; if (null != ExternDatas && ExternDatas.Count > 0) { if (null == panel.ExternDatas) { panel.ExternDatas = new List <ExternData>(); } foreach (ExternData ed in this.ExternDatas) { panel.ExternDatas.Add(ed); } } if (null != this.Border) { panel.Border = this.Border.Clone() as ElementBorder; panel.Border.OwnerElement = panel; } panel.Transparent = this.Transparent; panel.ForeColor = this.ForeColor; panel.HasBottomBorder = this.HasBottomBorder; panel.HasLeftBorder = this.HasLeftBorder; panel.HasRightBorder = this.HasRightBorder; panel.HasTopBorder = this.HasTopBorder; panel.Height = this.Height; panel.Width = this.Width; panel.VerticalScale = this.VerticalScale; panel.HorizontalScale = this.HorizontalScale; panel.Location = this.Location; panel.Text = this.Text; panel.HasBorder = this.HasBorder; panel.AutoSize = AutoSize; panel.Visible = Visible; panel.MESType = MESType; try { if (null != Font) { panel.Font = new Font(this.Font.FontFamily, this.Font.Size); } } catch (Exception) { } if (null != this.SourceField) { panel.SourceField = this.SourceField.Clone() as SourceField; } panel.MoveX = this.MoveX; panel.MoveY = this.MoveY; panel.Name = this.Name; panel.TotalHeight = this.TotalHeight; panel.OrignalHeight = this.OrignalHeight; panel.VisibleExpression = VisibleExpression; if (null != ((IElement)this).ExtendObject) { ((IElement)panel).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(panel); }
public PmsPanel(IElement element) : base() { PmsPanelWrapper panel = element as PmsPanelWrapper; BackColor = panel.BackColor; BorderName = panel.BorderName; if (null != panel.ExternDatas && panel.ExternDatas.Count > 0) { ExternDatas = new List <ExternData>(); foreach (ExternData ed in panel.ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } ExternDatas.Add(new ExternData(ed.Key, value)); } } if (null != panel.Border) { Border = panel.Border.Clone() as ElementBorder; Border.OwnerElement = this; } Transparent = panel.Transparent; ForeColor = panel.ForeColor; HasBottomBorder = panel.HasBottomBorder; HasLeftBorder = panel.HasLeftBorder; HasRightBorder = panel.HasRightBorder; HasTopBorder = panel.HasTopBorder; Height = panel.Height; Width = panel.Width; VerticalScale = panel.VerticalScale; HorizontalScale = panel.HorizontalScale; Location = panel.Location; Text = panel.Text; RealText = panel.RealText; HasBorder = panel.HasBorder; AutoSize = panel.AutoSize; try { Font = new Font(panel.Font.FontFamily, panel.Font.Size); } catch (Exception) { } if (null != panel.SourceField) { SourceField = panel.SourceField.Clone() as SourceField; } MoveX = panel.MoveX; MoveY = panel.MoveY; Name = panel.Name; TotalHeight = panel.TotalHeight; OrignalHeight = panel.OrignalHeight; VisibleExpression = panel.VisibleExpression; Visible = panel.Visible; MESType = panel.MESType; if (null != ((IElement)panel).ExtendObject) { ((IElement)this).ExtendObject = ((IElement)panel).ExtendObject.Clone() as ExtendObject; } }