private GraphLineCollection GetLinesInSelection()
        {
            GraphLineCollection coll = new GraphLineCollection();
            //Console.WriteLine("date selection: " + _mindt.ToString("dd/MM HH:mm:ss") + " - " + _maxdt.ToString("dd/MM HH:mm:ss"));
            bool _measurementfound = false;

            while (!_measurementfound)
            {
                foreach (GraphLine _line in _lines)
                {
                    foreach (GraphMeasurement gm in _line.Measurements)
                    {
                        if (gm.Timestamp >= _mindt && gm.Timestamp <= _maxdt)
                        {
                            _measurementfound = true;
                            AddMeasurementToCollection(coll, _line.ChannelName, _line.Symbol, gm.Timestamp, gm.Value, _line.Minrange, _line.Maxrange, _line.LineColor);
                        }
                    }
                }
                if (!_measurementfound)
                {
                    if (!(PanToLeft()))
                    {
                        _measurementfound = true;
                    }
                }
            }
            return(coll);
        }
 public GraphLineCollectionPropertyDescriptor(GraphLineCollection coll, int idx)
     :
     base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index      = idx;
 }
        public void AddMeasurementToCollection(GraphLineCollection coll, string Graphname, string SymbolName, DateTime Timestamp, float value, float minrange, float maxrange, Color linecolor)
        {
            bool _linefound = false;

            foreach (GraphLine line in coll)
            {
                if (line.Symbol == SymbolName)
                {
                    _linefound = true;
                    //                    if (value < minrange) minrange = value - 5;
                    //                    if (value > maxrange) maxrange = value + 5;

                    line.AddPoint(value, Timestamp, minrange, maxrange, linecolor);
                    break;
                }
            }
            if (!_linefound)
            {
                GraphLine _newline = new GraphLine();
                _newline.Symbol      = SymbolName;
                _newline.ChannelName = Graphname;
                _newline.Clear();
                coll.Add(_newline);
                _newline.AddPoint(value, Timestamp, minrange, maxrange, linecolor);
                _newline.LineVisible = GetRegistryValue(Graphname);
            }
        }
 public void SetDataSource(GraphLineCollection lines)
 {
     //checkedListBoxControl1.DataSource = lines;
     foreach (GraphLine line in lines)
     {
         if (line.LineVisible)
         {
             checkedListBoxControl1.Items.Add(line.Symbol, line.ChannelName, CheckState.Checked, true);
         }
         else
         {
             checkedListBoxControl1.Items.Add(line.Symbol, line.ChannelName, CheckState.Unchecked, true);
         }
     }
 }
Example #5
0
 public void SetDataSource(GraphLineCollection lines)
 {
     //checkedListBoxControl1.DataSource = lines;
     foreach (GraphLine line in lines)
     {
         if (line.LineVisible)
         {
             checkedListBoxControl1.Items.Add(line.Symbol, line.ChannelName, CheckState.Checked, true);
         }
         else
         {
             checkedListBoxControl1.Items.Add(line.Symbol, line.ChannelName, CheckState.Unchecked, true);
         }
     }
 }
        private string DetermineGraphNameByLinesPosition(Rectangle r, float x, float y, out DateTime measurementdt, out float value, out bool _valid)
        {
            float _max_dev = 3;

            _valid        = false;
            measurementdt = DateTime.Now;
            value         = 0;
            GraphLineCollection linesinselection = GetLinesInSelection();

            foreach (GraphLine line in linesinselection)
            {
                if (line.LineVisible)
                {
                    int cnt = 0;
                    foreach (GraphMeasurement measurement in line.Measurements)
                    {
                        if (cnt > 0)
                        {
                            //Console.WriteLine("  measurement " + measurement.Timestamp.ToString("HH:mm:ss") + " " + measurement.Value.ToString("F2"));
                            float sectionwidth = (float)(r.Width - 175) / (float)line.Maxpoints;
                            float x1           = (float)(cnt - 1) * sectionwidth + 100;
                            float x2           = (float)cnt * sectionwidth + 100;
                            float y1           = (r.Height - 100) - (line.Measurements[cnt - 1].Value - line.Minrange) / (line.Maxrange - line.Minrange) * (r.Height - 100);
                            float y2           = (r.Height - 100) - (line.Measurements[cnt].Value - line.Minrange) / (line.Maxrange - line.Minrange) * (r.Height - 100);
                            if (Math.Abs(x1 - x) <= _max_dev && Math.Abs(y1 - y) <= _max_dev)
                            {
                                value         = line.Measurements[cnt - 1].Value;
                                measurementdt = line.Measurements[cnt - 1].Timestamp;
                                //Console.WriteLine("Match: " + value.ToString() + " dt: " + measurementdt.ToString("dd/MM HH:mm:ss") + " x1: " + x1.ToString() + " y1: " + y1.ToString() + " x2: " + x2.ToString() + " y2: " + y2.ToString());
                                _valid = true;
                                return(line.Symbol);
                            }
                            else if (Math.Abs(x2 - x) <= _max_dev && Math.Abs(y2 - y) <= _max_dev)
                            {
                                value         = measurement.Value;
                                measurementdt = measurement.Timestamp;
                                _valid        = true;
                                //Console.WriteLine("Match: " + value.ToString() + " dt: " + measurementdt.ToString("dd/MM HH:mm:ss") + " x1: " + x1.ToString() + " y1: " + y1.ToString() + " x2: " + x2.ToString() + " y2: " + y2.ToString());
                                return(line.Symbol);
                            }
                        }
                        cnt++;
                    }
                }
            }
            return(string.Empty);
        }
 private GraphLineCollection GetLinesInSelection()
 {
     GraphLineCollection coll = new GraphLineCollection();
     //Console.WriteLine("date selection: " + _mindt.ToString("dd/MM HH:mm:ss") + " - " + _maxdt.ToString("dd/MM HH:mm:ss"));
     bool _measurementfound = false;
     while (!_measurementfound)
     {
         foreach (GraphLine _line in _lines)
         {
             foreach (GraphMeasurement gm in _line.Measurements)
             {
                 if (gm.Timestamp >= _mindt && gm.Timestamp <= _maxdt)
                 {
                     _measurementfound = true;
                     AddMeasurementToCollection(coll, _line.ChannelName, _line.Symbol, gm.Timestamp, gm.Value, _line.Minrange, _line.Maxrange, _line.LineColor);
                 }
             }
         }
         if (!_measurementfound)
         {
             if(!(PanToLeft())) _measurementfound = true;
         }
     }
     return coll;
 }
        public void AddMeasurementToCollection(GraphLineCollection coll, string Graphname, string SymbolName, DateTime Timestamp, float value, float minrange, float maxrange, Color linecolor)
        {
            bool _linefound = false;
            foreach (GraphLine line in coll)
            {
                if (line.Symbol == SymbolName)
                {
                    _linefound = true;
                    //                    if (value < minrange) minrange = value - 5;
                    //                    if (value > maxrange) maxrange = value + 5;

                    line.AddPoint(value, Timestamp, minrange, maxrange, linecolor);
                    break;
                }
            }
            if (!_linefound)
            {
                GraphLine _newline = new GraphLine();
                _newline.Symbol = SymbolName;
                _newline.ChannelName = Graphname;
                _newline.Clear();
                coll.Add(_newline);
                _newline.AddPoint(value, Timestamp, minrange, maxrange, linecolor);
                _newline.LineVisible = GetRegistryValue(Graphname);
            }
        }
 public GraphLineCollectionPropertyDescriptor(GraphLineCollection coll, int idx)
     : base("#" + idx.ToString(), null)
 {
     this.collection = coll;
     this.index = idx;
 }