private void FinalizeMapReading() { if (!PrimaryKeyMaps.Any()) { throw new Exception("No primary key maps found on " + typeof(T).Name + ". Use the AutonumberAttribute or KeyAttribute to mark a property as a primary key."); } if (StandardMaps.Any()) { AllMaps.AddRange(StandardMaps); } AllMaps.AddRange(PrimaryKeyMaps); if (!AllMaps.Any()) { throw new Exception("No mappable properties found on " + typeof(T).Name); } AllMapsDictionary = new Dictionary <string, string>(); foreach (IMap map in AllMaps) { AllMapsDictionary.Add(map.PropertyName, map.ColumnName); } }
/// <summary> /// Forces the update of inaccessible private static fields of the Map class. /// </summary> public static void UpdateMaps() { try { AllMaps.Sort((m1, m2) => { var res = 0; if (m1.CompareNull(m2, ref res)) { return(res); } return(m1.MapIndex.CompareTo(m2.MapIndex)); }); if (_InternalMapNames == null) { return; } _InternalMapNames.SetValue(null, null); } catch (Exception e) { Instances.CSOptions.ToConsole("Update of Map Values and Names array failed:"); Instances.CSOptions.ToConsole(e); } }
public void Delete() { if (Deleted) { return; } Wipe(); Deleted = true; var dr = DefaultRegion; if (dr != null) { dr.Unregister(); DefaultRegion = null; } if (Maps.InBounds(MapIndex) && Maps[MapIndex] == this) { Maps[MapIndex] = null; } if (AllMaps.Remove(this)) { UpdateMaps(); } Instances.Maps.Remove(Serial); }
public InstanceMap(int index, Map parent, string name, Season season, MapRules rules) : base(parent.MapID, index, parent.MapID, parent.Width, parent.Height, (int)season, name, rules) { InstanceRegions = new List <InstanceRegion>(); Mobiles = new List <Mobile>(); Items = new List <Item>(); BounceInfo = new Dictionary <PlayerMobile, MapPoint>(); if (!Maps.InBounds(MapIndex) || MapIndex == 255 || MapIndex == 127) { Serial = new InstanceMapSerial(-MapIndex); Deleted = true; return; } Serial = new InstanceMapSerial(MapIndex); Parent = parent; Maps[MapIndex] = this; AllMaps.Add(this); UpdateMaps(); }
public static void Add(Layer layer, bool updateTree) { if (!LayerList.ContainsKey(layer.ID)) { if (AllMaps.ContainsKey(layer.ReferenceFrame)) { LayerList[layer.ID] = layer; AllMaps[layer.ReferenceFrame].Layers.Add(layer); version++; if (updateTree) { LoadTree(); } } } }
public static void ConnectAllChildren() { foreach (String key in AllMaps.Keys) { LayerMap map = AllMaps[key]; if (String.IsNullOrEmpty(map.Frame.Parent) && !LayerMaps.ContainsKey(map.Frame.Name)) { LayerMaps[map.Name] = map; } else if (!String.IsNullOrEmpty(map.Frame.Parent) && AllMaps.ContainsKey(map.Frame.Parent)) { if (!AllMaps[map.Frame.Parent].ChildMaps.ContainsKey(map.Frame.Name)) { AllMaps[map.Frame.Parent].ChildMaps[map.Frame.Name] = map; } } } }
public virtual void Delete() { if (m_Deleted || !World.OnDelete(this)) { return; } AllMaps.Remove(this); EjectPlayers(); OnDelete(); m_Deleted = true; World.RemoveMap(this); OnAfterDelete(); }
private static void AddMoons(string file) { string[] data = file.Split("\r\n"); bool first = true; foreach (string line in data) { if (first) { first = false; continue; } string[] parts = line.Split("\t"); string planet = parts[0]; LayerMap frame = new LayerMap(parts[2], ReferenceFrames.Custom); frame.Frame.SystemGenerated = true; frame.Frame.Epoch = double.Parse(parts[1]); frame.Frame.SemiMajorAxis = double.Parse(parts[3]) * 1000; frame.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital; frame.Frame.Inclination = double.Parse(parts[7]); frame.Frame.LongitudeOfAscendingNode = double.Parse(parts[8]); frame.Frame.Eccentricity = double.Parse(parts[4]); frame.Frame.MeanAnomolyAtEpoch = double.Parse(parts[6]); frame.Frame.MeanDailyMotion = double.Parse(parts[9]); frame.Frame.ArgumentOfPeriapsis = double.Parse(parts[5]); frame.Frame.Scale = 1; frame.Frame.SemiMajorAxisUnits = AltUnits.Meters; frame.Frame.MeanRadius = double.Parse(parts[16]) * 1000; frame.Frame.RotationalPeriod = double.Parse(parts[17]); frame.Frame.ShowAsPoint = false; frame.Frame.ShowOrbitPath = true; frame.Frame.RepresentativeColor = Color.FromArgb(255, 144, 238, 144); frame.Frame.Oblateness = 0; LayerMaps["Sun"].ChildMaps[planet] = frame; AllMaps.Clear(); AddAllMaps(LayerMaps, null); } }
private void Form1_Load(object sender, EventArgs e) { comboBox1.DisplayMember = "Name"; comboBox1.DataSource = Helpers.HelpUrls.AllHelps; comboBox1.SelectedIndex = 0; comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged; APIHelper.RegisterHotKey(Handle, 100, APIHelper.KeyModifiers.Alt, Keys.S); AllMaps.Init_AllMaps(); comb_map.Items.Clear(); comb_map.DisplayMember = "NameDetail"; comb_map.ValueMember = "Key"; var dt = AllMaps.Data.Select(x => x.Value); comb_map.DataSource = dt.ToArray(); comb_map.SelectedIndex = 0; AllPlaces.Init_Place(); AllPoints.Init_Points(); button7_Click(null, null); }
public static void PurgeLayerMapDeep(LayerMap target, bool topLevel) { foreach (Layer layer in target.Layers) { LayerManager.DeleteLayerByID(layer.ID, false, false); } target.Layers.Clear(); foreach (string key in target.ChildMaps.Keys) { LayerMap map = target.ChildMaps[key]; PurgeLayerMapDeep(map, false); } target.ChildMaps.Clear(); if (topLevel) { if (!String.IsNullOrEmpty(target.Frame.Parent)) { if (AllMaps.ContainsKey(target.Frame.Parent)) { AllMaps[target.Frame.Parent].ChildMaps.Remove(target.Name); } } else { if (LayerMaps.ContainsKey(target.Name)) { LayerMaps.Remove(target.Name); } } } AllMaps.Remove(target.Name); version++; }
//todo remove the stuff from draw that is redundant once predraw has run internal static void PreDraw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested) { if (!AllMaps.ContainsKey(referenceFrame)) { return; } LayerMap thisMap = AllMaps[referenceFrame]; if (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0) { return; } if (TourPlayer.Playing) { TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController as TourPlayer; if (player != null) { TourDocument tour = player.Tour; if (tour.CurrentTourStop != null) { player.UpdateTweenPosition(-1); tour.CurrentTourStop.UpdateLayerOpacity(); foreach (Guid key in tour.CurrentTourStop.Layers.Keys) { LayerInfo info = tour.CurrentTourStop.Layers[key]; if (LayerList.ContainsKey(info.ID)) { LayerList[info.ID].Opacity = info.FrameOpacity; LayerList[info.ID].SetParams(info.FrameParams); } } } } } Matrix3d matOld = renderContext.World; Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating; double oldNominalRadius = renderContext.NominalRadius; if (thisMap.Frame.Reference == ReferenceFrames.Custom) { thisMap.ComputeFrame(renderContext); if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital) //if (true) { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World); } else { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); } renderContext.NominalRadius = thisMap.Frame.MeanRadius; } for (int pass = 0; pass < 2; pass++) { foreach (Layer layer in AllMaps[referenceFrame].Layers) { if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer))) { if (layer.Enabled) // && astronomical == layer.Astronomical) { double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime); double layerEnd = SpaceTimeController.UtcToJulian(layer.EndTime); double fadeIn = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); double fadeOut = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut) { float fadeOpacity = 1; if (SpaceTimeController.JNow < layerStart) { fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000)); } if (SpaceTimeController.JNow > layerEnd) { fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000)); } if (thisMap.Frame.Reference == ReferenceFrames.Sky) { layer.Astronomical = true; } layer.PreDraw(renderContext, opacity * fadeOpacity); } } } } } if (nested) { foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys) { LayerMap map = AllMaps[referenceFrame].ChildMaps[key]; if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity)) { PreDraw(renderContext, opacity, astronomical, map.Name, nested); } } } renderContext.NominalRadius = oldNominalRadius; renderContext.World = matOld; renderContext.WorldBaseNonRotating = matOldNonRotating; }
internal static void Draw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested, bool cosmos) { if (!AllMaps.ContainsKey(referenceFrame)) { return; } LayerMap thisMap = AllMaps[referenceFrame]; if (!thisMap.Enabled || (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0 && !(thisMap.Frame.ShowAsPoint || thisMap.Frame.ShowOrbitPath))) { return; } if (TourPlayer.Playing) { TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController; if (player != null) { TourDocument tour = player.Tour; if (tour.CurrentTourStop != null) { player.UpdateTweenPosition(-1); tour.CurrentTourStop.UpdateLayerOpacity(); foreach (Guid key in tour.CurrentTourStop.Layers.Keys) { LayerInfo info = tour.CurrentTourStop.Layers[key]; if (LayerList.ContainsKey(info.ID)) { LayerList[info.ID].Opacity = info.FrameOpacity; LayerList[info.ID].SetParams(info.FrameParams); } } } } } Matrix3d matOld = renderContext.World; Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating; double oldNominalRadius = renderContext.NominalRadius; if (thisMap.Frame.Reference == ReferenceFrames.Custom) { thisMap.ComputeFrame(renderContext); if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital && thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Trajectory) //if (true) { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World); } else { renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); } renderContext.NominalRadius = thisMap.Frame.MeanRadius; } if (thisMap.Frame.ShowAsPoint) { // todo Draw point planet... // Planets.DrawPointPlanet(renderContext.Device, new Vector3d(0, 0, 0), (float).2, thisMap.Frame.RepresentativeColor, true); } for (int pass = 0; pass < 2; pass++) { foreach (Layer layer in AllMaps[referenceFrame].Layers) { if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer))) { if (layer.Enabled) // && astronomical == layer.Astronomical) { double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime); double layerEnd = SpaceTimeController.UtcToJulian(layer.EndTime); double fadeIn = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); double fadeOut = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0); if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut) { float fadeOpacity = 1; if (SpaceTimeController.JNow < layerStart) { fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000)); } if (SpaceTimeController.JNow > layerEnd) { fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000)); } layer.Astronomical = astronomical; //if (thisMap.Frame.Reference == ReferenceFrames.Sky) //{ // layer.Astronomical = true; //} layer.Draw(renderContext, opacity * fadeOpacity, cosmos); } } } } } if (nested) { foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys) { LayerMap map = AllMaps[referenceFrame].ChildMaps[key]; if (map.Frame.ShowOrbitPath && Settings.Active.SolarSystemOrbits) { if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Orbital) { if (map.Frame.Orbit == null) { map.Frame.Orbit = new Orbit(map.Frame.Elements, 360, map.Frame.RepresentativeColor, 1, (float)renderContext.NominalRadius); } Matrix3d matSaved = renderContext.World; renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating); map.Frame.Orbit.Draw3D(renderContext, 1f * .25f, Vector3d.Create(0, 0, 0)); renderContext.World = matSaved; } else if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Trajectory) { //todo add trajectories back //if (map.Frame.trajectoryLines == null) //{ // map.Frame.trajectoryLines = new LineList(renderContext.Device); // map.Frame.trajectoryLines.ShowFarSide = true; // map.Frame.trajectoryLines.UseNonRotatingFrame = true; // int count = map.Frame.Trajectory.Count - 1; // for (int i = 0; i < count; i++) // { // Vector3d pos1 = map.Frame.Trajectory[i].Position; // Vector3d pos2 = map.Frame.Trajectory[i + 1].Position; // pos1.Multiply(1 / renderContext.NominalRadius); // pos2.Multiply(1 / renderContext.NominalRadius); // map.Frame.trajectoryLines.AddLine(pos1, pos2, map.Frame.RepresentativeColor, new Dates()); // } //} //Matrix3D matSaved = renderContext.World; //renderContext.World = thisMap.Frame.WorldMatrix * renderContext.WorldBaseNonRotating; //map.Frame.trajectoryLines.DrawLines(renderContext, Earth3d.MainWindow.showMinorOrbits.Opacity * .25f); //renderContext.World = matSaved; } } if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity)) { Draw(renderContext, opacity, astronomical, map.Name, nested, cosmos); } } } renderContext.NominalRadius = oldNominalRadius; renderContext.World = matOld; renderContext.WorldBaseNonRotating = matOldNonRotating; }
// Merged layers from Tour Player Alternate universe into the real layer manager layers list public static void MergeToursLayers() { tourLayers = false; bool OverWrite = false; bool CollisionChecked = false; foreach (String key in allMapsTours.Keys) { LayerMap map = allMapsTours[key]; if (!allMaps.ContainsKey(map.Name)) { LayerMap newMap = new LayerMap(map.Name, ReferenceFrames.Custom); newMap.Frame = map.Frame; newMap.LoadedFromTour = true; LayerManager.AllMaps[newMap.Name] = newMap; } } ConnectAllChildren(); foreach (Guid key in layerListTours.Keys) { Layer layer = layerListTours[key]; if (LayerList.ContainsKey(layer.ID)) { if (!CollisionChecked) { //todo add UI in the future if (true) // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { OverWrite = true; } else { OverWrite = false; } CollisionChecked = true; } if (OverWrite) { LayerManager.DeleteLayerByID(layer.ID, true, false); } } if (!LayerList.ContainsKey(layer.ID)) { if (AllMaps.ContainsKey(layer.ReferenceFrame)) { LayerList[layer.ID] = layer; AllMaps[layer.ReferenceFrame].Layers.Add(layer); } } else { layer.CleanUp(); } } layerListTours.Clear(); allMapsTours.Clear(); layerMapsTours.Clear(); LoadTree(); }
static public void InitLayers() { ClearLayers(); //LayerMap iss = null; //if (!TourLayers) //{ // string[] isstle = new string[0]; // try // { // //This is downloaded now on startup // string url = "http://www.worldwidetelescope.org/wwtweb/isstle.aspx"; // string filename = string.Format(@"{0}data\isstle.txt", Properties.Settings.Default.CahceDirectory); // DataSetManager.DownloadFile(url, filename, false, false); // isstle = File.ReadAllLines(filename); // } // catch // { // } // iss = new LayerMap("ISS", ReferenceFrames.Custom); // iss.Frame.Epoch = SpaceTimeController.TwoLineDateToJulian("10184.51609218"); // iss.Frame.SemiMajorAxis = 6728829.41; // iss.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital; // iss.Frame.Inclination = 51.6442; // iss.Frame.LongitudeOfAscendingNode = 147.0262; // iss.Frame.Eccentricity = .0009909; // iss.Frame.MeanAnomolyAtEpoch = 325.5563; // iss.Frame.MeanDailyMotion = 360 * 15.72172655; // iss.Frame.ArgumentOfPeriapsis = 286.4623; // iss.Frame.Scale = 1; // iss.Frame.SemiMajorAxisUnits = AltUnits.Meters; // iss.Frame.MeanRadius = 130; // iss.Frame.Oblateness = 0; // iss.Frame.ShowOrbitPath = true; // if (isstle.Length > 1) // { // iss.Frame.FromTLE(isstle[0], isstle[1], 398600441800000); // } //} LayerMaps["Sun"] = new LayerMap("Sun", ReferenceFrames.Sun); LayerMaps["Sun"].ChildMaps["Mercury"] = new LayerMap("Mercury", ReferenceFrames.Mercury); LayerMaps["Sun"].ChildMaps["Venus"] = new LayerMap("Venus", ReferenceFrames.Venus); LayerMaps["Sun"].ChildMaps["Earth"] = new LayerMap("Earth", ReferenceFrames.Earth); LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps["Moon"] = new LayerMap("Moon", ReferenceFrames.Moon); //if (!TourLayers) //{ // LayerMaps["Sun"].ChildMaps["Earth"].ChildMaps.Add("ISS", iss); //} LayerMaps["Sun"].ChildMaps["Mars"] = new LayerMap("Mars", ReferenceFrames.Mars); LayerMaps["Sun"].ChildMaps["Jupiter"] = new LayerMap("Jupiter", ReferenceFrames.Jupiter); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Io"] = new LayerMap("Io", ReferenceFrames.Io); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Europa"] = new LayerMap("Europa", ReferenceFrames.Europa); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Ganymede"] = new LayerMap("Ganymede", ReferenceFrames.Ganymede); LayerMaps["Sun"].ChildMaps["Jupiter"].ChildMaps["Callisto"] = new LayerMap("Callisto", ReferenceFrames.Callisto); LayerMaps["Sun"].ChildMaps["Saturn"] = new LayerMap("Saturn", ReferenceFrames.Saturn); LayerMaps["Sun"].ChildMaps["Uranus"] = new LayerMap("Uranus", ReferenceFrames.Uranus); LayerMaps["Sun"].ChildMaps["Neptune"] = new LayerMap("Neptune", ReferenceFrames.Neptune); LayerMaps["Sun"].ChildMaps["Pluto"] = new LayerMap("Pluto", ReferenceFrames.Pluto); // AddMoons(); LayerMaps["Sky"] = new LayerMap("Sky", ReferenceFrames.Sky); LayerMaps["Sun"].Open = true; AllMaps.Clear(); AddAllMaps(LayerMaps, null); version++; LoadTree(); }
public virtual void Register() { AllMaps.Add(this); World.AddMap(this); }