Beispiel #1
0
 public void AppendObject(IDrawableObject drawableObject)
 {
     if (!DrawableObjects.Contains(drawableObject))
     {
         DrawableObjects.Add(drawableObject);
     }
 }
Beispiel #2
0
        private void CreateNode()
        {
            NodeObject newNode = new NodeObject();

            ActivateNode(newNode);
            nodes.Add(newNode);
            DrawableObjects.Add(newNode);
        }
Beispiel #3
0
        public FreeHandRegion(Image backgroundImage = null)
            : base(backgroundImage)
        {
            points         = new List <Point>(128);
            regionFillPath = new GraphicsPath();

            lastNode = new NodeObject();
            DrawableObjects.Add(lastNode);
        }
Beispiel #4
0
        private NodeObject CreateNode()
        {
            NodeObject newNode = new NodeObject(borderPen, nodeBackgroundBrush);

            ActivateNode(newNode);
            nodes.Add(newNode);
            DrawableObjects.Add(newNode);
            return(newNode);
        }
Beispiel #5
0
 public FreeHandRegion()
 {
     points         = new List <Point>(128);
     regionFillPath = new GraphicsPath();
     lastNode       = new NodeObject()
     {
         Shape = NodeShape.Circle
     };
     DrawableObjects.Add(lastNode);
 }
Beispiel #6
0
        private void CreateNode()
        {
            NodeObject newNode = new NodeObject()
            {
                Shape = NodeShape.Diamond
            };

            ActivateNode(newNode);
            nodes.Add(newNode);
            DrawableObjects.Add(newNode);
        }
Beispiel #7
0
        internal void UpdateObjects()
        {
            DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();

            Point position = InputManager.ClientMousePosition;

            if (objects.All(x => !x.IsDragging))
            {
                for (int i = 0; i < objects.Length; i++)
                {
                    DrawableObject obj = objects[i];

                    if (obj.Visible)
                    {
                        obj.IsCursorHover = obj.Rectangle.Contains(position);

                        if (obj.IsCursorHover)
                        {
                            if (InputManager.IsMousePressed(MouseButtons.Left))
                            {
                                obj.OnMousePressed(position);
                            }

                            for (int j = i + 1; j < objects.Length; j++)
                            {
                                objects[j].IsCursorHover = false;
                            }

                            break;
                        }
                    }
                }
            }
            else
            {
                if (InputManager.IsMouseReleased(MouseButtons.Left))
                {
                    foreach (DrawableObject obj in objects)
                    {
                        if (obj.IsDragging)
                        {
                            obj.OnMouseReleased(position);
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private void PolygonRegionSurface_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (DrawableObjects.Cast <NodeObject>().Any(node => node.IsMouseHover || node.IsDragging))
                {
                    return;
                }

                if (nodes.Count == 0)
                {
                    CreateNode();
                }

                CreateNode();

                isAreaCreated = true;
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (isAreaCreated)
                {
                    foreach (NodeObject node in nodes)
                    {
                        if (node.IsMouseHover)
                        {
                            nodes.Remove(node);
                            DrawableObjects.Remove(node);
                            return;
                        }
                    }

                    isAreaCreated = false;
                    nodes.Clear();
                    DrawableObjects.Clear();
                }
                else
                {
                    Close(SurfaceResult.Close);
                }
            }
        }
Beispiel #9
0
 public void RemoveObject(IDrawableObject drawableObject)
 {
     DrawableObjects.Remove(drawableObject);
 }
Beispiel #10
0
 public void InsertObject(IDrawableObject drawableObject, int index)
 {
     DrawableObjects.Insert(index, drawableObject);
 }
Beispiel #11
0
 public void ClearObjects()
 {
     DrawableObjects.Clear();
 }