当前位置: 首页>>代码示例>>C#>>正文


C# ProjectLayoutElement.DeepCopy方法代码示例

本文整理汇总了C#中CardMaker.XML.ProjectLayoutElement.DeepCopy方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectLayoutElement.DeepCopy方法的具体用法?C# ProjectLayoutElement.DeepCopy怎么用?C# ProjectLayoutElement.DeepCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CardMaker.XML.ProjectLayoutElement的用法示例。


在下文中一共展示了ProjectLayoutElement.DeepCopy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetOverrideElement

        public ProjectLayoutElement GetOverrideElement(ProjectLayoutElement zElement, int nCardIndex, List<string> arrayLine, DeckLine zDeckLine)
        {
            Dictionary<string, int> dictionaryOverrideColumns;
            string sNameLower = zElement.name.ToLower();
            DictionaryElementOverrides.TryGetValue(sNameLower, out dictionaryOverrideColumns);
            if (null == dictionaryOverrideColumns)
            {
                return zElement;
            }

            var zOverrideElement = new ProjectLayoutElement();
            zOverrideElement.DeepCopy(zElement, false);
            zOverrideElement.name = zElement.name;

            foreach (string sKey in dictionaryOverrideColumns.Keys)
            {
                Type zType = typeof(ProjectLayoutElement);
                PropertyInfo zProperty = zType.GetProperty(sKey);
                if (null != zProperty && zProperty.CanWrite)
                {
                    MethodInfo zMethod = zProperty.GetSetMethod();
                    int nOverrideValueColumnIdx = dictionaryOverrideColumns[sKey];
                    if (arrayLine.Count <= nOverrideValueColumnIdx)
                    {
                        continue;
                    }
                    string sValue = arrayLine[nOverrideValueColumnIdx].Trim();

                    // Note: TranslateString maintains an element name based cache, the key is critical to make this translation unique
                    sValue = TranslateString(sValue, nCardIndex, zDeckLine, zOverrideElement, sKey).String;

                    if (!string.IsNullOrEmpty(sValue))
                    {
                        if (zProperty.PropertyType == typeof(string))
                        {
                            zMethod.Invoke(zOverrideElement, new object[] { sValue });
                        }
                        else if (zProperty.PropertyType == typeof(float))
                        {
                            float fValue;
                            if (float.TryParse(sValue, out fValue))
                            {
                                zMethod.Invoke(zOverrideElement, new object[] { fValue });
                            }
                        }
                        else if (zProperty.PropertyType == typeof(bool))
                        {
                            bool bValue;
                            if (bool.TryParse(sValue, out bValue))
                            {
                                zMethod.Invoke(zOverrideElement, new object[] { bValue });
                            }
                        }
                        else if (zProperty.PropertyType == typeof(Int32))
                        {
                            int nValue;
                            if (int.TryParse(sValue, out nValue))
                            {
                                zMethod.Invoke(zOverrideElement, new object[] { nValue });
                            }
                        }
                    }
                }
            }
            zOverrideElement.InitializeCache(); // any cached items must be recached
            return zOverrideElement;
        }
开发者ID:nhmkdev,项目名称:cardmaker,代码行数:67,代码来源:TranslatorBase.cs

示例2: DeepCopy

 /// <summary>
 /// Performs a partial deepy copy based on the input element, the name field is left unchanged
 /// </summary>
 /// <param name="zLayout">The layout to copy from</param>
 /// <param name="bCopyRefs">Flag indicating whether to copy the refereces</param>
 public void DeepCopy(ProjectLayout zLayout, bool bCopyRefs = true)
 {
     width = zLayout.width;
     height = zLayout.height;
     defaultCount = zLayout.defaultCount;
     dpi = zLayout.dpi;
     drawBorder = zLayout.drawBorder;
     buffer = zLayout.buffer;
     combineReferences = zLayout.combineReferences;
     exportNameFormat = zLayout.exportNameFormat;
     exportRotation = zLayout.exportRotation;
     exportWidth = zLayout.exportWidth;
     exportHeight = zLayout.exportHeight;
     exportTransparentBackground = zLayout.exportTransparentBackground;
     if (null != zLayout.Element)
     {
         var listElements = new List<ProjectLayoutElement>();
         foreach (ProjectLayoutElement zElement in zLayout.Element)
         {
             var zElementCopy = new ProjectLayoutElement(zElement.name);
             zElementCopy.DeepCopy(zElement, true);
             listElements.Add(zElementCopy);
         }
         Element = listElements.ToArray();
     }
     if (bCopyRefs && null != zLayout.Reference)
     {
         var listReferences = new List<ProjectLayoutReference>();
         foreach (var zReference in zLayout.Reference)
         {
             var zReferenceCopy = new ProjectLayoutReference();
             zReferenceCopy.DeepCopy(zReference);
             listReferences.Add(zReferenceCopy);
         }
         Reference = listReferences.ToArray();
     }
 }
开发者ID:ksuquix,项目名称:cardmaker,代码行数:42,代码来源:ProjectLayout.cs

示例3: AddElements

        private void AddElements(IEnumerable<string> collectionNames, ProjectLayoutElement zBaseElement)
        {
            // construct a new list of elements
            var listElements = new List<ProjectLayoutElement>();
            if (null != LayoutManager.Instance.ActiveLayout.Element)
            {
                listElements.AddRange(LayoutManager.Instance.ActiveLayout.Element);
            }

            foreach (string sName in collectionNames)
            {
                string sTrimmed = sName.Trim();
                if (m_dictionaryItems.ContainsKey(sTrimmed)) // no duplicates!
                {
                    continue;
                }
                var zCardElement = new ProjectLayoutElement(sTrimmed);

                if (null != zBaseElement)
                {
                    zCardElement.DeepCopy(zBaseElement, true);
                }
                else
                {
                    zCardElement.lineheight = 14;
                    zCardElement.SetElementColor(Color.Black);
                    zCardElement.SetElementFont(new Font("Arial", 12));
                }
                listElements.Add(zCardElement);
                ListViewItem zLvi = CreateListViewItem(zCardElement);
                listViewElements.Items.Add(zLvi);
            }

            var zLayout = LayoutManager.Instance.ActiveLayout;
            if (null == zLayout.Element ||
                // it is possible nothing was added if all names were duplicates (skip in that case)
                zLayout.Element.Length < listElements.Count)
            {
                // UserAction
                SetupLayoutUndo(listElements);

                // assign the new list to the actual project layout
                LayoutManager.Instance.ActiveLayout.Element = listElements.ToArray();
                LayoutManager.Instance.FireLayoutUpdatedEvent(true);
            }
        }
开发者ID:nhmkdev,项目名称:cardmaker,代码行数:46,代码来源:MDILayoutControl.cs


注:本文中的CardMaker.XML.ProjectLayoutElement.DeepCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。