public SystemInfo(ISystem system)
        {
            _system = system;

            var reactiveSystem = system as ReactiveSystem;
            var isReactive = reactiveSystem != null;
            Type systemType;
            if (isReactive) {
                _interfaceFlags = getInterfaceFlags(reactiveSystem.subsystem, isReactive);
                systemType = reactiveSystem.subsystem.GetType();
            } else {
                _interfaceFlags = getInterfaceFlags(system, isReactive);
                systemType = system.GetType();
            }

            var debugSystem = system as DebugSystems;
            if (debugSystem != null) {
                _systemName = debugSystem.name;
            } else {
                _systemName = systemType.Name.EndsWith(SYSTEM_SUFFIX, StringComparison.Ordinal)
                    ? systemType.Name.Substring(0, systemType.Name.Length - SYSTEM_SUFFIX.Length)
                    : systemType.Name;
            }

            isActive = true;
        }
        protected void UpdateLinkedSystem()
        {
            SystemLink selectedItem = (SystemLink)cbSystemLink.SelectedItem;
            _linkSystem = selectedItem.LinkSystem;

            if (selectedItem.LinkSystem != null)
            {
                lblEDSMLink.Text = selectedItem.LinkSystem.name;
            }
            else
            {
                lblEDSMLink.Text = "";
            }

            if (selectedItem.LinkSystem != null && selectedItem.LinkSystem.HasCoordinate)
            {
                tbSysCoordX.Text = selectedItem.LinkSystem.x.ToString("0.000");
                tbSysCoordY.Text = selectedItem.LinkSystem.y.ToString("0.000");
                tbSysCoordZ.Text = selectedItem.LinkSystem.z.ToString("0.000");
                tbSysCoordX.TextAlign = HorizontalAlignment.Right;
                tbSysCoordY.TextAlign = HorizontalAlignment.Right;
                tbSysCoordZ.TextAlign = HorizontalAlignment.Right;
            }
            else
            {
                tbSysCoordX.Text = "?";
                tbSysCoordY.Text = "?";
                tbSysCoordZ.Text = "?";
                tbSysCoordX.TextAlign = HorizontalAlignment.Center;
                tbSysCoordY.TextAlign = HorizontalAlignment.Center;
                tbSysCoordZ.TextAlign = HorizontalAlignment.Center;
            }
        }
示例#3
0
        public void add(ISystem system, int priority)
        {
            priority = priority == -1 ? system.defaultPriority : priority;
            Debug.Assert(priority != -1);

            SystemNode newNode = new SystemNode(system, priority);
            if (_head == null)
            {
                _head = newNode;
            }
            else
            {
                int countBefore = count;

                SystemNode current = _head;
                while (current.next != null)
                {
                    if (current.next.priority > priority)
                    {
                        break;
                    }
                    current = current.next;
                }
                current.insert(newNode);

                int countAfter = count;
                Debug.Assert(countAfter == countBefore + 1);
            }
            Logger.log(string.Format("Added {0} system to SystemManager.", system.systemType));
        }
示例#4
0
 public TestRecord( TestMode testMode, ISystem system, int threadId, long timeInTicks )
 {
     this.TestMode = testMode;
     this.System = system;
     this.ThreadId = threadId;
     this.Time = timeInTicks;
 }
        public void AddLogicSystem(ISystem system)
        {
            if (system == null)
                throw new ArgumentNullException("system");

            logicSystems.Add(system);
        }
            protected override SystemExecutionOrdering GetExecutionOrdering(ISystem system) {
                if (system is SystemA) {
                    return SystemExecutionOrdering.AfterOther;
                }

                return SystemExecutionOrdering.Concurrent;
            }
示例#7
0
        public SpecRunner(IExecutionMode mode, ISystem system)
        {
            _mode = mode;
            _system = system;

            Status = SpecRunnerStatus.Valid;
        }
示例#8
0
        public FixtureLibrary StartSystem(FixtureAssembly fixtureAssembly, MarshalByRefObject remotePublisher)
        {
            _publisher = (IEventPublisher)remotePublisher;

            // TODO -- if fails, do a Thread.Sleep and try again
            _system = fixtureAssembly.FindSystem();
            ProjectFileSystem.RootFolder = fixtureAssembly.RootFolder;

            Project.Current = new Project
            {
                Profile = fixtureAssembly.Profile
            };

            try
            {
                var library = FixtureGraph.Library;
                _runner = new TestRunner(_system, library);
                if (_listener != null)
                {
                    _runner.Listener = _listener;
                }

                return library;
            }
            catch (TestEngineFailureException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new TestEngineFailureException(e.ToString());
            }
        }
        public SpecificationEngine(ISystem system, ISpecRunner runner, IExecutionObserver observer)
        {
            _system = system;
            _runner = runner;

            _executionQueue = new ConsumingQueue(request =>
            {
                if (request.IsCancelled)
                {
                    return;
                }

                _warmup.Wait(30.Seconds());

                observer.SpecStarted(request);
                var results = _runner.Execute(request, _executionQueue );

                if (!request.IsCancelled && results != null)
                {
                    // TODO -- combine the two things here?
                    request.SpecExecutionFinished(results);
                    observer.SpecFinished(request);
                }
            });

            _warmup = _system.Warmup().ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    _runner.MarkAsInvalid(t.Exception);
                }
            });
        }
        /// <summary>
        /// We want to ensure that our paddle system executes before us, as we are using data from
        /// it.
        /// </summary>
        protected override SystemExecutionOrdering GetExecutionOrdering(ISystem system) {
            if (system == _paddles) {
                return SystemExecutionOrdering.AfterOther;
            }

            return base.GetExecutionOrdering(system);
        }
示例#11
0
        public void CreatesInstanceForEverySystemInConstructor()
        {
            var systems = new ISystem[]{new TwoComponentSystem(), new OneComponentSystem()};
            var manager = new RuntimeSystemManager(systems, Mock.Of<ILogger>());

            manager.Systems.Count.ShouldBe(2);
            manager.Systems.ShouldAllBe(p => systems.Contains(p.System));
        }
示例#12
0
        public SpecRunner(IExecutionMode mode, ISystem system, IExecutionObserver observer)
        {
            _mode = mode;
            _system = system;
            _observer = observer;

            Status = SpecRunnerStatus.Valid;
        }
示例#13
0
文件: Driver.cs 项目: pzaps/CrossGFX
        public void Initialize(string resourceDirectory, IClipboard clipboard)
        {
            System = new System(clipboard);
            ResourceManager = new ResourceManager();
            MusicPlayer = new MusicPlayer();

            DriverLoader.AddEnvironmentPaths(new string[] { global::System.IO.Path.GetFullPath(resourceDirectory + "/drivers/x86/sdl") });
        }
示例#14
0
 public ExecutionRun(ISystem system, Timings timings, SpecExecutionRequest request, StopConditions stopConditions, IExecutionMode mode)
 {
     _system = system;
     _timings = timings;
     _request = request;
     _stopConditions = stopConditions;
     _mode = mode;
 }
示例#15
0
        public SpecRunner(IExecutionMode mode, ISystem system, ISpecExpiration specExpiration)
        {
            _mode = mode;
            _system = system;
            _specExpiration = specExpiration;

            Status = SpecRunnerStatus.Valid;
        }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the Engine class.
 /// </summary>
 public EngineComponent()
   : base(RS.engineName, RS.engineNickname,
       RS.engineDescription,
       RS.pluginCategoryName, RS.pluginSubcategoryName, RS.icon_engine, RS.engineGUID)
 {
   reset = RS.resetDefault;
   system = null;
 }
 public void AllConcurrentSystems(ISystem systemA, ISystem systemB, ISystem systemC) {
     List<SystemExecutionGroup> groups = SystemExecutionGroup.GetExecutionGroups(new List<ISystem>() {
         systemA, systemB, systemC
     });
     Assert.Equal(3, groups.Count);
     Assert.Equal(1, groups[0].Systems.Count);
     Assert.Equal(1, groups[1].Systems.Count);
     Assert.Equal(1, groups[2].Systems.Count);
 }
        // TODO -- if an error bubbles up, the SpecificationEngine should mark its runner
        //         as Invalid
        public static StepthroughExecutor Start(ISystem system, Specification specification, IResultObserver observer, IUserInterfaceObserver uiObserver, FixtureLibrary library)
        {
            var request = new SpecExecutionRequest(specification, observer);
            request.CreatePlan(library);

            // Got to watch because this can error out
            var execution = system.CreateContext();

            return new StepthroughExecutor(execution, request, uiObserver);
        }
示例#19
0
 public void RemoveSystem(ISystem system)
 {
     system.End();
     foreach (var priority in m_systems)
     {
         if (priority.Value.Contains(system))
         {
             priority.Value.Remove(system);
         }
     }
 }
        public JobClient(ISystem localSystem)
        {
            this.system = localSystem;
            startupEntryAdded = false;
            ShutdownOnCompletion = false;
            j = null;
            baseDir = new DirectoryInfo(Path.Combine(Utilities.ExecutingAssembly.Directory.FullName, "TestDLL"));
            workerThread = new Thread(new ThreadStart(Run));

            workerThread.IsBackground = true;
        }
        private void OnSetUp(string testName)
        {
            var systemBuilder = new SystemBuilder();
            systemContext = systemBuilder.BuildSystem();

            var dbConfig = CreateDatabaseConfig();

            if (testName != "CreateNewDatabase") {
                database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
            }
        }
示例#22
0
        public RuntimeSystemInstance(ISystem system)
        {
            System = system;
            IsEntitySystem = System is IEntitySystem;

            HasEntityAdd = System is Triggers.IOnEntityAdded;
            HasEntityRemove = System is Triggers.IOnEntityRemoved;
            HasEntityTick = System is Triggers.IOnEntityTick;
            HasTick = System is Triggers.IOnTick;

            CommandHandlers = CommandHandlerUtil.GetCommandHandlers(system).ToList();
        }
示例#23
0
        internal TestRun(TestExecutionRequest request, ITestObserver listener, FixtureLibrary library, ISystem system)
        {
            _request = request;
            _listener = listener;
            _library = library;
            _system = system;

            _result = new TestResult
            {
                RetryAttemptNumber = request.Test.RetryAttemptNumber
            };
        }
示例#24
0
        public void Start(EngineMode mode, Project project, MarshalByRefObject remoteListener)
        {
            Project.CurrentProject = project;

            EventAggregator.Start((IRemoteListener) remoteListener);

            _project = project;

            Type systemType = null;

            try
            {
                systemType = _project.DetermineSystemType();
                _system = Activator.CreateInstance(systemType).As<ISystem>();
                _services.Add(_system);

                var timeZone = new MachineTimeZoneContext();
                var clock = new Clock();
                var systemTime = new SystemTime(clock, timeZone);
                _specExpiration = new SpecExpiration(systemTime);

                if (mode == EngineMode.Interactive)
                {
                    _engine = buildUserInterfaceEngine();
                }
                else
                {
                    _engine = buildBatchedEngine(project.TracingStyle);
                }

                _engine.Start(project.StopConditions);

            }
            catch (Exception e)
            {
                var message = new SystemRecycled
                {
                    error = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
        }
示例#25
0
        private void SetSystem(ISystem currentSystem)
        {
            if (currentSystem == null)
                return;

            textBoxSystemName.Text = currentSystem.name;

            edObjects.Clear();

            edObjects = edmat.GetAll(textBoxSystemName.Text);
            UpDateListView();
            //addMaterialNodeControl1.CurrentSystem = currentSystem.name;
        }
示例#26
0
        /// <summary>
        /// Returns true if the given system can be executed completely independently from the other
        /// systems.
        /// </summary>
        /// <param name="system">The system to check.</param>
        /// <param name="systems">The systems to check against.</param>
        /// <returns>True if the system can be concurrently executed with the other
        /// systems.</returns>
        private static bool IsFullyConcurrent(ISystem system, List<ISystem> systems) {
            foreach (ISystem other in systems) {
                if (system.GetExecutionOrdering(other) != SystemExecutionOrdering.Concurrent) {
                    return false;
                }

                if (other.GetExecutionOrdering(system) != SystemExecutionOrdering.Concurrent) {
                    return false;
                }
            }

            return true;
        }
示例#27
0
        public void TestSetup()
        {
            var systemBuilder = new SystemBuilder();
            systemContext = systemBuilder.BuildSystem();

            var test = TestContext.CurrentContext.Test.Name;

            if (test != "CreateNew" &&
                test != "DatabaseNotExists") {
                var dbConfig = new Configuration.Configuration();
                dbConfig.SetValue("database.name", TestDbName);
                database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
            }
        }
示例#28
0
        public SystemInfo(ISystem system, Type systemType) {
            _system = system;

            var debugSystem = system as DebugSystems;
            if (debugSystem != null) {
                _systemName = debugSystem.name;
            } else {
                _systemName = systemType.Name.EndsWith(SYSTEM_SUFFIX, StringComparison.Ordinal)
                    ? systemType.Name.Substring(0, systemType.Name.Length - SYSTEM_SUFFIX.Length)
                    : systemType.Name;
            }
            
            isActive = true;
        }
示例#29
0
 public void remove()
 {
     if (_previous != null)
     {
         _previous.next = _next;
     }
     if (_next != null)
     {
         _next.previous = _previous;
     }
     _previous = null;
     _next = null;
     _system = null;
 }
示例#30
0
    protected override void SetOutputs(IGH_DataAccess da)
    {
      if (system == null)
      {
        system = new SystemType(agents, emitters, environment);
      }
      else
      {
        system = new SystemType(agents, emitters, environment, (SystemType) system);
      }

      // Finally assign the system to the output parameter.
      da.SetData(nextOutputIndex++, system);
      da.SetDataList(nextOutputIndex++, (List<IQuelea>)system.Quelea.SpatialObjects);
      da.SetData(nextOutputIndex++, new SpatialCollectionType(system.Quelea));
    }
示例#31
0
 public void DestroySystem(ISystem system)
 {
     _systemSubscriptions.RemoveAndDispose(system);
 }
示例#32
0
        private void toolStripButtonImportFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Text Files|*.txt";
            ofd.Title  = "Select a exploration set file";

            if (ofd.ShowDialog(FindForm()) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string[] sysnames;

            try
            {
                sysnames = System.IO.File.ReadAllLines(ofd.FileName);
            }
            catch (IOException)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), $"There was a problem opening file {ofd.FileName}", "Import file",
                                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <String> systems      = new List <String>();
            int           countunknown = 0;

            foreach (String name in sysnames)
            {
                String sysname = name;
                if (sysname.Contains(","))
                {
                    String[] values = sysname.Split(',');
                    sysname = values[0];
                }
                if (String.IsNullOrWhiteSpace(sysname))
                {
                    continue;
                }
                ISystem sc = SystemCache.FindSystem(sysname.Trim());
                if (sc == null)
                {
                    sc = new SystemClass(sysname.Trim());
                    countunknown++;
                }
                systems.Add(sc.Name);
            }

            if (systems.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(),
                                                      "The imported file contains no known system names",
                                                      "Unsaved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ClearExplorationSet();

            foreach (var sysname in systems)
            {
                dataGridViewExplore.Rows.Add(sysname, "", "");
            }

            UpdateSystemRows();
        }
 public void ShipInformation(ShipInformationList shp, string whereami, ISystem system, DB.SQLiteConnectionUser conn)
 {
     shp.FighterDestroyed();
 }
示例#34
0
        // Protected against bad JSON

        public int GetLogs(DateTime?starttimeutc, DateTime?endtimeutc, out List <JournalFSDJump> log, out DateTime logstarttime, out DateTime logendtime, out BaseUtils.ResponseData response)
        {
            log          = new List <JournalFSDJump>();
            logstarttime = DateTime.MaxValue;
            logendtime   = DateTime.MinValue;
            response     = new BaseUtils.ResponseData {
                Error = true, StatusCode = HttpStatusCode.Unauthorized
            };

            if (!ValidCredentials)
            {
                return(0);
            }

            string query = "get-logs?showId=1&apiKey=" + apiKey + "&commanderName=" + HttpUtility.UrlEncode(commanderName);

            if (starttimeutc != null)
            {
                query += "&startDateTime=" + HttpUtility.UrlEncode(starttimeutc.Value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
            }

            if (endtimeutc != null)
            {
                query += "&endDateTime=" + HttpUtility.UrlEncode(endtimeutc.Value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
            }

            response = RequestGet("api-logs-v1/" + query, handleException: true);

            if (response.Error)
            {
                if ((int)response.StatusCode == 429)
                {
                    return(429);
                }
                else
                {
                    return(0);
                }
            }

            var json = response.Body;

            if (json == null)
            {
                return(0);
            }

            try
            {
                JObject msg   = JObject.Parse(json);
                int     msgnr = msg["msgnum"].Int(0);

                JArray logs = (JArray)msg["logs"];

                if (logs != null)
                {
                    string startdatestr = msg["startDateTime"].Value <string>();
                    string enddatestr   = msg["endDateTime"].Value <string>();
                    if (startdatestr == null || !DateTime.TryParseExact(startdatestr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out logstarttime))
                    {
                        logstarttime = DateTime.MaxValue;
                    }
                    if (enddatestr == null || !DateTime.TryParseExact(enddatestr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out logendtime))
                    {
                        logendtime = DateTime.MinValue;
                    }

                    using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
                    {
                        foreach (JObject jo in logs)
                        {
                            string   name          = jo["system"].Value <string>();
                            string   ts            = jo["date"].Value <string>();
                            long     id            = jo["systemId"].Value <long>();
                            bool     firstdiscover = jo["firstDiscover"].Value <bool>();
                            DateTime etutc         = DateTime.ParseExact(ts, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); // UTC time

                            ISystem sc = SystemClassDB.GetSystem(id, cn, SystemClassDB.SystemIDType.EdsmId, name: name);
                            if (sc == null)
                            {
                                if (DateTime.UtcNow.Subtract(etutc).TotalHours < 6) // Avoid running into the rate limit
                                {
                                    sc = GetSystemsByName(name)?.FirstOrDefault(s => s.EDSMID == id);
                                }

                                if (sc == null)
                                {
                                    sc = new SystemClass(name)
                                    {
                                        EDSMID = id
                                    };
                                }
                            }

                            JournalFSDJump fsd = new JournalFSDJump(etutc, sc, EliteConfigInstance.InstanceConfig.DefaultMapColour, firstdiscover, (int)SyncFlags.EDSM);
                            log.Add(fsd);
                        }
                    }
                }

                return(msgnr);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Failed due to " + e.ToString());
                return(499);     // BAD JSON
            }
        }
示例#35
0
 public MissingGroupSystemInterfaceException(ISystem system, MemberInfo member)
     : base($"{member.Name} GroupFrom attribute cannot find an IGroupSystem on {system.GetType().Name}")
 {
     System = system;
     Member = member;
 }
示例#36
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string hostURL = "";
            bool   send    = false;

            ISystem sghSystem = null;

            if (!DA.GetData(0, ref hostURL))
            {
                return;
            }
            // if (!DA.GetData(1, ref conid)) return;
            if (!DA.GetData(1, ref send))
            {
                return;
            }
            if (!DA.GetData(2, ref sghSystem))
            {
                return;
            }

            string url = hostURL + "sWebSystemServer.asmx/ReceiveFromClient";

            string jsonData = "";
            string sysName  = "";


            if (sghSystem != null)
            {
                ISystem ssys = sghSystem as sSystem;
                sysName = ssys.systemSettings.systemName;

                jsonData = ssys.Jsonify();

                if (send)
                {
                    try
                    {
                        var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
                        request.ContentType = "application/json";
                        request.Method      = "POST";
                        request.Expect      = "application/json";

                        using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                        {
                            streamWriter.Write("{'sysFromClient':'" + jsonData + "'}");
                            streamWriter.Close();
                        }

                        var          httpResponse = (System.Net.HttpWebResponse)request.GetResponse();
                        StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());

                        string        resp = streamReader.ReadToEnd();
                        sJsonReceiver jj   = Newtonsoft.Json.JsonConvert.DeserializeObject <sJsonReceiver>(resp);
                        mmes = jj.d;
                    }

                    catch (System.Net.WebException e)
                    {
                        mmes = e.Message;
                    }
                }
            }

            if (mmes == "Uploaded To ASKSGH")
            {
                this.Message = "System : " + sysName + "\nhas been uploaded\nData Size:" + Math.Round(jsonData.Length / 1.0E6, 2) + "Mb";
            }
            else if (mmes == "Failed")
            {
                this.Message = "System Falied";
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, this.Message);
            }
            else
            {
                this.Message = "";
            }

            DA.SetData(0, mmes);
        }
示例#37
0
 public bool CanHandleSystem(ISystem system)
 {
     return(system.IsReactiveDataSystem());
 }
示例#38
0
 public static void Register(ISystem system)
 {
     System.Register(system);
 }
示例#39
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "All", "Stars only",
                                    "Planets only",             //2
                                    "Exploration List Stars",   //3
                                    "Exploration List Planets", //4
                     });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite();
                csv.SetCSVDelimiter(frm.Comma);

                try
                {
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path))
                    {
                        {
                            List <JournalScan> scans = null;

                            if (frm.SelectedIndex < 3)
                            {
                                var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC);
                                scans = entries.ConvertAll(x => (JournalScan)x);
                            }
                            else
                            {
                                ExplorationSetClass currentExplorationSet = new ExplorationSetClass();

                                string file = currentExplorationSet.DialogLoad(FindForm());

                                if (file != null)
                                {
                                    scans = new List <JournalScan>();

                                    foreach (string system in currentExplorationSet.Systems)
                                    {
                                        ISystem sys = SystemCache.FindSystem(system);
                                        if (sys != null)
                                        {
                                            var jl = EDSMClass.GetBodiesList(sys);
                                            List <JournalScan> sysscans = jl.Item1;
                                            if (sysscans != null)
                                            {
                                                scans.AddRange(sysscans);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            bool ShowStars   = frm.SelectedIndex < 2 || frm.SelectedIndex == 3;
                            bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4;

                            List <JournalSAAScanComplete> mappings = ShowPlanets ?
                                                                     JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC)
                                                                     .ConvertAll(x => (JournalSAAScanComplete)x)
                                                      : null;

                            if (frm.IncludeHeader)
                            {
                                // Write header

                                writer.Write(csv.Format("Time"));
                                writer.Write(csv.Format("BodyName"));
                                writer.Write(csv.Format("Estimated Value"));
                                writer.Write(csv.Format("DistanceFromArrivalLS"));
                                writer.Write(csv.Format("WasMapped"));
                                writer.Write(csv.Format("WasDiscovered"));
                                if (ShowStars)
                                {
                                    writer.Write(csv.Format("StarType"));
                                    writer.Write(csv.Format("StellarMass"));
                                    writer.Write(csv.Format("AbsoluteMagnitude"));
                                    writer.Write(csv.Format("Age MY"));
                                    writer.Write(csv.Format("Luminosity"));
                                }
                                writer.Write(csv.Format("Radius"));
                                writer.Write(csv.Format("RotationPeriod"));
                                writer.Write(csv.Format("SurfaceTemperature"));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("TidalLock"));
                                    writer.Write(csv.Format("TerraformState"));
                                    writer.Write(csv.Format("PlanetClass"));
                                    writer.Write(csv.Format("Atmosphere"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Silicates"));
                                    writer.Write(csv.Format("SulphurDioxide"));
                                    writer.Write(csv.Format("CarbonDioxide"));
                                    writer.Write(csv.Format("Nitrogen"));
                                    writer.Write(csv.Format("Oxygen"));
                                    writer.Write(csv.Format("Water"));
                                    writer.Write(csv.Format("Argon"));
                                    writer.Write(csv.Format("Ammonia"));
                                    writer.Write(csv.Format("Methane"));
                                    writer.Write(csv.Format("Hydrogen"));
                                    writer.Write(csv.Format("Helium"));
                                    writer.Write(csv.Format("Volcanism"));
                                    writer.Write(csv.Format("SurfaceGravity"));
                                    writer.Write(csv.Format("SurfacePressure"));
                                    writer.Write(csv.Format("Landable"));
                                    writer.Write(csv.Format("EarthMasses"));
                                    writer.Write(csv.Format("IcePercent"));
                                    writer.Write(csv.Format("RockPercent"));
                                    writer.Write(csv.Format("MetalPercent"));
                                }
                                // Common orbital param
                                writer.Write(csv.Format("SemiMajorAxis"));
                                writer.Write(csv.Format("Eccentricity"));
                                writer.Write(csv.Format("OrbitalInclination"));
                                writer.Write(csv.Format("Periapsis"));
                                writer.Write(csv.Format("OrbitalPeriod"));
                                writer.Write(csv.Format("AxialTilt"));


                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("Carbon"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Nickel"));
                                    writer.Write(csv.Format("Phosphorus"));
                                    writer.Write(csv.Format("Sulphur"));
                                    writer.Write(csv.Format("Arsenic"));
                                    writer.Write(csv.Format("Chromium"));
                                    writer.Write(csv.Format("Germanium"));
                                    writer.Write(csv.Format("Manganese"));
                                    writer.Write(csv.Format("Selenium"));
                                    writer.Write(csv.Format("Vanadium"));
                                    writer.Write(csv.Format("Zinc"));
                                    writer.Write(csv.Format("Zirconium"));
                                    writer.Write(csv.Format("Cadmium"));
                                    writer.Write(csv.Format("Mercury"));
                                    writer.Write(csv.Format("Molybdenum"));
                                    writer.Write(csv.Format("Niobium"));
                                    writer.Write(csv.Format("Tin"));
                                    writer.Write(csv.Format("Tungsten"));
                                    writer.Write(csv.Format("Antimony"));
                                    writer.Write(csv.Format("Polonium"));
                                    writer.Write(csv.Format("Ruthenium"));
                                    writer.Write(csv.Format("Technetium"));
                                    writer.Write(csv.Format("Tellurium"));
                                    writer.Write(csv.Format("Yttrium"));
                                }

                                writer.WriteLine();
                            }

                            foreach (JournalScan je in scans)
                            {
                                JournalScan scan = je as JournalScan;

                                if (ShowPlanets == false)  // Then only show stars.
                                {
                                    if (String.IsNullOrEmpty(scan.StarType))
                                    {
                                        continue;
                                    }
                                }

                                if (ShowStars == false)   // Then only show planets
                                {
                                    if (String.IsNullOrEmpty(scan.PlanetClass))
                                    {
                                        continue;
                                    }
                                }

                                if (ShowPlanets == true && !string.IsNullOrEmpty(scan.PlanetClass))
                                {
                                    var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID && m.BodyName == scan.BodyName);

                                    if (mapping != null)
                                    {
                                        scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget);
                                    }
                                }

                                writer.Write(csv.Format(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(scan.EventTimeUTC)));
                                writer.Write(csv.Format(scan.BodyName));
                                writer.Write(csv.Format(scan.EstimatedValue));
                                writer.Write(csv.Format(scan.DistanceFromArrivalLS));
                                writer.Write(csv.Format(scan.WasMapped));
                                writer.Write(csv.Format(scan.WasDiscovered));

                                if (ShowStars)
                                {
                                    writer.Write(csv.Format(scan.StarType));
                                    writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0));
                                    writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0));
                                    writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0));
                                    writer.Write(csv.Format(scan.Luminosity));
                                }


                                writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0));
                                writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0));
                                writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false));
                                    writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : ""));
                                    writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : ""));
                                    writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : ""));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Water")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium")));
                                    writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : ""));
                                    writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0));
                                    writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0));
                                    writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false));
                                    writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Ice")));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Rock")));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Metal")));
                                }
                                // Common orbital param
                                writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0));
                                writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0));
                                writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0));
                                writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0));
                                writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0));
                                writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format(scan.GetMaterial("Carbon")));
                                    writer.Write(csv.Format(scan.GetMaterial("Iron")));
                                    writer.Write(csv.Format(scan.GetMaterial("Nickel")));
                                    writer.Write(csv.Format(scan.GetMaterial("Phosphorus")));
                                    writer.Write(csv.Format(scan.GetMaterial("Sulphur")));
                                    writer.Write(csv.Format(scan.GetMaterial("Arsenic")));
                                    writer.Write(csv.Format(scan.GetMaterial("Chromium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Germanium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Manganese")));
                                    writer.Write(csv.Format(scan.GetMaterial("Selenium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Vanadium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Zinc")));
                                    writer.Write(csv.Format(scan.GetMaterial("Zirconium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Cadmium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Mercury")));
                                    writer.Write(csv.Format(scan.GetMaterial("Molybdenum")));
                                    writer.Write(csv.Format(scan.GetMaterial("Niobium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tin")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tungsten")));
                                    writer.Write(csv.Format(scan.GetMaterial("Antimony")));
                                    writer.Write(csv.Format(scan.GetMaterial("Polonium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Ruthenium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Technetium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tellurium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Yttrium")));
                                }
                                writer.WriteLine();
                            }
                        }

                        writer.Close();

                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                }
                catch
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        const double eccentricityLimit = 0.95;         //orbital eccentricity limit

        string Infoline(ISystem system, StarScan.SystemNode sysnode)
        {
            string infostr = "";

            if (sysnode?.StarNodes != null)
            {
                string st    = sysnode.StarTypesFound();
                int    stars = sysnode.StarsScanned();
                int    total = sysnode.StarPlanetsScanned();

                infostr = string.Format("{0} Star(s) {1}".T(EDTx.UserControlStarList_CS), stars, st);

                if (total > stars)
                {
                    infostr += " " + string.Format("{0} Other bodies".T(EDTx.UserControlStarList_OB), (total - stars).ToString());
                }

                if (sysnode.FSSTotalBodies.HasValue && total < sysnode.FSSTotalBodies.Value)        // only show if you've not got them all
                {
                    infostr += ", " + "Total".T(EDTx.UserControlStarList_Total) + " " + sysnode.FSSTotalBodies.Value.ToString();
                }

                string jumponium = "";

                // selectors for showing something
                bool showplanets      = displayfilters.Contains("planets");
                bool showstars        = displayfilters.Contains("stars");
                bool showvalueables   = displayfilters.Contains("valueables");
                bool showbeltclusters = displayfilters.Contains("beltcluster");

                // selectors for what to print
                bool showsignals = displayfilters.Contains("signals");
                bool showvol     = displayfilters.Contains("volcanism");
                bool showv       = displayfilters.Contains("values");
                bool showsi      = displayfilters.Contains("shortinfo");
                bool showg       = displayfilters.Contains("gravity");
                bool showatmos   = displayfilters.Contains("atmos");
                bool showrings   = displayfilters.Contains("rings");

                bool showjumponium = displayfilters.Contains("jumponium");

                foreach (StarScan.ScanNode sn in sysnode.Bodies)
                {
                    if (sn?.ScanData != null)   // must have scan data..
                    {
                        if (
                            (sn.ScanData.IsBeltCluster && showbeltclusters) ||     // major selectors for line display
                            (sn.ScanData.IsPlanet && showplanets) ||
                            (sn.ScanData.IsStar && showstars) ||
                            (showvalueables && (sn.ScanData.AmmoniaWorld || sn.ScanData.CanBeTerraformable || sn.ScanData.WaterWorld || sn.ScanData.Earthlike))
                            )
                        {
                            string info = sn.ScanData.SurveyorInfoLine(system, sn.Signals != null && showsignals, showvol, showv, showsi, showg,
                                                                       showatmos && sn.ScanData.IsLandable, showrings,
                                                                       lowRadiusLimit, largeRadiusLimit, eccentricityLimit);
                            infostr = infostr.AppendPrePad(info, Environment.NewLine);
                        }

                        sn.ScanData.AccumulateJumponium(ref jumponium, sn.ScanData.BodyDesignationOrName);
                    }
                }

                if (jumponium.HasChars())
                {
                    infostr = infostr.AppendPrePad("This system has materials for FSD boost".T(EDTx.UserControlStarList_FSD), Environment.NewLine);
                    if (showjumponium)
                    {
                        infostr = infostr.AppendPrePad(jumponium, Environment.NewLine);
                    }
                }
            }

            return(infostr);
        }
        void Search(MaterialCommodityData cm, Dictionary <string, Tuple <HistoryEntry, string, double> > foundlist,
                    string prefix = "")
        {
            ISystem cursystem = discoveryform.history.CurrentSystem; // could be null

            foreach (var he in discoveryform.history)                // oldest first..
            {
                Tuple <HistoryEntry, string> found = null;
                bool checkstation = false;

                if (he.EntryType == JournalTypeEnum.Scan)
                {
                    var je = he.journalEntry as JournalScan;
                    if (je.HasMaterial(cm.FDName))
                    {
                        found = new Tuple <HistoryEntry, string>(he, prefix + je.BodyName);
                    }
                }
                else if (he.EntryType == JournalTypeEnum.Market)
                {
                    var je = he.journalEntry as JournalMarket;
                    if (je.HasCommodityToBuy(cm.FDName))
                    {
                        found        = new Tuple <HistoryEntry, string>(he, prefix + je.Station);
                        checkstation = true;
                    }
                }
                else if (he.EntryType == JournalTypeEnum.EDDCommodityPrices)
                {
                    var je = he.journalEntry as JournalEDDCommodityPrices;
                    if (je.HasCommodityToBuy(cm.FDName))
                    {
                        found        = new Tuple <HistoryEntry, string>(he, prefix + je.Station);
                        checkstation = true;
                    }
                }
                else if (he.EntryType == JournalTypeEnum.MaterialDiscovered)
                {
                    var je = he.journalEntry as JournalMaterialDiscovered;
                    if (je.Name.Equals(cm.FDName))
                    {
                        found = new Tuple <HistoryEntry, string>(he, prefix + "Discovered at ".T(EDTx.SearchMaterialsCommodities_DIS) + he.WhereAmI);
                    }
                }
                else if (he.EntryType == JournalTypeEnum.MaterialCollected)
                {
                    var je = he.journalEntry as JournalMaterialCollected;
                    if (je.Name.Equals(cm.FDName))
                    {
                        found = new Tuple <HistoryEntry, string>(he, prefix + "Collected at ".T(EDTx.SearchMaterialsCommodities_COL) + he.WhereAmI);
                    }
                }

                else if (he.EntryType == JournalTypeEnum.MissionCompleted)
                {
                    var je = he.journalEntry as JournalMissionCompleted;
                    if (je.HasReceivedReward(cm.FDName))
                    {
                        found = new Tuple <HistoryEntry, string>(he, prefix + "Mission Reward at ".T(EDTx.SearchMaterialsCommodities_MR) + he.WhereAmI);
                    }
                }

                else if (he.EntryType == JournalTypeEnum.SAASignalsFound)
                {
                    var je = he.journalEntry as JournalSAASignalsFound;
                    if (je.Contains(cm.FDName) > 0)
                    {
                        found = new Tuple <HistoryEntry, string>(he, prefix + "Discovered at ".T(EDTx.SearchMaterialsCommodities_DIS) + je.BodyName);
                    }
                }

                if (found != null)
                {
                    string keyname = he.System.Name + (checkstation ? ":" + he.WhereAmI : "");
                    double dist    = cursystem.Distance(he.System);

                    if (foundlist.ContainsKey(keyname))
                    {
                        if (!foundlist[keyname].Item2.Contains(found.Item2))     // don't double repeat
                        {
                            foundlist[keyname] = new Tuple <HistoryEntry, string, double>(he, foundlist[keyname].Item2.AppendPrePad(found.Item2, Environment.NewLine), dist);
                        }
                    }
                    else
                    {
                        foundlist[keyname] = new Tuple <HistoryEntry, string, double>(he, found.Item2, dist);
                    }
                }
            }
        }
示例#42
0
        // cursystem = null, curbookmark = null, new system free entry bookmark
        // cursystem != null, curbookmark = null, system bookmark found, update
        // cursystem != null, curbookmark = null, no system bookmark found, new bookmark on system
        // curbookmark != null, edit current bookmark

        public static void ShowBookmarkForm(Object sender, EDDiscoveryForm discoveryForm, ISystem cursystem, BookmarkClass curbookmark, bool notedsystem)
        {
            Form senderForm = ((Control)sender)?.FindForm() ?? discoveryForm;

            // try and find the associated bookmark..
            BookmarkClass bkmark = (curbookmark != null) ? curbookmark : (cursystem != null ? GlobalBookMarkList.Instance.FindBookmarkOnSystem(cursystem.Name) : null);

            SystemNoteClass sn   = (cursystem != null) ? SystemNoteClass.GetNoteOnSystem(cursystem.Name, cursystem.EDSMID) : null;
            string          note = (sn != null) ? sn.Note : "";

            BookmarkForm frm = new BookmarkForm();

            if (notedsystem && bkmark == null)                      // note on a system
            {
                long targetid = TargetClass.GetTargetNotedSystem(); // who is the target of a noted system (0=none)
                long noteid   = sn.id;

                frm.InitialisePos(cursystem);
                frm.NotedSystem(cursystem.Name, note, noteid == targetid);       // note may be passed in null
                frm.ShowDialog(senderForm);

                if ((frm.IsTarget && targetid != noteid) || (!frm.IsTarget && targetid == noteid)) // changed..
                {
                    if (frm.IsTarget)
                    {
                        TargetClass.SetTargetNotedSystem(cursystem.Name, noteid, cursystem.X, cursystem.Y, cursystem.Z);
                    }
                    else
                    {
                        TargetClass.ClearTarget();
                    }
                }
            }
            else
            {
                bool     regionmarker = false;
                DateTime timeutc;

                if (bkmark == null)                         // new bookmark
                {
                    timeutc = DateTime.UtcNow;
                    if (cursystem == null)
                    {
                        frm.NewFreeEntrySystemBookmark(timeutc);
                    }
                    else
                    {
                        frm.NewSystemBookmark(cursystem, note, timeutc);
                    }
                }
                else                                        // update bookmark
                {
                    regionmarker = bkmark.isRegion;
                    timeutc      = bkmark.TimeUTC;
                    frm.Bookmark(bkmark);
                }

                DialogResult res = frm.ShowDialog(senderForm);

                long curtargetid = TargetClass.GetTargetBookmark();      // who is the target of a bookmark (0=none)

                if (res == DialogResult.OK)
                {
                    BookmarkClass newcls = GlobalBookMarkList.Instance.AddOrUpdateBookmark(bkmark, !regionmarker, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z),
                                                                                           timeutc, frm.Notes, frm.SurfaceLocations);


                    if ((frm.IsTarget && curtargetid != newcls.id) || (!frm.IsTarget && curtargetid == newcls.id)) // changed..
                    {
                        if (frm.IsTarget)
                        {
                            TargetClass.SetTargetBookmark(regionmarker ? ("RM:" + newcls.Heading) : newcls.StarName, newcls.id, newcls.x, newcls.y, newcls.z);
                        }
                        else
                        {
                            TargetClass.ClearTarget();
                        }
                    }
                }
                else if (res == DialogResult.Abort && bkmark != null)
                {
                    if (curtargetid == bkmark.id)
                    {
                        TargetClass.ClearTarget();
                    }

                    GlobalBookMarkList.Instance.Delete(bkmark);
                }
            }

            discoveryForm.NewTargetSet(sender);
        }
示例#43
0
        private List <string> ExtractElements(JournalScan sc, ISystem sys, out bool isbeltcluster, out ScanNodeType starscannodetype)
        {
            starscannodetype = ScanNodeType.star;
            isbeltcluster    = false;
            List <string> elements;
            string        rest = sc.IsStarNameRelatedReturnRest(sys.name);

            if (rest != null)                                   // if we have a relationship..
            {
                if (sc.IsStar && !sc.IsEDSMBody && sc.DistanceFromArrivalLS == 0 && rest.Length >= 2)
                {
                    elements = new List <string> {
                        rest
                    };
                    starscannodetype = ScanNodeType.star;
                }
                else if (rest.Length > 0)
                {
                    elements = rest.Split(' ').ToList();

                    if (elements.Count == 4 && elements[0].Length == 1 && char.IsLetter(elements[0][0]) &&
                        elements[1].Equals("belt", StringComparison.InvariantCultureIgnoreCase) &&
                        elements[2].Equals("cluster", StringComparison.InvariantCultureIgnoreCase))
                    {
                        elements = new List <string> {
                            "Main Star", elements[0] + " " + elements[1], elements[2] + " " + elements[3]
                        };
                        isbeltcluster = true;
                    }
                    else if (elements.Count == 5 && elements[0].Length == 1 &&
                             elements[1].Length == 1 && char.IsLetter(elements[1][0]) &&
                             elements[2].Equals("belt", StringComparison.InvariantCultureIgnoreCase) &&
                             elements[3].Equals("cluster", StringComparison.InvariantCultureIgnoreCase))
                    {
                        elements = new List <string> {
                            elements[0], elements[1] + " " + elements[2], elements[3] + " " + elements[4]
                        };
                        isbeltcluster = true;
                    }

                    if (char.IsDigit(elements[0][0]))       // if digits, planet number, no star designator
                    {
                        elements.Insert(0, "Main Star");    // no star designator, main star, add MAIN
                    }
                    else if (elements[0].Length > 1)        // designator, is it multiple chars..
                    {
                        starscannodetype = ScanNodeType.barycentre;
                    }
                }
                else
                {
                    elements = new List <string>();         // only 1 item, the star, which is the same as the system name..
                    elements.Add("Main Star");              // Sol / SN:Sol should come thru here
                }
            }
            else if (sc.IsStar && !sc.IsEDSMBody && sc.DistanceFromArrivalLS == 0)
            {
                elements = new List <string> {
                    sc.BodyName
                };
                starscannodetype = ScanNodeType.star;
            }
            else
            {                                               // so not part of starname
                elements = sc.BodyName.Split(' ').ToList(); // not related in any way (earth) so assume all bodyparts, and
                elements.Insert(0, "Main Star");            // insert the MAIN designator as the star designator
            }

            return(elements);
        }
示例#44
0
 public void AddSystem(ISystem system)
 {
     this.systems.Add(system);
 }
示例#45
0
        private void UpdateSystemRow(int rowindex)
        {
            const int idxVisits  = 5;
            const int idxScans   = 6;
            const int idxPriStar = 7;
            const int idxInfo    = 8;
            const int idxNote    = 9;

            ISystem currentSystem = discoveryform.history.CurrentSystem; // may be null

            if (rowindex < dataGridViewExplore.Rows.Count && dataGridViewExplore[0, rowindex].Value != null)
            {
                string  sysname = dataGridViewExplore[0, rowindex].Value.ToString();
                ISystem sys     = (ISystem)dataGridViewExplore[0, rowindex].Tag;

                if (sys == null)
                {
                    sys = SystemCache.FindSystem(sysname);
                }

                if (sys != null && currentSystem != null)
                {
                    double dist    = sys.Distance(currentSystem);
                    string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : "";
                    dataGridViewExplore[1, rowindex].Value = strdist;
                }

                dataGridViewExplore[0, rowindex].Tag = sys;
                dataGridViewExplore.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor;

                if (sys != null)
                {
                    if (sys.HasCoordinate)
                    {
                        dataGridViewExplore[2, rowindex].Value = sys.X.ToString("0.00");
                        dataGridViewExplore[3, rowindex].Value = sys.Y.ToString("0.00");
                        dataGridViewExplore[4, rowindex].Value = sys.Z.ToString("0.00");
                    }

                    dataGridViewExplore[idxVisits, rowindex].Value = discoveryform.history.GetVisitsCount(sysname).ToString();

                    List <JournalScan> scans = discoveryform.history.GetScans(sysname);
                    dataGridViewExplore[idxScans, rowindex].Value = scans.Count.ToString();

                    string pristar = "";
                    // Search for primary star
                    foreach (var scan in scans)
                    {
                        if (scan.IsStar && scan.DistanceFromArrivalLS == 0.0)
                        {
                            pristar = scan.StarType;
                            break;
                        }
                    }
                    dataGridViewExplore[idxPriStar, rowindex].Value = pristar;


                    string info = "";

                    foreach (var scan in scans)
                    {
                        if (scan.IsStar)
                        {
                            if (scan.StarTypeID == EDStar.AeBe)
                            {
                                info = info + " " + "AeBe";
                            }
                            if (scan.StarTypeID == EDStar.N)
                            {
                                info = info + " " + "NS";
                            }
                            if (scan.StarTypeID == EDStar.H)
                            {
                                info = info + " " + "BH";
                            }
                        }
                        else
                        {
                            if (scan.PlanetTypeID == EDPlanet.Earthlike_body)
                            {
                                info = info + " " + "ELW";
                            }
                            if (scan.PlanetTypeID == EDPlanet.Water_world)
                            {
                                info = info + " " + "WW";
                            }
                        }
                    }

                    dataGridViewExplore[idxInfo, rowindex].Value = info.Trim();


                    string          note = "";
                    SystemNoteClass sn   = SystemNoteClass.GetNoteOnSystem(sys.Name, sys.EDSMID);
                    if (sn != null && !string.IsNullOrWhiteSpace(sn.Note))
                    {
                        note = sn.Note;
                    }
                    else
                    {
                        BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sys.Name);
                        if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note))
                        {
                            note = bkmark.Note;
                        }
                        else
                        {
                            var gmo = discoveryform.galacticMapping.Find(sys.Name);
                            if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description))
                            {
                                note = gmo.description;
                            }
                        }
                    }
                    dataGridViewExplore[idxNote, rowindex].Value = note.WordWrap(60);
                }

                if (sys == null && sysname != "")
                {
                    dataGridViewExplore.Rows[rowindex].ErrorText = "System not known";
                }
                else
                {
                    dataGridViewExplore.Rows[rowindex].ErrorText = "";
                }
            }
        }
示例#46
0
        private void UpdateTo(bool updatename)
        {
            changesilence = true;

            if (textBox_To.ReadOnly == false)                // if entering system name..
            {
                ISystem ds1 = discoveryform.history.FindSystem(SystemNameOnly(textBox_To.Text), discoveryform.galacticMapping);

                if (ds1 != null)
                {
                    if (updatename)                          // can't fix it as you type.. so leave alone
                    {
                        if (ds1 is GalacticMapSystem)
                        {
                            GalacticMapSystem gms = (GalacticMapSystem)ds1;
                            textBox_To.Text     = gms.GalMapObject.name;
                            textBox_ToName.Text = gms.Name;
                        }
                        else
                        {
                            textBox_To.Text     = ds1.Name;
                            textBox_ToName.Text = ds1.Name;
                        }
                    }

                    textBox_ToX.Text = ds1.X.ToString("0.00");
                    textBox_ToY.Text = ds1.Y.ToString("0.00");
                    textBox_ToZ.Text = ds1.Z.ToString("0.00");
                }
                else
                {
                    textBox_ToX.Text = textBox_ToY.Text = textBox_ToZ.Text = "";
                }
            }
            else // Co-ords..
            {
                string  res = "";
                Point3D curpos;
                if (GetCoordsTo(out curpos))
                {
                    ISystem nearest = SystemClassDB.FindNearestSystemTo(curpos.X, curpos.Y, curpos.Z);

                    if (nearest != null)
                    {
                        double distance = Point3D.DistanceBetween(curpos, new Point3D(nearest.X, nearest.Y, nearest.Z));
                        if (distance < 0.1)
                        {
                            res = nearest.Name;
                        }
                        else
                        {
                            res = nearest.Name + " @ " + distance.ToString("0.00") + "ly";
                        }
                    }
                }

                textBox_To.Text     = res;
                textBox_ToName.Text = res;
            }

            UpdateDistance();

            changesilence        = false;
            button_Route.Enabled = IsValid();
        }
示例#47
0
 public bool CanHandleSystem(ISystem system)
 {
     return(system is ISetupSystem);
 }
示例#48
0
 public void ShipInformation(ShipInformationList shp, string whereami, ISystem system, DB.SQLiteConnectionUser conn)
 {
     shp.ModuleStore(this);
 }
        private void UpdateSystemRows()
        {
            Cursor = Cursors.WaitCursor;

            for (int rowindex = 0; rowindex < dataGridView.Rows.Count; rowindex++)
            {
                dataGridView[1, rowindex].ReadOnly = true;
                dataGridView[2, rowindex].ReadOnly = true;
                dataGridView[3, rowindex].ReadOnly = true;
                dataGridView[4, rowindex].ReadOnly = true;
                dataGridView[5, rowindex].ReadOnly = true;

                string sysname = dataGridView[0, rowindex].Value as string;       // value may be null, so protect (2999)

                if (sysname.HasChars())
                {
                    var sys = discoveryform.history.FindSystem(sysname, discoveryform.galacticMapping, true);      // use EDSM directly if required

                    dataGridView[1, rowindex].Value = "";

                    if (rowindex > 0 && dataGridView[0, rowindex - 1].Value != null && dataGridView[0, rowindex].Value != null)
                    {
                        string prevsysname = dataGridView[0, rowindex - 1].Value as string;     // protect against null

                        if (prevsysname.HasChars())
                        {
                            var prevsys = discoveryform.history.FindSystem(prevsysname, discoveryform.galacticMapping, true);       // use EDSM directly

                            if ((sys?.HasCoordinate ?? false) && (prevsys?.HasCoordinate ?? false))
                            {
                                double dist    = sys.Distance(prevsys);
                                string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : "";
                                dataGridView[1, rowindex].Value = strdist;
                            }
                        }
                    }

                    dataGridView[0, rowindex].Tag = sys;
                    dataGridView.Rows[rowindex].Cells[0].Style.ForeColor = (sys != null && sys.HasCoordinate) ? Color.Empty : discoveryform.theme.UnknownSystemColor;

                    string          note = "";
                    SystemNoteClass sn   = SystemNoteClass.GetNoteOnSystem(sysname);
                    if (sn != null && !string.IsNullOrWhiteSpace(sn.Note))
                    {
                        note = sn.Note;
                    }

                    BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sysname);
                    if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note))
                    {
                        note = note.AppendPrePad(bkmark.Note, "; ");
                    }

                    var gmo = discoveryform.galacticMapping.Find(sysname);
                    if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description))
                    {
                        note = note.AppendPrePad(gmo.description, "; ");
                    }

                    dataGridView[2, rowindex].Value = note;

                    if (sys != null && sys.HasCoordinate)
                    {
                        dataGridView[3, rowindex].Value       = sys.X.ToString("0.0.#");
                        dataGridView[4, rowindex].Value       = sys.Y.ToString("0.0.#");
                        dataGridView[5, rowindex].Value       = sys.Z.ToString("0.0.#");
                        dataGridView.Rows[rowindex].ErrorText = "";
                    }
                    else
                    {
                        dataGridView.Rows[rowindex].ErrorText = "System not known location".T(EDTx.UserControlExpedition_EDSMUnk);
                    }
                }
            }

            txtCmlDistance.Text = txtP2PDIstance.Text = "";

            if (dataGridView.Rows.Count > 1)
            {
                double  distance = 0;
                ISystem firstSC  = null;
                ISystem lastSC   = null;
                for (int i = 0; i < dataGridView.Rows.Count; i++)
                {
                    if (firstSC == null && dataGridView[0, i].Tag != null)
                    {
                        firstSC = (ISystem)dataGridView[0, i].Tag;
                    }
                    if (dataGridView[0, i].Tag != null)
                    {
                        lastSC = (ISystem)dataGridView[0, i].Tag;
                    }
                    String value = dataGridView[1, i].Value as string;
                    if (!String.IsNullOrWhiteSpace(value))
                    {
                        distance += Double.Parse(value);
                    }
                }

                txtCmlDistance.Text = distance.ToString("0.00") + "LY";

                if (firstSC != null && lastSC != null)
                {
                    distance            = firstSC.Distance(lastSC);
                    txtP2PDIstance.Text = distance.ToString("0.00") + "LY";
                }
            }

            Cursor = Cursors.Default;
        }
示例#50
0
 public System1Operation(IOperationStore store, ISystem system, ValidationResult data, int order) : base(store, data, order)
 {
     System = system;
 }
示例#51
0
 public void ShipInformation(ShipInformationList shp, string whereami, ISystem system)
 {
     shp.SetUserShipName(this);
 }
示例#52
0
        public static void SetTargetSystem(Object sender, EDDiscoveryForm discoveryform, String sn, Boolean prompt)
        {
            Form senderForm = ((Control)sender)?.FindForm() ?? discoveryform;

            if (string.IsNullOrWhiteSpace(sn))
            {
                if (prompt && TargetClass.IsTargetSet())      // if prompting, and target is set, ask for delete
                {
                    if (ExtendedControls.MessageBoxTheme.Show(senderForm, "Confirm deletion of target", "Delete a target", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        TargetClass.ClearTarget();
                        discoveryform.NewTargetSet(sender);          // tells everyone who cares a new target was set
                    }
                }

                return;
            }

            ISystem sc         = discoveryform.history.FindSystem(sn);
            string  msgboxtext = null;

            if (sc != null && sc.HasCoordinate)
            {
                SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(sc.Name, sc.EDSMID);        // has it got a note?

                if (nc != null)
                {
                    TargetClass.SetTargetNotedSystem(sc.Name, nc.id, sc.X, sc.Y, sc.Z);
                    msgboxtext = "Target set on system with note " + sc.Name;
                }
                else
                {
                    BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sn);    // has it been bookmarked?

                    if (bk != null)
                    {
                        TargetClass.SetTargetBookmark(sc.Name, bk.id, bk.x, bk.y, bk.z);
                        msgboxtext = "Target set on bookmarked system " + sc.Name;
                    }
                    else
                    {
                        bool createbookmark = false;
                        if ((prompt && ExtendedControls.MessageBoxTheme.Show(senderForm, "Make a bookmark on " + sc.Name + " and set as target?", "Make Bookmark", MessageBoxButtons.OKCancel) == DialogResult.OK) || !prompt)
                        {
                            createbookmark = true;
                        }

                        if (createbookmark)
                        {
                            BookmarkClass newbk = GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, true, sn, sc.X, sc.Y, sc.Z, DateTime.UtcNow, "");
                            TargetClass.SetTargetBookmark(sc.Name, newbk.id, newbk.x, newbk.y, newbk.z);
                        }
                    }
                }
            }
            else
            {
                if (sn.Length > 2 && sn.Substring(0, 2).Equals("G:"))
                {
                    sn = sn.Substring(2, sn.Length - 2);
                }

                GalacticMapObject gmo = discoveryform.galacticMapping.Find(sn, true, true);    // ignore if its off, find any part of string, find if disabled

                if (gmo != null)
                {
                    TargetClass.SetTargetGMO("G:" + gmo.name, gmo.id, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z);
                    msgboxtext = "Target set on galaxy object " + gmo.name;
                }
                else
                {
                    msgboxtext = "Unknown system, system is without co-ordinates or galaxy object not found";
                }
            }

            discoveryform.NewTargetSet(sender);          // tells everyone who cares a new target was set

            if (msgboxtext != null && prompt)
            {
                ExtendedControls.MessageBoxTheme.Show(senderForm, msgboxtext, "Create a target", MessageBoxButtons.OK);
            }
        }
示例#53
0
 public FtpClient()
 {
     system = new Sys();
 }
示例#54
0
        private void extCheckBoxStar_Click(object sender, EventArgs e)
        {
            if (extCheckBoxStar.Checked == true)
            {
                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                int width = 500;
                f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "System:".T(EDTx.UserControlScan_System), new Point(10, 40), new Size(110, 24), null));
                f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", typeof(ExtendedControls.ExtTextBoxAutoComplete), "", new Point(120, 40), new Size(width - 120 - 20, 24), null));

                f.AddOK(new Point(width - 20 - 80, 80));
                f.AddCancel(new Point(width - 200, 80));

                f.Trigger += (dialogname, controlname, tag) =>
                {
                    if (controlname == "OK" || controlname == "Cancel" || controlname == "Close")
                    {
                        f.ReturnResult(controlname == "OK" ? DialogResult.OK : DialogResult.Cancel);
                    }
                    else if (controlname == "Sys:Return")
                    {
                        if (f.Get("Sys").HasChars())
                        {
                            f.ReturnResult(DialogResult.OK);
                        }

                        f.SwallowReturn = true;
                    }
                };

                f.InitCentred(this.FindForm(), this.FindForm().Icon, "Show System".T(EDTx.UserControlScan_EnterSys), null, null, closeicon: true);
                f.GetControl <ExtendedControls.ExtTextBoxAutoComplete>("Sys").SetAutoCompletor(SystemCache.ReturnSystemAutoCompleteList, true);
                DialogResult res = f.ShowDialog(this.FindForm());

                if (res == DialogResult.OK)
                {
                    string sname = f.Get("Sys");
                    if (sname.HasChars())
                    {
                        showing_matcomds = null;
                        showing_system   = new EliteDangerousCore.SystemClass(sname);
                        override_system  = true;
                        DrawSystem();
                        extCheckBoxStar.Checked = true;
                    }
                    else
                    {
                        extCheckBoxStar.Checked = false;
                    }
                }
                else
                {
                    extCheckBoxStar.Checked = false;
                }
            }
            else
            {
                override_system = false;
                DrawSystem(last_he);
                extCheckBoxStar.Checked = false;
            }
        }
示例#55
0
 public AggregateOrderbookService(IExtPricesSettingsService extPricesSettingsService, ISystem system)
 {
     _extPricesSettingsService = extPricesSettingsService;
     _system = system;
 }
示例#56
0
        private void tsbAddSystems_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            FindSystemsUserControl usc = new FindSystemsUserControl();

            usc.ReturnSystems = (List <Tuple <ISystem, double> > syslist) =>
            {
                List <String> systems      = new List <String>();
                int           countunknown = 0;
                foreach (Tuple <ISystem, double> ret in syslist)
                {
                    string name = ret.Item1.Name;

                    ISystem sc = SystemCache.FindSystem(name.Trim());
                    if (sc == null)
                    {
                        sc = new SystemClass(name.Trim());
                        countunknown++;
                    }
                    systems.Add(sc.Name);
                }

                if (systems.Count == 0)
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "The imported file contains no known system names",
                                                          "Unsaved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    foreach (var sysname in systems)
                    {
                        dataGridViewExplore.Rows.Add(sysname, "", "");
                    }

                    UpdateSystemRows();
                }

                f.DialogResult = DialogResult.OK;
                f.Close();
            };

            f.Add(new ExtendedControls.ConfigurableForm.Entry("UC", null, "", new Point(5, 30), new Size(740, 150), null)
            {
                control = usc
            });
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel", new Point(650, 190), new Size(80, 24), "Press to Cancel"));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "Cancel")
                {
                    f.DialogResult = DialogResult.Cancel;
                    f.Close();
                }
            };

            f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(750, 240), new Point(-999, -999), "Add Systems",
                         callback: () => { usc.Font = EDDTheme.Instance.GetFontStandardFontSize(); usc.Init(0, false, discoveryform); });
            usc.Closing();
        }
示例#57
0
 public void Accepted(JournalMissionAccepted m, ISystem sys, string body)
 {
     Missions[Key(m)] = new MissionState(m, sys, body); // add a new one..
 }
示例#58
0
        public static HistoryEntry FromJournalEntry(JournalEntry je, HistoryEntry prev, bool checkdbforunknownsystem, out bool journalupdate)
        {
            ISystem isys    = prev == null ? new SystemClass("Unknown") : prev.System;
            int     indexno = prev == null ? 1 : prev.Indexno + 1;

            journalupdate = false;

            if (je.EventTypeID == JournalTypeEnum.Location || je.EventTypeID == JournalTypeEnum.FSDJump)
            {
                JournalLocOrJump jl = je as JournalLocOrJump;

                ISystem newsys;

                if (jl != null && jl.HasCoordinate)       // LAZY LOAD IF it has a co-ord.. the front end will when it needs it
                {
                    newsys = new SystemClass(jl.StarSystem, jl.StarPos.X, jl.StarPos.Y, jl.StarPos.Z)
                    {
                        EDSMID         = jl.EdsmID < 0 ? 0 : jl.EdsmID, // pass across the EDSMID for the lazy load process.
                        SystemAddress  = jl.SystemAddress,
                        Population     = jl.Population ?? 0,
                        Faction        = jl.Faction,
                        Government     = jl.EDGovernment,
                        Allegiance     = jl.EDAllegiance,
                        State          = jl.EDState,
                        Security       = jl.EDSecurity,
                        PrimaryEconomy = jl.EDEconomy,
                        Power          = jl.PowerList,
                        PowerState     = jl.PowerplayState,
                        source         = jl.StarPosFromEDSM ? SystemSource.FromEDSM : SystemSource.FromJournal,
                    };

                    SystemCache.FindCachedJournalSystem(newsys);

                    // If it was a new system, pass the coords back to the StartJump
                    if (prev != null && prev.journalEntry is JournalStartJump)
                    {
                        prev.System = newsys;       // give the previous startjump our system..
                    }
                }
                else
                {
                    // NOTE Rob: 09-JAN-2018 I've removed the Jumpstart looking up a system by name since they were using up lots of lookup time during history reading.
                    // This is used for pre 2.2 systems without co-ords, which now should be limited.
                    // JumpStart still gets the system when the FSD loc is processed, see above.
                    // Jumpstart was also screwing about with the EDSM ID fill in which was broken.  This is now working again.

                    // Default one
                    newsys        = new SystemClass(jl.StarSystem);  // this will be a synthesised one, unless we find an EDSM to replace it
                    newsys.EDSMID = je.EdsmID;

                    ISystem s = checkdbforunknownsystem ? SystemCache.FindSystem(newsys) : null; // did we find it?

                    if (s != null)                                                               // found a system..
                    {
                        if (jl != null && jl.HasCoordinate)                                      // if journal Loc, and journal has a star position, use that instead of EDSM..
                        {
                            s.X = Math.Round(jl.StarPos.X * 32.0) / 32.0;
                            s.Y = Math.Round(jl.StarPos.Y * 32.0) / 32.0;
                            s.Z = Math.Round(jl.StarPos.Z * 32.0) / 32.0;
                        }

                        //Debug.WriteLine("HistoryList found system {0} {1}", s.id_edsm, s.name);
                        newsys = s;

                        if (jl != null && je.EdsmID <= 0 && newsys.EDSMID > 0) // only update on a JL..
                        {
                            journalupdate = true;
                            Debug.WriteLine("HE EDSM ID update requested {0} {1}", newsys.EDSMID, newsys.Name);
                        }
                    }
                    else
                    {
                        newsys.EDSMID = -1;        // mark as checked but not found
                    }
                }

                JournalFSDJump jfsd = je as JournalFSDJump;

                if (jfsd != null)
                {
                    if (jfsd.JumpDist <= 0 && isys.HasCoordinate && newsys.HasCoordinate) // if no JDist, its a really old entry, and if previous has a co-ord
                    {
                        jfsd.JumpDist = isys.Distance(newsys);                            // fill it out here

                        if (jfsd.JumpDist > 0)
                        {
                            journalupdate = true;
                            Debug.WriteLine("Je Jump distance update(3) requested {0} {1} {2}", newsys.EDSMID, newsys.Name, jfsd.JumpDist);
                        }
                    }
                }

                isys = newsys;
            }

            HistoryEntry he = new HistoryEntry
            {
                Indexno      = indexno,
                journalEntry = je,
                System       = isys,
                EntryStatus  = HistoryEntryStatus.Update(prev?.EntryStatus, je, isys.Name)
            };

            he.TravelStatus = HistoryTravelStatus.Update(prev?.TravelStatus, prev, he);     // need a real he so can't do that as part of the constructor.

            return(he);
        }
示例#59
0
        public static HistoryEntry FromJournalEntry(JournalEntry je, HistoryEntry prev, bool checkedsm, out bool journalupdate, SQLiteConnectionSystem conn = null, EDCommander cmdr = null)
        {
            ISystem isys    = prev == null ? new SystemClassDB("Unknown") : prev.System;
            int     indexno = prev == null ? 1 : prev.Indexno + 1;

            int mapcolour = 0;

            journalupdate = false;
            bool starposfromedsm = false;
            bool firstdiscover   = false;


            if (je.EventTypeID == JournalTypeEnum.Location || je.EventTypeID == JournalTypeEnum.FSDJump)
            {
                JournalLocOrJump jl   = je as JournalLocOrJump;
                JournalFSDJump   jfsd = je as JournalFSDJump;

                ISystem newsys;

                if (jl.HasCoordinate)       // LAZY LOAD IF it has a co-ord.. the front end will when it needs it
                {
                    newsys         = new SystemClassDB(jl.StarSystem, jl.StarPos.X, jl.StarPos.Y, jl.StarPos.Z);
                    newsys.id_edsm = jl.EdsmID < 0 ? 0 : jl.EdsmID;               // pass across the EDSMID for the lazy load process.

                    if (jfsd != null && jfsd.JumpDist <= 0 && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does have pos, we can compute distance and update entry
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);     // fill it out here
                        journalupdate = true;
                    }
                }
                else
                {                           // Default one
                    newsys         = new SystemClassDB(jl.StarSystem);
                    newsys.id_edsm = jl.EdsmID;

                    if (checkedsm)                                              // see if we can find the right system
                    {
                        SystemClassDB s = SystemClassDB.FindEDSM(newsys, conn); // has no co-ord, did we find it?

                        if (s != null)                                          // yes, use, and update the journal with the esdmid, and also the position if we have a co-ord
                        {                                                       // so next time we don't have to do this again..
                            if (jl.HasCoordinate)
                            {
                                s.x = Math.Round(jl.StarPos.X * 32.0) / 32.0;
                                s.y = Math.Round(jl.StarPos.Y * 32.0) / 32.0;
                                s.z = Math.Round(jl.StarPos.Z * 32.0) / 32.0;
                            }

                            newsys = s;

                            if (jfsd != null && jfsd.JumpDist <= 0 && newsys.HasCoordinate && isys.HasCoordinate) // if we don't have a jump distance (pre 2.2) but the last sys does, we can compute
                            {
                                jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);                             // fill it out here.  EDSM systems always have co-ords, but we should check anyway
                                journalupdate = true;
                            }

                            if (jl.EdsmID <= 0 && newsys.id_edsm > 0)
                            {
                                journalupdate = true;
                            }
                        }
                    }
                }

                if (jfsd != null)
                {
                    if (jfsd.JumpDist <= 0 && isys.HasCoordinate && newsys.HasCoordinate) // if no JDist, its a really old entry, and if previous has a co-ord
                    {
                        jfsd.JumpDist = SystemClassDB.Distance(isys, newsys);             // fill it out here
                        journalupdate = true;
                    }

                    mapcolour = jfsd.MapColor;
                }

                isys            = newsys;
                starposfromedsm = jl.HasCoordinate ? jl.StarPosFromEDSM : newsys.HasCoordinate;
                firstdiscover   = jl.EDSMFirstDiscover;
            }

            string summary, info, detailed;

            je.FillInformation(out summary, out info, out detailed);

            HistoryEntry he = new HistoryEntry
            {
                Indexno             = indexno,
                EntryType           = je.EventTypeID,
                Journalid           = je.Id,
                journalEntry        = je,
                System              = isys,
                EventTimeUTC        = je.EventTimeUTC,
                MapColour           = mapcolour,
                EdsmSync            = je.SyncedEDSM,
                EDDNSync            = je.SyncedEDDN,
                EGOSync             = je.SyncedEGO,
                StartMarker         = je.StartMarker,
                StopMarker          = je.StopMarker,
                EventSummary        = summary,
                EventDescription    = info,
                EventDetailedInfo   = detailed,
                IsStarPosFromEDSM   = starposfromedsm,
                IsEDSMFirstDiscover = firstdiscover,
                Commander           = cmdr ?? EDCommander.GetCommander(je.CommanderId)
            };


            // WORK out docked/landed state

            if (prev != null)
            {
                if (prev.docked.HasValue)                   // copy docked..
                {
                    he.docked = prev.docked;
                }
                if (prev.landed.HasValue)
                {
                    he.landed = prev.landed;
                }

                he.shiptype          = prev.shiptype;
                he.shipid            = prev.shipid;
                he.whereami          = prev.whereami;
                he.onCrewWithCaptain = prev.onCrewWithCaptain;
                he.gamemode          = prev.gamemode;
                he.group             = prev.group;
            }

            if (je.EventTypeID == JournalTypeEnum.Location)
            {
                JournalLocation jl = je as JournalLocation;
                he.docked   = jl.Docked;
                he.whereami = jl.Docked ? jl.StationName : jl.Body;
            }
            else if (je.EventTypeID == JournalTypeEnum.Docked)
            {
                JournalDocked jl = je as JournalDocked;
                he.docked   = true;
                he.whereami = jl.StationName;
            }
            else if (je.EventTypeID == JournalTypeEnum.Undocked)
            {
                he.docked = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Touchdown)
            {
                he.landed = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.Liftoff)
            {
                he.landed = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseEntry)
            {
                he.whereami = (je as JournalSupercruiseEntry).StarSystem;
            }
            else if (je.EventTypeID == JournalTypeEnum.SupercruiseExit)
            {
                he.whereami = (je as JournalSupercruiseExit).Body;
            }
            else if (je.EventTypeID == JournalTypeEnum.FSDJump)
            {
                he.whereami = (je as JournalFSDJump).StarSystem;
            }
            else if (je.EventTypeID == JournalTypeEnum.LoadGame)
            {
                JournalLoadGame jl = je as JournalLoadGame;

                he.onCrewWithCaptain = null;        // can't be in a crew at this point
                he.gamemode          = jl.GameMode; // set game mode
                he.group             = jl.Group;    // and group, may be empty
                he.landed            = jl.StartLanded;

                if (jl.Ship.IndexOf("buggy", StringComparison.InvariantCultureIgnoreCase) == -1)        // load game with buggy, can't tell what ship we get back into, so ignore
                {
                    he.shiptype = (je as JournalLoadGame).Ship;
                    he.shipid   = (je as JournalLoadGame).ShipId;
                }
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardBuy)         // BUY does not have ship id, but the new entry will that is written later - journals 8.34
            {
                he.shiptype = (je as JournalShipyardBuy).ShipType;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardNew)
            {
                he.shiptype = (je as JournalShipyardNew).ShipType;
                he.shipid   = (je as JournalShipyardNew).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardSwap)
            {
                he.shiptype = (je as JournalShipyardSwap).ShipType;
                he.shipid   = (je as JournalShipyardSwap).ShipId;
            }
            else if (je.EventTypeID == JournalTypeEnum.JoinACrew)
            {
                he.onCrewWithCaptain = (je as JournalJoinACrew).Captain;
            }
            else if (je.EventTypeID == JournalTypeEnum.QuitACrew)
            {
                he.onCrewWithCaptain = null;
            }

            if (prev != null && prev.travelling)      // if we are travelling..
            {
                he.travelled_distance    = prev.travelled_distance;
                he.travelled_missingjump = prev.travelled_missingjump;
                he.travelled_jumps       = prev.travelled_jumps;

                if (he.IsFSDJump && !he.MultiPlayer)   // if jump, and not multiplayer..
                {
                    double dist = ((JournalFSDJump)je).JumpDist;
                    if (dist <= 0)
                    {
                        he.travelled_missingjump++;
                    }
                    else
                    {
                        he.travelled_distance += dist;
                        he.travelled_jumps++;
                    }
                }

                he.travelled_seconds = prev.travelled_seconds;
                TimeSpan diff = he.EventTimeUTC.Subtract(prev.EventTimeUTC);

                if (he.EntryType != JournalTypeEnum.LoadGame && diff < new TimeSpan(2, 0, 0))   // time between last entry and load game is not real time
                {
                    he.travelled_seconds += diff;
                }

                if (he.StopMarker || he.StartMarker)
                {
                    //Debug.WriteLine("Travelling stop at " + he.Indexno);
                    he.travelling         = false;
                    he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelled " + he.travelled_distance.ToStringInvariant("0.0") + " LY"
                                            + ", " + he.travelled_jumps + " jumps"
                                            + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                            ", time " + he.travelled_seconds;

                    he.travelled_distance = 0;
                    he.travelled_seconds  = new TimeSpan(0);
                }
                else
                {
                    he.travelling = true;

                    if (he.IsFSDJump)
                    {
                        he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelling" +
                                                " distance " + he.travelled_distance.ToString("0.0") + " LY"
                                                + ", " + he.travelled_jumps + " jumps"
                                                + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                                ", time " + he.travelled_seconds;
                    }
                }
            }

            if (he.StartMarker)
            {
                //Debug.WriteLine("Travelling start at " + he.Indexno);
                he.travelling = true;
            }

            return(he);
        }
示例#60
0
        public abstract void FillInformation(out string info, out string detailed);     // all entries must implement

        // the long name of it, such as Approach Body. May be overridden, is translated
        public virtual string SummaryName(ISystem sys)
        {
            return(TranslatedEventNames.ContainsKey(EventTypeID) ? TranslatedEventNames[EventTypeID] : EventTypeID.ToString());
        }                                                                                                                                                                      // entry may be overridden for specialist output