Beispiel #1
0
 public RedoUndo(customRectangle rectangle, Map map)
 {
     X          = rectangle.X;
     Y          = rectangle.Y;
     typeBlock  = rectangle.TypeBlock;
     currentMap = map;
 }
        private void mapCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (cmbBrush.SelectedIndex > -1 && e.LeftButton == MouseButtonState.Pressed)
            {
                if (queueCheckbox.IsChecked == true)
                {
                    map.QueueChecked = true;
                }
                else
                {
                    map.QueueChecked = false;
                }
                Point  click = e.MouseDevice.GetPosition(mapCanvas);
                string t     = (cmbBrush.SelectedItem as ComboBoxItem).Content.ToString();

                int x = (int)((click.X / map.BlockScale));
                int y = (int)((click.Y / map.BlockScale));

                if (DrawRectangleCheckbox.IsChecked == true)
                {
                    customRectangle rectangle = new customRectangle();
                    rectangle.X = x;
                    rectangle.Y = y;
                    try
                    {
                        rectangle.Width  = Convert.ToInt32(newRectangleBreedte.Text);
                        rectangle.Height = Convert.ToInt32(newRectangleHoogte.Text);
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("Alleen nummers mogen ingevuld worden");
                        newRectangleBreedte.Text = newRectangleBreedte.placeHolderText;

                        newRectangleHoogte.Text = newRectangleHoogte.placeHolderText;
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(excp.ToString());
                    }

                    rectangle.TypeBlock = Convert.ToInt32(t);

                    map.DrawOnMap(rectangle, click);
                }
                else
                {
                    singleBlock.X         = x;
                    singleBlock.Y         = y;
                    singleBlock.TypeBlock = Convert.ToInt32(t);

                    map.DrawOnMap(singleBlock, click);
                }
            }
        }
Beispiel #3
0
        public void DrawOnMap(customRectangle rectangle, Point click)
        {
            int defaultY = rectangle.Y;

            if (QueueChecked)
            {
                for (int x = 0; x < rectangle.Width; x++)
                {
                    for (int y = 0; y < rectangle.Height; y++)
                    {
                        RedoUndo newAction = new RedoUndo(rectangle, this);
                        undoHistory.Push(newAction);
                        Queue tempQueue = new Queue(rectangle.X, rectangle.Y, Convert.ToInt32(rectangle.TypeBlock), this);
                        tempQueue.QueueTask();
                        rectangle.Y += 1;
                    }
                    rectangle.Y  = defaultY;
                    rectangle.X += 1;
                }
            }
            else
            {
                for (int x = 0; x < rectangle.Width; x++)
                {
                    for (int y = 0; y < rectangle.Height; y++)
                    {
                        RedoUndo newAction = new RedoUndo(rectangle, this);
                        undoHistory.Push(newAction);
                        currentMap.SetElement(rectangle.X, rectangle.Y, Convert.ToInt32(rectangle.TypeBlock));
                        RenderMap();
                        rectangle.Y += 1;
                    }
                    rectangle.Y  = defaultY;
                    rectangle.X += 1;
                }
            }
        }
Beispiel #4
0
        public void DrawOnMap(customRectangle rectangle, Point click)
        {
            int defaultY = rectangle.Y;
            if (QueueChecked)
            {
                for (int x = 0; x < rectangle.Width; x++)
                {
                    for (int y = 0; y < rectangle.Height; y++)
                    {
                        RedoUndo newAction = new RedoUndo(rectangle, this);
                        undoHistory.Push(newAction);
                        Queue tempQueue = new Queue(rectangle.X, rectangle.Y, Convert.ToInt32(rectangle.TypeBlock), this);
                        tempQueue.QueueTask();
                        rectangle.Y += 1;
                    }
                    rectangle.Y = defaultY;
                    rectangle.X += 1;
                }

            }
            else
            {
                for (int x = 0; x < rectangle.Width; x++)
                {
                    for (int y = 0; y < rectangle.Height; y++)
                    {
                        RedoUndo newAction = new RedoUndo(rectangle, this);
                        undoHistory.Push(newAction);
                        currentMap.SetElement(rectangle.X, rectangle.Y, Convert.ToInt32(rectangle.TypeBlock));
                        RenderMap();
                        rectangle.Y += 1;
                    }
                    rectangle.Y = defaultY;
                    rectangle.X += 1;

                }

            }
        }