Exemplo n.º 1
0
        public void HistoryChanged(HistoryList hl) // on History change
        {
            if (hl == null)                        // just for safety
            {
                return;
            }

            Tuple <long, int> pos = CurrentGridPosByJID();

            current_historylist = hl;
            rowsbyjournalid.Clear();
            systemsentered.Clear();
            dataGridViewStarList.Rows.Clear();

            var filter = (TravelHistoryFilter)comboBoxHistoryWindow.SelectedItem ?? TravelHistoryFilter.NoFilter;

            List <HistoryEntry> result = filter.Filter(hl);     // last entry, first in list

            result = HistoryList.FilterHLByTravel(result);      // keep only travel entries (location after death, FSD jumps)


            foreach (HistoryEntry he in result)        // last first..
            {
                if (!systemsentered.ContainsKey(he.System.name))
                {
                    systemsentered[he.System.name] = new List <HistoryEntry>();
                }

                systemsentered[he.System.name].Add(he);     // first entry is newest jump to, second is next last, etc
            }

            foreach (List <HistoryEntry> syslist in systemsentered.Values) // will be in order of entry..
            {
                AddNewHistoryRow(false, syslist);                          // add, with the properties of the first (latest) entry, giving the number of entries..
            }

            StaticFilters.FilterGridView(dataGridViewStarList, textBoxFilter.Text);

            int rowno = FindGridPosByJID(pos.Item1, true);     // find row.. must be visible..  -1 if not found/not visible

            if (rowno >= 0)
            {
                dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[pos.Item2];       // its the current cell which needs to be set, moves the row marker as well            currentGridRow = (rowno!=-1) ?
            }
            else if (dataGridViewStarList.Rows.GetRowCount(DataGridViewElementStates.Visible) > 0)
            {
                rowno = dataGridViewStarList.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[StarHistoryColumns.StarName];
            }
            else
            {
                rowno = -1;
            }

            dataGridViewStarList.Columns[0].HeaderText = EDDiscoveryForm.EDDConfig.DisplayUTC ? "Game Time" : "Time";

            //System.Diagnostics.Debug.WriteLine("Fire HC");

            FireChangeSelection();      // and since we repainted, we should fire selection, as we in effect may have selected a new one
        }
Exemplo n.º 2
0
        private void AddNewEntry(HistoryEntry he, HistoryList hl)           // on new entry from discovery system
        {
            if (!loadcomplete)
            {
                todo.Enqueue(new Action(() => AddNewEntry(he, hl)));
                return;
            }

            if (he.IsFSDJump || he.journalEntry is JournalScan || he.journalEntry is JournalFSSDiscoveryScan)
            {
                DataGridViewRow rowpresent = null;
                foreach (DataGridViewRow rowf in dataGridViewStarList.Rows)
                {
                    var list = (List <HistoryEntry>)rowf.Tag;
                    if (list != null && list[0].System.Name.Equals(he.System.Name))
                    {
                        rowpresent = rowf;
                        break;
                    }
                }

                if (he.IsFSDJump)
                {
                    if (rowpresent != null) // if its in the list, move to top and increment he's
                    {
                        dataGridViewStarList.Rows.Remove(rowpresent);
                        List <HistoryEntry> syslist = (List <HistoryEntry>)rowpresent.Tag;
                        syslist.Insert(0, he);                                // add onto list
                        rowpresent.Cells[2].Value = syslist.Count.ToString(); // update count
                        dataGridViewStarList.Rows.Insert(0, rowpresent);      // move to top..
                    }
                    else
                    {
                        // process thru normal filter to see if its displayable

                        var filter = (TravelHistoryFilter)comboBoxHistoryWindow.SelectedItem ?? TravelHistoryFilter.NoFilter;
                        List <HistoryEntry> result = filter.Filter(hl);     // last entry, first in list
                        result = HistoryList.FilterHLByTravel(result);      // keep only travel entries (location after death, FSD jumps)
                        List <List <HistoryEntry> > syslists = HistoryList.SystemAggregateList(result);

                        if (syslists.Count > 0 && syslists[0][0].System.Name == he.System.Name) // if the filtered result has our system in (which must be the first, since its newest), its inside the filter, add
                        {
                            string filtertext = textBoxFilter.Text;
                            var    row        = CreateHistoryRow(syslists[0], filtertext);
                            if (row != null)    // text may have filtered it out
                            {
                                dataGridViewStarList.Rows.Insert(0, row);
                            }
                        }
                    }

                    if (checkBoxCursorToTop.Checked && dataGridViewStarList.DisplayedRowCount(false) > 0)   // Move focus to new row
                    {
                        //System.Diagnostics.Debug.WriteLine("Auto Sel");
                        dataGridViewStarList.ClearSelection();
                        int rowno = dataGridViewStarList.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                        if (rowno != -1)
                        {
                            dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[1];       // its the current cell which needs to be set, moves the row marker as well
                        }
                        FireChangeSelection();
                    }
                }
                else
                {
                    if (rowpresent != null)         // only need to do something if its displayed
                    {
                        List <HistoryEntry> syslist = (List <HistoryEntry>)rowpresent.Tag;
                        var    node = discoveryform.history.starscan?.FindSystem(syslist[0].System, false); // may be null
                        string info = Infoline(syslist, node);                                              // lookup node, using star name, no EDSM lookup.
                        rowpresent.Cells[3].Value = info;                                                   // update info
                        rowpresent.Cells[4].Value = node?.ScanValue(true).ToString("N0") ?? "-";            // update scan value
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void HistoryChanged(HistoryList hl, bool disablesorting) // on History change
        {
            if (hl == null)                                             // just for safety
            {
                return;
            }

            loadcomplete = false;

            autoupdateedsm.Stop();

            Tuple <long, int> pos = CurrentGridPosByJID();

            current_historylist = hl;

            SortOrder sortorder = dataGridViewStarList.SortOrder;
            int       sortcol   = dataGridViewStarList.SortedColumn?.Index ?? -1;

            if (sortcol >= 0 && disablesorting)
            {
                dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = SortOrder.None;
                sortcol = -1;
            }

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " SL " + displaynumber + " Load start");

            rowsbyjournalid.Clear();
            dataGridViewStarList.Rows.Clear();

            dataGridViewStarList.Columns[0].HeaderText = EDDiscoveryForm.EDDConfig.DisplayUTC ? "Game Time".T(EDTx.GameTime) : "Time".T(EDTx.Time);

            var filter = (TravelHistoryFilter)comboBoxHistoryWindow.SelectedItem ?? TravelHistoryFilter.NoFilter;

            List <HistoryEntry> result = filter.Filter(hl);     // last entry, first in list

            result = HistoryList.FilterHLByTravel(result);      // keep only travel entries (location after death, FSD jumps)
            List <List <HistoryEntry> >  syslists      = HistoryList.SystemAggregateList(result);
            List <List <HistoryEntry>[]> syslistchunks = new List <List <HistoryEntry>[]>();

            for (int i = 0; i < syslists.Count; i += 1000)
            {
                int totake = Math.Min(1000, syslists.Count - i);
                List <HistoryEntry>[] syslistchunk = new List <HistoryEntry> [totake];
                syslists.CopyTo(i, syslistchunk, 0, totake);
                syslistchunks.Add(syslistchunk);
            }

            todo.Clear();

            string filtertext = textBoxFilter.Text;

            foreach (var syslistchunk in syslistchunks)
            {
                todo.Enqueue(() =>
                {
                    dataViewScrollerPanel.Suspend();
                    foreach (var syslist in syslistchunk)
                    {
                        var row = CreateHistoryRow(syslist, filtertext);
                        if (row != null)
                        {
                            dataGridViewStarList.Rows.Add(row);
                        }
                    }

                    dataViewScrollerPanel.Resume();
                });
            }

            todo.Enqueue(() =>
            {
                dataGridViewStarList.FilterGridView(filtertext);

                int rowno = FindGridPosByJID(pos.Item1, true);     // find row.. must be visible..  -1 if not found/not visible

                if (rowno >= 0)
                {
                    dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[pos.Item2];       // its the current cell which needs to be set, moves the row marker as well currentGridRow = (rowno!=-1) ?
                }
                else if (dataGridViewStarList.Rows.GetRowCount(DataGridViewElementStates.Visible) > 0)
                {
                    rowno = dataGridViewStarList.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                    dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[StarHistoryColumns.StarName];
                }
                else
                {
                    rowno = -1;
                }

                System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " SL " + displaynumber + " Load Finish");

                if (sortcol >= 0)
                {
                    dataGridViewStarList.Sort(dataGridViewStarList.Columns[sortcol], (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                    dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = sortorder;
                }

                //System.Diagnostics.Debug.WriteLine("Fire HC");

                autoupdaterowoffset = autoupdaterowstart = 0;
                autoupdateedsm.Start();

                FireChangeSelection();      // and since we repainted, we should fire selection, as we in effect may have selected a new one

                loadcomplete = true;
            });

            todotimer.Start();
        }
Exemplo n.º 4
0
        public void HistoryChanged(HistoryList hl, bool disablesorting) // on History change
        {
            if (hl == null)                                             // just for safety
            {
                return;
            }

            loadcomplete = false;

            autoupdateedsm.Stop();

            Tuple <long, int> pos = CurrentGridPosByJID();

            current_historylist = hl;

            SortOrder sortorder = dataGridViewStarList.SortOrder;
            int       sortcol   = dataGridViewStarList.SortedColumn?.Index ?? -1;

            if (sortcol >= 0 && disablesorting)
            {
                dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = SortOrder.None;
                sortcol = -1;
            }

            rowsbyjournalid.Clear();
            dataGridViewStarList.Rows.Clear();

            checkBoxJumponium.Enabled = checkBoxBodyClasses.Enabled = buttonExtExcel.Enabled = comboBoxHistoryWindow.Enabled = false;

            dataGridViewStarList.Columns[0].HeaderText = EDDiscoveryForm.EDDConfig.GetTimeTitle();

            var filter = (TravelHistoryFilter)comboBoxHistoryWindow.SelectedItem ?? TravelHistoryFilter.NoFilter;

            List <HistoryEntry> result = filter.Filter(hl);     // last entry, first in list

            result = HistoryList.FilterHLByTravel(result);      // keep only travel entries (location after death, FSD jumps)
            List <List <HistoryEntry> >  syslists      = HistoryList.SystemAggregateList(result);
            List <List <HistoryEntry>[]> syslistchunks = new List <List <HistoryEntry>[]>();

            int chunksize = 500;

            for (int i = 0; i < syslists.Count; i += chunksize, chunksize = 2000)
            {
                int totake = Math.Min(chunksize, syslists.Count - i);
                List <HistoryEntry>[] syslistchunk = new List <HistoryEntry> [totake];
                syslists.CopyTo(i, syslistchunk, 0, totake);
                syslistchunks.Add(syslistchunk);
            }

            todo.Clear();

            string filtertext = textBoxFilter.Text;

            System.Diagnostics.Stopwatch swtotal = new System.Diagnostics.Stopwatch(); swtotal.Start();

            foreach (var syslistchunk in syslistchunks)
            {
                todo.Enqueue(() =>
                {
                    List <DataGridViewRow> rowstoadd = new List <DataGridViewRow>();

                    foreach (var syslist in syslistchunk)
                    {
                        var row = CreateHistoryRow(syslist, filtertext);
                        if (row != null)
                        {
                            rowstoadd.Add(row);
                        }
                    }

                    dataGridViewStarList.Rows.AddRange(rowstoadd.ToArray());
                });

                if (dataGridViewStarList.MoveToSelection(rowsbyjournalid, ref pos, false, Columns.StarName))
                {
                    FireChangeSelection();
                }
            }

            todo.Enqueue(() =>
            {
                dataGridViewStarList.FilterGridView(filtertext);
                System.Diagnostics.Debug.WriteLine(BaseUtils.AppTicks.TickCount + " SL TOTAL TIME " + swtotal.ElapsedMilliseconds);

                if (dataGridViewStarList.MoveToSelection(rowsbyjournalid, ref pos, true, Columns.StarName))
                {
                    FireChangeSelection();
                }

                if (sortcol >= 0)
                {
                    dataGridViewStarList.Sort(dataGridViewStarList.Columns[sortcol], (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                    dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = sortorder;
                }

                //System.Diagnostics.Debug.WriteLine("Fire HC");

                autoupdaterowoffset = autoupdaterowstart = 0;
                autoupdateedsm.Start();

                loadcomplete = true;
                checkBoxJumponium.Enabled = checkBoxBodyClasses.Enabled = buttonExtExcel.Enabled = comboBoxHistoryWindow.Enabled = true;
            });

            todotimer.Start();
        }
Exemplo n.º 5
0
        public void HistoryChanged(HistoryList hl, bool disablesorting)           // on History change
        {
            autoupdateedsm.Stop();

            if (hl == null)     // just for safety
            {
                return;
            }

            Tuple <long, int> pos = CurrentGridPosByJID();

            current_historylist = hl;

            SortOrder sortorder = dataGridViewStarList.SortOrder;
            int       sortcol   = dataGridViewStarList.SortedColumn?.Index ?? -1;

            if (sortcol >= 0 && disablesorting)
            {
                dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = SortOrder.None;
                sortcol = -1;
            }

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCount100 + " SL " + displaynumber + " Load start");

            rowsbyjournalid.Clear();
            systemsentered.Clear();
            dataGridViewStarList.Rows.Clear();

            var filter = (TravelHistoryFilter)comboBoxHistoryWindow.SelectedItem ?? TravelHistoryFilter.NoFilter;

            List <HistoryEntry> result = filter.Filter(hl);     // last entry, first in list

            result = HistoryList.FilterHLByTravel(result);      // keep only travel entries (location after death, FSD jumps)


            foreach (HistoryEntry he in result)        // last first..
            {
                if (!systemsentered.ContainsKey(he.System.Name))
                {
                    systemsentered[he.System.Name] = new List <HistoryEntry>();
                }

                systemsentered[he.System.Name].Add(he);     // first entry is newest jump to, second is next last, etc
            }

            foreach (List <HistoryEntry> syslist in systemsentered.Values) // will be in order of entry..
            {
                DataGridViewRow rw = CreateHistoryRow(syslist, textBoxFilter.Text);
                if (rw != null)
                {
                    dataGridViewStarList.Rows.Add(rw);
                }
            }

            dataGridViewStarList.FilterGridView(textBoxFilter.Text);

            int rowno = FindGridPosByJID(pos.Item1, true);     // find row.. must be visible..  -1 if not found/not visible

            if (rowno >= 0)
            {
                dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[pos.Item2];       // its the current cell which needs to be set, moves the row marker as well currentGridRow = (rowno!=-1) ?
            }
            else if (dataGridViewStarList.Rows.GetRowCount(DataGridViewElementStates.Visible) > 0)
            {
                rowno = dataGridViewStarList.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                dataGridViewStarList.CurrentCell = dataGridViewStarList.Rows[rowno].Cells[StarHistoryColumns.StarName];
            }
            else
            {
                rowno = -1;
            }

            dataGridViewStarList.Columns[0].HeaderText = EDDiscoveryForm.EDDConfig.DisplayUTC ? "Game Time" : "Time";

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCount100 + " SL " + displaynumber + " Load Finish");

            if (sortcol >= 0)
            {
                dataGridViewStarList.Sort(dataGridViewStarList.Columns[sortcol], (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                dataGridViewStarList.Columns[sortcol].HeaderCell.SortGlyphDirection = sortorder;
            }

            //System.Diagnostics.Debug.WriteLine("Fire HC");

            autoupdaterowoffset = autoupdaterowstart = 0;
            autoupdateedsm.Start();

            FireChangeSelection();      // and since we repainted, we should fire selection, as we in effect may have selected a new one
        }