コード例 #1
0
    public static void Main()
    {
        TextObject text = new TextObject("Hello");

        IScalable scalable = (IScalable)text;

        scalable.ScaleX(0.5F);
        scalable.ScaleY(0.5F);
    }
コード例 #2
0
    public static void Main()
    {
        DiagramObject[] dArray = new DiagramObject[100];

        dArray[0] = new DiagramObject();
        dArray[1] = new TextObject("Text Dude");
        dArray[2] = new TextObject("Text Backup");

        // array gets initialized here, with classes that
        // derive from DiagramObject. Some of them implement
        // IScalable.

        foreach (DiagramObject d in dArray)
        {
            IScalable scalable = d as IScalable;
            if (scalable != null)
            {
                scalable.ScaleX(0.1F);
                scalable.ScaleY(10.0F);
            }
        }
    }