Ejemplo n.º 1
0
 private void btNSpLyToText_Click(object sender, EventArgs e)
 {
     try
     {
         RestoreBeforeSelectLine();
         float        x, y;
         List <float> pix;
         List <int>   sn;
         SpView.GetCursorPosition(out x, out y, out pix, out sn);
         LineDbRecord lr = SpView.SelSpLine;
         if (lr == null)
         {
             MessageBox.Show(MainForm.MForm,
                             Common.MLS.Get(MLSConst, "Нет выбранной спектральной линии"), //"No selected spectr line"),
                             Common.MLS.Get(MLSConst, "Проблема"),                         //"Problem"),
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Warning);
             return;
         }
         InsertText(Math.Round(pix[0], 1) + "-" + Math.Round(lr.Ly, 2) + "   #" + lr.ElementName + " " + lr.IonLevel);
         RestoreBeforeSelectLine();
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
 }
Ejemplo n.º 2
0
 private void btSelLyToText_Click(object sender, EventArgs e)
 {
     try
     {
         RestoreBeforeSelectLine();
         LineDbRecord lr = SpView.SelSpLine;
         if (lr == null)
         {
             return;
         }
         InsertText(Math.Round(lr.Ly, 2) + "   #" + lr.ElementName + " " + lr.IonLevel);
         RestoreBeforeSelectLine();
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
 }
Ejemplo n.º 3
0
        LineDbRecord Add(LineDbRecord rec, bool find_prev)
        {
            AddCount++;
            if ((AddCount % 100) == 0)
            {
                CountLb.Text = Records.Count.ToString() + "(" + AddCount + ")";
                CountLb.Refresh();
            }
            if (Records.Count > 0)
            {
                int i = Records.Count - 1;
                if (Records[i].Element == rec.Element &&
                    Records[i].IonLevel == rec.IonLevel &&
                    Math.Abs(Records[i].Ly - rec.Ly) < 0.1)
                {
                    return(Records[i]);
                }
            }
            if (find_prev)
            {
                if (Records.Count != 0)
                {
                    int from = 0;
                    int to   = Records.Count;
                    while ((to - from) > 5)
                    {
                        int   i   = (to + from) / 2;
                        float dlt = Records[i].Ly - rec.Ly;
                        if (dlt > 0.2)
                        {
                            to = i;
                        }
                        else
                        {
                            if (dlt < -0.2)
                            {
                                from = i;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    for (int i = from; i < to; i++)
                    {
                        if (Records[i].Element == rec.Element &&
                            Records[i].IonLevel == rec.IonLevel &&
                            Math.Abs(Records[i].Ly - rec.Ly) < 0.1)
                        {
                            return(Records[i]);
                        }
                    }
                }

                /*for (int i = 0; i < Records.Count; i++)
                 *  if (Records[i].Element == rec.Element &&
                 *      Records[i].IonLevel == rec.IonLevel &&
                 *      Math.Abs(Records[i].Ly - rec.Ly) < 0.1)
                 *      return Records[i];*/
            }
            if (rec.Ly >= (float)LyFrom.Value &&
                rec.Ly <= (float)LyTo.Value &&
                (rec.IonLevel < (int)IonLevel.Value ||
                 rec.IonLevel == 255))
            {
                bool inserted = false;
                for (int i = 0; i < Records.Count; i++)
                {
                    if (Records[i].Ly > rec.Ly)
                    {
                        inserted = true;
                        Records.Insert(i, rec);
                        break;
                    }
                }
                if (inserted == false)
                {
                    Records.Add(rec);
                }
            }
            return(rec);
        }