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


C# Rect.getShapeCount方法代码示例

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


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

示例1: instantiateShapes

        /// <summary>
        /// Centralized method to handle the instantiation of all Shapes and Tessellations.
        /// </summary>
        /// <param name="shape">Used to determine which shape to instantiate.</param>
        /// <param name="ratio">Optional parameter that defaults to 0. (Only used for rectangle)</param>
        /// <returns>
        /// Returns a Control array of length 2, the first element being the instance of the Shape
        /// and the second being the instance of the Tessellation.
        /// </returns>
        private void instantiateShapes(out Shape instShape, out Tessellation instTess, int shape, double ratio = 0d)
        {
            // Checks for the default tabPage that is added as a placeholder, and removes it if a shape is being created.
            if (tabControl1.TabPages.Contains(tabPage1))
            {
                tabControl1.TabPages.Remove(tabPage1);
            }
            Shape tempShape = null;
            Tessellation tempTess = null;
            // Each switch case sets the lastTab field, adds the Shape instance to the shapes List, adds the Tessellation instance to the tessellations List,
            // adds the Shape to the tabControl and sets the ContextMenu of that tab to the context menu field in the Shape base class.
            switch (shape)
            {
                case 0:
                    tempShape = new Equilateral();
                    EventSource.output("Equilateral Triangle tab created.");
                    tempTess = new EquilateralTess();
                    tempTess.Name = "Equilateral" + (tempShape.getShapeCount() - 1);
                    break;
                case 1:
                    tempShape = new IsosTri90();
                    EventSource.output("90 Isosceles Triangle tab created.");
                    tempTess = new IsosTri90Tess();
                    tempTess.Name = "IsosTri90" + (tempShape.getShapeCount() - 1);
                    break;
                case 2:
                    tempShape = new IsosTri120();
                    EventSource.output("120 Isosceles Triangle tab created.");
                    tempTess = new IsosTri120Tess();
                    tempTess.Name = "IsosTri120" + (tempShape.getShapeCount() - 1);
                    break;
                case 3:
                    tempShape = new Tri3060();
                    EventSource.output("30-60-90 Triangle tab created.");
                    tempTess = new Tri3060Tess();
                    tempTess.Name = "Tri3060" + (tempShape.getShapeCount() - 1);
                    break;
                case 4:
                    tempShape = new Hexagon();
                    EventSource.output("120 Hexagon tab created.");
                    tempTess = new HexagonTess();
                    tempTess.Name = "Hexagon" + (tempShape.getShapeCount() - 1);
                    break;
                case 5:
                    tempShape = new Rhombus();
                    EventSource.output("60-120 Rhombus tab created.");
                    tempTess = new RhombusTess();
                    tempTess.Name = "Rhombus" + (tempShape.getShapeCount() - 1);
                    break;
                case 6:
                    tempShape = new Kite();
                    EventSource.output("60-90-120 Kite tab created.");
                    tempTess = new KiteTess();
                    tempTess.Name = "Kite" + (tempShape.getShapeCount() - 1);
                    break;
                case 7:
                    tempShape = new Rect(ratio);
                    EventSource.output("Rectangle tab created.");
                    tempTess = new RectTess(ratio);
                    tempTess.Name = "Rectangle" + (tempShape.getShapeCount() - 1);
                    break;
                default:
                    break;
            }

            // The order for this must remain the same, the Shape and Tessellation instances must be added to the Lists before they are added to the Controls
            // because it triggers an event for the tabControl when a new Control is added, and the lastTab must be configured correctly for it.
            if (shapes.Count() != 0)
                lastTab = (Shape)tabControl1.SelectedTab;
            shapes.Add(tempShape);
            tessellations.Add(tempTess);
            tabControl1.TabPages.Add(tempShape);
            instShape = tempShape;
            instTess = tempTess;
        }
开发者ID:jrpavoncello,项目名称:OrbitMapper,代码行数:84,代码来源:MainForms.cs


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