コード例 #1
0
        public override bool HandleEvent(Gdk.Event evnt)
        {
            Gdk.EventButton eventButton = evnt as Gdk.EventButton;
            if (eventButton != null)
            {
                if (eventButton.Type == Gdk.EventType.ButtonPress)
                {
                    using (Context context = Gdk.CairoHelper.Create(evnt.Window)) {
                        foreach (Shape shape in this.Model.GetSubModel <ShapesModel>().Shapes)
                        {
                            if (shape is ConnectorShape)
                            {
                                Glue g = CheckGlues(new PointD(eventButton.X, eventButton.Y), context, (shape as ConnectorShape).FromGlue, (shape as ConnectorShape).ToGlue);
                                if (g != null)
                                {
                                    dragGlue      = g;
                                    isDragging    = true;
                                    moved         = false;
                                    dragConnector = shape as ConnectorShape;
                                    //
                                    InteractionStateModel interState = this.Model.GetSubModel <InteractionStateModel>();
                                    this.Model.BeginUpdate();
                                    ConnectorShape interDragConnector = dragConnector.DeepCopy();
                                    interState.Interaction.Add(interDragConnector);
                                    Glue interDragGlue = dragGlue.DeepCopy();
                                    if (dragGlue == dragConnector.FromGlue)
                                    {
                                        interDragConnector.FromGlue = interDragGlue;
                                    }
                                    else
                                    {
                                        interDragConnector.ToGlue = interDragGlue;
                                    }
                                    interDragGlue.Parent = null;
                                    interDragGlue.Matrix.InitIdentity();
                                    interDragGlue.Center = new PointD(eventButton.X, eventButton.Y);
                                    interState.Interaction.Add(interDragGlue);
                                    this.Model.EndUpdate();
                                    //
                                    return(true);
                                }
                            }
                        }
                    }
                    foreach (Shape shape in this.Model.GetSubModel <SelectionModel>().Selected)
                    {
                        if (shape is ConnectorShape)
                        {
                            return(true);
                        }
                    }
                }
                else if (eventButton.Type == Gdk.EventType.ButtonRelease)
                {
                    if (dragGlue != null)
                    {
                        using (Context context = Gdk.CairoHelper.Create(evnt.Window)) {
                            foreach (Shape shape in this.Model.GetSubModel <ShapesModel>().Shapes)
                            {
                                List <Shape> glues = new List <Shape>();
                                foreach (Shape subShape in shape.Items)
                                {
                                    if (subShape is Glue)
                                    {
                                        glues.Add(subShape);
                                    }
                                }
                                Glue g = CheckGlues(new PointD(eventButton.X, eventButton.Y), context, glues);
                                if (g != null)
                                {
                                    this.Model.BeginUpdate();

                                    if (dragGlue == dragConnector.FromGlue)
                                    {
                                        dragConnector.FromGlue = g;
                                        dragConnector.From     = g.Parent;
                                    }
                                    else
                                    {
                                        dragConnector.ToGlue = g;
                                        dragConnector.To     = g.Parent;
                                    }

                                    this.Model.EndUpdate();

                                    break;
                                }
                            }
                        }

                        this.Model.BeginUpdate();
                        this.Model.GetSubModel <InteractionStateModel>().Interaction.Clear();
                        this.Model.EndUpdate();

                        isDragging = false;
                        dragGlue   = null;
                        return(true);
                    }
                }
            }

            Gdk.EventMotion eventMotion = evnt as Gdk.EventMotion;
            if (eventMotion != null)
            {
                if (isDragging && dragGlue != null)
                {
                    this.Model.BeginUpdate();
                    ConnectorShape interConnector = (ConnectorShape)this.Model.GetSubModel <InteractionStateModel>().Interaction[0];
                    Glue           interDragGlue  = (Glue)this.Model.GetSubModel <InteractionStateModel>().Interaction[1];
                    interDragGlue.Center = new PointD(eventMotion.X, eventMotion.Y);
                    this.Model.EndUpdate();
                    moved = true;
                    return(true);
                }
            }

            return(base.HandleEvent(evnt));
        }
コード例 #2
0
 public CurvedArrowShape(Shape from, Glue fromGlue, Shape to, Glue toGlue, List <Distance> controlPoints) : base(from, fromGlue, to, toGlue, controlPoints)
 {
 }
コード例 #3
0
 public CurvedArrowShape(Shape from, Glue fromGlue, Shape to, Glue toGlue) : base(from, fromGlue, to, toGlue)
 {
 }
コード例 #4
0
 public ConnectorShape(Shape from, Glue fromGlue, Shape to, Glue toGlue) : base(from, to)
 {
     this.fromGlue = fromGlue;
     this.toGlue   = toGlue;
 }
コード例 #5
0
 public PolylineArrowShape(Shape from, Glue fromGlue, Shape to, Glue toGlue, List <Distance> polyline) : base(from, fromGlue, to, toGlue)
 {
     this.Points = polyline;
 }
コード例 #6
0
 public PolylineArrowShape(Shape from, Glue fromGlue, Shape to, Glue toGlue) : base(from, fromGlue, to, toGlue)
 {
 }