コード例 #1
0
ファイル: SelectionTool.cs プロジェクト: thbin/TraceLab
        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);
            }
        }
コード例 #2
0
			public ResizeHandleUndoActivity(IDrawingView view, IFigure owner): base (view) {
				Undoable = true;
				Redoable = true;
				Owner = owner;
				OldDisplayBox = Owner.DisplayBox;
				NewDisplayBox = Owner.DisplayBox;
			}
コード例 #3
0
 public DrawInRegionVisitor(Gdk.Region region, Cairo.Context context, IDrawingView view)
 {
     this.context = context;
     this.region = region;
     this.view = view;
     this.figures = new List<Figure> ();
 }
コード例 #4
0
ファイル: NewConnectionHandle.cs プロジェクト: thbin/TraceLab
 public override void InvokeStep(double x, double y, IDrawingView view)
 {
     if (m_handle != null)
     {
         m_handle.InvokeStep(x, y, view);
     }
 }
コード例 #5
0
ファイル: HandleTracker.cs プロジェクト: thbin/TraceLab
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            _anchorHandle.InvokeStart(ev.X, ev.Y, view);
        }
コード例 #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);
        }
コード例 #7
0
 public override void InvokeEnd(double x, double y, IDrawingView view)
 {
     _newTarget = _newTarget ?? _oldTarget;
     UpdateUndoActivity();
     Connect(_newTarget);
     Connection.UpdateConnection();
 }
コード例 #8
0
ファイル: SelectionTool.cs プロジェクト: thbin/TraceLab
        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);
            }
        }
コード例 #9
0
ファイル: ResizeHandle.cs プロジェクト: thbin/TraceLab
 public ResizeHandleUndoActivity(IDrawingView view, IFigure owner) : base(view)
 {
     Undoable      = true;
     Redoable      = true;
     Owner         = owner;
     OldDisplayBox = Owner.DisplayBox;
     NewDisplayBox = Owner.DisplayBox;
 }
コード例 #10
0
			public ChangeAttributeUndoActivity (IDrawingView drawingView, 
				FigureAttribute attribute, object value) : base (drawingView) {
				_originalValues = new Dictionary<IFigure, object> ();
				Undoable        = true;
				Redoable        = true;
				Attribute       = attribute;
				Value           = value;
			}
コード例 #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();
        }
コード例 #12
0
		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);
		}
コード例 #13
0
        protected override void CreateUndoActivity(IDrawingView view)
        {
            ChangeConnectionHandleUndoActivity activity = new ChangeConnectionHandleUndoActivity(view);

            activity.Owner        = this;
            activity.OldConnector = _oldTarget;
            UndoActivity          = activity;
        }
コード例 #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;
 }
コード例 #15
0
ファイル: SouthHandle.cs プロジェクト: thbin/TraceLab
        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);
        }
コード例 #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;
        }
コード例 #17
0
        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);
        }
コード例 #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;
        }
コード例 #19
0
        public DrawingPresenter(IDrawingView drawingView, IMessageService messageService, ILoggingService loggingService)
        {
            _messageService = messageService;
            _loggingService = loggingService;
            _drawingView    = drawingView;

            _drawingView.ClassifyDrawing += OnClassifyDrawing;

            _drawingView.ClearDrawing += OnClearDrawing;
        }
コード例 #20
0
ファイル: LabelHandle.cs プロジェクト: mono/monohotdraw
        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));
        }
コード例 #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);
        }
コード例 #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();
			}
		}
コード例 #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();
		}
コード例 #24
0
        /// <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;
        }
コード例 #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();
        }
コード例 #26
0
ファイル: ToggleButtonHandle.cs プロジェクト: thbin/TraceLab
        public override void InvokeEnd(double x, double y, IDrawingView view)
        {
            base.InvokeEnd(x, y, view);

            if (clicked)
            {
                Active = !Active;
            }

            clicked = false;
        }
コード例 #27
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);
 }
コード例 #28
0
ファイル: NewConnectionHandle.cs プロジェクト: thbin/TraceLab
 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);
 }
コード例 #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;
        }
コード例 #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();
            }
        }
コード例 #31
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);
		}
コード例 #32
0
ファイル: ToggleButtonHandle.cs プロジェクト: thbin/TraceLab
        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();
        }
コード例 #33
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;
 }
コード例 #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();
        }
コード例 #35
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();
     }
 }
コード例 #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);
						}
				}
			}
		}
コード例 #37
0
ファイル: NewConnectionHandle.cs プロジェクト: thbin/TraceLab
        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();
            }
        }
コード例 #38
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;
 }
コード例 #39
0
        public override void Draw(Cairo.Context context, IDrawingView view)
        {
            context.Save();

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

            context.Restore();
        }
コード例 #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 ();
		}
コード例 #41
0
		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();
		}
コード例 #42
0
ファイル: RemoveNodeHandle.cs プロジェクト: thbin/TraceLab
        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;
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #45
0
ファイル: SelectionTool.cs プロジェクト: thbin/TraceLab
        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);
            }
        }
コード例 #46
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 ();
		}
コード例 #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();
        }
コード例 #48
0
		public NullUndoActivity (IDrawingView view) : base (view) {
			Undoable = false;
			Redoable = false;
		}
コード例 #49
0
		public KeyEvent(IDrawingView view, Gdk.Event gdkEvent) : base(view, gdkEvent) {
		}
コード例 #50
0
ファイル: SelectionTool.cs プロジェクト: CoEST/TraceLab
 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);
     }
 }
コード例 #51
0
		public void Draw (Context context, IDrawingView view) {
			WrappedHandle.Draw(context, view);
		}
コード例 #52
0
 public override void InvokeStart (double x, double y, IDrawingView view)
 {
     base.InvokeStart (x, y, view);
     
     clicked = true;
 }
コード例 #53
0
 public MouseEvent(IDrawingView view, Gdk.Event gdkEvent, PointD point)
     : base(view, gdkEvent)
 {
     DrawingPoint = point;
 }
コード例 #54
0
			public TextToolUndoActivity(IDrawingView view): base(view) {
				Undoable = true;
				Redoable = true;
			}
コード例 #55
0
			public ChangeConnectionHandleUndoActivity(IDrawingView view): base (view) {
				Undoable = true;
				Redoable = true;
			}
コード例 #56
0
			public BringToFrontUndoActivity (IDrawingView drawingView): base (drawingView) {
				Undoable = true;
				Redoable = true;
			}
コード例 #57
0
 public PolyLineFigureToolUndoActivity(IDrawingView view)
     : base(view)
 {
     Undoable = true;
     Redoable = true;
 }
コード例 #58
0
		public void InvokeStep (double x, double y, IDrawingView view) {
			WrappedHandle.InvokeStep(x, y, view);
		}
コード例 #59
0
			public SelectAllUndoActivity (IDrawingView drawingView) : base (drawingView) {
				Undoable = true;
				Redoable = true;
			}
コード例 #60
0
		protected override void CreateUndoActivity (IDrawingView view) {
			ChangeConnectionHandleUndoActivity activity = new ChangeConnectionHandleUndoActivity(view);
			activity.Owner = this;
			activity.OldConnector = _oldTarget;
			UndoActivity = activity;
		}