private void NewSector_Load(object sender, EventArgs e) { sp = new SectorProps(); String selectedName = tree.SelectedNode.Text; int id = mainFrm.systems.getIDFromName(selectedName); sp.SystemID = id; sp.Width = 200000; sp.Height = 200000; sp.Depth = 50000; sp.Name = "<New Sector>"; propertyGrid1.SelectedObject = sp; }
private void setupData(DataRow r) { //Retrieve Properties from sql row. String sectorName = r["name"].ToString(); float xmin = float.Parse(r["x_min"].ToString()); float xmax = float.Parse(r["x_max"].ToString()); float ymin = float.Parse(r["y_min"].ToString()); float ymax = float.Parse(r["y_max"].ToString()); float zmin = float.Parse(r["z_min"].ToString()); float zmax = float.Parse(r["z_max"].ToString()); int gridx = int.Parse(r["grid_x"].ToString()); int gridy = int.Parse(r["grid_y"].ToString()); int gridz = int.Parse(r["grid_z"].ToString()); float fognear = float.Parse(r["fog_near"].ToString()); float fogfar = float.Parse(r["fog_far"].ToString()); int debrismode = int.Parse(r["debris_mode"].ToString()); bool lightbackdrop = (Boolean)r["light_backdrop"]; bool fogbackdrop = (Boolean)r["fog_backdrop"]; bool swapbackdrop = (Boolean)r["swap_backdrop"]; float backdropfognear = float.Parse(r["backdrop_fog_near"].ToString()); float backdropfogfar = float.Parse(r["backdrop_fog_far"].ToString()); float maxtilt = float.Parse(r["max_tilt"].ToString()); bool autolevel = (Boolean)r["auto_level"]; float impulserate = float.Parse(r["impulse_rate"].ToString()); float decayvelocity = float.Parse(r["decay_velocity"].ToString()); float decayspin = float.Parse(r["decay_spin"].ToString()); int backdropasset = int.Parse(r["backdrop_asset"].ToString()); String greetings = r["greetings"].ToString(); String notes = r["notes"].ToString(); int systemid = int.Parse(r["system_id"].ToString()); float galaxyx = float.Parse(r["galaxy_x"].ToString()); float galaxyy = float.Parse(r["galaxy_y"].ToString()); float galaxyz = float.Parse(r["galaxy_z"].ToString()); int sector_type = int.Parse(r["sector_type"].ToString()); float width = xmax - xmin; float height = ymax - ymin; float depth = zmax - zmin; //Populate Properties sp = new SectorProps(); sp.Name = sectorName; sp.Width = width; sp.Height = height; sp.Depth = depth; sp.GridX = gridx; sp.GridY = gridy; sp.GridZ = gridz; sp.FogNear = fognear; sp.FogFar = fogfar; sp.DebrisMode = debrismode; sp.LightBackdrop = lightbackdrop; sp.FogBackdrop = fogbackdrop; sp.SwapBackdrop = swapbackdrop; sp.BackdropFogNear = backdropfognear; sp.BackdropFogFar = backdropfogfar; sp.MaxTilt = maxtilt; sp.AutoLevel = autolevel; sp.ImpulseRate = impulserate; sp.DecayVelocity = decayvelocity; sp.DecaySpin = decayspin; sp.BackdropAsset = backdropasset; sp.Greetings = greetings; sp.Notes = notes; sp.SystemID = systemid; sp.GalaxyX = galaxyx; sp.GalaxyY = galaxyy; sp.GalaxyZ = galaxyz; String oSector = ""; switch (sector_type) { case 0: oSector = "Space Sector"; break; case 1: oSector = "Rocky Planet Surface"; break; case 2: oSector = "Gas Giant Surface"; break;; } sp.SectorType = oSector; }