Exemplo n.º 1
0
    protected void RemoveAllTurmites()
    {
        Turmites.Clear();

        TurmitesList.Clear();

        Selected = 0;

        WorldPixbuf.Fill(0);

        RenderWorldPixbuf();

        World.ClearPixelWriteBuffer();

        World.Clear();
    }
Exemplo n.º 2
0
    protected void OnWorldEventBoxButtonPressEvent(object o, ButtonPressEventArgs args)
    {
        X0 = Convert.ToInt32(args.Event.X);
        Y0 = Convert.ToInt32(args.Event.Y);

        X1 = X0;
        Y1 = Y0;

        if (!Paused)
        {
            return;
        }

        if (args.Event.Button == 3)
        {
            IsDragging = false;

            for (int i = 0; i < Turmites.Count; i++)
            {
                var minX = Turmites[i].MinX;
                var minY = Turmites[i].MinY;
                var maxX = Turmites[i].MaxX;
                var maxY = Turmites[i].MaxY;

                var box = new Box(minX, minY, maxX, maxY);

                var cx = X1 + WorldParameters.CursorX;
                var cy = Y1 + WorldParameters.CursorY;

                if (GtkSelection.Selection.InBox(cx, cy, box))
                {
                    World.ClearWindow(Turmites[i].MinX, Turmites[i].MinY, Turmites[i].MaxX, Turmites[i].MaxY);

                    Turmites.RemoveAt(i);

                    Refresh();

                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();

                    break;
                }
            }

            if (Turmites.Count <= 0)
            {
                TurmitesList.Clear();
            }

            UpdateTurmitesList(TurmitesList, Turmites);
        }
        else
        {
            if (args.Event.Button == 1)
            {
                Selected = 0;

                for (int i = 0; i < Turmites.Count; i++)
                {
                    var minX = Turmites[i].MinX;
                    var minY = Turmites[i].MinY;
                    var maxX = Turmites[i].MaxX;
                    var maxY = Turmites[i].MaxY;

                    var box = new Box(minX, minY, maxX, maxY);

                    var cx = X1 + WorldParameters.CursorX;
                    var cy = Y1 + WorldParameters.CursorY;

                    if (GtkSelection.Selection.InBox(cx, cy, box))
                    {
                        IsDragging = true;

                        prevX = X0;
                        prevY = Y0;

                        Selected = i + 1;

                        InitializeSelected();

                        break;
                    }
                }
            }
        }
    }