private void FillExpeditions() { Dictionary <string, Func <DateTime> > excursions = new Dictionary <string, Func <DateTime> >() { { "All", () => VisitedSystems.Select(s => s.time).Union(new[] { DateTime.Now }).OrderBy(s => s).FirstOrDefault() }, { "Distant Worlds", () => new DateTime(2016, 1, 14) }, { "FGE Expedition start", () => new DateTime(2015, 8, 1) }, { "Last Week", () => DateTime.Now.AddDays(-7) }, { "Last Month", () => DateTime.Now.AddMonths(-1) }, { "Last Year", () => DateTime.Now.AddYears(-1) } }; foreach (var kvp in excursions) { var item = new ToolStripButton { Text = kvp.Key, CheckOnClick = true, DisplayStyle = ToolStripItemDisplayStyle.Text }; var startfunc = kvp.Value; item.Click += (s, e) => dropdownFilterHistory_Item_Click(s, e, item, startfunc); dropdownFilterDate.DropDownItems.Add(item); } var citem = new ToolStripButton { Text = "Custom", CheckOnClick = true, DisplayStyle = ToolStripItemDisplayStyle.Text }; citem.Click += (s, e) => dropdownFilterHistory_Custom_Click(s, e, citem); dropdownFilterDate.DropDownItems.Add(citem); startTime = excursions["All"](); endTime = DateTime.Now.AddDays(1); startPicker = new DateTimePicker(); endPicker = new DateTimePicker(); startPicker.ValueChanged += StartPicker_ValueChanged; endPicker.ValueChanged += EndPicker_ValueChanged; startPickerHost = new ToolStripControlHost(startPicker) { Visible = false }; endPickerHost = new ToolStripControlHost(endPicker) { Visible = false }; toolStripShowAllStars.Items.Add(startPickerHost); toolStripShowAllStars.Items.Add(endPickerHost); }
public void AddVisitedSystemsInformation() { if (VisitedSystems != null && VisitedSystems.Any()) { ISystem lastknownps = LastKnownSystemPosition(); // For some reason I am unable to fathom this errors during the session after DBUpgrade8 // colours just resolves to an object reference not set error, but after a restart it works fine // Not going to waste any more time, a one time restart is hardly the worst workaround in the world... IEnumerable <IGrouping <int, SystemPosition> > colours = from SystemPosition sysPos in VisitedSystems where sysPos.vs != null group sysPos by sysPos.vs.MapColour; if (colours != null) { foreach (IGrouping <int, SystemPosition> colour in colours) { if (DrawLines) { var datasetl = Data3DSetClass <LineData> .Create("visitedstars" + colour.Key.ToString(), Color.FromArgb(colour.Key), 2.0f); foreach (SystemPosition sp in colour) { if (sp.curSystem != null && sp.curSystem.HasCoordinate && sp.lastKnownSystem != null && sp.lastKnownSystem.HasCoordinate) { datasetl.Add(new LineData(sp.curSystem.x, sp.curSystem.y, sp.curSystem.z, sp.lastKnownSystem.x, sp.lastKnownSystem.y, sp.lastKnownSystem.z)); } } _datasets.Add(datasetl); } else { var datasetvs = Data3DSetClass <PointData> .Create("visitedstars" + colour.Key.ToString(), Color.FromArgb(colour.Key), 2.0f); foreach (SystemPosition sp in colour) { ISystem star = SystemData.GetSystem(sp.Name); if (star != null && star.HasCoordinate) { AddSystem(star, datasetvs); } } _datasets.Add(datasetvs); } } } } }
private void GenerateDataSetStandard() { if (_datasets != null) { foreach (var ds in _datasets) { if (ds is IDisposable) { ((IDisposable)ds).Dispose(); } } } InitStarLists(); selectedmaps = GetSelectedMaps(); builder = new DatasetBuilder() { // TODO: I'm working on deprecating "Origin" so that everything is build with an origin of (0,0,0) and the camera moves instead. // This will allow us a little more flexibility with moving the cursor around and improving translation/rotations. CenterSystem = CenterSystem, SelectedSystem = _clickedSystem, VisitedSystems = VisitedSystems.Where(s => s.time >= startTime && s.time <= endTime).OrderBy(s => s.time).ToList(), Images = selectedmaps.ToArray(), GridLines = toolStripButtonGrid.Checked, DrawLines = toolStripButtonDrawLines.Checked, AllSystems = toolStripButtonShowAllStars.Checked, Stations = toolStripButtonStations.Checked, UseImage = selectedmaps.Count != 0 }; if (_starList != null) { builder.StarList = _starList.ConvertAll(system => (ISystem)system); } if (ReferenceSystems != null) { builder.ReferenceSystems = ReferenceSystems.ConvertAll(system => (ISystem)system); } if (PlannedRoute != null) { builder.PlannedRoute = PlannedRoute.ConvertAll(system => (ISystem)system); } _datasets = builder.Build(); }
private async Task <int> ReadData(FileInfo fileInfo, StreamReader sr) { if (fileInfo == null) { throw new ArgumentNullException("fileInfo"); } if (sr == null) { throw new ArgumentNullException("sr"); } DateTime gammastart = new DateTime(2014, 11, 22, 13, 00, 00); var count = 0; DateTime filetime = DateTime.Now.AddDays(-500); string FirstLine = sr.ReadLine(); string line, str; NetLogFileInfo nfi = null; str = "20" + FirstLine.Substring(0, 8) + " " + FirstLine.Substring(9, 5); filetime = DateTime.Parse(str); if (_netlogfiles.ContainsKey(fileInfo.FullName)) { nfi = _netlogfiles[fileInfo.FullName]; sr.BaseStream.Position = nfi.filePos; sr.DiscardBufferedData(); } while ((line = sr.ReadLine()) != null) { if (line.Contains(" System:")) { SystemPosition ps = SystemPosition.Parse(filetime, line); if (ps != null) { if (ps.Name.Equals("Training")) { continue; } if (ps.Name.Equals("Destination")) { continue; } filetime = ps.Time; if (VisitedSystems.Count > 0) { if (VisitedSystems[VisitedSystems.Count - 1].Name.Equals(ps.Name)) { continue; } } if (ps.Time.Subtract(gammastart).TotalMinutes > 0) // Ta bara med efter gamma. { if (!VisitedSystems.Contains(ps)) { VisitedSystems.Add(ps); await AddNewSystem(ps); } count++; } } } } if (nfi == null) { nfi = new NetLogFileInfo(); } nfi.FileName = fileInfo.FullName; nfi.lastchanged = File.GetLastWriteTimeUtc(nfi.FileName); nfi.filePos = sr.BaseStream.Position; nfi.fileSize = fileInfo.Length; _netlogfiles[nfi.FileName] = nfi; _lastnfi = nfi; return(count); }