private void Vaults(GenerationProgress progress) { progress.Message = "Locking Vaults"; Point POrigin = new Point((int)(Main.maxTilesX * 0.3f), 100); VaultPlanet planet = new VaultPlanet(); planet.Place(POrigin, WorldGen.structures); Point origin = new Point((int)(Main.maxTilesX * 0.4f), (int)(Main.maxTilesY * 0.6f)); Vault a = new Vault(); a.Place(origin, WorldGen.structures); int DungeonSide = (Main.dungeonX > Main.maxTilesX / 2) ? (-1) : 1; origin = new Point(DungeonSide == 1 ? (Main.maxTilesX - 150) : 150, (int)(Main.maxTilesY * 0.7f)); Vault b = new Vault(); b.Place(origin, WorldGen.structures); origin = new Point((int)(Main.maxTilesX * 0.7f), (int)(Main.maxTilesY * 0.35f)); Vault c = new Vault(); c.Place(origin, WorldGen.structures); progress.Message = "Entering the Atmosphere"; Point OOrigin = new Point((int)(Main.maxTilesX * 0.25f), 100); Observatory observatory = new Observatory(); observatory.Place(OOrigin, WorldGen.structures); }
public static List <string> GetDataToDownload(int observatoryId, int instrumentId, int dataTypeId, DateTime date) { List <string> pathAndName = new List <string>(); // Get observatory by id. Observatory observatory = Repository.GetObservatory(observatoryId); // Get instrument by id. Instrument instrument = Repository.GetInstrument(observatory, instrumentId); // Get data type by id. DataType dataType = Repository.GetDataType(instrument.InstrumentType, dataTypeId); // Build path to the data file. string filePath = Path.Combine(observatory.RootFolder, string.Format(instrument.InstrumentType.FolderMask, date), string.Format(dataType.FileMask, date, instrument.Number, observatory.Location.First())); pathAndName.Add(Path.Combine(observatory.RootFolder, string.Format(instrument.InstrumentType.FolderMask, date))); string[] temp = dataType.FileMask.Split('{', '}'); foreach (var item in temp) { if (item.Contains("yy")) { pathAndName.Add(string.Format("{" + item.Trim(new char[] { 'm', 'H' }) + "}", date)); } } return(pathAndName); }
protected void ObservatoryDropDown_SelectedIndexChanged(object sender, EventArgs e) { int observatoryId = Convert.ToInt32(this.ObservatoryDropDown.SelectedValue); Observatory observatory = Repository.Observatories.Where(o => o.Id == observatoryId).First(); FillDropDown(this.InstrumentDropDown, observatory.Instruments); FillDropDown(this.DataTypeDropDown, observatory.Instruments.First().InstrumentType.DataTypes); }
/// <summary> /// Gets an observatory by id. /// </summary> /// <param name="observatoryId">An observatory id.</param> /// <returns>The observatory object.</returns> public static Observatory GetObservatory(int observatoryId) { Observatory result = Repository.Observatories.Where(o => o.Id == observatoryId).FirstOrDefault(); if (result == null) { throw new ArgumentException(string.Format("Observatory, id = '{0}', does not exists.", observatoryId)); } return(result); }
protected void InstrumentDropDown_SelectedIndexChanged(object sender, EventArgs e) { int observatoryId = Convert.ToInt32(this.ObservatoryDropDown.SelectedValue); Observatory observatory = Repository.Observatories.Where(o => o.Id == observatoryId).First(); int instrumentId = Convert.ToInt32(this.InstrumentDropDown.SelectedValue); Instrument insrument = observatory.Instruments.Where(i => i.Id == instrumentId).FirstOrDefault(); if (insrument != null) { FillDropDown(this.DataTypeDropDown, insrument.InstrumentType.DataTypes); } }
/// <summary> /// Gets an observatory instrument by id. /// </summary> /// <param name="observatory">An observatory object.</param> /// <param name="instrumentId">An instrument id.</param> /// <returns>The instrument object.</returns> public static Instrument GetInstrument(Observatory observatory, int instrumentId) { if (observatory == null) { throw new ArgumentNullException("observatory"); } Instrument result = observatory.Instruments.Where(i => i.Id == instrumentId).FirstOrDefault(); if (result == null) { throw new ArgumentException(string.Format("Instrument, id = '{0}', does not exists or belong to the specified observatory '{1}'.", instrumentId, observatory.ShortName)); } return(result); }
/// <summary> /// Returns plotted data for the specified date time. /// </summary> /// <param name="observatoryId">The observatory id.</param> /// <param name="instrumentId">The instrument id.</param> /// <param name="dataTypeId">The data type id.</param> /// <param name="date">The date.</param> /// <returns>The stream containing plotted data.</returns> public static Stream GetData(int observatoryId, int instrumentId, int dataTypeId, DateTime date) { // Get observatory by id. Observatory observatory = Repository.GetObservatory(observatoryId); // Get instrument by id. Instrument instrument = Repository.GetInstrument(observatory, instrumentId); // Get data type by id. DataType dataType = Repository.GetDataType(instrument.InstrumentType, dataTypeId); // Build path to the data file. string filePath = Path.Combine(observatory.RootFolder, string.Format(instrument.InstrumentType.FolderMask, date), string.Format(dataType.FileMask, date, instrument.Number, observatory.Location.First())); return(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { var observatoryIds = GetQueryParameterValues <int>(Default.ObservatoryParameter); var instrumentIds = GetQueryParameterValues <int>(Default.InstrumentParameter); var dataTypeIds = GetQueryParameterValues <int>(Default.DataTypeParameter); var dates = GetQueryParameterValues <DateTime>(Default.DateTimeParameter); for (int k = 0; k < observatoryIds.Length; k++) { Observatory observatory = Repository.GetObservatory(observatoryIds[k]); if (observatory == null) { observatory = Repository.Observatories.First(); } Instrument instrument = k < instrumentIds.Length ? observatory.Instruments.FirstOrDefault(i => i.Id == instrumentIds[k]) : null; if (instrument == null) { instrument = observatory.Instruments.First(); } DataType dataType = k < dataTypeIds.Length ? instrument.InstrumentType.DataTypes.FirstOrDefault(t => t.Id == dataTypeIds[k]) : null; if (dataType == null) { instrument.InstrumentType.DataTypes.First(); } this.DataConstructor.AddView(k, observatory.Id, instrument.Id, dataType.Id, dates.Length > 0 ? dates[0] : DateTime.Now); } if (observatoryIds.Length == 0) { var observatory = Repository.Observatories.First(); var instrument = observatory.Instruments.First(); var dataType = instrument.InstrumentType.DataTypes.First(); this.DataConstructor.AddView(0, observatory.Id, instrument.Id, dataType.Id, DateTime.Now); } } }
/// <summary> /// returns true if something has changed /// </summary> /// <param name="i"></param> /// <returns></returns> public bool UpdateSector(int i) { var rs = mapSectors[i]; if (rs == null) { return(false); } else { byte x2 = (byte)Random.Range(0, RingSector.MAX_POINTS_COUNT); if (rs.innerPointsIDs.ContainsKey(x2)) // в этой позиции уже есть точка { MapPoint mp = null; int id = -1; if (rs.innerPointsIDs.TryGetValue(x2, out id)) { mp = GetMapPointByID(id); if (mp != null) { return(mp.Update()); } else { return(false); } } else { rs.innerPointsIDs.Remove(x2); return(false); } } else // пустая позиция { return(rs.CreateNewPoint(x2, ascension, Observatory.GetVisibilityCoefficient())); } } }
/// <summary> /// Initializes control. /// </summary> /// <param name="number">The order number.</param> /// <param name="observatory">The observatory id.</param> /// <param name="instrument">The instrument id.</param> /// <param name="dataType">The data type id.</param> /// <param name="dateTime">The date time.</param> public void Initialize(int orderNumber, int observatoryId, int instrumentId, int dataTypeId, DateTime dateTime) { this.OrderNumber = orderNumber; Observatory observatory = Repository.GetObservatory(observatoryId); Instrument instrument = Repository.GetInstrument(observatory, instrumentId); DataType dataType = Repository.GetDataType(instrument.InstrumentType, dataTypeId); SetDateTimeFormat(dataType); FillDateTimeText(this.DateTimeText, dateTime); FillDropDown(this.ObservatoryDropDown, Repository.Observatories); this.ObservatoryDropDown.SelectedValue = observatory.Id.ToString(); FillDropDown(this.InstrumentDropDown, observatory.Instruments); this.InstrumentDropDown.SelectedValue = instrument.Id.ToString(); FillDropDown(this.DataTypeDropDown, instrument.InstrumentType.DataTypes); this.DataTypeDropDown.SelectedValue = dataType.Id.ToString(); // Hide 'Remove' button for the first view. this.RemoveButton.Visible = orderNumber != 0; FillImageControls(observatoryId, instrumentId, dataTypeId, dateTime); }