Esempio n. 1
0
        public void MouseUpEvent(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // If the left mouse button is released and the drawPreviewObject timer is active,
                // stop it and premanently draw the last preview CanvasObject onto the canvas.
                // Only preview object with valid parameters are being permanently drawn.
                if (IntervalManager.Singleton.GetTimerStatus("drawPreviewObject"))
                {
                    IntervalManager.Singleton.ManageTimer("drawPreviewObject", false);
                    CanvasObject previewObject = cm.PreviewObject.First().Key;
                    int[]        parameters    = previewObject.GetObjectParameters();

                    if (CheckForInvisibleObject(parameters))
                    {
                        DrawObject(previewObject.GetType().Name, parameters, true);
                        UpdateButtonStatus("undo");
                    }
                }
                // If the left mouse button is released and the moveSelectedObject timer is active,
                // stop it and store the new coordinates of the selected object.
                else if (IntervalManager.Singleton.GetTimerStatus("moveSelectedObject"))
                {
                    IntervalManager.Singleton.ManageTimer("moveSelectedObject", false);
                    cm.ChangeSelectedObject(cm.SelectedObject);
                }
            }
        }
Esempio n. 2
0
        public void MouseDownEvent(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // If the left mouse button is pressed while the copySelectedObject timer is active,
                // stop the timer and draw a permanent version of the current preview object onto the canvas.
                if (IntervalManager.Singleton.GetTimerStatus("copySelectedObject"))
                {
                    IntervalManager.Singleton.ManageTimer("copySelectedObject", false);

                    CanvasObject objectToDraw = cm.PreviewObject.First().Key;
                    DrawObject(objectToDraw.GetType().Name, objectToDraw.GetObjectParameters(), true);
                }
                // If the left mouse button is pressed while the moveAllObjects timer is active, stop the timer.
                else if (IntervalManager.Singleton.GetTimerStatus("moveAllObjects"))
                {
                    IntervalManager.Singleton.ManageTimer("moveAllObjects", false);
                }
                // If the left mouse button is pressed and there is no CanvasObject selected, start the drawPreviewObject timer.
                else if (cm.SelectedObject == null)
                {
                    startLocation = GetCursorPosition();
                    IntervalManager.Singleton.ManageTimer("drawPreviewObject", true);
                }
                // If the left mouse button is pressed and there is a CanvasObject selected, start the moveSelectedObject timer.
                else if (cm.SelectedObject != null)
                {
                    IntervalManager.Singleton.ManageTimer("moveSelectedObject", true);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Makes a copy of the selected CanvasObject, and creates a preview of the new object at the cursor location.
        /// </summary>
        public void CopySelectedObject(object sender, EventArgs e)
        {
            CanvasObject selectedObject = cm.GetCanvasObject(cm.SelectedObject);

            int[] data = selectedObject.GetObjectParameters();

            Point location = GetCursorPosition();

            data[0] = location.X;
            data[1] = location.Y;

            DrawObject(selectedObject.GetType().Name, data, false);
        }
        /// <summary>
        /// Removes an entry from the allCanvasObjects collection.
        /// </summary>
        /// <param name="value">The PictureBox which is the value of a stored dictionary entry.</param>
        public void RemoveObject(PictureBox value)
        {
            CanvasObject dictKey = null;

            foreach (var entry in allCanvasObjects)
            {
                if (entry.Value == value)
                {
                    dictKey = entry.Key;
                }
            }

            if (dictKey != null)
            {
                allCanvasObjects.Remove(dictKey);
            }
        }
 /// <summary>
 /// Registers the creation of a new CanvasObject, by storing it in the allCanvasObjects and allCanvasGraphics collections.
 /// </summary>
 /// <param name="newObject"></param>
 /// <param name="newGraphic"></param>
 public void AddObject(CanvasObject newObject, PictureBox newGraphic)
 {
     allCanvasObjects.Add(newObject, newGraphic);
 }