Пример #1
0
        // Async task to find results given cond in helist, using only vars specified.

        private System.Threading.Tasks.Task <List <Tuple <ISystem, object[]> > > Find(List <HistoryEntry> helist, BaseUtils.ConditionLists cond, HashSet <string> varsusedincondition, ISystem cursystem)
        {
            return(System.Threading.Tasks.Task.Run(() =>
            {
                List <Tuple <ISystem, object[]> > rows = new List <Tuple <ISystem, object[]> >();
                foreach (var he in helist)
                {
                    BaseUtils.Variables scandata = new BaseUtils.Variables();
                    scandata.AddPropertiesFieldsOfClass(he.journalEntry, "",
                                                        new Type[] { typeof(System.Drawing.Icon), typeof(System.Drawing.Image), typeof(System.Drawing.Bitmap), typeof(QuickJSON.JObject) }, 5,
                                                        varsusedincondition);

                    bool?res = cond.CheckAll(scandata, out string errlist, out BaseUtils.ConditionLists.ErrorClass errclass);   // need function handler..

                    if (res.HasValue && res.Value == true)
                    {
                        ISystem sys = he.System;
                        string sep = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " ";

                        JournalScan js = he.journalEntry as JournalScan;
                        JournalFSSBodySignals jb = he.journalEntry as JournalFSSBodySignals;
                        JournalSAASignalsFound jbs = he.journalEntry as JournalSAASignalsFound;

                        string name, info;
                        if (js != null)
                        {
                            name = js.BodyName;
                            info = js.DisplayString(0);
                        }
                        else if (jb != null)
                        {
                            name = jb.BodyName;
                            jb.FillInformation(he.System, "", out info, out string d);
                        }
                        else
                        {
                            name = jbs.BodyName;
                            jbs.FillInformation(he.System, "", out info, out string d);
                        }

                        object[] rowobj = { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(he.EventTimeUTC).ToString(),
                                            name,
                                            info,
                                            (cursystem != null ? cursystem.Distance(sys).ToString("0.#") : ""),
                                            sys.X.ToString("0.#") + sep + sys.Y.ToString("0.#") + sep + sys.Z.ToString("0.#") };
                        rows.Add(new Tuple <ISystem, object[]>(sys, rowobj));
                    }
                }

                return rows;
            }));
        }
Пример #2
0
        private void buttonFind_Click(object sender, EventArgs e)
        {
            BaseUtils.ConditionLists cond = Valid();
            if (cond != null)
            {
                this.Cursor = Cursors.WaitCursor;
                dataGridView.Rows.Clear();

                DataGridViewColumn sortcol   = dataGridView.SortedColumn != null ? dataGridView.SortedColumn : dataGridView.Columns[0];
                SortOrder          sortorder = dataGridView.SortedColumn != null ? dataGridView.SortOrder : SortOrder.Descending;

                ISystem cursystem = discoveryform.history.CurrentSystem();        // could be null

                foreach (var he in discoveryform.history.FilterByScan())
                {
                    JournalScan js = he.journalEntry as JournalScan;

                    BaseUtils.Variables scandata = new BaseUtils.Variables();
                    scandata.AddPropertiesFieldsOfClass(js, "", new Type[] { typeof(System.Drawing.Icon), typeof(System.Drawing.Image), typeof(System.Drawing.Bitmap), typeof(BaseUtils.JSON.JObject) }, 5);

                    bool?res = cond.CheckAll(scandata, out string errlist, out BaseUtils.ConditionLists.ErrorClass errclass);    // need function handler..

                    if (res.HasValue && res.Value == true)
                    {
                        ISystem  sys    = he.System;
                        string   sep    = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " ";
                        object[] rowobj =
                        {
                            EDDConfig.Instance.ConvertTimeToSelectedFromUTC(he.EventTimeUTC).ToString(),
                            js.BodyName,
                            js.DisplayString(0),
                            (cursystem != null ? cursystem.Distance(sys).ToString("0.#") : ""),
                            sys.X.ToString("0.#") + sep + sys.Y.ToString("0.#") + sep + sys.Z.ToString("0.#")
                        };

                        dataGridView.Rows.Add(rowobj);
                        dataGridView.Rows[dataGridView.Rows.Count - 1].Tag = sys;
                    }

                    if (errclass == BaseUtils.ConditionLists.ErrorClass.LeftSideVarUndefined || errclass == BaseUtils.ConditionLists.ErrorClass.RightSideBadFormat)
                    {
                        ExtendedControls.MessageBoxTheme.Show(errlist, "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }
                }

                dataGridView.Sort(sortcol, (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                dataGridView.Columns[sortcol.Index].HeaderCell.SortGlyphDirection = sortorder;
                this.Cursor = Cursors.Default;
            }
        }
Пример #3
0
        private void buttonFind_Click(object sender, EventArgs e)
        {
            BaseUtils.ConditionLists cond = Valid();
            if (cond != null)
            {
                this.Cursor = Cursors.WaitCursor;
                dataGridView.Rows.Clear();

                DataGridViewColumn sortcol   = dataGridView.SortedColumn != null ? dataGridView.SortedColumn : dataGridView.Columns[0];
                SortOrder          sortorder = dataGridView.SortedColumn != null ? dataGridView.SortOrder : SortOrder.Descending;

                ISystem cursystem = discoveryform.history.CurrentSystem;        // could be null

                foreach (var he in discoveryform.history.FilterByScan)
                {
                    JournalScan js = he.journalEntry as JournalScan;

                    BaseUtils.Variables scandata = new BaseUtils.Variables();
                    scandata.AddPropertiesFieldsOfClass(js, "", new Type[] { typeof(System.Drawing.Icon), typeof(System.Drawing.Image), typeof(System.Drawing.Bitmap), typeof(Newtonsoft.Json.Linq.JObject) }, 5);

                    bool?res = cond.CheckAll(scandata, out string errlist);   // need function handler..

                    if (res.HasValue && res.Value == true)
                    {
                        ISystem  sys    = he.System;
                        string   sep    = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + " ";
                        object[] rowobj =
                        {
                            (EDDConfig.Instance.DisplayUTC ? he.EventTimeUTC : he.EventTimeLocal).ToString(),
                            js.BodyName,
                            js.DisplayString(0,                                                              true),
                            (cursystem != null ? cursystem.Distance(sys).ToString("0.#") : ""),
                            sys.X.ToString("0.#") + sep + sys.Y.ToString("0.#") + sep + sys.Z.ToString("0.#")
                        };

                        dataGridView.Rows.Add(rowobj);
                        dataGridView.Rows[dataGridView.Rows.Count - 1].Tag = sys;
                    }
                }

                dataGridView.Sort(sortcol, (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                dataGridView.Columns[sortcol.Index].HeaderCell.SortGlyphDirection = sortorder;
                this.Cursor = Cursors.Default;
            }
        }