Пример #1
0
        private static void AddElementWhenNameContains(string content, GraphicText text, IGraphicElement graphicElement)
        {
            if (graphicElement.Name.Contains(content))
            {
                graphicElement.Add(text);
            }

            foreach (IGraphicElement childElement in graphicElement.GetChildElements())
            {
                AddElementWhenNameContains(content, text, childElement);
            }
        }
Пример #2
0
        private static void Demo2()
        {
            Console.WriteLine("Build a drawing  ...");
            var drawing = BuildDrawing();

            drawing.Draw();

            Console.WriteLine("\n----------- Edit the drawing -----------");
            Console.WriteLine("adding a text to all elements which contain 'great' ");

            GraphicText text = new GraphicText("This is a nice graphic", ConsoleColor.DarkBlue);

            AddElementWhenNameContains("great", text, drawing);

            Console.WriteLine("\n-----------The drawing after edit ---------");
            drawing.Draw();
        }