Ejemplo n.º 1
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Let the plugins know
                General.Plugins.OnMapCloseBegin();

                // Stop processing
                General.MainWindow.StopProcessing();

                // Change to no mode
                General.Editing.ChangeMode((EditMode)null);

                // Unbind any methods
                General.Actions.UnbindMethods(this);

                // Dispose
                if (grid != null)
                {
                    grid.Dispose();
                }
                if (launcher != null)
                {
                    launcher.Dispose();
                }
                if (copypaste != null)
                {
                    copypaste.Dispose();
                }
                if (undoredo != null)
                {
                    undoredo.Dispose();
                }
                General.WriteLogLine("Unloading data resources...");
                if (data != null)
                {
                    data.Dispose();
                }
                General.WriteLogLine("Unloading map data...");
                if (map != null)
                {
                    map.Dispose();
                }
                General.WriteLogLine("Stopping graphics device...");
                if (renderer2d != null)
                {
                    renderer2d.Dispose();
                }
                if (renderer3d != null)
                {
                    renderer3d.Dispose();
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                }
                visualcamera = null;
                grid         = null;
                launcher     = null;
                copypaste    = null;
                undoredo     = null;
                data         = null;
                //tempwad = null;
                map        = null;
                renderer2d = null;
                renderer3d = null;
                graphics   = null;

                // We may spend some time to clean things up here
                GC.Collect();

                // Let the plugins know
                General.Plugins.OnMapCloseEnd();

                // Done
                isdisposed = true;
            }
        }