private void OnCanvasEvent(object obj, CanvasEventArgs args)
 {
     EventButton ev = new EventButton (args.Event.Handle);
     switch (ev.Type)
     {
         case EventType.ButtonPress:
             if (ev.Button == 1)
             {
                 holding= true;
                 firstCell = taskArea.GetCellAt (ev.X, ev.Y);
                 StartDrawing (ev);
             }
             break;
         case EventType.MotionNotify:
             if (holding && stask != null)
             {
                 curCell = taskArea.GetCellAt (ev.X, ev.Y);
                 stask.Y2 = ev.Y;
             }
             break;
         case EventType.ButtonRelease:
             holding = false;
             double rounded = RoundDownTask (ev.Y);
             stask.Y2 = rounded;
             PointToTime (firstCell, curCell, stask.Task, firstX, firstY, ev.X, rounded);
             break;
         default:
             break;
     }
 }
Exemple #2
0
 public GLGraphics(CanvasEventArgs e)
 {
     _canvas = e.Canvas;
     _graphics = e.Graphics;
     FillTextBackground = FillTextBackground_Default;
     TextBackgroundColor = _canvas.BackColor;
 }
Exemple #3
0
        private void HandleDoubleClick(ILayoutHost host, CanvasEventArgs e)
        {
            if (host == null)
            {
                return;
            }
            ILayoutRuntime runtime = host.LayoutRuntime;

            if (runtime == null)
            {
                return;
            }
            IElement[] eles = runtime.Hit(e.LayoutX, e.LayoutY);
            if (eles == null || eles.Length == 0)
            {
                return;
            }
            _scale = runtime.Scale;
            foreach (IElement ele in eles)
            {
                if (ele is TextElement)
                {
                    if (ele.IsLocked)
                    {
                        continue;
                    }
                    _currentHost    = host;
                    _txtEle         = ele as TextElement;
                    _txtEle.Visible = false;
                    TextBox box = CreatTextbox(host);
                    return;
                }
                else if (ele is MultlineTextElement)
                {
                    if (ele.IsLocked)
                    {
                        continue;
                    }
                    _currentHost = host;
                    CreatMultlineTextbox(host, ele as MultlineTextElement);
                    return;
                }
            }
        }
        private void btnRejectReportedAlert_Click(object sender, RoutedEventArgs e)
        {
            var msgBox = new MessageBoxUserControl("Are you sure want to Reject?", true);

            msgBox.Owner = Window.GetWindow(this);
            msgBox.ShowDialog();

            var res = msgBox.GetResult();

            if (res == false)
            {
                return;
            }

            OnGoToNextStep(new GoToNextStepEventArgs
            {
                Confirmation = false
            });

            //OnProcessNextAlert(new ProcessNextItemEventArgs() { CanProcessNextItem = true});


            ClearControls();

            //    var msgBoxDone = new MessageBoxUserControl(Properties.Resources.strDispatchedPatrolConfirm, false);
            //    msgBoxDone.Owner = Window.GetWindow(this);
            //    msgBoxDone.ShowDialog();

            //    var resCon = msgBoxDone.GetResult();

            CanvasEventArgs canvasEventArgs = new CanvasEventArgs();

            ClosePopup();

            OnCloseCanvas(canvasEventArgs);

            //ClosePopup();
            //Storyboard OpenNotifiedAlertDetailsPopup = (Storyboard)TryFindResource("OpenNotifiedViolatorDetailsinRight");
            //OpenNotifiedAlertDetailsPopup.Begin();

            //Storyboard CloseNotifiedAlertDetailsPopup = (Storyboard)TryFindResource("CloseNotifiedViolatorDetailsinRight");
            //CloseNotifiedAlertDetailsPopup.Begin();
        }
Exemple #5
0
        private void UpdateCurrent(CanvasEventArgs canvasEventArgs)
        {
            current.Shape.Width  = Math.Abs(x1 - canvasEventArgs.X);
            current.Shape.Height = Math.Abs(y1 - canvasEventArgs.Y);

            current.Shape.Margin = ShapeUtils.GetMargin(
                Math.Min(x1, canvasEventArgs.X),
                Math.Min(y1, canvasEventArgs.Y)
                );

            if (canvasEventArgs.MouseState == MouseState.UP)
            {
                current.ShapeState = ShapeState.FINISHED;
            }
            else if (canvasEventArgs.MouseState == MouseState.MOVE)
            {
                current.ShapeState = ShapeState.DRAWING;
            }
        }
        private async void ClosePopup_OnClick(object Sender, RoutedEventArgs E)
        {
            try
            {
                Storyboard sb = new Storyboard();
                sb = (Storyboard)TryFindResource("MyStoryboard");
                sb.Begin();
                await Task.Delay(1000);

                CanvasEventArgs canvasEventArgs = new CanvasEventArgs();

                OnCloseCanvas(canvasEventArgs);
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                MessageBox.Show(Utility.GetErrorMessage());
                Utility.LogOut();
            }
        }
Exemple #7
0
        public DrawingShape GetShape(CanvasEventArgs canvasEventArgs)
        {
            if (canvasEventArgs.MouseState == MouseState.DOWN)
            {
                x1 = canvasEventArgs.X;
                y1 = canvasEventArgs.Y;

                current = new DrawingShape(
                    new Line
                {
                    Stroke          = StrokeColor,
                    X1              = x1,
                    X2              = x1,
                    Y1              = y1,
                    Y2              = y1,
                    StrokeThickness = DEF_STROKE_THICKNESS
                }, ShapeState.START);
            }
            else
            {
                if (current.Shape is not Line l)
                {
                    throw new Exception("Shape-Tool type mismatch, tool type: LineTool, expected shape type Line");
                }

                l.X2 = canvasEventArgs.X;
                l.Y2 = canvasEventArgs.Y;

                if (canvasEventArgs.MouseState == MouseState.UP)
                {
                    current.ShapeState = ShapeState.FINISHED;
                }
                else if (canvasEventArgs.MouseState == MouseState.MOVE)
                {
                    current.ShapeState = ShapeState.DRAWING;
                }
            }

            return(current);
        }
Exemple #8
0
        public DrawingShape GetShape(CanvasEventArgs canvasEventArgs)
        {
            if (canvasEventArgs.MouseState == MouseState.DOWN)
            {
                current = new DrawingShape(
                    new Ellipse
                {
                    Stroke          = StrokeColor,
                    StrokeThickness = DEF_STROKE_THICKNESS,
                },
                    ShapeState.START
                    );

                x1 = canvasEventArgs.X;
                y1 = canvasEventArgs.Y;
            }
            else
            {
                UpdateCurrent(canvasEventArgs);
            }
            return(current);
        }
Exemple #9
0
        protected void OnCanvasEvent(object obj, CanvasEventArgs args)
        {
            Gdk.EventButton ev = new Gdk.EventButton(args.Event.Handle);
            if (args.Event.Type == Gdk.EventType.EnterNotify)
            {
                WidthUnits = extraWidth;
            }
            if (args.Event.Type == Gdk.EventType.LeaveNotify)
            {
                if (!Selected)
                {
                    WidthUnits = normalWidth;
                }
            }
            if (ev.Type == Gdk.EventType.TwoButtonPress)
            {
                ReadonlyTaskInfoDialog dialog = new ReadonlyTaskInfoDialog(Task);
                dialog.Run();
                dialog.Destroy();
            }
            else if (ev.Type == Gdk.EventType.ButtonPress)
            {
                switch (ev.Button)
                {
                case 1:
                    Selected = !Selected;
                    break;

                case 2:
                    ChangePriority();
                    break;

                default:
                    break;
                }
            }
        }
Exemple #10
0
        public override void Event(object sender, enumCanvasEventType eventType, CanvasEventArgs e)
        {
            ILayoutHost host = sender as ILayoutHost;

            switch (eventType)
            {
            case enumCanvasEventType.DoubleClick:
                HandleDoubleClick(host, e);
                break;

            case enumCanvasEventType.KeyDown:
                HandleKey(host, e);
                break;

            case enumCanvasEventType.MouseDown:
                if (Control.MouseButtons == MouseButtons.Left)
                {
                    _isMoving   = false;
                    _beginPoint = new PointF(e.LayoutX, e.LayoutY);
                    //by chennan 20131107 修改图元无法点选选中
                    HitByPoint(sender as ILayoutHost, e.LayoutX, e.LayoutY);

                    _editedElement = GetEditedElementFromSelection(sender as ILayoutHost, e);
                    if (_editedElement == null)
                    {
                        HitByPoint(sender as ILayoutHost, e.LayoutX, e.LayoutY);
                        _editedElement = GetEditedElementFromSelection(sender as ILayoutHost, e);
                    }
                    if (_editedElement != null)
                    {
                        if (_anchorIndex != -1)
                        {
                            _action = enumAction.EditAnchor;
                        }
                        else
                        {
                            _action = enumAction.MovingElement;
                        }
                    }
                    else
                    {
                        _beginPointScreen.X = e.ScreenX;
                        _beginPointScreen.Y = e.ScreenY;
                        _action             = enumAction.SelectByRect;
                    }
                }
                break;

            case enumCanvasEventType.MouseMove:
                if (_action == enumAction.SelectByRect)
                {
                    _isMoving = false;
                    //   _isMultiSelect = false;
                    _crtPointScreen.X = e.ScreenX;
                    _crtPointScreen.Y = e.ScreenY;
                    host.Render();
                }
                else if (_action == enumAction.MovingElement)
                {
                    if (_editedElement.IsLocked)
                    {
                        break;
                    }
                    _isMultiSelect = false;
                    MovingElement(host, e);
                }
                else if (_action == enumAction.EditAnchor)
                {
                    if (_editedElement.IsLocked)
                    {
                        break;
                    }
                    _isMoving = false;
                    //  _isMultiSelect = false;
                    host.Container.Cursor = GetCursorByAnchor();
                    _editedBox.Apply(host.LayoutRuntime, _anchorIndex, _beginPoint, new PointF(e.LayoutX, e.LayoutY));
                    _beginPoint.X = e.LayoutX;
                    _beginPoint.Y = e.LayoutY;
                    host.Render();
                }
                break;

            case enumCanvasEventType.MouseUp:
                if (_beginPoint.IsEmpty)
                {
                    return;
                }
                if ((e.LayoutX - _beginPoint.X) < float.Epsilon && (e.LayoutY - _beginPoint.Y) < float.Epsilon)
                {
                    bool isEmpty = HitByPoint(sender as ILayoutHost, e.LayoutX, e.LayoutY);
                    //by chennan 20131107 多选时未点选到正确位置不去除之前已选取的图元
                    if (isEmpty && ((Control.ModifierKeys & Keys.Shift) != Keys.Shift))
                    {
                        host.LayoutRuntime.ClearSelection();
                    }
                    else
                    {
                        ClearOtherSelection(host, e);
                    }
                }
                else
                {
                    RectangleF rect = new RectangleF(Math.Min(_beginPoint.X, e.LayoutX),
                                                     Math.Min(_beginPoint.Y, e.LayoutY),
                                                     Math.Abs(_beginPoint.X - e.LayoutX),
                                                     Math.Abs(_beginPoint.Y - e.LayoutY));
                    HitByRect(sender as ILayoutHost, rect);
                }
                host.Render();
                _action               = enumAction.None;
                _anchorIndex          = -1;
                host.Container.Cursor = Cursor;
                break;
            }
        }
Exemple #11
0
 public virtual DrawingShape GetShape(CanvasEventArgs canvasEventArgs, TikzStyle style)
 {
     return(null);
 }
Exemple #12
0
 private void reportDesigner1_ElementEndDraw(object sender, CanvasEventArgs e)
 {
     this.UpdateButtonState(null);
 }
Exemple #13
0
 // handler for click events on line segments
 private void LineEventHandler(object source, CanvasEventArgs args)
 {
     //if (!_is_selected) return;
     EventButton eb;
     switch (args.Event.Type)
     {
         case EventType.ButtonPress:
             eb = new EventButton (args.Event.Handle);
             if (eb.Button == 1 && !_mouse_left_pressed)
             {
                 if (_control_points.Count == 0) { CreateControlPoints (); }
                 BreakSegment ((CanvasLine) source, args);
                 _mouse_left_pressed = true;
             }
             break;
         case EventType.ButtonRelease:
             eb = new EventButton (args.Event.Handle);
             if (eb.Button == 1) { _mouse_left_pressed = false; }
             break;
     }
 }
Exemple #14
0
 public virtual void Event(object sender, enumCanvasEventType eventType, CanvasEventArgs e)
 {
 }
        private void levelView_PaintCanvas(object sender, CanvasEventArgs e)
        {
            FPCanvas canvas = e.Canvas;

            if (!texturesLoaded)
            {
                InitAllTextures(canvas);
                texturesLoaded = true;
            }

            canvas.DisableTexturing();
            canvas.EnableBlend();

            DrawGrid(canvas);

            canvas.EnableTexturing();
            canvas.SetCurrentColor(Color.White);

            for (int i = 0; i < gameObjects.Count; i++)
            {
                var gameObject = gameObjects[i];
                canvas.SetCurrentColor(Color.White);
                gameObject.Draw(canvas);
                if (selectedIndices.Contains(i))
                {
                    DrawHandlesOnGameObject(canvas, gameObject);
                }
            }

            var draggedObject = this.DraggedObject;

            if (draggedObject != null)
                DrawHandlesOnGameObject(canvas, draggedObject);

            canvas.DisableTexturing();
            if (drawingSelection)
            {
                canvas.SetCurrentColor(Color.FromArgb(50, Color.White));
                canvas.FillRectangle(SelectionRect);
                canvas.SetCurrentColor(Color.FromArgb(230, Color.White));
                canvas.DrawRectangle(SelectionRect);
            }
        }
        private void CamerasList_OnSelectionChanged(object Sender, SelectionChangedEventArgs E)
        {
            try
            {
                var selectedItem = CamerasList.SelectedItem as AssetsViewDTO;
                if (selectedItem == null)
                {
                    return;
                }

                CamerasListViewModel vm = DataContext as CamerasListViewModel;
                if (vm == null)
                {
                    return;
                }

                //vm.PopupCanvas.Children.Clear();

                //vm.PopupCanvas.Children.Add(new CameraDetailsUserControl(selectedItem, vm.PopupCanvas));

                //Canvas.SetRight(vm.PopupCanvas, 690);

                //vm.PopupCanvas.Visibility = Visibility.Visible;

                var detailsCtrl = new CameraDetailsUserControl(selectedItem);
                detailsCtrl.CloseCanvas += detailsCtrl_CloseCanvas;

                CanvasEventArgs canvasEventArgs = new CanvasEventArgs
                {
                    ChildControl = detailsCtrl,
                    Width        = 730
                };

                OnAddChildContent(canvasEventArgs);

                PublishMessages(selectedItem);

                CamerasList.SelectedItem      = null;
                selectedItem.ImgCheckedSource = "../images/true.png";
                if (vm.SetCheckedList(selectedItem))
                {
                    var parent = GetParent() as SOPList;
                    if (parent == null)
                    {
                        return;
                    }
                    var parentVM = parent.DataContext as SOPViewModel;
                    if (parentVM == null)
                    {
                        return;
                    }
                    parentVM.SetStepChecked(vm);
                    //parent.
                }
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                MessageBox.Show(Utility.GetErrorMessage());
                Utility.LogOut();
            }
        }
Exemple #17
0
        private void DispatchButton_OnClick(object Sender, RoutedEventArgs E)
        {
            try
            {
                var vm = DataContext as PatrolDetailsViewModel;
                if (vm == null)
                {
                    return;
                }

                //var msgBox = new MessageBoxUserControl("سوف يتم إرسال الدورية . هل أنت متأكد؟", true);
                var msgBox = new MessageBoxUserControl(Properties.Resources.strDispatchPatrolConfirmation, true);
                msgBox.Owner = Window.GetWindow(this);
                msgBox.ShowDialog();

                var res = msgBox.GetResult();

                if (res == false)
                {
                    return;
                }

                bool saved = false;
                switch (vm.SOPSource)
                {
                case SOPSources.Fog:
                    saved = AddDuty(vm);
                    break;

                case SOPSources.DetectedAccident:
                    saved = AddIncident(vm);
                    break;

                case SOPSources.WantedCar:
                    saved = AddDuty(vm);
                    break;
                }

                if (saved)
                {
                    vm.Patrol.IsAssigned = true;
                    OnGoToNextStep(new GoToNextStepEventArgs
                    {
                        Confirmation = true
                    });

                    ClearControls();

                    var msgBoxDone = new MessageBoxUserControl(Properties.Resources.strDispatchedPatrolConfirm, false);
                    msgBoxDone.Owner = Window.GetWindow(this);
                    msgBoxDone.ShowDialog();

                    var resCon = msgBoxDone.GetResult();

                    CanvasEventArgs canvasEventArgs = new CanvasEventArgs();

                    OnCloseCanvas(canvasEventArgs);
                }
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                MessageBox.Show(Utility.GetErrorMessage());
                Utility.LogOut();
            }
        }
 protected void OnCanvasEvent(object obj, CanvasEventArgs args)
 {
     Gdk.EventButton ev = new Gdk.EventButton (args.Event.Handle);
     if (args.Event.Type == Gdk.EventType.EnterNotify)
         WidthUnits = extraWidth;
     if (args.Event.Type == Gdk.EventType.LeaveNotify)
         if (!Selected)
             WidthUnits = normalWidth;
     if (ev.Type == Gdk.EventType.TwoButtonPress)
     {
         ReadonlyTaskInfoDialog dialog = new ReadonlyTaskInfoDialog (Task);
         dialog.Run ();
         dialog.Destroy ();
     }
     else if (ev.Type == Gdk.EventType.ButtonPress)
     {
         switch (ev.Button)
         {
             case 1:
                 Selected = !Selected;
                 break;
             case 2:
                 ChangePriority ();
                 break;
             default:
                 break;
         }
     }
 }
Exemple #19
0
 protected override void EnterNotify(CanvasEventArgs args)
 {
     _is_mouse_hover = true;
 }
Exemple #20
0
 private void glView1_PaintCanvas(object sender, CanvasEventArgs e)
 {
     GLGraphics g = new GLGraphics(e);
     Draw(g);
 }
Exemple #21
0
        public DrawingShape GetShape(CanvasEventArgs canvasEventArgs, TikzStyle style)
        {
            if (canvasEventArgs.MouseState == MouseState.DOWN)
            {
                firstPoint = canvasEventArgs.Point;
                ArrowLine line = new ArrowLine
                {
                    X1 = firstPoint.X,
                    X2 = firstPoint.X,
                    Y1 = firstPoint.Y,
                    Y2 = firstPoint.Y,
                };

                line.SetStyle(style);
                current = new DrawingShape(new TikzLine(line, style), ShapeState.START);
            }
            else
            {
                if (current.TikzShape.Shape is not ArrowLine l)
                {
                    throw new Exception("Shape-Tool type mismatch, tool type: LineTool, expected shape type Line");
                }

                l.X2 = canvasEventArgs.Point.X;
                l.Y2 = canvasEventArgs.Point.Y;

                if (canvasEventArgs.ModKey)
                {
                    //Snap mode, from start to one of axis contraints
                    //Axis constraints are divided by 45deg angles

                    //Get angle between start point and mouse pointer
                    //origin Axis X
                    double angle = Math.Atan2(l.Y2 - l.Y1, l.X2 - l.X1); //rads

                    //Determine constraint axis based on angle between X axis and current line
                    //22.5 -> pi/8

                    //X AXIS -> 0
                    //45 -> PI/4
                    //90 -> PI/2
                    //135 -> PI/2 + PI/4 = 3PI/4
                    //180 -> PI
                    //180 -> -PI
                    //225 -> -3PI/4
                    //270 -> -PI/2
                    //360 -> 0

                    double snapAngle = Math.Ceiling(angle / (Math.PI / 8.0)) * (Math.PI / 8.0);
                    //calculate new points based on snapAngle

                    double maxDim = Math.Max(Math.Abs(l.X2 - l.X1), Math.Abs(l.Y2 - l.Y1));
                    l.X2 = l.X1 + Math.Cos(snapAngle) * maxDim;
                    l.Y2 = l.Y1 + Math.Sin(snapAngle) * maxDim;
                }

                if (canvasEventArgs.MouseState == MouseState.UP)
                {
                    current.ShapeState = ShapeState.FINISHED;
                    Canvas.SetLeft(l, 0);
                    Canvas.SetTop(l, 0);
                }
                else if (canvasEventArgs.MouseState == MouseState.MOVE)
                {
                    current.ShapeState = ShapeState.DRAWING;
                }
            }

            return(current);
        }
Exemple #22
0
        public DrawingShape GetShape(CanvasEventArgs a, TikzStyle style)
        {
            if (click == 0) // first click, draw a straight line
            {
                if (a.MouseState == MouseState.DOWN)
                {
                    //FIXME: small bug here, sometimes when a user clicks for the first time long line appears for a split second, noticeable but should not influence performance

                    firstPoint = a.Point;

                    bezier = new BezierSegment()
                    {
                        Point3 = a.Point.GetSystemPoint()
                    };
                    figure = new PathFigure();
                    figure.Segments.Add(bezier);
                    path = new ArrowPath();

                    path.SetStyle(style);
                    path.Margin = ShapeUtils.GetMargin(firstPoint.X, firstPoint.Y);

                    pf        = new PathFigure[] { figure };
                    path.Data = new PathGeometry(pf);

                    current = new DrawingShape(
                        new TikzBezier(path, style),
                        ShapeState.START
                        );
                }
                else if (a.MouseState == MouseState.MOVE)
                {
                    bezier.Point3 = GetPointWithoutMargin(firstPoint, a.Point);
                }
                else
                {
                    bezier.Point3 = GetPointWithoutMargin(firstPoint, a.Point);
                    click++;
                }

                return(current);
            }
            else if (click == 1) // second click, select first control point
            {
                if (a.MouseState == MouseState.DOWN)
                {
                    secondPointSelected = true;
                    bezier.Point1       = GetPointWithoutMargin(firstPoint, a.Point);
                }
                else if (a.MouseState == MouseState.MOVE)
                {
                    if (secondPointSelected)
                    {
                        bezier.Point1 = GetPointWithoutMargin(firstPoint, a.Point);
                    }
                }
                else
                {
                    bezier.Point1 = GetPointWithoutMargin(firstPoint, a.Point);
                    click++;
                }

                return(current);
            }
            else if (click == 2) // third click, select second control point
            {
                if (a.MouseState == MouseState.DOWN)
                {
                    thirdPointSelected = true;
                    bezier.Point2      = GetPointWithoutMargin(firstPoint, a.Point);
                }
                else if (a.MouseState == MouseState.MOVE)
                {
                    if (thirdPointSelected)
                    {
                        bezier.Point2 = GetPointWithoutMargin(firstPoint, a.Point);
                    }
                }
                else
                {
                    bezier.Point2      = GetPointWithoutMargin(firstPoint, a.Point);
                    current.ShapeState = ShapeState.FINISHED;
                    click = 0;
                    secondPointSelected = thirdPointSelected = false;
                }

                Canvas.SetLeft(current.TikzShape.Shape, 0);
                Canvas.SetTop(current.TikzShape.Shape, 0);

                return(current);
            }
            else
            {
                throw new Exception("Sth went wrong, bezier line should be drawn in 3 clicks");
            }
        }
Exemple #23
0
 protected override void LeaveNotify(CanvasEventArgs args)
 {
     SetLineHighlighted (false);
 }
 private void gameView_PaintCanvas(object sender, CanvasEventArgs e)
 {
     FPCanvas canvas = e.Canvas;
     game.Draw(canvas);
 }
Exemple #25
0
 private void BreakSegment(CanvasLine segment, CanvasEventArgs args)
 {
     EventButton eb = new EventButton (args.Event.Handle);
     BreakSegment (segment, eb.X, eb.Y);
 }
Exemple #26
0
 protected override void LeaveNotify(CanvasEventArgs args)
 {
     _is_mouse_hover = false;
 }
Exemple #27
0
 public override void Event(object sender, enumCanvasEventType eventType, CanvasEventArgs e)
 {
 }
 //Used for saving the changes when losing focus. Called from event
 private void ClickCanvasEvent(object obj, CanvasEventArgs args)
 {
     EventButton eb = new EventButton (args.Event.Handle);
     if (args.Event.Type == EventType.ButtonPress)
     {
         if (_is_control_point != true)
         {
             HideMe (eb);
         }
     }
     else if (args.Event.Type == EventType.ButtonRelease)
     {
         HideMe (eb);
         _was_resized = false;
     }
 }
Exemple #29
0
 protected override void EnterNotify(CanvasEventArgs args)
 {
     SetLineHighlighted (true);
 }
 void alertControl_AddChildContent(object sender, CanvasEventArgs e)
 {
     OnAddChildContent(this, e);
 }
        private void CanvasEventCb(object o, CanvasEventArgs args)
        {
            Gdk.Event ev = args.Event;
            //System.Console.WriteLine ("UMLControlPoint> " + ev.Type);
            switch (ev.Type)
            {
                case EventType.EnterNotify:
                {
                    if (!_hover) { SetHover (true); } else { SetPressed (); }
                    break;
                }
                case EventType.LeaveNotify:
                {
                    SetHover (false);
                    break;
                }
                case EventType.ButtonPress:
                {
                    EventButton eb = new EventButton (ev.Handle);
                    if (eb.Button == 1)
                    {
                        if (_movable == false) { break; }

                        if (ev.Type == EventType.ButtonPress)
                        {
                            SetPressed (eb.X, eb.Y);
                        }
                    }
                    if (ButtonPressed != null)
                    {
                        ButtonPressed (this, eb);
                        // stop the event from being further emitted
                        args.RetVal = true;
                    }
                    break;
                }
                case EventType.ButtonRelease:
                {
                    EventButton eb = new EventButton (ev.Handle);
                    if (eb.Button == 1)
                    {
                        if (_movable == false) { break; }

                        _pressed = false;

                        if (_container != null)
                        {
                            _container.UMLElement.UMLControlPoint = false;
                        }
                    }
                    if (ButtonReleased != null)
                    {
                        ButtonReleased (this, eb);
                        // stop the event from being further emitted
                        args.RetVal = true;
                    }
                    break;
                }
                case EventType.MotionNotify:
                {
                    if (_pressed)
                    {
                        if (_movable == false) { break; }
                        EventMotion em = new EventMotion (ev.Handle);
                        ForceMove (em.X, em.Y);
                    }
                    break;
                }
            } // end switch
        }