Exemple #1
0
        static void Main(string[] args)
        {
            bool showBorder = true;

            if (showBorder)
            {
                _window   = new BorderDecorator(new Window());
                _textView = new BorderDecorator(new TestView());
            }
            else
            {
                _textView = new TestView();
                _window   = new Window();
            }

            _textView.Draw();
            _window.Draw();

            Component window = new Window();

            window.Draw();

            Component windowWithBorder = new BorderDecorator(new Window());

            windowWithBorder.Draw();

            Component textView = new BorderDecorator(new ColorDecorator(new TestView()));

            textView.Draw();
        }
Exemple #2
0
        private static void Example()
        {
            IWindow originalWindow = new Window();

            // notice how we're stacking decorators on top of each other
            WindowDecorator window = new SpecialBordersWindow(new ScrollableWindow(originalWindow))
            {
                Title     = "My Decorated Window",
                Color     = Color.Green,
                Shape     = "Star",
                Thickness = 2
            };

            window.Draw();
            window.Title = "New Title";

            Console.WriteLine();
            originalWindow.Draw(); // notice how the new title is still in effect
        }
Exemple #3
0
 public virtual void Draw()
 {
     _windowToBeDecorated.Draw();
 }