Ejemplo n.º 1
0
 private void Form1_MouseUp(object sender, MouseEventArgs e)
 {
     if (mouseButtonPressed && lineFigureSelected)
     {
         endPoint      = e.Location;
         drawingEditor = new DrawingEditor(new Line(startPoint, endPoint));
         drawingEditor.Draw();
         Controls.Add(drawingEditor.Manipulator);
         Refresh();
     }
     mouseButtonPressed = false;
 }
Ejemplo n.º 2
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && textFigureSelected)
     {
         startPoint    = e.Location;
         text          = textBox1.Text;
         drawingEditor = new DrawingEditor(new TextShape(startPoint, text));
         drawingEditor.Draw();
         Controls.Add(drawingEditor.Manipulator);
         Refresh();
     }
 }
Ejemplo n.º 3
0
        public DrawingEditor CreateDrawingEditor()
        {
            // Notice how TextShape adapts TextView to the Shape interface so that
            // TextView can be added to the editor as a Shape. An adapter focuses on
            // resolving incompatibilities between two interfaces and therefore makes
            // things work after they are designed where as Bridge makes them work
            // before they are designed.

            DrawingEditor   editor   = new DrawingEditor();
            ShapeTarget     shape1   = new Line();
            TextViewAdaptee textView = new TextViewAdaptee();
            ShapeTarget     shape2   = new TextShapeAdapter(textView);

            editor.AddShape(shape1);
            editor.AddShape(shape2);

            return(editor);
        }