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


C# IFigure.Clone方法代码示例

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


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

示例1: CreateDilatedFigure

        public static List<IFigure> CreateDilatedFigure(Drawing drawing, IFigure source, IFigure center, IFigure lengthProvider1, IFigure lengthProvider2, double factor)
        {
            Check.NotNull(source, "source");
            Check.NotNull(center, "center");

            var list = new List<IFigure>() { source, center };

            var lp1 = lengthProvider1 as ILengthProvider;
            var lp2 = lengthProvider2 as ILengthProvider;
            if (lp1 != null)
            {
                if (lp2 != null)
                {
                    factor = lp1.Length / lp2.Length;
                    list.Add(lp1, lp2);
                }
                else
                {
                    factor = lp1.Length;
                    list.Add(lp1);
                }
            }

            List<IFigure> result = new List<IFigure>();
            if (source is IPoint)
            {
                var dilatedPoint = Factory.CreateDilatedPoint(drawing, list, factor);
                if (dilatedPoint == null)
                {
                    throw "dilatedPoint is null. source = {0}, center = {1}, segment1 = {2}, segment2 = {3}, factor = {4}"
                        .Format(source, center, lengthProvider1, lengthProvider2, factor)
                        .AsException();
                }
                dilatedPoint.Visible = source.Visible;
                result.Add(dilatedPoint);
            }
            else if (source is ILine || source is IEllipse || source is IPolygonalChain)
            {
                var dependencies = new List<IFigure>();
                foreach (var dependency in source.Dependencies)
                {
                    var dilatedDependency = CreateDilatedFigure(drawing, dependency, center, lengthProvider1, lengthProvider2, factor);
                    if (dilatedDependency == null)
                    {
                        throw "dilatedDependency is null. dependency = {0}, center = {1}, segment1 = {2}, segment2 = {3} factor = {2}"
                            .Format(dependency, center, lengthProvider1, lengthProvider2, factor)
                            .AsException();
                    }
                    if (dilatedDependency.IsEmpty())
                    {
                        throw "dilatedDependency is empty. dependency = {0}, center = {1}, segment1 = {2}, segment2 = {3} factor = {2}"
                            .Format(dependency, center, lengthProvider1, lengthProvider2, factor)
                            .AsException();
                    }
                    result.AddRange(dilatedDependency);
                    var last = dilatedDependency.Last();
                    if (last == null)
                    {
                        throw "last = null".AsException();
                    }
                    dependencies.Add(last);
                }
                var dilated = source.Clone();
                if (dilated == null)
                {
                    throw "dilated = null".AsException();
                }
                dilated.UnregisterFromDependencies();
                dilated.Dependencies.SetItems(dependencies);
                result.Add(dilated);
            }
            return result;
        }
开发者ID:ondrej11,项目名称:o106,代码行数:73,代码来源:Transformer.cs

示例2: CreateTranslatedFigure

 public static List<IFigure> CreateTranslatedFigure(Drawing drawing, IFigure source, List<IFigure> dependenciesSubset, double magnitude, double direction)
 {
     Check.NotNull(source, "source");
     List<IFigure> result = new List<IFigure>();
     if (source is IPoint)
     {
         var list = new List<IFigure>() { source };
         list.AddRange(dependenciesSubset);
         var translatedPoint = Factory.CreateTranslatedPoint(drawing, list, magnitude, direction);
         if (translatedPoint == null)
         {
             throw "translatedPoint is null. source = {0}, magnitude = {1}, direction = {2}"
                 .Format(source, magnitude, direction)
                 .AsException();
         }
         translatedPoint.Visible = source.Visible;
         result.Add(translatedPoint);
     }
     else if (source is ILine || source is IEllipse || source is IPolygonalChain)
     {
         var dependencies = new List<IFigure>();
         foreach (var dependency in source.Dependencies)
         {
             var translatedDependency = CreateTranslatedFigure(drawing, dependency, dependenciesSubset, magnitude, direction);
             if (translatedDependency == null)
             {
                 throw "translatedDependency is null. dependency = {0}, center = {1}, direction = {2}"
                     .Format(dependency, magnitude, direction)
                     .AsException();
             }
             if (translatedDependency.IsEmpty())
             {
                 throw "translatedDependency is empty. dependency = {0}, center = {1}, direction = {2}"
                     .Format(dependency, magnitude, direction)
                     .AsException();
             }
             result.AddRange(translatedDependency);
             var last = translatedDependency.Last();
             if (last == null)
             {
                 throw "last = null".AsException();
             }
             dependencies.Add(last);
         }
         var translated = source.Clone();
         if (translated == null)
         {
             throw "translated = null".AsException();
         }
         translated.UnregisterFromDependencies();
         translated.Dependencies = dependencies;
         result.Add(translated);
     }
     return result;
 }
开发者ID:ondrej11,项目名称:o106,代码行数:55,代码来源:Transformer.cs

示例3: CreateReflectedFigure

        public static List<IFigure> CreateReflectedFigure(Drawing drawing, IFigure source, IFigure mirror)
        {
            Check.NotNull(source, "source");
            Check.NotNull(mirror, "mirror");

            List<IFigure> result = new List<IFigure>();
            if (source is IPoint)
            {
                var reflectedPoint = Factory.CreateReflectedPoint(drawing, new [] { source, mirror });
                if (reflectedPoint == null)
                {
                    throw "reflectedPoint is null. source = {0}, mirror = {1}"
                        .Format(source, mirror)
                        .AsException();
                }
                reflectedPoint.Visible = source.Visible;
                reflectedPoint.Name = source.Name + "'";
                result.Add(reflectedPoint);
            }
            else if ((source is ILine || source is IEllipse || source is IPolygonalChain) && !(mirror is ICircle))
            {
                var dependencies = new List<IFigure>();
                foreach (var dependency in source.Dependencies)
                {
                    var reflectedDependency = CreateReflectedFigure(drawing, dependency, mirror);
                    if (reflectedDependency == null)
                    {
                        throw "reflectedDependency is null. dependency = {0}, mirror = {1}"
                            .Format(dependency, mirror)
                            .AsException();
                    }
                    if (reflectedDependency.IsEmpty())
                    {
                        throw "reflectedDependency is empty. dependency = {0}, mirror = {1}"
                            .Format(dependency, mirror)
                            .AsException();
                    }
                    result.AddRange(reflectedDependency);
                    var last = reflectedDependency.Last();
                    if (last == null)
                    {
                        throw "last = null".AsException();
                    }
                    dependencies.Add(last);
                }
                var reflected = source.Clone();
                if (reflected == null)
                {
                    throw "reflected = null".AsException();
                }
                reflected.UnregisterFromDependencies();
                reflected.Dependencies.SetItems(dependencies);
                result.Add(reflected);

                // Flip the wind of arcs.
                var arc = reflected as IArc;
                if (arc != null && mirror is ILine)
                {
                    arc.Clockwise = !arc.Clockwise;
                }

            }
            return result;
        }
开发者ID:ondrej11,项目名称:o106,代码行数:64,代码来源:Transformer.cs

示例4: CreateRotatedFigure

        public static List<IFigure> CreateRotatedFigure(Drawing drawing, IFigure source, IFigure center, IFigure angleProvider, double angle)
        {
            Check.NotNull(source, "source");
            Check.NotNull(center, "center");

            var list = new List<IFigure>() { source, center };

            var safeAngleProvider = angleProvider as IAngleProvider;
            if (safeAngleProvider != null)
            {
                angle = safeAngleProvider.Angle;
                list.Add(angleProvider);
            }

            List<IFigure> result = new List<IFigure>();
            if (source is IPoint)
            {
                var rotatedPoint = Factory.CreateRotatedPoint(drawing, list, angle);
                if (rotatedPoint == null)
                {
                    throw "rotatedPoint is null. source = {0}, center = {1}, angleArc = {2}, angle = {3}"
                        .Format(source, center, angleProvider, angle)
                        .AsException();
                }
                rotatedPoint.Visible = source.Visible;
                result.Add(rotatedPoint);
            }
            else if (source is ILine || source is IEllipse || source is IPolygonalChain)
            {
                var dependencies = new List<IFigure>();
                foreach (var dependency in source.Dependencies)
                {
                    var rotatedDependency = CreateRotatedFigure(drawing, dependency, center, angleProvider, angle);
                    if (rotatedDependency == null)
                    {
                        throw "rotatedDependency is null. dependency = {0}, center = {1}, angleArc = {2}, angle = {3}"
                            .Format(dependency, center, angleProvider, angle)
                            .AsException();
                    }
                    if (rotatedDependency.IsEmpty())
                    {
                        throw "rotatedDependency is empty. dependency = {0}, center = {1}, angleArc = {2} angle = {3}"
                            .Format(dependency, center, angleProvider, angle)
                            .AsException();
                    }
                    result.AddRange(rotatedDependency);
                    var last = rotatedDependency.Last();
                    if (last == null)
                    {
                        throw "last = null".AsException();
                    }
                    dependencies.Add(last);
                }
                var rotated = source.Clone();
                if (rotated == null)
                {
                    throw "rotated = null".AsException();
                }
                rotated.UnregisterFromDependencies();
                rotated.Dependencies = dependencies;
                result.Add(rotated);
            }
            return result;
        }
开发者ID:ondrej11,项目名称:o106,代码行数:64,代码来源:Transformer.cs

示例5: Add

 public void Add(IFigure component)
 {
     children.Add(component.Clone());
 }
开发者ID:SokolovMS,项目名称:DesignPatterns,代码行数:4,代码来源:CompositeFigure.cs


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