Exemplo n.º 1
0
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            if (IsRightButtonPressed(ev))
            {
                DelegateTool = new PanTool(Editor, CursorFactory.GetCursorFromType(Gdk.CursorType.Arrow));
            }
            else
            {
                IHandle handle = view.FindHandle(ev.X, ev.Y);
                if (handle != null)
                {
                    DelegateTool = new HandleTracker(Editor, new UndoableHandle(handle));
                }
                else
                {
                    IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);
                    if (figure != null)
                    {
                        DelegateTool = figure.CreateFigureTool(Editor, new DragTool(Editor, figure));
                    }
                    else
                    {
                        DelegateTool = new SelectAreaTool(Editor);
                    }
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseDown(ev);
            }
        }
Exemplo n.º 2
0
			public ResizeHandleUndoActivity(IDrawingView view, IFigure owner): base (view) {
				Undoable = true;
				Redoable = true;
				Owner = owner;
				OldDisplayBox = Owner.DisplayBox;
				NewDisplayBox = Owner.DisplayBox;
			}
 public DrawInRegionVisitor(Gdk.Region region, Cairo.Context context, IDrawingView view)
 {
     this.context = context;
     this.region = region;
     this.view = view;
     this.figures = new List<Figure> ();
 }
Exemplo n.º 4
0
 public override void InvokeStep(double x, double y, IDrawingView view)
 {
     if (m_handle != null)
     {
         m_handle.InvokeStep(x, y, view);
     }
 }
Exemplo n.º 5
0
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            _anchorHandle.InvokeStart(ev.X, ev.Y, view);
        }
Exemplo n.º 6
0
        public override void MouseDown(MouseEvent ev)
        {
            IDrawingView view = ev.View;

            SetAnchorCoords(ev.X, ev.Y);
            View = view;

            Gdk.EventType type = ev.GdkEvent.Type;
            if (type == EventType.TwoButtonPress)
            {
                CreateUndoActivity();
                _showingWidget        = true;
                _textview.Buffer.Text = ((MultiLineTextFigure)Figure).Text;

                View.AddWidget(_textview, 0, 0);
                CalculateTextViewSize();

                _textview.Show();
                _textview.GrabFocus();

                //selects all
                _textview.Buffer.SelectRange(_textview.Buffer.StartIter, _textview.Buffer.EndIter);

                return;
            }
            DefaultTool.MouseDown(ev);
        }
Exemplo n.º 7
0
 public override void InvokeEnd(double x, double y, IDrawingView view)
 {
     _newTarget = _newTarget ?? _oldTarget;
     UpdateUndoActivity();
     Connect(_newTarget);
     Connection.UpdateConnection();
 }
Exemplo n.º 8
0
        public override void MouseMove(MouseEvent ev)
        {
            IDrawingView view   = ev.View;
            Widget       widget = (Widget)view;
            IHandle      handle = view.FindHandle(ev.X, ev.Y);

            if (handle != null)
            {
                widget.GdkWindow.Cursor = handle.CreateCursor();
            }
            else
            {
                IFigure figure = view.Drawing.FindFigure(ev.X, ev.Y);
                if (figure != null)
                {
                    widget.GdkWindow.Cursor = CursorFactory.GetCursorFromType(Gdk.CursorType.Fleur);
                }
                else
                {
                    widget.GdkWindow.Cursor = null;
                }
            }

            if (DelegateTool != null)
            {
                DelegateTool.MouseMove(ev);
            }
        }
Exemplo n.º 9
0
 public ResizeHandleUndoActivity(IDrawingView view, IFigure owner) : base(view)
 {
     Undoable      = true;
     Redoable      = true;
     Owner         = owner;
     OldDisplayBox = Owner.DisplayBox;
     NewDisplayBox = Owner.DisplayBox;
 }
			public ChangeAttributeUndoActivity (IDrawingView drawingView, 
				FigureAttribute attribute, object value) : base (drawingView) {
				_originalValues = new Dictionary<IFigure, object> ();
				Undoable        = true;
				Redoable        = true;
				Attribute       = attribute;
				Value           = value;
			}
Exemplo n.º 11
0
        public override void InvokeStep(double x, double y, IDrawingView view)
        {
            TargetFigure = FindConnectableFigure(x, y, view.Drawing);
            _newTarget   = FindConnectionTarget(x, y, view.Drawing);
            Point        = _newTarget != null?FindPoint(_newTarget) : new PointD(x, y);

            Connection.UpdateConnection();
        }
		public override void InvokeStep (double x, double y, IDrawingView view)	{
			RectangleD r = Owner.DisplayBox;

			PointD new_location = new PointD (r.X, Math.Min (r.Y + r.Height, y));
			PointD new_corner   = new PointD (Math.Max (r.X, x), r.Y + r.Height);

			Owner.DisplayBox = new RectangleD (new_location, new_corner);
		}
Exemplo n.º 13
0
        protected override void CreateUndoActivity(IDrawingView view)
        {
            ChangeConnectionHandleUndoActivity activity = new ChangeConnectionHandleUndoActivity(view);

            activity.Owner        = this;
            activity.OldConnector = _oldTarget;
            UndoActivity          = activity;
        }
Exemplo n.º 14
0
 public ChangeAttributeUndoActivity(IDrawingView drawingView,
                                    FigureAttribute attribute, object value) : base(drawingView)
 {
     _originalValues = new Dictionary <IFigure, object> ();
     Undoable        = true;
     Redoable        = true;
     Attribute       = attribute;
     Value           = value;
 }
Exemplo n.º 15
0
        public override void InvokeStep(double x, double y, IDrawingView view)
        {
            RectangleD r = Owner.DisplayBox;

            PointD new_location = new PointD(r.X, r.Y);
            PointD new_corner   = new PointD(r.X + r.Width, Math.Max(r.Y, y));

            Owner.DisplayBox = new RectangleD(new_location, new_corner);
        }
Exemplo n.º 16
0
        protected override void CreateUndoActivity(IDrawingView view)
        {
            PolyLineHandleUndoActivity activity = new PolyLineHandleUndoActivity(view);

            activity.Owner    = Owner as PolyLineFigure;
            activity.Index    = Index;
            activity.OldPoint = activity.Owner.PointAt(Index);
            UndoActivity      = activity;
        }
        public override void InvokeStep(double x, double y, IDrawingView view)
        {
            RectangleD r = Owner.DisplayBox;

            var new_location = new PointD (Math.Min (r.X + r.Width, x), r.Y);
            var new_corner   = new PointD (r.X + r.Width, Math.Max (r.Y, y));

            Owner.DisplayBox = new RectangleD (new_location, new_corner);
        }
Exemplo n.º 18
0
        protected void CreateUndoActivity()
        {
            IDrawingView         view     = Editor.View;
            DragToolUndoActivity activity = new DragToolUndoActivity(view);

            activity.AffectedFigures = view.SelectionEnumerator.ToFigures();
            activity.StartPoint      = new PointD(AnchorX, AnchorY);
            UndoActivity             = activity;
        }
Exemplo n.º 19
0
        public DrawingPresenter(IDrawingView drawingView, IMessageService messageService, ILoggingService loggingService)
        {
            _messageService = messageService;
            _loggingService = loggingService;
            _drawingView    = drawingView;

            _drawingView.ClassifyDrawing += OnClassifyDrawing;

            _drawingView.ClearDrawing += OnClearDrawing;
        }
Exemplo n.º 20
0
        public override void InvokeStep(double x, double y, IDrawingView view)
        {
            LabelFigure label = (LabelFigure) Owner;
            PointD delta = label.HandleDeltaPosition();
            Owner.MoveTo(x - delta.X, y - delta.Y);

            double offsetX = Owner.DisplayBox.Width/2 - delta.X;
            double offsetY = Owner.DisplayBox.Height/2 - delta.Y;
            label.SetPosition(new PointD(x + offsetX, y + offsetY));
        }
Exemplo n.º 21
0
        public override void MouseUp(MouseEvent ev)
        {
            IDrawingView view = ev.View;

            Gdk.EventButton gdk_event = ev.GdkEvent as EventButton;
            DrawSelectionRect((Gtk.Widget)view, gdk_event.Window);
            bool shift_pressed = (gdk_event.State & ModifierType.ShiftMask) != 0;

            SelectFiguresOnRect(view, shift_pressed);
        }
Exemplo n.º 22
0
		public void InvokeEnd (double x, double y, IDrawingView view) {
			WrappedHandle.InvokeEnd(x, y, view);
			
			IUndoActivity activity = WrappedHandle.UndoActivity;
			
			if (activity != null && activity.Undoable && view.Editor.UndoManager != null) {
				view.Editor.UndoManager.PushUndo(activity);
				view.Editor.UndoManager.ClearRedos();
			}
		}
Exemplo n.º 23
0
		public virtual void Draw (Context context, IDrawingView view) {
			RectangleD rect = ViewDisplayBox(view);
			context.Save();
			context.LineWidth = LineWidth;
			context.Rectangle (GdkCairoHelper.CairoRectangle (rect));
			context.Color = FillColor;
			context.FillPreserve ();
			context.Color = LineColor;
			context.Stroke ();
			context.Restore();
		}
        /// <inheritdoc/>
        void IDrawingModel.Detach([NotNull] IDrawingView view)
        {
            if (view == null) throw new ArgumentNullException(nameof(view));

            if (!ReferenceEquals(canvasView, view))
            {
                // TODO: do something. E.g. exception?
                return;
            }
            canvasView = null;
        }
Exemplo n.º 25
0
        public override void MouseDown(MouseEvent ev)
        {
            IDrawingView view = ev.View;

            base.MouseDown(ev);
            view.Drawing.Add(Prototype);
            Prototype.MoveTo(ev.X, ev.Y);
            view.ClearSelection();
            view.AddToSelection(Prototype);
            CreateUndoActivity();
        }
Exemplo n.º 26
0
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            base.InvokeEnd(x, y, view);

            if (clicked)
            {
                Active = !Active;
            }

            clicked = false;
        }
 public override void InvokeStart(double x, double y, IDrawingView view) 
 {
     m_connection = CreateConnection();
     m_connection.EndPoint = new PointD (x, y);
     m_connection.StartPoint = new PointD (x, y);
     m_connection.ConnectStart (Owner.ConnectorAt(x, y));
     m_connection.UpdateConnection();
     view.Drawing.Add(m_connection);
     view.ClearSelection();
     view.AddToSelection(m_connection);
     m_handle = view.FindHandle(x, y);
 }
Exemplo n.º 28
0
 public override void InvokeStart(double x, double y, IDrawingView view)
 {
     m_connection            = CreateConnection();
     m_connection.EndPoint   = new PointD(x, y);
     m_connection.StartPoint = new PointD(x, y);
     m_connection.ConnectStart(Owner.ConnectorAt(x, y));
     m_connection.UpdateConnection();
     view.Drawing.Add(m_connection);
     view.ClearSelection();
     view.AddToSelection(m_connection);
     m_handle = view.FindHandle(x, y);
 }
Exemplo n.º 29
0
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            base.InvokeEnd(x, y, view);

            if (clicked)
            {
                Experiment ownerExperiment = m_ownerConnection.Owner;
                ownerExperiment.RemoveConnection(m_ownerConnection.ExperimentNodeConnection);
            }

            clicked = false;
        }
Exemplo n.º 30
0
        public void InvokeEnd(double x, double y, IDrawingView view)
        {
            WrappedHandle.InvokeEnd(x, y, view);

            IUndoActivity activity = WrappedHandle.UndoActivity;

            if (activity != null && activity.Undoable && view.Editor.UndoManager != null)
            {
                view.Editor.UndoManager.PushUndo(activity);
                view.Editor.UndoManager.ClearRedos();
            }
        }
		public override void InvokeEnd (double x, double y, IDrawingView view) {
			PolyLineFigure figure = ((PolyLineFigure) Owner);
			// eliminates handles in the middle of a straight line
			if (figure.PointCount > 2 && Index != 0 && Index != (figure.PointCount - 1)) {
				PointD p1 = figure.PointAt (Index - 1);
				PointD p2 = figure.PointAt (Index + 1);
				if (Geometry.LineContainsPoint (p1.X, p1.Y, p2.X, p2.Y, x, y)) {
					figure.RemovePointAt (Index);
				}
			}
			base.InvokeEnd(x, y, view);
		}
Exemplo n.º 32
0
        protected virtual void DrawOn(Cairo.Context context, IDrawingView view)
        {
            FillColor = new Color(0.5, 0.5, 0.5, 0.3);
            RectangleD rect   = ViewDisplayBox(view);
            PointD     center = rect.Center;

            double margin = Width * 0.2;

            context.MoveTo(rect.Left + margin, Dot5(center.Y));
            context.LineTo(rect.Right - margin, Dot5(center.Y));
            context.Stroke();
        }
 public override void InvokeEnd (double x, double y, IDrawingView view)
 {
     base.InvokeEnd (x, y, view);
     
     if (clicked) 
     {
         Experiment ownerExperiment = m_ownerConnection.Owner;
         ownerExperiment.RemoveConnection(m_ownerConnection.ExperimentNodeConnection);
     }
     
     clicked = false;
 }
Exemplo n.º 34
0
        public virtual void Draw(Context context, IDrawingView view)
        {
            RectangleD rect = ViewDisplayBox(view);

            context.Save();
            context.LineWidth = LineWidth;
            context.Rectangle(GdkCairoHelper.CairoRectangle(rect));
            context.Color = FillColor;
            context.FillPreserve();
            context.Color = LineColor;
            context.Stroke();
            context.Restore();
        }
 public override void InvokeEnd(double x, double y, IDrawingView view) 
 {
     if (m_handle != null) {
         m_handle.InvokeEnd(x, y, view);
     }
     
     if (m_connection.EndConnector == null) {
         m_connection.DisconnectStart ();
         m_connection.DisconnectEnd ();
         view.Drawing.Remove(m_connection);
         view.ClearSelection();
     }
 }
Exemplo n.º 36
0
		public void SelectFiguresOnRect (IDrawingView view, bool shift_pressed) 	{
			foreach (IFigure figure in view.Drawing.FiguresEnumeratorReverse) {
				RectangleD rect = figure.DisplayBox;
				if (_selectionRect.Contains (rect.X, rect.Y)
					&& _selectionRect.Contains (rect.X2, rect.Y2)) {
						if (shift_pressed) {
							view.ToggleSelection (figure);
						}
						else {
							view.AddToSelection (figure);
						}
				}
			}
		}
Exemplo n.º 37
0
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            if (m_handle != null)
            {
                m_handle.InvokeEnd(x, y, view);
            }

            if (m_connection.EndConnector == null)
            {
                m_connection.DisconnectStart();
                m_connection.DisconnectEnd();
                view.Drawing.Remove(m_connection);
                view.ClearSelection();
            }
        }
 public override void InvokeEnd (double x, double y, IDrawingView view)
 {
     base.InvokeEnd (x, y, view);
     
     if (clicked) 
     {
         IEditableExperiment experiment = m_ownerComponent.ExperimentNode.Owner as IEditableExperiment;
         if(experiment != null) 
         {
             experiment.RemoveVertex(m_ownerComponent.ExperimentNode);
         }
     }
     
     clicked = false;
 }
Exemplo n.º 39
0
        public override void Draw(Cairo.Context context, IDrawingView view)
        {
            context.Save();

            if (Active)
            {
                DrawOn(context, view);
            }
            else
            {
                DrawOff(context, view);
            }

            context.Restore();
        }
Exemplo n.º 40
0
		public override void Draw (Context context, IDrawingView view) {
			RectangleD rect = ViewDisplayBox(view);
			
			double middle = rect.Width / 2.0;

			context.LineWidth = LineWidth;
			context.Save ();
			context.Translate (rect.X + middle, rect.Y + middle);
			context.Arc (0.0, 0.0, middle, 0.0, 2.0 * Math.PI);
			context.Restore ();
			context.Color = new Cairo.Color (0.2, 0.2, 1.0, 0.5);
			context.FillPreserve ();
			context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
			context.Stroke ();
		}
		public override void Draw (Cairo.Context context, IDrawingView view)
		{
			context.Save();
			base.Draw(context, view);
			
			context.LineWidth = 1.0;
			
			if (Active) {
				DrawOn(context, view);
			}
			else {
				DrawOff(context, view);
			}
			context.Restore();
		}
Exemplo n.º 42
0
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            base.InvokeEnd(x, y, view);

            if (clicked)
            {
                IEditableExperiment experiment = m_ownerComponent.ExperimentNode.Owner as IEditableExperiment;
                if (experiment != null)
                {
                    experiment.RemoveVertex(m_ownerComponent.ExperimentNode);
                }
            }

            clicked = false;
        }
Exemplo n.º 43
0
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            PolyLineFigure figure = ((PolyLineFigure)Owner);

            // eliminates handles in the middle of a straight line
            if (figure.PointCount > 2 && Index != 0 && Index != (figure.PointCount - 1))
            {
                PointD p1 = figure.PointAt(Index - 1);
                PointD p2 = figure.PointAt(Index + 1);
                if (Geometry.LineContainsPoint(p1.X, p1.Y, p2.X, p2.Y, x, y))
                {
                    figure.RemovePointAt(Index);
                }
            }
            base.InvokeEnd(x, y, view);
        }
Exemplo n.º 44
0
        public override void Draw(Context context, IDrawingView view)
        {
            RectangleD rect = ViewDisplayBox(view);

            double middle = rect.Width / 2.0;

            context.LineWidth = LineWidth;
            context.Save();
            context.Translate(rect.X + middle, rect.Y + middle);
            context.Arc(0.0, 0.0, middle, 0.0, 2.0 * Math.PI);
            context.Restore();
            context.Color = new Cairo.Color(0.2, 0.2, 1.0, 0.5);
            context.FillPreserve();
            context.Color = new Cairo.Color(0.0, 0.0, 0.0, 1.0);
            context.Stroke();
        }
Exemplo n.º 45
0
        private void DeleteFigures(IDrawingView view)
        {
            List <IFigure> figures = new List <IFigure> ();

            foreach (IFigure fig in view.SelectionEnumerator)
            {
                figures.Add(fig);
            }

            view.ClearSelection();

            foreach (IFigure fig in figures)
            {
                view.Drawing.Remove(fig);
            }
        }
		public override void Draw (Context context, IDrawingView view) {
			RectangleD rect = ViewDisplayBox(view);
			
			context.LineWidth = LineWidth;

			context.MoveTo (rect.Center.X, rect.Top);
			context.LineTo (rect.Right, rect.Center.Y);
			context.LineTo (rect.Center.X, rect.Bottom);
			context.LineTo (rect.Left, rect.Center.Y);
			context.LineTo (rect.Center.X, rect.Top);

			context.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.8);
			context.FillPreserve ();
			context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
			context.Stroke ();
		}
Exemplo n.º 47
0
        public override void Draw(Context context, IDrawingView view)
        {
            RectangleD rect = ViewDisplayBox(view);

            context.LineWidth = LineWidth;

            context.MoveTo(rect.Center.X, rect.Top);
            context.LineTo(rect.Right, rect.Center.Y);
            context.LineTo(rect.Center.X, rect.Bottom);
            context.LineTo(rect.Left, rect.Center.Y);
            context.LineTo(rect.Center.X, rect.Top);

            context.Color = new Cairo.Color(1.0, 0.0, 0.0, 0.8);
            context.FillPreserve();
            context.Color = new Cairo.Color(0.0, 0.0, 0.0, 1.0);
            context.Stroke();
        }
		public NullUndoActivity (IDrawingView view) : base (view) {
			Undoable = false;
			Redoable = false;
		}
Exemplo n.º 49
0
		public KeyEvent(IDrawingView view, Gdk.Event gdkEvent) : base(view, gdkEvent) {
		}
Exemplo n.º 50
0
 private void DeleteFigures (IDrawingView view) {
     List <IFigure> figures = new List <IFigure> ();
     
     foreach (IFigure fig in view.SelectionEnumerator) {
         figures.Add (fig);
     }
     
     view.ClearSelection ();
     
     foreach (IFigure fig in figures) {
         view.Drawing.Remove (fig);
     }
 }
Exemplo n.º 51
0
		public void Draw (Context context, IDrawingView view) {
			WrappedHandle.Draw(context, view);
		}
 public override void InvokeStart (double x, double y, IDrawingView view)
 {
     base.InvokeStart (x, y, view);
     
     clicked = true;
 }
 public MouseEvent(IDrawingView view, Gdk.Event gdkEvent, PointD point)
     : base(view, gdkEvent)
 {
     DrawingPoint = point;
 }
Exemplo n.º 54
0
			public TextToolUndoActivity(IDrawingView view): base(view) {
				Undoable = true;
				Redoable = true;
			}
			public ChangeConnectionHandleUndoActivity(IDrawingView view): base (view) {
				Undoable = true;
				Redoable = true;
			}
			public BringToFrontUndoActivity (IDrawingView drawingView): base (drawingView) {
				Undoable = true;
				Redoable = true;
			}
 public PolyLineFigureToolUndoActivity(IDrawingView view)
     : base(view)
 {
     Undoable = true;
     Redoable = true;
 }
Exemplo n.º 58
0
		public void InvokeStep (double x, double y, IDrawingView view) {
			WrappedHandle.InvokeStep(x, y, view);
		}
			public SelectAllUndoActivity (IDrawingView drawingView) : base (drawingView) {
				Undoable = true;
				Redoable = true;
			}
		protected override void CreateUndoActivity (IDrawingView view) {
			ChangeConnectionHandleUndoActivity activity = new ChangeConnectionHandleUndoActivity(view);
			activity.Owner = this;
			activity.OldConnector = _oldTarget;
			UndoActivity = activity;
		}